material-components / material-components/material-components-android
[MaterialDatePicker][MaterialTimePicker] Support Fragment Result API
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem? Please describe.**
The current API of both `MaterialDatePicker` and `MaterialTimePicker` only supports listeners, such as `MaterialTimePicker.addOnNegativeButtonClickListener(listener)`, which unfortunately do not persist across configuration changes.
**Describe the solution you'd like**
Both `MaterialDatePicker` and `MaterialTimePicker` should support [Fragment Result API](https://developer.android.com/guide/fragments/communicate#fragment-result) so that the dialogs work properly even after a configuration change has occurred.
**Describe alternatives you've considered**
Both classes are final so adding this behavior ourselves is not possible.
I also considered extracting the `Dialog` logic and creating a `DialogFragment` myself so that we can set Fragment results.
**Additional context**
Because of this oversight, we decided not to use the `MaterialDatePicker` because it can not be implemented reliably. We continue to use `android.app.DatePickerDialog` which extends `AlertDialog` so that we can wrap it in a `FragmentDialog` which allows us to implement Fragment Result API ourselves.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MaterialDatePicker and MaterialTimePicker listener APIs and the linked Android Fragment Result API documentation. Define how each dialog exposes results across configuration changes, then verify that both picker types retain and deliver those results after recreation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100