diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-09-16 21:28:57 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-09-24 14:53:20 +0000 |
| commit | 3b06141028c23e1f950c281419ff1b905bf1dd0d (patch) | |
| tree | 4cb45acb085a8bdfa77368531e91478729291058 /android/src | |
| parent | 32251c6897ecd9c2f43e9f5d4353764782ebe5ea (diff) | |
| download | mullvadvpn-3b06141028c23e1f950c281419ff1b905bf1dd0d.tar.xz mullvadvpn-3b06141028c23e1f950c281419ff1b905bf1dd0d.zip | |
Replace XML attributes with `KeyListener` instance
Diffstat (limited to 'android/src')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountInput.kt | 5 | ||||
| -rw-r--r-- | android/src/main/res/layout/account_input.xml | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountInput.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountInput.kt index 35e910c063..2c8dd24a9f 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountInput.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountInput.kt @@ -3,6 +3,7 @@ package net.mullvad.mullvadvpn.ui.widget import android.content.Context import android.text.Editable import android.text.TextWatcher +import android.text.method.DigitsKeyListener import android.text.style.MetricAffectingSpan import android.util.AttributeSet import android.view.LayoutInflater @@ -48,6 +49,10 @@ class AccountInput : LinearLayout { onFocusChangeListener = OnFocusChangeListener { view, inputHasFocus -> hasFocus = inputHasFocus && view.isEnabled } + + // Manually initializing the `DigitsKeyListener` allows spaces to be used and still keeps + // the input type as a number so that the correct software keyboard type is shown + keyListener = DigitsKeyListener.getInstance("01234567890 ") } private val button = container.findViewById<ImageButton>(R.id.login_button).apply { diff --git a/android/src/main/res/layout/account_input.xml b/android/src/main/res/layout/account_input.xml index 1c23583c42..96aa3c7c46 100644 --- a/android/src/main/res/layout/account_input.xml +++ b/android/src/main/res/layout/account_input.xml @@ -1,12 +1,10 @@ <merge xmlns:android="http://schemas.android.com/apk/res/android"> <EditText android:id="@+id/login_input" - android:digits="0123456789" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:paddingHorizontal="12dp" android:background="@drawable/account_input_background" - android:inputType="number" android:singleLine="true" android:imeOptions="flagNoPersonalizedLearning" android:textCursorDrawable="@drawable/text_input_cursor" |
