remember "show advanced tabs" setting

Closes #669
This commit is contained in:
Vincent Breitmoser 2014-08-31 00:39:37 +02:00
parent a73abf57f1
commit 38c6cf045c
3 changed files with 18 additions and 4 deletions

View File

@ -71,6 +71,7 @@ public final class Constants {
public static final String KEY_SERVERS_DEFAULT_VERSION = "keyServersDefaultVersion"; public static final String KEY_SERVERS_DEFAULT_VERSION = "keyServersDefaultVersion";
public static final String WRITE_VERSION_HEADER = "writeVersionHeader"; public static final String WRITE_VERSION_HEADER = "writeVersionHeader";
public static final String FIRST_TIME = "firstTime"; 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 = "cachedConsolidate";
public static final String CACHED_CONSOLIDATE_SECRETS = "cachedConsolidateSecrets"; public static final String CACHED_CONSOLIDATE_SECRETS = "cachedConsolidateSecrets";
public static final String CACHED_CONSOLIDATE_PUBLICS = "cachedConsolidatePublics"; public static final String CACHED_CONSOLIDATE_PUBLICS = "cachedConsolidatePublics";

View File

@ -135,6 +135,16 @@ public class Preferences {
editor.commit(); 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() { public boolean getCachedConsolidate() {
return mSharedPreferences.getBoolean(Pref.CACHED_CONSOLIDATE, false); return mSharedPreferences.getBoolean(Pref.CACHED_CONSOLIDATE, false);
} }

View File

@ -50,11 +50,11 @@ import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.ContactHelper; import org.sufficientlysecure.keychain.helper.ContactHelper;
import org.sufficientlysecure.keychain.helper.ExportHelper; import org.sufficientlysecure.keychain.helper.ExportHelper;
import org.sufficientlysecure.keychain.helper.Preferences;
import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
import org.sufficientlysecure.keychain.service.OperationResultParcel; import org.sufficientlysecure.keychain.service.OperationResultParcel;
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter; import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
@ -161,9 +161,12 @@ public class ViewKeyActivity extends ActionBarActivity implements
initNfc(mDataUri); initNfc(mDataUri);
mShowAdvancedTabs = false; mShowAdvancedTabs = Preferences.getPreferences(this).getShowAdvancedTabs();
initTabs(mDataUri); initTabs(mDataUri);
if (mShowAdvancedTabs) {
addAdvancedTabs(mDataUri);
}
// switch to tab selected by extra // switch to tab selected by extra
mViewPager.setCurrentItem(switchToTab); mViewPager.setCurrentItem(switchToTab);
@ -270,6 +273,7 @@ public class ViewKeyActivity extends ActionBarActivity implements
} }
case R.id.menu_key_view_advanced: { case R.id.menu_key_view_advanced: {
mShowAdvancedTabs = !mShowAdvancedTabs; mShowAdvancedTabs = !mShowAdvancedTabs;
Preferences.getPreferences(this).setShowAdvancedTabs(mShowAdvancedTabs);
item.setChecked(mShowAdvancedTabs); item.setChecked(mShowAdvancedTabs);
if (mShowAdvancedTabs) { if (mShowAdvancedTabs) {
addAdvancedTabs(mDataUri); 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 * guarantee that this activity starts when receiving a beamed message. For now, this code
* uses the tag dispatch system. * 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)); mNfcKeyringBytes), NdefRecord.createApplicationRecord(Constants.PACKAGE_NAME));
return msg;
} }
}; };