fix Decrypt*Fragment for RequiredInputParcel (except decryptOriginalFilename)
This commit is contained in:
@@ -49,7 +49,8 @@ public abstract class CryptoOperationFragment extends Fragment {
|
||||
return;
|
||||
}
|
||||
|
||||
case PASSPHRASE: {
|
||||
case PASSPHRASE:
|
||||
case PASSPHRASE_SYMMETRIC: {
|
||||
Intent intent = new Intent(getActivity(), PassphraseDialogActivity.class);
|
||||
intent.putExtra(PassphraseDialogActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
||||
startActivityForResult(intent, REQUEST_CODE_PASSPHRASE);
|
||||
|
||||
@@ -93,9 +93,6 @@ public class DecryptFilesFragment extends DecryptFragment {
|
||||
mDecryptButton = view.findViewById(R.id.decrypt_file_action_decrypt);
|
||||
view.findViewById(R.id.decrypt_file_browse).setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
// reset state
|
||||
mPassphrase = null;
|
||||
mNfcDecryptedSessionKey = null;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
FileHelper.openDocument(DecryptFilesFragment.this, "*/*", REQUEST_CODE_INPUT);
|
||||
} else {
|
||||
@@ -207,8 +204,7 @@ public class DecryptFilesFragment extends DecryptFragment {
|
||||
data.putInt(KeychainIntentService.TARGET, IOType.URI.ordinal());
|
||||
data.putParcelable(KeychainIntentService.ENCRYPT_DECRYPT_OUTPUT_URI, mOutputUri);
|
||||
|
||||
// data.putParcelable(KeychainIntentService.DECRYPT_PASSPHRASE, mPassphrase);
|
||||
// data.putByteArray(KeychainIntentService.DECRYPT_NFC_DECRYPTED_SESSION_KEY, mNfcDecryptedSessionKey);
|
||||
data.putParcelable(KeychainIntentService.EXTRA_CRYPTO_INPUT, cryptoInput);
|
||||
|
||||
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
||||
|
||||
@@ -235,20 +231,6 @@ public class DecryptFilesFragment extends DecryptFragment {
|
||||
DecryptVerifyResult pgpResult =
|
||||
returnData.getParcelable(DecryptVerifyResult.EXTRA_RESULT);
|
||||
|
||||
// if (pgpResult.isPending()) {
|
||||
// if ((pgpResult.getResult() & DecryptVerifyResult.RESULT_PENDING_ASYM_PASSPHRASE) ==
|
||||
// DecryptVerifyResult.RESULT_PENDING_ASYM_PASSPHRASE) {
|
||||
// startPassphraseDialog(pgpResult.getKeyIdPassphraseNeeded());
|
||||
// } else if ((pgpResult.getResult() & DecryptVerifyResult.RESULT_PENDING_SYM_PASSPHRASE) ==
|
||||
// DecryptVerifyResult.RESULT_PENDING_SYM_PASSPHRASE) {
|
||||
// startPassphraseDialog(Constants.key.symmetric);
|
||||
// } else if ((pgpResult.getResult() & DecryptVerifyResult.RESULT_PENDING_NFC) ==
|
||||
// DecryptVerifyResult.RESULT_PENDING_NFC) {
|
||||
// startNfcDecrypt(pgpResult.getNfcSubKeyId(), pgpResult.getNfcPassphrase(), pgpResult.getNfcEncryptedSessionKey());
|
||||
// } else {
|
||||
// throw new RuntimeException("Unhandled pending result!");
|
||||
// }
|
||||
|
||||
if (pgpResult.success()) {
|
||||
|
||||
switch (mCurrentCryptoOperation) {
|
||||
@@ -304,22 +286,6 @@ public class DecryptFilesFragment extends DecryptFragment {
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
// case REQUEST_CODE_PASSPHRASE: {
|
||||
// if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
// mPassphrase = data.getParcelableExtra(PassphraseDialogActivity.MESSAGE_DATA_PASSPHRASE);
|
||||
//// decryptOriginalFilename();
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// case REQUEST_CODE_NFC_DECRYPT: {
|
||||
// if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
// mNfcDecryptedSessionKey = data.getByteArrayExtra(OpenPgpApi.EXTRA_NFC_DECRYPTED_SESSION_KEY);
|
||||
//// decryptOriginalFilename();
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
|
||||
case REQUEST_CODE_INPUT: {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
setInputUri(data.getData());
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
@@ -32,14 +31,10 @@ import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.State;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
|
||||
public abstract class DecryptFragment extends CryptoOperationFragment {
|
||||
private static final int RESULT_CODE_LOOKUP_KEY = 0x00007006;
|
||||
|
||||
// public static final int REQUEST_CODE_PASSPHRASE = 0x00008001;
|
||||
// public static final int REQUEST_CODE_NFC_DECRYPT = 0x00008002;
|
||||
|
||||
protected long mSignatureKeyId = 0;
|
||||
|
||||
protected LinearLayout mResultLayout;
|
||||
@@ -56,11 +51,6 @@ public abstract class DecryptFragment extends CryptoOperationFragment {
|
||||
protected TextView mSignatureEmail;
|
||||
protected TextView mSignatureAction;
|
||||
|
||||
|
||||
// State
|
||||
protected Passphrase mPassphrase;
|
||||
protected byte[] mNfcDecryptedSessionKey;
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@@ -30,7 +29,6 @@ import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpApi;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
|
||||
@@ -52,10 +50,7 @@ public class DecryptTextFragment extends DecryptFragment {
|
||||
// view
|
||||
private LinearLayout mValidLayout;
|
||||
private LinearLayout mInvalidLayout;
|
||||
private Button mInvalidButton;
|
||||
private TextView mText;
|
||||
private View mShareButton;
|
||||
private View mCopyButton;
|
||||
|
||||
// model
|
||||
private String mCiphertext;
|
||||
@@ -82,23 +77,26 @@ public class DecryptTextFragment extends DecryptFragment {
|
||||
View view = inflater.inflate(R.layout.decrypt_text_fragment, container, false);
|
||||
mValidLayout = (LinearLayout) view.findViewById(R.id.decrypt_text_valid);
|
||||
mInvalidLayout = (LinearLayout) view.findViewById(R.id.decrypt_text_invalid);
|
||||
mInvalidButton = (Button) view.findViewById(R.id.decrypt_text_invalid_button);
|
||||
mText = (TextView) view.findViewById(R.id.decrypt_text_plaintext);
|
||||
mShareButton = view.findViewById(R.id.action_decrypt_share_plaintext);
|
||||
mCopyButton = view.findViewById(R.id.action_decrypt_copy_plaintext);
|
||||
mShareButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
View vShareButton = view.findViewById(R.id.action_decrypt_share_plaintext);
|
||||
vShareButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(sendWithChooserExcludingEncrypt(mText.getText().toString()));
|
||||
}
|
||||
});
|
||||
mCopyButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
View vCopyButton = view.findViewById(R.id.action_decrypt_copy_plaintext);
|
||||
vCopyButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
copyToClipboard(mText.getText().toString());
|
||||
}
|
||||
});
|
||||
mInvalidButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
Button vInvalidButton = (Button) view.findViewById(R.id.decrypt_text_invalid_button);
|
||||
vInvalidButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mInvalidLayout.setVisibility(View.GONE);
|
||||
@@ -162,8 +160,7 @@ public class DecryptTextFragment extends DecryptFragment {
|
||||
data.putParcelable(KeychainIntentService.EXTRA_CRYPTO_INPUT, cryptoInput);
|
||||
data.putInt(KeychainIntentService.TARGET, IOType.BYTES.ordinal());
|
||||
data.putByteArray(KeychainIntentService.DECRYPT_CIPHERTEXT_BYTES, mCiphertext.getBytes());
|
||||
// data.putParcelable(KeychainIntentService.DECRYPT_PASSPHRASE, mPassphrase);
|
||||
// data.putByteArray(KeychainIntentService.DECRYPT_NFC_DECRYPTED_SESSION_KEY, mNfcDecryptedSessionKey);
|
||||
data.putParcelable(KeychainIntentService.EXTRA_CRYPTO_INPUT, cryptoInput);
|
||||
|
||||
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
||||
|
||||
@@ -189,19 +186,6 @@ public class DecryptTextFragment extends DecryptFragment {
|
||||
DecryptVerifyResult pgpResult =
|
||||
returnData.getParcelable(DecryptVerifyResult.EXTRA_RESULT);
|
||||
|
||||
// if (pgpResult.isPending()) {
|
||||
// if ((pgpResult.getResult() & DecryptVerifyResult.RESULT_PENDING_ASYM_PASSPHRASE) ==
|
||||
// DecryptVerifyResult.RESULT_PENDING_ASYM_PASSPHRASE) {
|
||||
// startPassphraseDialog(pgpResult.getKeyIdPassphraseNeeded());
|
||||
// } else if ((pgpResult.getResult() & DecryptVerifyResult.RESULT_PENDING_SYM_PASSPHRASE) ==
|
||||
// DecryptVerifyResult.RESULT_PENDING_SYM_PASSPHRASE) {
|
||||
// startPassphraseDialog(Constants.key.symmetric);
|
||||
// } else if ((pgpResult.getResult() & DecryptVerifyResult.RESULT_PENDING_NFC) ==
|
||||
// DecryptVerifyResult.RESULT_PENDING_NFC) {
|
||||
// startNfcDecrypt(pgpResult.getNfcSubKeyId(), pgpResult.getNfcPassphrase(), pgpResult.getNfcEncryptedSessionKey());
|
||||
// } else {
|
||||
// throw new RuntimeException("Unhandled pending result!");
|
||||
// }
|
||||
if (pgpResult.success()) {
|
||||
|
||||
byte[] decryptedMessage = returnData
|
||||
@@ -250,34 +234,4 @@ public class DecryptTextFragment extends DecryptFragment {
|
||||
getActivity().startService(intent);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
// switch (requestCode) {
|
||||
//
|
||||
// case REQUEST_CODE_PASSPHRASE: {
|
||||
// if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
// mPassphrase = data.getParcelableExtra(PassphraseDialogActivity.MESSAGE_DATA_PASSPHRASE);
|
||||
// decryptStart();
|
||||
// } else {
|
||||
// getActivity().finish();
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// case REQUEST_CODE_NFC_DECRYPT: {
|
||||
// if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
// mNfcDecryptedSessionKey = data.getByteArrayExtra(OpenPgpApi.EXTRA_NFC_DECRYPTED_SESSION_KEY);
|
||||
// decryptStart();
|
||||
// } else {
|
||||
// getActivity().finish();
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// default: {
|
||||
// super.onActivityResult(requestCode, resultCode, data);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -97,10 +97,19 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
keyId = getIntent().getLongExtra(EXTRA_SUBKEY_ID, 0);
|
||||
} else {
|
||||
RequiredInputParcel requiredInput = getIntent().getParcelableExtra(EXTRA_REQUIRED_INPUT);
|
||||
if (requiredInput.mType != RequiredInputType.PASSPHRASE) {
|
||||
throw new AssertionError("Wrong required input type for PassphraseDialogActivity!");
|
||||
switch (requiredInput.mType) {
|
||||
case PASSPHRASE_SYMMETRIC: {
|
||||
keyId = Constants.key.symmetric;
|
||||
break;
|
||||
}
|
||||
case PASSPHRASE: {
|
||||
keyId = requiredInput.getSubKeyId();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw new AssertionError("Unsupported required input type for PassphraseDialogActivity!");
|
||||
}
|
||||
}
|
||||
keyId = requiredInput.getSubKeyId();
|
||||
}
|
||||
|
||||
Intent serviceIntent = getIntent().getParcelableExtra(EXTRA_SERVICE_INTENT);
|
||||
|
||||
Reference in New Issue
Block a user