remember last selected passphrase cache ttl
This commit is contained in:
parent
d04439df6b
commit
03ca1292fa
|
@ -115,6 +115,7 @@ public final class Constants {
|
||||||
|
|
||||||
public static final class Pref {
|
public static final class Pref {
|
||||||
public static final String PASSPHRASE_CACHE_SUBS = "passphraseCacheSubs";
|
public static final String PASSPHRASE_CACHE_SUBS = "passphraseCacheSubs";
|
||||||
|
public static final String PASSPHRASE_CACHE_LAST_TTL = "passphraseCacheLastTtl";
|
||||||
public static final String LANGUAGE = "language";
|
public static final String LANGUAGE = "language";
|
||||||
public static final String KEY_SERVERS = "keyServers";
|
public static final String KEY_SERVERS = "keyServers";
|
||||||
public static final String PREF_VERSION = "keyServersDefaultVersion";
|
public static final String PREF_VERSION = "keyServersDefaultVersion";
|
||||||
|
|
|
@ -210,6 +210,8 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||||
vTimeToLiveLayout.setVisibility(mRequiredInput.mSkipCaching ? View.GONE : View.VISIBLE);
|
vTimeToLiveLayout.setVisibility(mRequiredInput.mSkipCaching ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
mTimeToLiveSpinner = (CacheTTLSpinner) mLayout.findViewById(R.id.ttl_spinner);
|
mTimeToLiveSpinner = (CacheTTLSpinner) mLayout.findViewById(R.id.ttl_spinner);
|
||||||
|
int ttlSeconds = Preferences.getPreferences(getContext()).getCacheTtlSeconds();
|
||||||
|
mTimeToLiveSpinner.setSelectedTimeToLive(ttlSeconds);
|
||||||
|
|
||||||
alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
|
@ -426,6 +428,8 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||||
final Passphrase passphrase = new Passphrase(mPassphraseEditText);
|
final Passphrase passphrase = new Passphrase(mPassphraseEditText);
|
||||||
final int timeToLiveSeconds = mTimeToLiveSpinner.getSelectedTimeToLive();
|
final int timeToLiveSeconds = mTimeToLiveSpinner.getSelectedTimeToLive();
|
||||||
|
|
||||||
|
Preferences.getPreferences(getContext()).setCacheTtlSeconds(timeToLiveSeconds);
|
||||||
|
|
||||||
// Early breakout if we are dealing with a symmetric key
|
// Early breakout if we are dealing with a symmetric key
|
||||||
if (mRequiredInput.mType == RequiredInputType.PASSPHRASE_SYMMETRIC) {
|
if (mRequiredInput.mType == RequiredInputType.PASSPHRASE_SYMMETRIC) {
|
||||||
if (!mRequiredInput.mSkipCaching) {
|
if (!mRequiredInput.mSkipCaching) {
|
||||||
|
|
|
@ -67,4 +67,14 @@ public class CacheTTLSpinner extends AppCompatSpinner {
|
||||||
Object item = getAdapter().getItem(selectedItemPosition);
|
Object item = getAdapter().getItem(selectedItemPosition);
|
||||||
return ((Cursor) item).getInt(1);
|
return ((Cursor) item).getInt(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSelectedTimeToLive(int ttlSeconds) {
|
||||||
|
for (int i = 0; i < TTL_TIMES.length; i++) {
|
||||||
|
boolean isSelectedOrLast = ttlSeconds <= TTL_TIMES[i] || (i == TTL_TIMES.length - 1);
|
||||||
|
if (isSelectedOrLast) {
|
||||||
|
setSelection(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,16 @@ public class Preferences {
|
||||||
return mSharedPreferences.getBoolean(Pref.PASSPHRASE_CACHE_SUBS, false);
|
return mSharedPreferences.getBoolean(Pref.PASSPHRASE_CACHE_SUBS, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCacheTtlSeconds() {
|
||||||
|
return mSharedPreferences.getInt(Pref.PASSPHRASE_CACHE_LAST_TTL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCacheTtlSeconds(int ttlSeconds) {
|
||||||
|
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||||
|
editor.putInt(Pref.PASSPHRASE_CACHE_LAST_TTL, ttlSeconds);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getCachedConsolidate() {
|
public boolean getCachedConsolidate() {
|
||||||
return mSharedPreferences.getBoolean(Pref.CACHED_CONSOLIDATE, false);
|
return mSharedPreferences.getBoolean(Pref.CACHED_CONSOLIDATE, false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue