material-components / material-components/material-components-android

[MaterialDatePicker][MaterialTimePicker] Support Fragment Result API

Open
#3,447 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request Widget: DatePicker Widget: TimePicker
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.