sforkowany z mirror/meshtastic-android
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.master
rodzic
ab46bf6ab9
commit
c821eb3681
app/src/main/java/com/geeksville/mesh/ui/components
|
@ -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)
|
||||
|
|
Ładowanie…
Reference in New Issue