Skip to content

Commit

Permalink
Merge branch 'replace-numberpassword-keyboard-on-firestick-tv-droid-1…
Browse files Browse the repository at this point in the history
…398'
  • Loading branch information
Rawa committed Oct 24, 2024
2 parents 9fe50f7 + 13f2951 commit eba4129
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 @@ -81,6 +81,7 @@ import net.mullvad.mullvadvpn.compose.textfield.mullvadWhiteTextFieldColors
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.accountNumberKeyboardType
import net.mullvad.mullvadvpn.compose.util.accountNumberVisualTransformation
import net.mullvad.mullvadvpn.compose.util.showSnackbarImmediately
import net.mullvad.mullvadvpn.lib.theme.AppTheme
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.accountNumberKeyboardType(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.accountNumberKeyboardType(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 eba4129

Please sign in to comment.