material-components / material-components-android

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

[MaterialDatePicker] Disabling input mods switch change and setting input text #3624

Open SmirnovDV-98 opened 11 months ago

SmirnovDV-98 commented 11 months ago

1st point - I've been looking for options to switch off text input mode, block input variants changing or just remove the inputmode toggle(attached image1). I've saw a previous discussions about such issue, such as https://github.com/material-components/material-components-android/issues/1380 , but none of the suggested methods works now. Setting attributes visibility/clickable through styles causes error: causes exception, that reffers to 31st line of mtrl_picker_dialog and method builder.setToggleInputModeEnable(false) doesn't exist anymore.

2nd point - is there any kind of way to set text watcher for text input field, or any other way that allow to apply mask like "##.##.####" to inputting symbol. Such as auto-adding . to number input like 21.02.1993, and not allow to input any further. Simple date formats, that could be set with setTextInputFormat() doesn't provide such functionality, not preventing further year input for formats like "dd.MM.yyyy"

Attached image1 screen_1

hunterstich commented 11 months ago

Hi @SmirnovDV-98,

1 - We don't have any plans to make it easier to disable the text input switch as this is the primary means of making the component accessible for some users

2 - To clarify, you'd like to be able to set a text watcher on the input field to run any transformations when the text changes? Like stopping additional input after the full date has been input?

SmirnovDV-98 commented 11 months ago

About second part. Yes, I'd like to have a ability to control behavior of the text input, such as stopping additional input, or adding any kind of custom validation checks after last symbol was entered.