mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-02 13:12:48 -04: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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user