ditch passphrase "time to live" setting
This commit is contained in:
parent
1f2d9c85e0
commit
d04439df6b
|
@ -496,11 +496,6 @@
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
android:label="@string/title_smartpgp_authorities_preference"
|
android:label="@string/title_smartpgp_authorities_preference"
|
||||||
android:windowSoftInputMode="stateHidden" />
|
android:windowSoftInputMode="stateHidden" />
|
||||||
<activity
|
|
||||||
android:name=".ui.SettingsCacheTTLActivity"
|
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
|
||||||
android:label="@string/title_cache_ttl_preference"
|
|
||||||
android:windowSoftInputMode="stateHidden" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.BackupActivity"
|
android:name=".ui.BackupActivity"
|
||||||
android:configChanges="keyboardHidden|keyboard"
|
android:configChanges="keyboardHidden|keyboard"
|
||||||
|
|
|
@ -114,8 +114,6 @@ public final class Constants {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class Pref {
|
public static final class Pref {
|
||||||
public static final String PASSPHRASE_CACHE_TTLS = "passphraseCacheTtls";
|
|
||||||
public static final String PASSPHRASE_CACHE_DEFAULT = "passphraseCacheDefault";
|
|
||||||
public static final String PASSPHRASE_CACHE_SUBS = "passphraseCacheSubs";
|
public static final String PASSPHRASE_CACHE_SUBS = "passphraseCacheSubs";
|
||||||
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";
|
||||||
|
|
|
@ -204,17 +204,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||||
|
|
||||||
// Load the preferences from an XML resource
|
// Load the preferences from an XML resource
|
||||||
addPreferencesFromResource(R.xml.passphrase_preferences);
|
addPreferencesFromResource(R.xml.passphrase_preferences);
|
||||||
|
|
||||||
findPreference(Constants.Pref.PASSPHRASE_CACHE_TTLS)
|
|
||||||
.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
Intent intent = new Intent(getActivity(), SettingsCacheTTLActivity.class);
|
|
||||||
intent.putExtra(SettingsCacheTTLActivity.EXTRA_TTL_PREF,
|
|
||||||
sPreferences.getPassphraseCacheTtl());
|
|
||||||
startActivity(intent);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,82 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2015 Vincent Breitmoser <v.breitmoser@my.amazin.horse>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
|
||||||
import org.sufficientlysecure.keychain.ui.base.BaseActivity;
|
|
||||||
import org.sufficientlysecure.keychain.util.Preferences.CacheTTLPrefs;
|
|
||||||
|
|
||||||
|
|
||||||
public class SettingsCacheTTLActivity extends BaseActivity {
|
|
||||||
|
|
||||||
public static final String EXTRA_TTL_PREF = "ttl_pref";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
Intent intent = getIntent();
|
|
||||||
CacheTTLPrefs ttlPrefs = (CacheTTLPrefs) intent.getSerializableExtra(EXTRA_TTL_PREF);
|
|
||||||
loadFragment(savedInstanceState, ttlPrefs);
|
|
||||||
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case android.R.id.home:
|
|
||||||
finish();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initLayout() {
|
|
||||||
setContentView(R.layout.settings_cache_ttl);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadFragment(Bundle savedInstanceState, CacheTTLPrefs ttlPrefs) {
|
|
||||||
// However, if we're being restored from a previous state,
|
|
||||||
// then we don't need to do anything and should return or else
|
|
||||||
// we could end up with overlapping fragments.
|
|
||||||
if (savedInstanceState != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SettingsCacheTTLFragment fragment = SettingsCacheTTLFragment.newInstance(ttlPrefs);
|
|
||||||
|
|
||||||
// Add the fragment to the 'fragment_container' FrameLayout
|
|
||||||
// NOTE: We use commitAllowingStateLoss() to prevent weird crashes!
|
|
||||||
getSupportFragmentManager().beginTransaction()
|
|
||||||
.replace(R.id.settings_cache_ttl_fragment, fragment)
|
|
||||||
.commitAllowingStateLoss();
|
|
||||||
// do it immediately!
|
|
||||||
getSupportFragmentManager().executePendingTransactions();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,199 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2015 Vincent Breitmoser <v.breitmoser@my.amazin.horse>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
|
||||||
import org.sufficientlysecure.keychain.ui.util.recyclerview.DividerItemDecoration;
|
|
||||||
import org.sufficientlysecure.keychain.util.Preferences;
|
|
||||||
import org.sufficientlysecure.keychain.util.Preferences.CacheTTLPrefs;
|
|
||||||
|
|
||||||
|
|
||||||
public class SettingsCacheTTLFragment extends Fragment {
|
|
||||||
|
|
||||||
public static final String ARG_TTL_PREFS = "ttl_prefs";
|
|
||||||
|
|
||||||
private CacheTTLListAdapter mAdapter;
|
|
||||||
|
|
||||||
public static SettingsCacheTTLFragment newInstance(CacheTTLPrefs ttlPrefs) {
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putSerializable(ARG_TTL_PREFS, ttlPrefs);
|
|
||||||
|
|
||||||
SettingsCacheTTLFragment fragment = new SettingsCacheTTLFragment();
|
|
||||||
fragment.setArguments(args);
|
|
||||||
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
|
|
||||||
savedInstanceState) {
|
|
||||||
|
|
||||||
return inflater.inflate(R.layout.settings_cache_ttl_fragment, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
|
|
||||||
CacheTTLPrefs prefs = (CacheTTLPrefs) getArguments().getSerializable(ARG_TTL_PREFS);
|
|
||||||
|
|
||||||
mAdapter = new CacheTTLListAdapter(prefs);
|
|
||||||
|
|
||||||
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.cache_ttl_recycler_view);
|
|
||||||
recyclerView.setHasFixedSize(true);
|
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
|
||||||
recyclerView.setAdapter(mAdapter);
|
|
||||||
recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST,
|
|
||||||
true));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void savePreference() {
|
|
||||||
FragmentActivity activity = getActivity();
|
|
||||||
if (activity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CacheTTLPrefs prefs = mAdapter.getPrefs();
|
|
||||||
Preferences.getPreferences(activity).setPassphraseCacheTtl(prefs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CacheTTLListAdapter extends RecyclerView.Adapter<CacheTTLListAdapter.ViewHolder> {
|
|
||||||
|
|
||||||
private final ArrayList<Boolean> mPositionIsChecked;
|
|
||||||
|
|
||||||
public CacheTTLListAdapter(CacheTTLPrefs prefs) {
|
|
||||||
this.mPositionIsChecked = new ArrayList<>();
|
|
||||||
for (int ttlTime : CacheTTLPrefs.CACHE_TTLS) {
|
|
||||||
mPositionIsChecked.add(prefs.ttlTimes.contains(ttlTime));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public CacheTTLPrefs getPrefs() {
|
|
||||||
ArrayList<String> ttls = new ArrayList<>();
|
|
||||||
for (int i = 0; i < mPositionIsChecked.size(); i++) {
|
|
||||||
if (mPositionIsChecked.get(i)) {
|
|
||||||
ttls.add(Integer.toString(CacheTTLPrefs.CACHE_TTLS.get(i)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new CacheTTLPrefs(ttls);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
|
||||||
View view = LayoutInflater.from(parent.getContext())
|
|
||||||
.inflate(R.layout.settings_cache_ttl_item, parent, false);
|
|
||||||
return new ViewHolder(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(final ViewHolder holder, int position) {
|
|
||||||
holder.bind(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return mPositionIsChecked.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
CheckBox mChecked;
|
|
||||||
TextView mTitle;
|
|
||||||
|
|
||||||
public ViewHolder(View itemView) {
|
|
||||||
super(itemView);
|
|
||||||
mChecked = (CheckBox) itemView.findViewById(R.id.ttl_selected);
|
|
||||||
mTitle = (TextView) itemView.findViewById(R.id.ttl_title);
|
|
||||||
|
|
||||||
itemView.setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
mChecked.performClick();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void bind(final int position) {
|
|
||||||
|
|
||||||
int ttl = CacheTTLPrefs.CACHE_TTLS.get(position);
|
|
||||||
boolean isChecked = mPositionIsChecked.get(position);
|
|
||||||
|
|
||||||
mTitle.setText(CacheTTLPrefs.CACHE_TTL_NAMES.get(ttl));
|
|
||||||
// avoid some ui flicker by skipping unnecessary updates
|
|
||||||
if (mChecked.isChecked() != isChecked) {
|
|
||||||
mChecked.setChecked(isChecked);
|
|
||||||
}
|
|
||||||
|
|
||||||
mChecked.setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
setTtlChecked(position);
|
|
||||||
savePreference();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setTtlChecked(int position) {
|
|
||||||
boolean isChecked = mPositionIsChecked.get(position);
|
|
||||||
int checkedItems = countCheckedItems();
|
|
||||||
|
|
||||||
boolean isLastChecked = isChecked && checkedItems == 1;
|
|
||||||
boolean isOneTooMany = !isChecked && checkedItems >= 3;
|
|
||||||
if (isLastChecked) {
|
|
||||||
Notify.create(getActivity(), R.string.settings_cache_ttl_at_least_one, Style.ERROR).show();
|
|
||||||
} else if (isOneTooMany) {
|
|
||||||
Notify.create(getActivity(), R.string.settings_cache_ttl_max_three, Style.ERROR).show();
|
|
||||||
} else {
|
|
||||||
mPositionIsChecked.set(position, !isChecked);
|
|
||||||
}
|
|
||||||
notifyItemChanged(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int countCheckedItems() {
|
|
||||||
int result = 0;
|
|
||||||
for (boolean isChecked : mPositionIsChecked) {
|
|
||||||
if (isChecked) {
|
|
||||||
result += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -26,32 +26,36 @@ import android.support.v7.widget.AppCompatSpinner;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.util.Preferences;
|
|
||||||
import org.sufficientlysecure.keychain.util.Preferences.CacheTTLPrefs;
|
|
||||||
|
|
||||||
|
|
||||||
public class CacheTTLSpinner extends AppCompatSpinner {
|
public class CacheTTLSpinner extends AppCompatSpinner {
|
||||||
|
public static final int[] TTL_TIMES = {
|
||||||
|
0,
|
||||||
|
60 * 60,
|
||||||
|
60 * 60 * 24,
|
||||||
|
Integer.MAX_VALUE
|
||||||
|
};
|
||||||
|
public static final int[] TTL_STRINGS = {
|
||||||
|
R.string.cache_ttl_lock_screen,
|
||||||
|
R.string.cache_ttl_one_hour,
|
||||||
|
R.string.cache_ttl_one_day,
|
||||||
|
R.string.cache_ttl_forever
|
||||||
|
};
|
||||||
|
|
||||||
public CacheTTLSpinner(Context context, AttributeSet attrs) {
|
public CacheTTLSpinner(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
initView(context);
|
initView();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CacheTTLSpinner(Context context, AttributeSet attrs, int defStyle) {
|
public CacheTTLSpinner(Context context, AttributeSet attrs, int defStyle) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
initView(context);
|
initView();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initView(Context context) {
|
private void initView() {
|
||||||
|
MatrixCursor cursor = new MatrixCursor(new String[] { "_id", "TTL", "description" }, TTL_TIMES.length);
|
||||||
CacheTTLPrefs prefs = Preferences.getPreferences(context).getPassphraseCacheTtl();
|
for (int i = 0; i < TTL_TIMES.length; i++) {
|
||||||
MatrixCursor cursor = new MatrixCursor(new String[] { "_id", "TTL", "description" }, 5);
|
cursor.addRow(new Object[] { i, TTL_TIMES[i], getContext().getString(TTL_STRINGS[i]) });
|
||||||
int i = 0;
|
|
||||||
for (int ttl : CacheTTLPrefs.CACHE_TTLS) {
|
|
||||||
if ( ! prefs.ttlTimes.contains(ttl)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
cursor.addRow(new Object[] { i++, ttl, getContext().getString(CacheTTLPrefs.CACHE_TTL_NAMES.get(ttl)) });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setAdapter(new SimpleCursorAdapter(getContext(), R.layout.simple_item, cursor,
|
setAdapter(new SimpleCursorAdapter(getContext(), R.layout.simple_item, cursor,
|
||||||
|
@ -63,5 +67,4 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
package org.sufficientlysecure.keychain.util;
|
package org.sufficientlysecure.keychain.util;
|
||||||
|
|
||||||
|
|
||||||
|
import java.net.Proxy;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
|
@ -31,21 +35,9 @@ import android.preference.PreferenceManager;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.Constants.Pref;
|
import org.sufficientlysecure.keychain.Constants.Pref;
|
||||||
import org.sufficientlysecure.keychain.KeychainApplication;
|
import org.sufficientlysecure.keychain.KeychainApplication;
|
||||||
import org.sufficientlysecure.keychain.R;
|
|
||||||
import org.sufficientlysecure.keychain.keyimport.HkpKeyserverAddress;
|
import org.sufficientlysecure.keychain.keyimport.HkpKeyserverAddress;
|
||||||
import org.sufficientlysecure.keychain.service.KeyserverSyncAdapterService;
|
import org.sufficientlysecure.keychain.service.KeyserverSyncAdapterService;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.net.Proxy;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Singleton Implementation of a Preference Helper
|
* Singleton Implementation of a Preference Helper
|
||||||
*/
|
*/
|
||||||
|
@ -307,67 +299,6 @@ public class Preferences {
|
||||||
!ContentResolver.getPeriodicSyncs(account, authority).isEmpty();
|
!ContentResolver.getPeriodicSyncs(account, authority).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CacheTTLPrefs getPassphraseCacheTtl() {
|
|
||||||
Set<String> pref = mSharedPreferences.getStringSet(Constants.Pref.PASSPHRASE_CACHE_TTLS, null);
|
|
||||||
if (pref == null) {
|
|
||||||
return CacheTTLPrefs.getDefault();
|
|
||||||
}
|
|
||||||
return new CacheTTLPrefs(pref);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassphraseCacheTtl(CacheTTLPrefs prefs) {
|
|
||||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
|
||||||
editor.putStringSet(Constants.Pref.PASSPHRASE_CACHE_TTLS, prefs.getStringSet());
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class CacheTTLPrefs implements Serializable {
|
|
||||||
public static final Map<Integer, Integer> CACHE_TTL_NAMES;
|
|
||||||
public static final ArrayList<Integer> CACHE_TTLS;
|
|
||||||
|
|
||||||
static {
|
|
||||||
HashMap<Integer, Integer> cacheTtlNames = new HashMap<>();
|
|
||||||
cacheTtlNames.put(0, R.string.cache_ttl_lock_screen);
|
|
||||||
cacheTtlNames.put(60 * 10, R.string.cache_ttl_ten_minutes);
|
|
||||||
cacheTtlNames.put(60 * 30, R.string.cache_ttl_thirty_minutes);
|
|
||||||
cacheTtlNames.put(60 * 60, R.string.cache_ttl_one_hour);
|
|
||||||
cacheTtlNames.put(60 * 60 * 3, R.string.cache_ttl_three_hours);
|
|
||||||
cacheTtlNames.put(60 * 60 * 24, R.string.cache_ttl_one_day);
|
|
||||||
cacheTtlNames.put(60 * 60 * 24 * 3, R.string.cache_ttl_three_days);
|
|
||||||
cacheTtlNames.put(Integer.MAX_VALUE, R.string.cache_ttl_forever);
|
|
||||||
CACHE_TTL_NAMES = Collections.unmodifiableMap(cacheTtlNames);
|
|
||||||
|
|
||||||
CACHE_TTLS = new ArrayList<>(CacheTTLPrefs.CACHE_TTL_NAMES.keySet());
|
|
||||||
Collections.sort(CACHE_TTLS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashSet<Integer> ttlTimes;
|
|
||||||
|
|
||||||
public CacheTTLPrefs(Collection<String> ttlStrings) {
|
|
||||||
ttlTimes = new HashSet<>();
|
|
||||||
for (String ttlString : ttlStrings) {
|
|
||||||
ttlTimes.add(Integer.parseInt(ttlString));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashSet<String> getStringSet() {
|
|
||||||
HashSet<String> ttlTimeStrings = new HashSet<>();
|
|
||||||
for (Integer ttlTime : ttlTimes) {
|
|
||||||
ttlTimeStrings.add(Integer.toString(ttlTime));
|
|
||||||
}
|
|
||||||
return ttlTimeStrings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CacheTTLPrefs getDefault() {
|
|
||||||
ArrayList<String> ttlStrings = new ArrayList<>();
|
|
||||||
ttlStrings.add(Integer.toString(0));
|
|
||||||
ttlStrings.add(Integer.toString(60 * 60));
|
|
||||||
ttlStrings.add(Integer.toString(60 * 60 * 24));
|
|
||||||
return new CacheTTLPrefs(ttlStrings);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// cloud prefs
|
// cloud prefs
|
||||||
|
|
||||||
public CloudSearchPrefs getCloudSearchPrefs() {
|
public CloudSearchPrefs getCloudSearchPrefs() {
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/cache_ttl_recycler_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent" />
|
|
|
@ -20,7 +20,6 @@
|
||||||
<string name="title_api_registered_apps">"Apps"</string>
|
<string name="title_api_registered_apps">"Apps"</string>
|
||||||
<string name="title_key_server_preference">"OpenPGP keyservers"</string>
|
<string name="title_key_server_preference">"OpenPGP keyservers"</string>
|
||||||
<string name="title_smartpgp_authorities_preference">"SmartPGP: Trusted authorities"</string>
|
<string name="title_smartpgp_authorities_preference">"SmartPGP: Trusted authorities"</string>
|
||||||
<string name="title_cache_ttl_preference">"Customize 'Remember' choices"</string>
|
|
||||||
<string name="title_change_passphrase">"Change Password"</string>
|
<string name="title_change_passphrase">"Change Password"</string>
|
||||||
<string name="title_share_fingerprint_with">"Share fingerprint with…"</string>
|
<string name="title_share_fingerprint_with">"Share fingerprint with…"</string>
|
||||||
<string name="title_share_key">"Share key with…"</string>
|
<string name="title_share_key">"Share key with…"</string>
|
||||||
|
@ -164,7 +163,6 @@
|
||||||
<string name="label_encryption_algorithm">"Encryption algorithm"</string>
|
<string name="label_encryption_algorithm">"Encryption algorithm"</string>
|
||||||
<string name="label_hash_algorithm">"Hash algorithm"</string>
|
<string name="label_hash_algorithm">"Hash algorithm"</string>
|
||||||
<string name="label_symmetric">"Encrypt with password"</string>
|
<string name="label_symmetric">"Encrypt with password"</string>
|
||||||
<string name="label_passphrase_cache_ttl">"Customize 'Remember' choices"</string>
|
|
||||||
<string name="label_passphrase_cache_subs">"Remember passwords by subkey"</string>
|
<string name="label_passphrase_cache_subs">"Remember passwords by subkey"</string>
|
||||||
<string name="label_message_compression">"Text compression"</string>
|
<string name="label_message_compression">"Text compression"</string>
|
||||||
<string name="label_file_compression">"File compression"</string>
|
<string name="label_file_compression">"File compression"</string>
|
||||||
|
@ -1754,16 +1752,9 @@
|
||||||
<string name="title_edit_subkeys">"Edit Subkeys"</string>
|
<string name="title_edit_subkeys">"Edit Subkeys"</string>
|
||||||
<string name="btn_search_for_query">"Search for\n'%s'"</string>
|
<string name="btn_search_for_query">"Search for\n'%s'"</string>
|
||||||
<string name="cache_ttl_lock_screen">"until screen off"</string>
|
<string name="cache_ttl_lock_screen">"until screen off"</string>
|
||||||
<string name="cache_ttl_ten_minutes">"for ten minutes"</string>
|
|
||||||
<string name="cache_ttl_thirty_minutes">"for thirty minutes"</string>
|
|
||||||
<string name="cache_ttl_one_hour">"for one hour"</string>
|
<string name="cache_ttl_one_hour">"for one hour"</string>
|
||||||
<string name="cache_ttl_three_hours">"for three hours"</string>
|
|
||||||
<string name="cache_ttl_one_day">"for one day"</string>
|
<string name="cache_ttl_one_day">"for one day"</string>
|
||||||
<string name="cache_ttl_three_days">"for three days"</string>
|
<string name="cache_ttl_forever">"until cleared"</string>
|
||||||
<string name="cache_ttl_forever">"forever"</string>
|
|
||||||
<string name="settings_cache_select_three">"Pick up to three."</string>
|
|
||||||
<string name="settings_cache_ttl_at_least_one">"At least one item must be selected!"</string>
|
|
||||||
<string name="settings_cache_ttl_max_three">"Can\'t select more than three items!"</string>
|
|
||||||
<string name="remember">"Remember"</string>
|
<string name="remember">"Remember"</string>
|
||||||
<string name="security_token_error_pgp_app_not_installed">"No PGP app was found on the security token"</string>
|
<string name="security_token_error_pgp_app_not_installed">"No PGP app was found on the security token"</string>
|
||||||
<string name="prompt_fidesmo_pgp_install_title">"Install PGP?"</string>
|
<string name="prompt_fidesmo_pgp_install_title">"Install PGP?"</string>
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<PreferenceScreen
|
|
||||||
android:key="passphraseCacheTtls"
|
|
||||||
android:title="@string/label_passphrase_cache_ttl" />
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="passphraseCacheSubs"
|
android:key="passphraseCacheSubs"
|
||||||
|
|
Loading…
Reference in a new issue