Skip to content

Commit

Permalink
Use KeyboardType.Number on Amazon FireStick
Browse files Browse the repository at this point in the history
  • Loading branch information
kl committed Oct 22, 2024
1 parent 1ec8c9d commit 672e465
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import net.mullvad.mullvadvpn.compose.transitions.LoginTransition
import net.mullvad.mullvadvpn.compose.util.CollectSideEffectWithLifecycle
import net.mullvad.mullvadvpn.compose.util.OnNavResultValue
import net.mullvad.mullvadvpn.compose.util.accountNumberVisualTransformation
import net.mullvad.mullvadvpn.compose.util.numberPasswordInputType
import net.mullvad.mullvadvpn.compose.util.showSnackbarImmediately
import net.mullvad.mullvadvpn.lib.theme.AppTheme
import net.mullvad.mullvadvpn.lib.theme.Dimens
Expand Down Expand Up @@ -285,7 +286,7 @@ private fun ColumnScope.LoginInput(
keyboardOptions =
KeyboardOptions(
imeAction = if (state.loginButtonEnabled) ImeAction.Done else ImeAction.None,
keyboardType = KeyboardType.NumberPassword,
keyboardType = KeyboardType.numberPasswordInputType(LocalContext.current),
),
onValueChange = onAccountNumberChange,
singleLine = true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package net.mullvad.mullvadvpn.compose.util

import android.content.Context
import androidx.compose.ui.text.input.KeyboardType

fun KeyboardType.Companion.numberPasswordInputType(context: Context): KeyboardType =
if (isFireStick(context)) {
Number
} else {
NumberPassword
}

// see: https://developer.amazon.com/docs/fire-tv/identify-amazon-fire-tv-devices.html
private fun isFireStick(context: Context): Boolean =
context.packageManager.hasSystemFeature("amazon.hardware.fire_tv")

0 comments on commit 672e465

Please sign in to comment.