Support numeric9x4 passphrase-format during decryption

This commit is contained in:
Vincent Breitmoser
2018-04-13 19:07:59 +02:00
parent cb56a44f77
commit ded58588ad
9 changed files with 288 additions and 12 deletions

View File

@@ -201,6 +201,30 @@ public class PassphraseDialogActivity extends FragmentActivity {
return dialog;
}
if (mRequiredInput.mType == RequiredInputType.NUMERIC_9X4) {
LayoutInflater inflater = LayoutInflater.from(theme);
View view = inflater.inflate(R.layout.passphrase_dialog_numeric_9x4, null);
alert.setView(view);
mBackupCodeEditText = new EditText[9];
mBackupCodeEditText[0] = view.findViewById(R.id.transfer_code_block_1);
mBackupCodeEditText[1] = view.findViewById(R.id.transfer_code_block_2);
mBackupCodeEditText[2] = view.findViewById(R.id.transfer_code_block_3);
mBackupCodeEditText[3] = view.findViewById(R.id.transfer_code_block_4);
mBackupCodeEditText[4] = view.findViewById(R.id.transfer_code_block_5);
mBackupCodeEditText[5] = view.findViewById(R.id.transfer_code_block_6);
mBackupCodeEditText[6] = view.findViewById(R.id.transfer_code_block_7);
mBackupCodeEditText[7] = view.findViewById(R.id.transfer_code_block_8);
mBackupCodeEditText[8] = view.findViewById(R.id.transfer_code_block_9);
setupEditTextFocusNext(mBackupCodeEditText);
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);
mLayout = (ViewAnimator) inflater.inflate(R.layout.passphrase_dialog, null);
alert.setView(mLayout);
@@ -432,6 +456,23 @@ public class PassphraseDialogActivity extends FragmentActivity {
return;
}
if (mRequiredInput.mType == RequiredInputType.NUMERIC_9X4) {
StringBuilder backupCodeInput = new StringBuilder(36);
for (EditText editText : mBackupCodeEditText) {
if (editText.getText().length() < 4) {
return;
}
backupCodeInput.append(editText.getText());
backupCodeInput.append('-');
}
backupCodeInput.deleteCharAt(backupCodeInput.length() - 1);
Passphrase passphrase = new Passphrase(backupCodeInput.toString());
finishCaching(passphrase, null);
return;
}
final Passphrase passphrase = new Passphrase(mPassphraseEditText);
final int timeToLiveSeconds = mTimeToLiveSpinner.getSelectedTimeToLive();

View File

@@ -162,7 +162,8 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
case PASSPHRASE:
case PASSPHRASE_SYMMETRIC:
case BACKUP_CODE: {
case BACKUP_CODE:
case NUMERIC_9X4: {
Intent intent = new Intent(activity, PassphraseDialogActivity.class);
intent.putExtra(PassphraseDialogActivity.EXTRA_REQUIRED_INPUT, requiredInput);
intent.putExtra(PassphraseDialogActivity.EXTRA_CRYPTO_INPUT, cryptoInputParcel);