Fix to hide PIN input in dialog

This commit is contained in:
Dominik Schürmann
2017-01-05 14:02:57 +01:00
parent 960ebfed0c
commit 068327c939

View File

@@ -291,17 +291,14 @@ public class PassphraseDialogActivity extends FragmentActivity {
final ImageButton keyboard = (ImageButton) mLayout.findViewById(R.id.passphrase_keyboard); final ImageButton keyboard = (ImageButton) mLayout.findViewById(R.id.passphrase_keyboard);
if (keyType == CanonicalizedSecretKey.SecretKeyType.PIN) { if (keyType == CanonicalizedSecretKey.SecretKeyType.PIN) {
mPassphraseEditText.setInputType(InputType.TYPE_CLASS_NUMBER); mPassphraseEditText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_VARIATION_PASSWORD);
mPassphraseEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
keyboard.setVisibility(View.GONE); keyboard.setVisibility(View.GONE);
} else if (keyType == CanonicalizedSecretKey.SecretKeyType.DIVERT_TO_CARD) { } else if (keyType == CanonicalizedSecretKey.SecretKeyType.DIVERT_TO_CARD) {
if (Preferences.getPreferences(activity).useNumKeypadForSecurityTokenPin()) { if (Preferences.getPreferences(activity).useNumKeypadForSecurityTokenPin()) {
mPassphraseEditText.setInputType(InputType.TYPE_CLASS_NUMBER); setKeyboardNumeric(keyboard);
keyboard.setImageResource(R.drawable.ic_alphabetical_black_24dp);
keyboard.setContentDescription(getString(R.string.passphrase_keyboard_hint_alpha));
} else { } else {
mPassphraseEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); setKeyboardAlphabetic(keyboard);
keyboard.setImageResource(R.drawable.ic_numeric_black_24dp);
keyboard.setContentDescription(getString(R.string.passphrase_keyboard_hint_numeric));
} }
keyboard.setVisibility(View.VISIBLE); keyboard.setVisibility(View.VISIBLE);
@@ -312,15 +309,11 @@ public class PassphraseDialogActivity extends FragmentActivity {
if (prefs.useNumKeypadForSecurityTokenPin()) { if (prefs.useNumKeypadForSecurityTokenPin()) {
prefs.setUseNumKeypadForSecurityTokenPin(false); prefs.setUseNumKeypadForSecurityTokenPin(false);
mPassphraseEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); setKeyboardAlphabetic(keyboard);
keyboard.setImageResource(R.drawable.ic_numeric_black_24dp);
keyboard.setContentDescription(getString(R.string.passphrase_keyboard_hint_alpha));
} else { } else {
prefs.setUseNumKeypadForSecurityTokenPin(true); prefs.setUseNumKeypadForSecurityTokenPin(true);
mPassphraseEditText.setInputType(InputType.TYPE_CLASS_NUMBER); setKeyboardNumeric(keyboard);
keyboard.setImageResource(R.drawable.ic_alphabetical_black_24dp);
keyboard.setContentDescription(getString(R.string.passphrase_keyboard_hint_numeric));
} }
} }
}); });
@@ -339,6 +332,22 @@ public class PassphraseDialogActivity extends FragmentActivity {
return dialog; return dialog;
} }
private void setKeyboardNumeric(ImageButton keyboard) {
mPassphraseEditText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_VARIATION_PASSWORD);
// somehow InputType.TYPE_TEXT_VARIATION_PASSWORD is not enough...
mPassphraseEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
keyboard.setImageResource(R.drawable.ic_alphabetical_black_24dp);
keyboard.setContentDescription(getString(R.string.passphrase_keyboard_hint_alpha));
}
private void setKeyboardAlphabetic(ImageButton keyboard) {
mPassphraseEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
// somehow InputType.TYPE_TEXT_VARIATION_PASSWORD is not enough...
mPassphraseEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
keyboard.setImageResource(R.drawable.ic_numeric_black_24dp);
keyboard.setContentDescription(getString(R.string.passphrase_keyboard_hint_numeric));
}
/** /**
* Hack to open keyboard. * Hack to open keyboard.
* This is the only method that I found to work across all Android versions * This is the only method that I found to work across all Android versions