Accept digits in the PIN field in addition to l/r/u/d (#1330)

## Description
This enhances the PIN entry system by allowing users to input digits
using the numbers 0-9. This is useful for those using a keyboard or
universal remote with a number pad.

### Testing
Tested on Nvidia Shield Pro and Onn 4k Pro

## Screenshots
<img width="3840" height="2160" alt="Screenshot_20260429_083041"
src="https://github.com/user-attachments/assets/9e603bda-f1d3-4268-a04c-b077297fdfac"
/>

---------

Co-authored-by: Damontecres <damontecres@gmail.com>
This commit is contained in:
Brian Gunter 2026-05-11 10:23:02 -04:00 committed by GitHub
parent cb46aa4159
commit 08db2b0efc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 0 deletions

View file

@ -25,6 +25,7 @@ import androidx.compose.ui.input.key.key
import androidx.compose.ui.input.key.onKeyEvent import androidx.compose.ui.input.key.onKeyEvent
import androidx.compose.ui.input.key.type import androidx.compose.ui.input.key.type
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.tv.material3.MaterialTheme import androidx.tv.material3.MaterialTheme
@ -72,6 +73,16 @@ fun PinEntry(
Key.DirectionRight -> "R" Key.DirectionRight -> "R"
Key.DirectionDown -> "D" Key.DirectionDown -> "D"
Key.DirectionLeft -> "L" Key.DirectionLeft -> "L"
Key.Zero, Key.NumPad0 -> "0"
Key.One, Key.NumPad1 -> "1"
Key.Two, Key.NumPad2 -> "2"
Key.Three, Key.NumPad3 -> "3"
Key.Four, Key.NumPad4 -> "4"
Key.Five, Key.NumPad5 -> "5"
Key.Six, Key.NumPad6 -> "6"
Key.Seven, Key.NumPad7 -> "7"
Key.Eight, Key.NumPad8 -> "8"
Key.Nine, Key.NumPad9 -> "9"
else -> return@onKeyEvent false else -> return@onKeyEvent false
} }
onTextChange.invoke(str) onTextChange.invoke(str)
@ -122,6 +133,16 @@ fun PinEntryCreate(
Key.DirectionRight -> "R" Key.DirectionRight -> "R"
Key.DirectionDown -> "D" Key.DirectionDown -> "D"
Key.DirectionLeft -> "L" Key.DirectionLeft -> "L"
Key.Zero, Key.NumPad0 -> "0"
Key.One, Key.NumPad1 -> "1"
Key.Two, Key.NumPad2 -> "2"
Key.Three, Key.NumPad3 -> "3"
Key.Four, Key.NumPad4 -> "4"
Key.Five, Key.NumPad5 -> "5"
Key.Six, Key.NumPad6 -> "6"
Key.Seven, Key.NumPad7 -> "7"
Key.Eight, Key.NumPad8 -> "8"
Key.Nine, Key.NumPad9 -> "9"
else -> return@onKeyEvent false else -> return@onKeyEvent false
} }
onTextChange.invoke(str) onTextChange.invoke(str)
@ -154,6 +175,7 @@ fun PinEntryCreate(
@Composable @Composable
fun PinArrowRow(modifier: Modifier = Modifier) { fun PinArrowRow(modifier: Modifier = Modifier) {
Row( Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = modifier, modifier = modifier,
) { ) {
@ -167,6 +189,12 @@ fun PinArrowRow(modifier: Modifier = Modifier) {
fontFamily = FontAwesome, fontFamily = FontAwesome,
) )
} }
Text(
text = stringResource(R.string.pin_digits_hint),
color = MaterialTheme.colorScheme.onSurface,
style = MaterialTheme.typography.headlineSmall,
fontWeight = FontWeight.SemiBold,
)
} }
} }

View file

@ -390,6 +390,7 @@
<string name="incorrect">Incorrect</string> <string name="incorrect">Incorrect</string>
<string name="pin_too_short">PIN must be 4 keys or longer</string> <string name="pin_too_short">PIN must be 4 keys or longer</string>
<string name="will_remove_pin">Will remove PIN</string> <string name="will_remove_pin">Will remove PIN</string>
<string name="pin_digits_hint">[0-9]</string>
<string name="image_cache_size">Image disk cache size (MB)</string> <string name="image_cache_size">Image disk cache size (MB)</string>
<string name="view_options">View options</string> <string name="view_options">View options</string>
<string name="columns">Columns</string> <string name="columns">Columns</string>