remember last selected passphrase cache ttl
This commit is contained in:
@@ -210,6 +210,8 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
vTimeToLiveLayout.setVisibility(mRequiredInput.mSkipCaching ? View.GONE : View.VISIBLE);
|
||||
|
||||
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() {
|
||||
|
||||
@@ -426,6 +428,8 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
final Passphrase passphrase = new Passphrase(mPassphraseEditText);
|
||||
final int timeToLiveSeconds = mTimeToLiveSpinner.getSelectedTimeToLive();
|
||||
|
||||
Preferences.getPreferences(getContext()).setCacheTtlSeconds(timeToLiveSeconds);
|
||||
|
||||
// Early breakout if we are dealing with a symmetric key
|
||||
if (mRequiredInput.mType == RequiredInputType.PASSPHRASE_SYMMETRIC) {
|
||||
if (!mRequiredInput.mSkipCaching) {
|
||||
|
||||
@@ -67,4 +67,14 @@ public class CacheTTLSpinner extends AppCompatSpinner {
|
||||
Object item = getAdapter().getItem(selectedItemPosition);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user