Show passphrase fragment for all textable types

PR #2864 removed the code unconditionally displaying passphrase dialog
and the codepath inside onCreate has become the only one that can display
the fragment. However, the if-clause does not consider new types other
than PASSPHRASE that emerged with development of OKC.

Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
This commit is contained in:
Vasyl Gello
2024-02-12 16:39:45 +02:00
parent c846e65d7c
commit 4ebf335821
2 changed files with 18 additions and 2 deletions

View File

@@ -39,6 +39,20 @@ public class RequiredInputParcel implements Parcelable {
return new String(mInputData[0]);
}
public boolean isTextInput() {
switch (mType) {
case BACKUP_CODE:
case NUMERIC_9X4:
case NUMERIC_9X4_AUTOCRYPT:
case PASSPHRASE:
case PASSPHRASE_AUTH:
case PASSPHRASE_SYMMETRIC:
return true;
default:
return false;
}
}
public enum RequiredInputType {
PASSPHRASE, PASSPHRASE_SYMMETRIC, PASSPHRASE_AUTH,
BACKUP_CODE, NUMERIC_9X4, NUMERIC_9X4_AUTOCRYPT,

View File

@@ -107,7 +107,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
// this activity itself has no content view (see manifest)
RequiredInputParcel requiredInput = getIntent().getParcelableExtra(EXTRA_REQUIRED_INPUT);
if (requiredInput.mType != RequiredInputType.PASSPHRASE) {
if (!requiredInput.isTextInput()) {
return;
}
@@ -115,7 +115,9 @@ public class PassphraseDialogActivity extends FragmentActivity {
try {
KeyRepository keyRepository = KeyRepository.create(this);
// use empty passphrase for empty passphrase
if (keyRepository.getSecretKeyType(requiredInput.getSubKeyId()) == SecretKeyType.PASSPHRASE_EMPTY) {
Long subKeyId = requiredInput.getSubKeyId();
if (subKeyId != null &&
keyRepository.getSecretKeyType(subKeyId) == SecretKeyType.PASSPHRASE_EMPTY) {
// also return passphrase back to activity
Intent returnIntent = new Intent();
cryptoInputParcel = cryptoInputParcel.withPassphrase(new Passphrase(""), requiredInput.getSubKeyId());