From 38c6cf045c6e451b3a150bf9b659056c2252d27c Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sun, 31 Aug 2014 00:39:37 +0200 Subject: [PATCH] remember "show advanced tabs" setting Closes #669 --- .../org/sufficientlysecure/keychain/Constants.java | 1 + .../keychain/helper/Preferences.java | 10 ++++++++++ .../keychain/ui/ViewKeyActivity.java | 11 +++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java index 9f84da815..d8dad2517 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java @@ -71,6 +71,7 @@ public final class Constants { public static final String KEY_SERVERS_DEFAULT_VERSION = "keyServersDefaultVersion"; public static final String WRITE_VERSION_HEADER = "writeVersionHeader"; public static final String FIRST_TIME = "firstTime"; + public static final String SHOW_ADVANCED_TABS = "showAdvancedTabs"; public static final String CACHED_CONSOLIDATE = "cachedConsolidate"; public static final String CACHED_CONSOLIDATE_SECRETS = "cachedConsolidateSecrets"; public static final String CACHED_CONSOLIDATE_PUBLICS = "cachedConsolidatePublics"; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java index 0415baf64..866be82d2 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java @@ -135,6 +135,16 @@ public class Preferences { editor.commit(); } + public boolean getShowAdvancedTabs() { + return mSharedPreferences.getBoolean(Pref.SHOW_ADVANCED_TABS, false); + } + + public void setShowAdvancedTabs(boolean value) { + SharedPreferences.Editor editor = mSharedPreferences.edit(); + editor.putBoolean(Pref.SHOW_ADVANCED_TABS, value); + editor.commit(); + } + public boolean getCachedConsolidate() { return mSharedPreferences.getBoolean(Pref.CACHED_CONSOLIDATE, false); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index 2c0881ea4..08300ff04 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -50,11 +50,11 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.ContactHelper; import org.sufficientlysecure.keychain.helper.ExportHelper; +import org.sufficientlysecure.keychain.helper.Preferences; import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; import org.sufficientlysecure.keychain.service.OperationResultParcel; import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter; @@ -161,9 +161,12 @@ public class ViewKeyActivity extends ActionBarActivity implements initNfc(mDataUri); - mShowAdvancedTabs = false; + mShowAdvancedTabs = Preferences.getPreferences(this).getShowAdvancedTabs(); initTabs(mDataUri); + if (mShowAdvancedTabs) { + addAdvancedTabs(mDataUri); + } // switch to tab selected by extra mViewPager.setCurrentItem(switchToTab); @@ -270,6 +273,7 @@ public class ViewKeyActivity extends ActionBarActivity implements } case R.id.menu_key_view_advanced: { mShowAdvancedTabs = !mShowAdvancedTabs; + Preferences.getPreferences(this).setShowAdvancedTabs(mShowAdvancedTabs); item.setChecked(mShowAdvancedTabs); if (mShowAdvancedTabs) { addAdvancedTabs(mDataUri); @@ -344,9 +348,8 @@ public class ViewKeyActivity extends ActionBarActivity implements * guarantee that this activity starts when receiving a beamed message. For now, this code * uses the tag dispatch system. */ - NdefMessage msg = new NdefMessage(NdefRecord.createMime(Constants.NFC_MIME, + return new NdefMessage(NdefRecord.createMime(Constants.NFC_MIME, mNfcKeyringBytes), NdefRecord.createApplicationRecord(Constants.PACKAGE_NAME)); - return msg; } };