Check if backup code in passphrase dialog

This commit is contained in:
Dominik Schürmann
2015-10-15 23:08:30 +02:00
parent cac7c3234a
commit 6ea58aa0a7
3 changed files with 23 additions and 0 deletions

View File

@@ -149,6 +149,7 @@ public final class Constants {
public static final class key { public static final class key {
public static final int none = 0; public static final int none = 0;
public static final int symmetric = -1; public static final int symmetric = -1;
public static final int backup_code = -2;
} }
} }

View File

@@ -117,6 +117,10 @@ public class PassphraseDialogActivity extends FragmentActivity {
mSubKeyId = Constants.key.symmetric; mSubKeyId = Constants.key.symmetric;
break; break;
} }
case BACKUP_CODE: {
mSubKeyId = Constants.key.backup_code;
break;
}
case PASSPHRASE: { case PASSPHRASE: {
// handle empty passphrases by directly returning an empty crypto input parcel // handle empty passphrases by directly returning an empty crypto input parcel
@@ -208,6 +212,17 @@ public class PassphraseDialogActivity extends FragmentActivity {
// No title, see http://www.google.com/design/spec/components/dialogs.html#dialogs-alerts // No title, see http://www.google.com/design/spec/components/dialogs.html#dialogs-alerts
//alert.setTitle() //alert.setTitle()
if (mSubKeyId == Constants.key.backup_code) {
LayoutInflater inflater = LayoutInflater.from(theme);
View view = inflater.inflate(R.layout.passphrase_dialog_backup_code, null);
alert.setView(view);
AlertDialog dialog = alert.create();
dialog.setButton(DialogInterface.BUTTON_POSITIVE,
activity.getString(R.string.btn_unlock), (DialogInterface.OnClickListener) null);
return dialog;
}
LayoutInflater inflater = LayoutInflater.from(theme); LayoutInflater inflater = LayoutInflater.from(theme);
View view = inflater.inflate(R.layout.passphrase_dialog, null); View view = inflater.inflate(R.layout.passphrase_dialog, null);
alert.setView(view); alert.setView(view);
@@ -229,8 +244,10 @@ public class PassphraseDialogActivity extends FragmentActivity {
CanonicalizedSecretKey.SecretKeyType keyType = CanonicalizedSecretKey.SecretKeyType.PASSPHRASE; CanonicalizedSecretKey.SecretKeyType keyType = CanonicalizedSecretKey.SecretKeyType.PASSPHRASE;
String message; String message;
String hint;
if (mSubKeyId == Constants.key.symmetric || mSubKeyId == Constants.key.none) { if (mSubKeyId == Constants.key.symmetric || mSubKeyId == Constants.key.none) {
message = getString(R.string.passphrase_for_symmetric_encryption); message = getString(R.string.passphrase_for_symmetric_encryption);
hint = getString(R.string.label_passphrase);
} else { } else {
try { try {
ProviderHelper helper = new ProviderHelper(activity); ProviderHelper helper = new ProviderHelper(activity);
@@ -255,12 +272,15 @@ public class PassphraseDialogActivity extends FragmentActivity {
switch (keyType) { switch (keyType) {
case PASSPHRASE: case PASSPHRASE:
message = getString(R.string.passphrase_for, userId); message = getString(R.string.passphrase_for, userId);
hint = getString(R.string.label_passphrase);
break; break;
case PIN: case PIN:
message = getString(R.string.pin_for, userId); message = getString(R.string.pin_for, userId);
hint = getString(R.string.label_pin);
break; break;
case DIVERT_TO_CARD: case DIVERT_TO_CARD:
message = getString(R.string.yubikey_pin_for, userId); message = getString(R.string.yubikey_pin_for, userId);
hint = getString(R.string.label_pin);
break; break;
// special case: empty passphrase just returns the empty passphrase // special case: empty passphrase just returns the empty passphrase
case PASSPHRASE_EMPTY: case PASSPHRASE_EMPTY:
@@ -283,6 +303,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
} }
mPassphraseText.setText(message); mPassphraseText.setText(message);
mPassphraseEditText.setHint(hint);
// 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

View File

@@ -132,6 +132,7 @@
<string name="label_file_colon">"File:"</string> <string name="label_file_colon">"File:"</string>
<string name="label_no_passphrase">"No Password"</string> <string name="label_no_passphrase">"No Password"</string>
<string name="label_passphrase">"Password"</string> <string name="label_passphrase">"Password"</string>
<string name="label_pin">"PIN"</string>
<string name="label_unlock">"Unlocking…"</string> <string name="label_unlock">"Unlocking…"</string>
<string name="label_passphrase_again">"Repeat Password"</string> <string name="label_passphrase_again">"Repeat Password"</string>
<string name="label_show_passphrase">"Show Password"</string> <string name="label_show_passphrase">"Show Password"</string>