mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
fix #625: handle Samsung Keyboard dot-minus key in TextField validation
Samsung Keyboard numerical keypad features a combined '.-' key that outputs a dot (.) on first press and replaces it with a minus (-) on second press. there is no option to output each symbol separately (short or long press, etc). updated validation logic to handle dot symbol at the start of the input string.
This commit is contained in:
parent
ab46bf6ab9
commit
c821eb3681
1 changed files with 2 additions and 1 deletions
|
|
@ -101,6 +101,7 @@ fun EditTextPreference(
|
|||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
var valueState by remember(value) { mutableStateOf(value.toString()) }
|
||||
val decimalSeparators = setOf('.', ',', '٫', '、', '·') // set of possible decimal separators
|
||||
|
||||
EditTextPreference(
|
||||
title = title,
|
||||
|
|
@ -112,7 +113,7 @@ fun EditTextPreference(
|
|||
),
|
||||
keyboardActions = keyboardActions,
|
||||
onValueChanged = {
|
||||
if (it.isEmpty()) valueState = it
|
||||
if (it.length <= 1 || it.first() in decimalSeparators) valueState = it
|
||||
else it.toDoubleOrNull()?.let { double ->
|
||||
valueState = it
|
||||
onValueChanged(double)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue