aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-04-01 00:38:01 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-04-01 00:39:32 +0200
commitad69622b6983d139e2cef1380f502edef19d2180 (patch)
tree17d06ee5ce8a683503b3ecc9e56f265c4f99324b /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui
parentcc44ff1a8b3b51331023ef738ccd28bece32da40 (diff)
downloadopen-keychain-ad69622b6983d139e2cef1380f502edef19d2180.tar.gz
open-keychain-ad69622b6983d139e2cef1380f502edef19d2180.tar.bz2
open-keychain-ad69622b6983d139e2cef1380f502edef19d2180.zip
fix Decrypt*Fragment for RequiredInputParcel (except decryptOriginalFilename)
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CryptoOperationFragment.java3
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFilesFragment.java36
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java10
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptTextFragment.java66
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java15
5 files changed, 25 insertions, 105 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CryptoOperationFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CryptoOperationFragment.java
index f0a7859f7..b136492b4 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CryptoOperationFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CryptoOperationFragment.java
@@ -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);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFilesFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFilesFragment.java
index cd66902ba..766e65e8b 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFilesFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFilesFragment.java
@@ -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());
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java
index 38ad54ad3..f320a6d84 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java
@@ -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);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptTextFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptTextFragment.java
index 086830389..9c6c89c43 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptTextFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptTextFragment.java
@@ -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);
-// }
-// }
-// }
-
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java
index 074e40b22..007608f80 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java
@@ -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);