material-components / material-components/material-components-android
[MaterialDatePicker] Support programatic mtrl_picker_* string values
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
Some applications do not use static string resources files, such as applications that receive localized values from a server. In this case overriding `mtrl_picker_*` string resource values is not a valid solution to change the UI of various components. Another use-case would be needing to add additional contextual data into these strings when shown on the UI (like in the code example below).

It would be nice if this library could provide a way to modify some of these string values at runtime as they are displayed on the UI. This would be especially useful for error states where additional context from the application could be useful to the user.
Something like:
```kotlin
val minDate = calcMinDate()
val maxDate = calcMaxDate()
MaterialDatePicker.Builder.datePicker()
.setSelection(...)
.setInputMode(...)
.setPickerOutOfRangeError { date ->
// alternative to setting mtrl_picker_out_of_range
"Please enter a date that is within the range of $minDate to $maxDate. $date is outside of this range"
}
```
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.Builder API and the existing mtrl_picker_* string resources; no source files or tests are named in the issue. Determine which displayed strings, especially out-of-range errors, need runtime customization and how the proposed callbacks should coexist with resource defaults. Done means applications can supply contextual string values programmatically while existing resource overrides continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100