diff options
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java | 67 |
1 files changed, 30 insertions, 37 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java index 94f828b48..7e08f6b7c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java @@ -81,10 +81,6 @@ public class EncryptActivity extends DrawerActivity implements EncryptActivityIn PagerTabStripAdapter mTabsAdapterContent; // tabs - Bundle mAsymmetricFragmentBundle = new Bundle(); - Bundle mSymmetricFragmentBundle = new Bundle(); - Bundle mMessageFragmentBundle = new Bundle(); - Bundle mFileFragmentBundle = new Bundle(); int mSwitchToMode = PAGER_MODE_ASYMMETRIC; int mSwitchToContent = PAGER_CONTENT_MESSAGE; @@ -93,7 +89,7 @@ public class EncryptActivity extends DrawerActivity implements EncryptActivityIn private static final int PAGER_CONTENT_MESSAGE = 0; private static final int PAGER_CONTENT_FILE = 1; - // model used by message and file fragments + // model used by fragments private long mEncryptionKeyIds[] = null; private String mEncryptionUserIds[] = null; private long mSigningKeyId = Constants.key.none; @@ -267,21 +263,23 @@ public class EncryptActivity extends DrawerActivity implements EncryptActivityIn if (isContentMessage()) { data.putInt(KeychainIntentService.TARGET, KeychainIntentService.IO_BYTES); data.putByteArray(KeychainIntentService.ENCRYPT_MESSAGE_BYTES, mMessage.getBytes()); + + data.putInt(KeychainIntentService.ENCRYPT_COMPRESSION_ID, + Preferences.getPreferences(this).getDefaultMessageCompression()); } else { data.putInt(KeychainIntentService.SOURCE, KeychainIntentService.IO_URIS); data.putParcelableArrayList(KeychainIntentService.ENCRYPT_INPUT_URIS, mInputUris); data.putInt(KeychainIntentService.TARGET, KeychainIntentService.IO_URIS); data.putParcelableArrayList(KeychainIntentService.ENCRYPT_OUTPUT_URIS, mOutputUris); + + data.putInt(KeychainIntentService.ENCRYPT_COMPRESSION_ID, + Preferences.getPreferences(this).getDefaultFileCompression()); } // Always use armor for messages data.putBoolean(KeychainIntentService.ENCRYPT_USE_ASCII_ARMOR, mUseArmor || isContentMessage()); - // TODO: Only default compression right now... - int compressionId = Preferences.getPreferences(this).getDefaultMessageCompression(); - data.putInt(KeychainIntentService.ENCRYPT_COMPRESSION_ID, compressionId); - if (isModeSymmetric()) { Log.d(Constants.TAG, "Symmetric encryption enabled!"); String passphrase = mPassphrase; @@ -426,7 +424,6 @@ public class EncryptActivity extends DrawerActivity implements EncryptActivityIn if (isModeSymmetric()) { // symmetric encryption checks - if (mPassphrase == null) { Notify.showNotify(this, R.string.passphrases_do_not_match, Notify.Style.ERROR); return false; @@ -453,20 +450,24 @@ public class EncryptActivity extends DrawerActivity implements EncryptActivityIn return false; } - if (mSigningKeyId != 0 && PassphraseCacheService.getCachedPassphrase(this, mSigningKeyId) == null) { - PassphraseDialogFragment.show(this, mSigningKeyId, - new Handler() { - @Override - public void handleMessage(Message message) { - if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) { - // restart - startEncrypt(); + try { + if (mSigningKeyId != 0 && PassphraseCacheService.getCachedPassphrase(this, mSigningKeyId) == null) { + PassphraseDialogFragment.show(this, mSigningKeyId, + new Handler() { + @Override + public void handleMessage(Message message) { + if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) { + // restart + startEncrypt(); + } } } - } - ); + ); - return false; + return false; + } + } catch (PassphraseCacheService.KeyNotFoundException e) { + Log.e(Constants.TAG, "Key not found!", e); } } return true; @@ -502,16 +503,12 @@ public class EncryptActivity extends DrawerActivity implements EncryptActivityIn // Handle intent actions handleActions(getIntent()); - mTabsAdapterMode.addTab(EncryptAsymmetricFragment.class, - mAsymmetricFragmentBundle, getString(R.string.label_asymmetric)); - mTabsAdapterMode.addTab(EncryptSymmetricFragment.class, - mSymmetricFragmentBundle, getString(R.string.label_symmetric)); + mTabsAdapterMode.addTab(EncryptAsymmetricFragment.class, null, getString(R.string.label_asymmetric)); + mTabsAdapterMode.addTab(EncryptSymmetricFragment.class, null, getString(R.string.label_symmetric)); mViewPagerMode.setCurrentItem(mSwitchToMode); - mTabsAdapterContent.addTab(EncryptMessageFragment.class, - mMessageFragmentBundle, getString(R.string.label_message)); - mTabsAdapterContent.addTab(EncryptFileFragment.class, - mFileFragmentBundle, getString(R.string.label_files)); + mTabsAdapterContent.addTab(EncryptMessageFragment.class, null, getString(R.string.label_message)); + mTabsAdapterContent.addTab(EncryptFileFragment.class, null, getString(R.string.label_files)); mViewPagerContent.setCurrentItem(mSwitchToContent); mUseArmor = Preferences.getPreferences(this).getDefaultAsciiArmor(); @@ -603,14 +600,10 @@ public class EncryptActivity extends DrawerActivity implements EncryptActivityIn String textData = extras.getString(EXTRA_TEXT); - long signatureKeyId = extras.getLong(EXTRA_SIGNATURE_KEY_ID); - long[] encryptionKeyIds = extras.getLongArray(EXTRA_ENCRYPTION_KEY_IDS); + mSigningKeyId = extras.getLong(EXTRA_SIGNATURE_KEY_ID); + mEncryptionKeyIds = extras.getLongArray(EXTRA_ENCRYPTION_KEY_IDS); // preselect keys given by intent - mAsymmetricFragmentBundle.putLongArray(EncryptAsymmetricFragment.ARG_ENCRYPTION_KEY_IDS, - encryptionKeyIds); - mAsymmetricFragmentBundle.putLong(EncryptAsymmetricFragment.ARG_SIGNATURE_KEY_ID, - signatureKeyId); mSwitchToMode = PAGER_MODE_ASYMMETRIC; /** @@ -618,11 +611,11 @@ public class EncryptActivity extends DrawerActivity implements EncryptActivityIn */ if (ACTION_ENCRYPT.equals(action) && textData != null) { // encrypt text based on given extra - mMessageFragmentBundle.putString(EncryptMessageFragment.ARG_TEXT, textData); + mMessage = textData; mSwitchToContent = PAGER_CONTENT_MESSAGE; } else if (ACTION_ENCRYPT.equals(action) && uris != null && !uris.isEmpty()) { // encrypt file based on Uri - mFileFragmentBundle.putParcelableArrayList(EncryptFileFragment.ARG_URIS, uris); + mInputUris = uris; mSwitchToContent = PAGER_CONTENT_FILE; } else if (ACTION_ENCRYPT.equals(action)) { Log.e(Constants.TAG, |