material-components / material-components-android

Modular and customizable Material Design UI components for Android
Apache License 2.0
16.11k stars 3.04k forks source link

[MaterialDatePicker] OnSelectionChangedListener and DateSelector are not accessible. #1727

Open kevintorch opened 3 years ago

kevintorch commented 3 years ago

Description: Trying to implement custom DateSelector. but it shows error as

"com.google.android.material.datepicker.OnSelectionChangedListener' is not public in 'com.google.android.material.datepicker'. Cannot be accessed from outside package"

and

"DateSelector can only be accessed from within the same library group (groupId=com.google.android.material)"

Expected behavior: Basically I want the same behavior as SingleDateSelector or RangeDateSelector

Material Library version: 1.3.0-alpha02

matpag commented 3 years ago

Maybe DateSelector should be opened and everyone should be able to implement a custom one if needed. Obviously the builder should have an additional MaterialDatePicker.Builder.withPicker(customDateSelector);

I don't know if implementing a new custom DateSelector it's an "easy" task...

kevintorch commented 3 years ago

Maybe DateSelector should be opened and everyone should be able to implement a custom one if needed. Obviously the builder should have an additional MaterialDatePicker.Builder.withPicker(customDateSelector);

I don't know if implementing a new custom DateSelector it's an "easy" task...

Actually it has MaterialDatePicker.Builder.customSelector(DateSelector) method. but it's no use.

and second, it's not that difficult to implement a custom DateSelector. I've seen the classes

matpag commented 3 years ago

You are right, it's this, https://github.com/material-components/material-components-android/blob/22973ff10305397bfc72fed41684175fee8aeefb/lib/java/com/google/android/material/datepicker/MaterialDatePicker.java#L546-L550 but it's Library Group restricted as everything else.

and second, it's not that difficult to implement a custom DateSelector. I've seen the classes

Nice to know 👍

AleksandarAleksiev commented 3 years ago

I have the same issue. I need to listen on selection changes and need to add custom logic forDateSelector:isSelectionComplete but 🤷‍♂️ no possible at the moment.

lsuski commented 3 years ago

E.g this could be used to implement optional range selection

saoudiabderraouf commented 2 years ago

Hello everyone, actually I have the same issue. I need to listen on selection changes and need to disable some dates when first date is selected but no possible at the moment. I hope they add a listener.

sme-shyl001 commented 2 months ago

Still not fixed :(