diff options
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain')
3 files changed, 33 insertions, 15 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 9fd3a4988..4361705f9 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java @@ -21,6 +21,8 @@ import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; +import android.view.Menu; +import android.view.MenuItem; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; @@ -56,9 +58,33 @@ public class EncryptActivity extends BaseActivity { } } - public void toggleModeFragment() { - boolean symmetric = getModeFragment() instanceof EncryptModeAsymmetricFragment; + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.check_use_symmetric: { + item.setChecked(!item.isChecked()); + setModeFragment(item.isChecked()); + return true; + } + default: { + return super.onOptionsItemSelected(item); + } + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.encrypt_activity, menu); + + Fragment frag = + getSupportFragmentManager().findFragmentById(R.id.encrypt_mode_container); + boolean isSymmetric = frag instanceof EncryptModeSymmetricFragment; + menu.findItem(R.id.check_use_symmetric).setChecked(isSymmetric); + + return super.onCreateOptionsMenu(menu); + } + private void setModeFragment(boolean symmetric) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.encrypt_mode_container, symmetric diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java index fa35cc9ac..713c03fc2 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java @@ -250,9 +250,6 @@ public class EncryptFilesFragment extends CryptoOperationFragment { @Override public boolean onOptionsItemSelected(MenuItem item) { - if (item.isCheckable()) { - item.setChecked(!item.isChecked()); - } switch (item.getItemId()) { case R.id.encrypt_save: { encryptClicked(false); @@ -262,24 +259,24 @@ public class EncryptFilesFragment extends CryptoOperationFragment { encryptClicked(true); break; } - case R.id.check_use_symmetric: { - EncryptActivity encryptActivity = (EncryptActivity) getActivity(); - encryptActivity.toggleModeFragment(); - break; - } case R.id.check_use_armor: { + // we can NOT do this for every item, others might care! + item.setChecked(!item.isChecked()); mUseArmor = item.isChecked(); break; } case R.id.check_delete_after_encrypt: { + item.setChecked(!item.isChecked()); mDeleteAfterEncrypt = item.isChecked(); break; } case R.id.check_enable_compression: { + item.setChecked(!item.isChecked()); mUseCompression = item.isChecked(); break; } case R.id.check_encrypt_filenames: { + item.setChecked(!item.isChecked()); mEncryptFilenames = item.isChecked(); break; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextFragment.java index 89bc97e16..90eb2b1f3 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextFragment.java @@ -137,11 +137,6 @@ public class EncryptTextFragment extends CryptoOperationFragment { item.setChecked(!item.isChecked()); } switch (item.getItemId()) { - case R.id.check_use_symmetric: { - EncryptActivity modeInterface = (EncryptActivity) getActivity(); - modeInterface.toggleModeFragment(); - break; - } case R.id.check_enable_compression: { mUseCompression = item.isChecked(); break; |