Passphrase dialog: Button to switch between keyboard layouts
@@ -31,6 +31,7 @@ import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.Layout;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.view.ContextThemeWrapper;
|
||||
@@ -42,6 +43,7 @@ import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ViewAnimator;
|
||||
@@ -286,12 +288,46 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
mPassphraseEditText.setImeActionLabel(getString(android.R.string.ok), EditorInfo.IME_ACTION_DONE);
|
||||
mPassphraseEditText.setOnEditorActionListener(this);
|
||||
|
||||
if ((keyType == CanonicalizedSecretKey.SecretKeyType.DIVERT_TO_CARD && Preferences.getPreferences(activity).useNumKeypadForSecurityTokenPin())
|
||||
|| keyType == CanonicalizedSecretKey.SecretKeyType.PIN) {
|
||||
final ImageButton keyboard = (ImageButton) mLayout.findViewById(R.id.passphrase_keyboard);
|
||||
|
||||
if (keyType == CanonicalizedSecretKey.SecretKeyType.PIN) {
|
||||
mPassphraseEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
mPassphraseEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||
keyboard.setVisibility(View.GONE);
|
||||
} else if (keyType == CanonicalizedSecretKey.SecretKeyType.DIVERT_TO_CARD) {
|
||||
if (Preferences.getPreferences(activity).useNumKeypadForSecurityTokenPin()) {
|
||||
mPassphraseEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
keyboard.setImageResource(R.drawable.ic_alphabetical_black_24dp);
|
||||
keyboard.setContentDescription(getString(R.string.passphrase_keyboard_hint_alpha));
|
||||
} else {
|
||||
mPassphraseEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
keyboard.setImageResource(R.drawable.ic_numeric_black_24dp);
|
||||
keyboard.setContentDescription(getString(R.string.passphrase_keyboard_hint_numeric));
|
||||
}
|
||||
|
||||
keyboard.setVisibility(View.VISIBLE);
|
||||
keyboard.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Preferences prefs = Preferences.getPreferences(activity);
|
||||
if (prefs.useNumKeypadForSecurityTokenPin()) {
|
||||
prefs.setUseNumKeypadForSecurityTokenPin(false);
|
||||
|
||||
mPassphraseEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
keyboard.setImageResource(R.drawable.ic_numeric_black_24dp);
|
||||
keyboard.setContentDescription(getString(R.string.passphrase_keyboard_hint_alpha));
|
||||
} else {
|
||||
prefs.setUseNumKeypadForSecurityTokenPin(true);
|
||||
|
||||
mPassphraseEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
keyboard.setImageResource(R.drawable.ic_alphabetical_black_24dp);
|
||||
keyboard.setContentDescription(getString(R.string.passphrase_keyboard_hint_numeric));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
mPassphraseEditText.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
mPassphraseEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
keyboard.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
mPassphraseEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||
@@ -359,7 +395,6 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
@@ -206,6 +206,12 @@ public class Preferences {
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public void setUseNumKeypadForSecurityTokenPin(boolean useNumKeypad) {
|
||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||
editor.putBoolean(Pref.USE_NUMKEYPAD_FOR_SECURITY_TOKEN_PIN, useNumKeypad);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public boolean getUseArmor() {
|
||||
return mSharedPreferences.getBoolean(Pref.USE_ARMOR, false);
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 333 B |
|
After Width: | Height: | Size: 351 B |
|
After Width: | Height: | Size: 211 B |
|
After Width: | Height: | Size: 234 B |
|
After Width: | Height: | Size: 310 B |
|
After Width: | Height: | Size: 352 B |
|
After Width: | Height: | Size: 411 B |
|
After Width: | Height: | Size: 475 B |
|
After Width: | Height: | Size: 530 B |
|
After Width: | Height: | Size: 601 B |
@@ -23,15 +23,32 @@
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:text="@string/enter_passphrase" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/passphrase_passphrase"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:imeOptions="actionDone"
|
||||
android:hint="@string/label_passphrase"
|
||||
android:ems="10"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
android:orientation="horizontal">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/passphrase_passphrase"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:imeOptions="actionDone"
|
||||
android:hint="@string/label_passphrase"
|
||||
android:ems="10"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/passphrase_keyboard"
|
||||
android:src="@drawable/ic_numeric_black_24dp"
|
||||
style="@style/MaterialFlatButton"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_gravity="center_vertical" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -152,7 +152,6 @@
|
||||
<string name="label_file_ascii_armor">"Enable ASCII Armor"</string>
|
||||
<string name="label_write_version_header">"Let others know that you're using OpenKeychain"</string>
|
||||
<string name="label_write_version_header_summary">"Writes 'OpenKeychain v2.7' to OpenPGP signatures, ciphertext, and exported keys"</string>
|
||||
<string name="label_use_num_keypad_for_security_token_pin">Use number keypad for PINs</string>
|
||||
<string name="label_asymmetric_from">"Sign with:"</string>
|
||||
<string name="label_to">"Encrypt to"</string>
|
||||
<string name="label_delete_after_encryption">"Delete files after encryption"</string>
|
||||
@@ -314,6 +313,8 @@
|
||||
<string name="passphrase_for_symmetric_encryption">"Enter password"</string>
|
||||
<string name="passphrase_for_backup">"Enter backup code"</string>
|
||||
<string name="passphrase_for">"Enter password for '%s'"</string>
|
||||
<string name="passphrase_keyboard_hint_alpha">"Change to alphabetic keyboard"</string>
|
||||
<string name="passphrase_keyboard_hint_numeric">"Change to numeric keyboard"</string>
|
||||
<string name="pin_for">"Enter PIN for '%s'"</string>
|
||||
<string name="security_token_pin_for">"Enter PIN to access Security Token for '%s'"</string>
|
||||
<string name="security_token_nfc_text">"Hold Security Token against the NFC marker at the back of your device."</string>
|
||||
|
||||
@@ -7,8 +7,4 @@
|
||||
android:defaultValue="false"
|
||||
android:key="passphraseCacheSubs"
|
||||
android:title="@string/label_passphrase_cache_subs" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="useNumKeypadForYubikeyPin"
|
||||
android:title="@string/label_use_num_keypad_for_security_token_pin" />
|
||||
</PreferenceScreen>
|
||||
|
||||