Merge pull request #1597 from open-keychain/inline-ttl
Select time to remember password in dialog
This commit is contained in:
@@ -466,6 +466,11 @@
|
|||||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
android:label="@string/title_key_server_preference"
|
android:label="@string/title_key_server_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"
|
||||||
|
|||||||
@@ -95,7 +95,8 @@ public final class Constants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final class Pref {
|
public static final class Pref {
|
||||||
public static final String PASSPHRASE_CACHE_TTL = "passphraseCacheTtl";
|
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";
|
||||||
|
|||||||
@@ -171,27 +171,6 @@ public class EditKeyOperation extends BaseOperation<SaveKeyringParcel> {
|
|||||||
return new EditKeyResult(EditKeyResult.RESULT_ERROR, log, null);
|
return new EditKeyResult(EditKeyResult.RESULT_ERROR, log, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is a new passphrase - cache it
|
|
||||||
if (saveParcel.mNewUnlock != null && cryptoInput.mCachePassphrase) {
|
|
||||||
log.add(LogType.MSG_ED_CACHING_NEW, 1);
|
|
||||||
|
|
||||||
// NOTE: Don't cache empty passphrases! Important for MOVE_KEY_TO_CARD
|
|
||||||
if (saveParcel.mNewUnlock.mNewPassphrase != null
|
|
||||||
&& ( ! saveParcel.mNewUnlock.mNewPassphrase.isEmpty())) {
|
|
||||||
PassphraseCacheService.addCachedPassphrase(mContext,
|
|
||||||
ring.getMasterKeyId(),
|
|
||||||
ring.getMasterKeyId(),
|
|
||||||
saveParcel.mNewUnlock.mNewPassphrase,
|
|
||||||
ring.getPublicKey().getPrimaryUserIdWithFallback());
|
|
||||||
} else if (saveParcel.mNewUnlock.mNewPin != null) {
|
|
||||||
PassphraseCacheService.addCachedPassphrase(mContext,
|
|
||||||
ring.getMasterKeyId(),
|
|
||||||
ring.getMasterKeyId(),
|
|
||||||
saveParcel.mNewUnlock.mNewPin,
|
|
||||||
ring.getPublicKey().getPrimaryUserIdWithFallback());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updateProgress(R.string.progress_done, 100, 100);
|
updateProgress(R.string.progress_done, 100, 100);
|
||||||
|
|
||||||
// make sure new data is synced into contacts
|
// make sure new data is synced into contacts
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class PassphraseCacheService extends Service {
|
|||||||
public static final String EXTRA_MESSENGER = "messenger";
|
public static final String EXTRA_MESSENGER = "messenger";
|
||||||
public static final String EXTRA_USER_ID = "user_id";
|
public static final String EXTRA_USER_ID = "user_id";
|
||||||
|
|
||||||
private static final long DEFAULT_TTL = 15;
|
private static final int DEFAULT_TTL = 0;
|
||||||
|
|
||||||
private static final int MSG_PASSPHRASE_CACHE_GET_OKAY = 1;
|
private static final int MSG_PASSPHRASE_CACHE_GET_OKAY = 1;
|
||||||
private static final int MSG_PASSPHRASE_CACHE_GET_KEY_NOT_FOUND = 2;
|
private static final int MSG_PASSPHRASE_CACHE_GET_KEY_NOT_FOUND = 2;
|
||||||
@@ -120,13 +120,14 @@ public class PassphraseCacheService extends Service {
|
|||||||
*/
|
*/
|
||||||
public static void addCachedPassphrase(Context context, long masterKeyId, long subKeyId,
|
public static void addCachedPassphrase(Context context, long masterKeyId, long subKeyId,
|
||||||
Passphrase passphrase,
|
Passphrase passphrase,
|
||||||
String primaryUserId) {
|
String primaryUserId,
|
||||||
|
int timeToLiveSeconds) {
|
||||||
Log.d(Constants.TAG, "PassphraseCacheService.addCachedPassphrase() for " + masterKeyId);
|
Log.d(Constants.TAG, "PassphraseCacheService.addCachedPassphrase() for " + masterKeyId);
|
||||||
|
|
||||||
Intent intent = new Intent(context, PassphraseCacheService.class);
|
Intent intent = new Intent(context, PassphraseCacheService.class);
|
||||||
intent.setAction(ACTION_PASSPHRASE_CACHE_ADD);
|
intent.setAction(ACTION_PASSPHRASE_CACHE_ADD);
|
||||||
|
|
||||||
intent.putExtra(EXTRA_TTL, Preferences.getPreferences(context).getPassphraseCacheTtl());
|
intent.putExtra(EXTRA_TTL, timeToLiveSeconds);
|
||||||
intent.putExtra(EXTRA_PASSPHRASE, passphrase);
|
intent.putExtra(EXTRA_PASSPHRASE, passphrase);
|
||||||
intent.putExtra(EXTRA_KEY_ID, masterKeyId);
|
intent.putExtra(EXTRA_KEY_ID, masterKeyId);
|
||||||
intent.putExtra(EXTRA_SUBKEY_ID, subKeyId);
|
intent.putExtra(EXTRA_SUBKEY_ID, subKeyId);
|
||||||
@@ -236,9 +237,7 @@ public class PassphraseCacheService extends Service {
|
|||||||
if (cachedPassphrase == null) {
|
if (cachedPassphrase == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
addCachedPassphrase(this, Constants.key.symmetric, Constants.key.symmetric,
|
return cachedPassphrase.mPassphrase;
|
||||||
cachedPassphrase.getPassphrase(), getString(R.string.passp_cache_notif_pwd));
|
|
||||||
return cachedPassphrase.getPassphrase();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to get master key id which is used as an identifier for cached passphrases
|
// try to get master key id which is used as an identifier for cached passphrases
|
||||||
@@ -285,10 +284,7 @@ public class PassphraseCacheService extends Service {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set it again to reset the cache life cycle
|
return cachedPassphrase.mPassphrase;
|
||||||
Log.d(Constants.TAG, "PassphraseCacheService: Cache passphrase again when getting it!");
|
|
||||||
addCachedPassphrase(this, masterKeyId, subKeyId, cachedPassphrase.getPassphrase(), cachedPassphrase.getPrimaryUserID());
|
|
||||||
return cachedPassphrase.getPassphrase();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -307,13 +303,18 @@ public class PassphraseCacheService extends Service {
|
|||||||
|
|
||||||
if (action.equals(BROADCAST_ACTION_PASSPHRASE_CACHE_SERVICE)) {
|
if (action.equals(BROADCAST_ACTION_PASSPHRASE_CACHE_SERVICE)) {
|
||||||
long keyId = intent.getLongExtra(EXTRA_KEY_ID, -1);
|
long keyId = intent.getLongExtra(EXTRA_KEY_ID, -1);
|
||||||
timeout(keyId);
|
removeTimeoutedPassphrase(keyId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action.equals(Intent.ACTION_SCREEN_OFF)) {
|
||||||
|
removeScreenLockPassphrases();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(BROADCAST_ACTION_PASSPHRASE_CACHE_SERVICE);
|
filter.addAction(BROADCAST_ACTION_PASSPHRASE_CACHE_SERVICE);
|
||||||
|
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||||
registerReceiver(mIntentReceiver, filter);
|
registerReceiver(mIntentReceiver, filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -341,35 +342,40 @@ public class PassphraseCacheService extends Service {
|
|||||||
return START_STICKY;
|
return START_STICKY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// register broadcastreceiver
|
|
||||||
registerReceiver();
|
|
||||||
|
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case ACTION_PASSPHRASE_CACHE_ADD: {
|
case ACTION_PASSPHRASE_CACHE_ADD: {
|
||||||
long ttl = intent.getLongExtra(EXTRA_TTL, DEFAULT_TTL);
|
|
||||||
long masterKeyId = intent.getLongExtra(EXTRA_KEY_ID, -1);
|
long masterKeyId = intent.getLongExtra(EXTRA_KEY_ID, -1);
|
||||||
long subKeyId = intent.getLongExtra(EXTRA_SUBKEY_ID, -1);
|
long subKeyId = intent.getLongExtra(EXTRA_SUBKEY_ID, -1);
|
||||||
|
long timeoutTtl = intent.getIntExtra(EXTRA_TTL, DEFAULT_TTL);
|
||||||
|
|
||||||
Passphrase passphrase = intent.getParcelableExtra(EXTRA_PASSPHRASE);
|
Passphrase passphrase = intent.getParcelableExtra(EXTRA_PASSPHRASE);
|
||||||
String primaryUserID = intent.getStringExtra(EXTRA_USER_ID);
|
String primaryUserID = intent.getStringExtra(EXTRA_USER_ID);
|
||||||
|
|
||||||
Log.d(Constants.TAG,
|
Log.d(Constants.TAG,
|
||||||
"PassphraseCacheService: Received ACTION_PASSPHRASE_CACHE_ADD intent in onStartCommand() with masterkeyId: "
|
"PassphraseCacheService: Received ACTION_PASSPHRASE_CACHE_ADD intent in onStartCommand() with masterkeyId: "
|
||||||
+ masterKeyId + ", subKeyId: " + subKeyId + ", ttl: " + ttl + ", usrId: " + primaryUserID
|
+ masterKeyId + ", subKeyId: " + subKeyId + ", ttl: " + timeoutTtl + ", usrId: " + primaryUserID
|
||||||
);
|
);
|
||||||
|
|
||||||
// if we don't cache by specific subkey id, or the requested subkey is the master key,
|
// if we don't cache by specific subkey id, or the requested subkey is the master key,
|
||||||
// just add master key id to the cache, otherwise, add this specific subkey to the cache
|
// just add master key id to the cache, otherwise, add this specific subkey to the cache
|
||||||
long referenceKeyId =
|
long referenceKeyId =
|
||||||
Preferences.getPreferences(mContext).getPassphraseCacheSubs() ? subKeyId : masterKeyId;
|
Preferences.getPreferences(mContext).getPassphraseCacheSubs() ? subKeyId : masterKeyId;
|
||||||
mPassphraseCache.put(referenceKeyId, new CachedPassphrase(passphrase, primaryUserID));
|
|
||||||
if (ttl > 0) {
|
CachedPassphrase cachedPassphrase;
|
||||||
|
if (timeoutTtl == 0L) {
|
||||||
|
cachedPassphrase = CachedPassphrase.getPassphraseLock(passphrase, primaryUserID);
|
||||||
|
} else {
|
||||||
|
cachedPassphrase = CachedPassphrase.getPassphraseTtlTimeout(passphrase, primaryUserID, timeoutTtl);
|
||||||
|
|
||||||
|
long triggerTime = new Date().getTime() + (timeoutTtl * 1000);
|
||||||
// register new alarm with keyId for this passphrase
|
// register new alarm with keyId for this passphrase
|
||||||
long triggerTime = new Date().getTime() + (ttl * 1000);
|
|
||||||
AlarmManager am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
|
AlarmManager am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
|
||||||
am.set(AlarmManager.RTC_WAKEUP, triggerTime, buildIntent(this, referenceKeyId));
|
am.set(AlarmManager.RTC_WAKEUP, triggerTime, buildIntent(this, referenceKeyId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mPassphraseCache.put(referenceKeyId, cachedPassphrase);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ACTION_PASSPHRASE_CACHE_GET: {
|
case ACTION_PASSPHRASE_CACHE_GET: {
|
||||||
@@ -439,16 +445,14 @@ public class PassphraseCacheService extends Service {
|
|||||||
return START_STICKY;
|
return START_STICKY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Called when one specific passphrase for keyId timed out. */
|
||||||
* Called when one specific passphrase for keyId timed out
|
private void removeTimeoutedPassphrase(long keyId) {
|
||||||
*/
|
|
||||||
private void timeout(long keyId) {
|
|
||||||
|
|
||||||
CachedPassphrase cPass = mPassphraseCache.get(keyId);
|
CachedPassphrase cPass = mPassphraseCache.get(keyId);
|
||||||
if (cPass != null) {
|
if (cPass != null) {
|
||||||
if (cPass.getPassphrase() != null) {
|
if (cPass.mPassphrase != null) {
|
||||||
// clean internal char[] from memory!
|
// clean internal char[] from memory!
|
||||||
cPass.getPassphrase().removeFromMemory();
|
cPass.mPassphrase.removeFromMemory();
|
||||||
}
|
}
|
||||||
// remove passphrase object
|
// remove passphrase object
|
||||||
mPassphraseCache.remove(keyId);
|
mPassphraseCache.remove(keyId);
|
||||||
@@ -459,6 +463,24 @@ public class PassphraseCacheService extends Service {
|
|||||||
updateService();
|
updateService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeScreenLockPassphrases() {
|
||||||
|
|
||||||
|
for (int i = 0; i < mPassphraseCache.size(); ) {
|
||||||
|
CachedPassphrase cPass = mPassphraseCache.valueAt(i);
|
||||||
|
if (cPass.mTimeoutMode == TimeoutMode.LOCK) {
|
||||||
|
// remove passphrase object
|
||||||
|
mPassphraseCache.removeAt(i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// only do this if we didn't remove at, which continues loop by reducing size!
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.d(Constants.TAG, "PassphraseCacheService Removing all cached-until-lock passphrases from memory!");
|
||||||
|
|
||||||
|
updateService();
|
||||||
|
}
|
||||||
|
|
||||||
private void updateService() {
|
private void updateService() {
|
||||||
if (mPassphraseCache.size() > 0) {
|
if (mPassphraseCache.size() > 0) {
|
||||||
startForeground(Constants.Notification.PASSPHRASE_CACHE, getNotification());
|
startForeground(Constants.Notification.PASSPHRASE_CACHE, getNotification());
|
||||||
@@ -483,7 +505,7 @@ public class PassphraseCacheService extends Service {
|
|||||||
|
|
||||||
// Moves events into the big view
|
// Moves events into the big view
|
||||||
for (int i = 0; i < mPassphraseCache.size(); i++) {
|
for (int i = 0; i < mPassphraseCache.size(); i++) {
|
||||||
inboxStyle.addLine(mPassphraseCache.valueAt(i).getPrimaryUserID());
|
inboxStyle.addLine(mPassphraseCache.valueAt(i).mPrimaryUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Moves the big view style object into the notification object.
|
// Moves the big view style object into the notification object.
|
||||||
@@ -516,6 +538,8 @@ public class PassphraseCacheService extends Service {
|
|||||||
super.onCreate();
|
super.onCreate();
|
||||||
mContext = this;
|
mContext = this;
|
||||||
Log.d(Constants.TAG, "PassphraseCacheService, onCreate()");
|
Log.d(Constants.TAG, "PassphraseCacheService, onCreate()");
|
||||||
|
|
||||||
|
registerReceiver();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -539,29 +563,34 @@ public class PassphraseCacheService extends Service {
|
|||||||
|
|
||||||
private final IBinder mBinder = new PassphraseCacheBinder();
|
private final IBinder mBinder = new PassphraseCacheBinder();
|
||||||
|
|
||||||
public class CachedPassphrase {
|
private enum TimeoutMode {
|
||||||
private String primaryUserID;
|
NEVER, TTL, LOCK
|
||||||
private Passphrase passphrase;
|
}
|
||||||
|
|
||||||
public CachedPassphrase(Passphrase passphrase, String primaryUserID) {
|
private static class CachedPassphrase {
|
||||||
setPassphrase(passphrase);
|
private String mPrimaryUserId;
|
||||||
setPrimaryUserID(primaryUserID);
|
private Passphrase mPassphrase;
|
||||||
|
private TimeoutMode mTimeoutMode;
|
||||||
|
private Long mTimeoutTime;
|
||||||
|
|
||||||
|
private CachedPassphrase(Passphrase passphrase, String primaryUserId, TimeoutMode timeoutMode, Long timeoutTime) {
|
||||||
|
mPassphrase = passphrase;
|
||||||
|
mPrimaryUserId = primaryUserId;
|
||||||
|
mTimeoutMode = timeoutMode;
|
||||||
|
mTimeoutTime = timeoutTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrimaryUserID() {
|
static CachedPassphrase getPassphraseNoTimeout(Passphrase passphrase, String primaryUserId) {
|
||||||
return primaryUserID;
|
return new CachedPassphrase(passphrase, primaryUserId, TimeoutMode.NEVER, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Passphrase getPassphrase() {
|
static CachedPassphrase getPassphraseTtlTimeout(Passphrase passphrase, String primaryUserId, long timeoutTime) {
|
||||||
return passphrase;
|
return new CachedPassphrase(passphrase, primaryUserId, TimeoutMode.TTL, timeoutTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrimaryUserID(String primaryUserID) {
|
static CachedPassphrase getPassphraseLock(Passphrase passphrase, String primaryUserId) {
|
||||||
this.primaryUserID = primaryUserID;
|
return new CachedPassphrase(passphrase, primaryUserId, TimeoutMode.LOCK, null);
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassphrase(Passphrase passphrase) {
|
|
||||||
this.passphrase = passphrase;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ public class RequiredInputParcel implements Parcelable {
|
|||||||
private Long mMasterKeyId;
|
private Long mMasterKeyId;
|
||||||
private Long mSubKeyId;
|
private Long mSubKeyId;
|
||||||
|
|
||||||
|
public boolean mSkipCaching = false;
|
||||||
|
|
||||||
private RequiredInputParcel(RequiredInputType type, byte[][] inputData,
|
private RequiredInputParcel(RequiredInputType type, byte[][] inputData,
|
||||||
int[] signAlgos, Date signatureTime, Long masterKeyId, Long subKeyId) {
|
int[] signAlgos, Date signatureTime, Long masterKeyId, Long subKeyId) {
|
||||||
mType = type;
|
mType = type;
|
||||||
@@ -66,6 +68,7 @@ public class RequiredInputParcel implements Parcelable {
|
|||||||
mSignatureTime = source.readInt() != 0 ? new Date(source.readLong()) : null;
|
mSignatureTime = source.readInt() != 0 ? new Date(source.readLong()) : null;
|
||||||
mMasterKeyId = source.readInt() != 0 ? source.readLong() : null;
|
mMasterKeyId = source.readInt() != 0 ? source.readLong() : null;
|
||||||
mSubKeyId = source.readInt() != 0 ? source.readLong() : null;
|
mSubKeyId = source.readInt() != 0 ? source.readLong() : null;
|
||||||
|
mSkipCaching = source.readInt() != 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,6 +174,7 @@ public class RequiredInputParcel implements Parcelable {
|
|||||||
} else {
|
} else {
|
||||||
dest.writeInt(0);
|
dest.writeInt(0);
|
||||||
}
|
}
|
||||||
|
dest.writeInt(mSkipCaching ? 1 : 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import android.view.ViewGroup;
|
|||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
|
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
import org.sufficientlysecure.keychain.util.FileHelper;
|
import org.sufficientlysecure.keychain.util.FileHelper;
|
||||||
|
|
||||||
@@ -157,7 +158,10 @@ public class BackupRestoreFragment extends Fragment {
|
|||||||
|
|
||||||
Intent intent = new Intent(activity, PassphraseDialogActivity.class);
|
Intent intent = new Intent(activity, PassphraseDialogActivity.class);
|
||||||
long masterKeyId = mIdsForRepeatAskPassphrase.get(mIndex++);
|
long masterKeyId = mIdsForRepeatAskPassphrase.get(mIndex++);
|
||||||
intent.putExtra(PassphraseDialogActivity.EXTRA_SUBKEY_ID, masterKeyId);
|
RequiredInputParcel requiredInput =
|
||||||
|
RequiredInputParcel.createRequiredDecryptPassphrase(masterKeyId, masterKeyId);
|
||||||
|
requiredInput.mSkipCaching = true;
|
||||||
|
intent.putExtra(PassphraseDialogActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
||||||
startActivityForResult(intent, REQUEST_REPEAT_PASSPHRASE);
|
startActivityForResult(intent, REQUEST_REPEAT_PASSPHRASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import android.widget.Button;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
import android.widget.ViewAnimator;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
@@ -60,8 +61,10 @@ import org.sufficientlysecure.keychain.remote.CryptoInputParcelCacheService;
|
|||||||
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
||||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||||
|
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.RequiredInputType;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.CustomAlertDialogBuilder;
|
import org.sufficientlysecure.keychain.ui.dialog.CustomAlertDialogBuilder;
|
||||||
import org.sufficientlysecure.keychain.ui.util.ThemeChanger;
|
import org.sufficientlysecure.keychain.ui.util.ThemeChanger;
|
||||||
|
import org.sufficientlysecure.keychain.ui.widget.CacheTTLSpinner;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||||
import org.sufficientlysecure.keychain.util.Preferences;
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
@@ -77,14 +80,10 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
public static final String RESULT_CRYPTO_INPUT = "result_data";
|
public static final String RESULT_CRYPTO_INPUT = "result_data";
|
||||||
|
|
||||||
public static final String EXTRA_REQUIRED_INPUT = "required_input";
|
public static final String EXTRA_REQUIRED_INPUT = "required_input";
|
||||||
public static final String EXTRA_SUBKEY_ID = "secret_key_id";
|
|
||||||
public static final String EXTRA_CRYPTO_INPUT = "crypto_input";
|
public static final String EXTRA_CRYPTO_INPUT = "crypto_input";
|
||||||
|
|
||||||
// special extra for OpenPgpService
|
// special extra for OpenPgpService
|
||||||
public static final String EXTRA_SERVICE_INTENT = "data";
|
public static final String EXTRA_SERVICE_INTENT = "data";
|
||||||
private long mSubKeyId;
|
|
||||||
|
|
||||||
private CryptoInputParcel mCryptoInputParcel;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -99,62 +98,37 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
mCryptoInputParcel = getIntent().getParcelableExtra(EXTRA_CRYPTO_INPUT);
|
CryptoInputParcel cryptoInputParcel = getIntent().getParcelableExtra(EXTRA_CRYPTO_INPUT);
|
||||||
|
if (cryptoInputParcel == null) {
|
||||||
if (mCryptoInputParcel == null) {
|
cryptoInputParcel = new CryptoInputParcel();
|
||||||
// not all usages of PassphraseActivity are from CryptoInputOperation
|
getIntent().putExtra(EXTRA_CRYPTO_INPUT, cryptoInputParcel);
|
||||||
// NOTE: This CryptoInputParcel cannot be used for signing operations without setting
|
|
||||||
// signature time
|
|
||||||
mCryptoInputParcel = new CryptoInputParcel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this activity itself has no content view (see manifest)
|
// this activity itself has no content view (see manifest)
|
||||||
|
RequiredInputParcel requiredInput = getIntent().getParcelableExtra(EXTRA_REQUIRED_INPUT);
|
||||||
|
if (requiredInput.mType != RequiredInputType.PASSPHRASE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (getIntent().hasExtra(EXTRA_SUBKEY_ID)) {
|
// handle empty passphrases by directly returning an empty crypto input parcel
|
||||||
mSubKeyId = getIntent().getLongExtra(EXTRA_SUBKEY_ID, 0);
|
try {
|
||||||
} else {
|
CanonicalizedSecretKeyRing pubRing =
|
||||||
RequiredInputParcel requiredInput = getIntent().getParcelableExtra(EXTRA_REQUIRED_INPUT);
|
new ProviderHelper(this).getCanonicalizedSecretKeyRing(
|
||||||
switch (requiredInput.mType) {
|
requiredInput.getMasterKeyId());
|
||||||
case PASSPHRASE_SYMMETRIC: {
|
// use empty passphrase for empty passphrase
|
||||||
mSubKeyId = Constants.key.symmetric;
|
if (pubRing.getSecretKey(requiredInput.getSubKeyId()).getSecretKeyType() ==
|
||||||
break;
|
SecretKeyType.PASSPHRASE_EMPTY) {
|
||||||
}
|
// also return passphrase back to activity
|
||||||
case BACKUP_CODE: {
|
Intent returnIntent = new Intent();
|
||||||
mSubKeyId = Constants.key.backup_code;
|
cryptoInputParcel.mPassphrase = new Passphrase("");
|
||||||
break;
|
returnIntent.putExtra(RESULT_CRYPTO_INPUT, cryptoInputParcel);
|
||||||
}
|
setResult(RESULT_OK, returnIntent);
|
||||||
case PASSPHRASE: {
|
finish();
|
||||||
|
|
||||||
// handle empty passphrases by directly returning an empty crypto input parcel
|
|
||||||
try {
|
|
||||||
CanonicalizedSecretKeyRing pubRing =
|
|
||||||
new ProviderHelper(this).getCanonicalizedSecretKeyRing(
|
|
||||||
requiredInput.getMasterKeyId());
|
|
||||||
// use empty passphrase for empty passphrase
|
|
||||||
if (pubRing.getSecretKey(requiredInput.getSubKeyId()).getSecretKeyType() ==
|
|
||||||
SecretKeyType.PASSPHRASE_EMPTY) {
|
|
||||||
// also return passphrase back to activity
|
|
||||||
Intent returnIntent = new Intent();
|
|
||||||
mCryptoInputParcel.mPassphrase = new Passphrase("");
|
|
||||||
returnIntent.putExtra(RESULT_CRYPTO_INPUT, mCryptoInputParcel);
|
|
||||||
setResult(RESULT_OK, returnIntent);
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (NotFoundException e) {
|
|
||||||
Log.e(Constants.TAG, "Key not found?!", e);
|
|
||||||
setResult(RESULT_CANCELED);
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mSubKeyId = requiredInput.getSubKeyId();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
throw new AssertionError("Unsupported required input type for PassphraseDialogActivity!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} catch (NotFoundException e) {
|
||||||
|
Log.e(Constants.TAG, "Key not found?!", e);
|
||||||
|
setResult(RESULT_CANCELED);
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -167,14 +141,8 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
* encryption. Based on mSecretKeyId it asks for a passphrase to open a private key or it asks
|
* encryption. Based on mSecretKeyId it asks for a passphrase to open a private key or it asks
|
||||||
* for a symmetric passphrase
|
* for a symmetric passphrase
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Intent serviceIntent = getIntent().getParcelableExtra(EXTRA_SERVICE_INTENT);
|
|
||||||
|
|
||||||
PassphraseDialogFragment frag = new PassphraseDialogFragment();
|
PassphraseDialogFragment frag = new PassphraseDialogFragment();
|
||||||
Bundle args = new Bundle();
|
frag.setArguments(getIntent().getExtras());
|
||||||
args.putLong(EXTRA_SUBKEY_ID, mSubKeyId);
|
|
||||||
args.putParcelable(EXTRA_SERVICE_INTENT, serviceIntent);
|
|
||||||
frag.setArguments(args);
|
|
||||||
frag.show(getSupportFragmentManager(), "passphraseDialog");
|
frag.show(getSupportFragmentManager(), "passphraseDialog");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,14 +159,14 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
public static class PassphraseDialogFragment extends DialogFragment implements TextView.OnEditorActionListener {
|
public static class PassphraseDialogFragment extends DialogFragment implements TextView.OnEditorActionListener {
|
||||||
private EditText mPassphraseEditText;
|
private EditText mPassphraseEditText;
|
||||||
private TextView mPassphraseText;
|
private TextView mPassphraseText;
|
||||||
private View mInput, mProgress;
|
|
||||||
private EditText[] mBackupCodeEditText;
|
private EditText[] mBackupCodeEditText;
|
||||||
|
|
||||||
private CanonicalizedSecretKeyRing mSecretRing = null;
|
private CanonicalizedSecretKeyRing mSecretRing = null;
|
||||||
private boolean mIsCancelled = false;
|
private boolean mIsCancelled = false;
|
||||||
private long mSubKeyId;
|
private RequiredInputParcel mRequiredInput;
|
||||||
|
|
||||||
private Intent mServiceIntent;
|
private ViewAnimator mLayout;
|
||||||
|
private CacheTTLSpinner mTimeToLiveSpinner;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
@@ -207,15 +175,14 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
|
|
||||||
ContextThemeWrapper theme = ThemeChanger.getDialogThemeWrapper(activity);
|
ContextThemeWrapper theme = ThemeChanger.getDialogThemeWrapper(activity);
|
||||||
|
|
||||||
mSubKeyId = getArguments().getLong(EXTRA_SUBKEY_ID);
|
mRequiredInput = getArguments().getParcelable(EXTRA_REQUIRED_INPUT);
|
||||||
mServiceIntent = getArguments().getParcelable(EXTRA_SERVICE_INTENT);
|
|
||||||
|
|
||||||
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(theme);
|
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(theme);
|
||||||
|
|
||||||
// No title, see http://www.google.com/design/spec/components/dialogs.html#dialogs-alerts
|
// No title, see http://www.google.com/design/spec/components/dialogs.html#dialogs-alerts
|
||||||
//alert.setTitle()
|
//alert.setTitle()
|
||||||
|
|
||||||
if (mSubKeyId == Constants.key.backup_code) {
|
if (mRequiredInput.mType == RequiredInputType.BACKUP_CODE) {
|
||||||
LayoutInflater inflater = LayoutInflater.from(theme);
|
LayoutInflater inflater = LayoutInflater.from(theme);
|
||||||
View view = inflater.inflate(R.layout.passphrase_dialog_backup_code, null);
|
View view = inflater.inflate(R.layout.passphrase_dialog_backup_code, null);
|
||||||
alert.setView(view);
|
alert.setView(view);
|
||||||
@@ -233,14 +200,19 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutInflater inflater = LayoutInflater.from(theme);
|
long subKeyId = mRequiredInput.getSubKeyId();
|
||||||
View view = inflater.inflate(R.layout.passphrase_dialog, null);
|
|
||||||
alert.setView(view);
|
|
||||||
|
|
||||||
mPassphraseText = (TextView) view.findViewById(R.id.passphrase_text);
|
LayoutInflater inflater = LayoutInflater.from(theme);
|
||||||
mPassphraseEditText = (EditText) view.findViewById(R.id.passphrase_passphrase);
|
mLayout = (ViewAnimator) inflater.inflate(R.layout.passphrase_dialog, null);
|
||||||
mInput = view.findViewById(R.id.input);
|
alert.setView(mLayout);
|
||||||
mProgress = view.findViewById(R.id.progress);
|
|
||||||
|
mPassphraseText = (TextView) mLayout.findViewById(R.id.passphrase_text);
|
||||||
|
mPassphraseEditText = (EditText) mLayout.findViewById(R.id.passphrase_passphrase);
|
||||||
|
|
||||||
|
View vTimeToLiveLayout = mLayout.findViewById(R.id.remember_layout);
|
||||||
|
vTimeToLiveLayout.setVisibility(mRequiredInput.mSkipCaching ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
|
mTimeToLiveSpinner = (CacheTTLSpinner) mLayout.findViewById(R.id.ttl_spinner);
|
||||||
|
|
||||||
alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@@ -255,14 +227,14 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
|
|
||||||
String message;
|
String message;
|
||||||
String hint;
|
String hint;
|
||||||
if (mSubKeyId == Constants.key.symmetric || mSubKeyId == Constants.key.none) {
|
if (mRequiredInput.mType == RequiredInputType.PASSPHRASE_SYMMETRIC) {
|
||||||
message = getString(R.string.passphrase_for_symmetric_encryption);
|
message = getString(R.string.passphrase_for_symmetric_encryption);
|
||||||
hint = getString(R.string.label_passphrase);
|
hint = getString(R.string.label_passphrase);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
ProviderHelper helper = new ProviderHelper(activity);
|
ProviderHelper helper = new ProviderHelper(activity);
|
||||||
mSecretRing = helper.getCanonicalizedSecretKeyRing(
|
mSecretRing = helper.getCanonicalizedSecretKeyRing(
|
||||||
KeychainContract.KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(mSubKeyId));
|
KeychainContract.KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(subKeyId));
|
||||||
// yes the inner try/catch block is necessary, otherwise the final variable
|
// yes the inner try/catch block is necessary, otherwise the final variable
|
||||||
// above can't be statically verified to have been set in all cases because
|
// above can't be statically verified to have been set in all cases because
|
||||||
// the catch clause doesn't return.
|
// the catch clause doesn't return.
|
||||||
@@ -278,7 +250,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
userId = null;
|
userId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyType = mSecretRing.getSecretKey(mSubKeyId).getSecretKeyType();
|
keyType = mSecretRing.getSecretKey(subKeyId).getSecretKeyType();
|
||||||
switch (keyType) {
|
switch (keyType) {
|
||||||
case PASSPHRASE:
|
case PASSPHRASE:
|
||||||
message = getString(R.string.passphrase_for, userId);
|
message = getString(R.string.passphrase_for, userId);
|
||||||
@@ -301,7 +273,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
|
|
||||||
} catch (ProviderHelper.NotFoundException e) {
|
} catch (ProviderHelper.NotFoundException e) {
|
||||||
alert.setTitle(R.string.title_key_not_found);
|
alert.setTitle(R.string.title_key_not_found);
|
||||||
alert.setMessage(getString(R.string.key_not_found, mSubKeyId));
|
alert.setMessage(getString(R.string.key_not_found, mRequiredInput.getSubKeyId()));
|
||||||
alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
dismiss();
|
dismiss();
|
||||||
@@ -397,7 +369,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
final Passphrase passphrase;
|
final Passphrase passphrase;
|
||||||
if (mSubKeyId == Constants.key.backup_code) {
|
if (mRequiredInput.mType == RequiredInputType.BACKUP_CODE) {
|
||||||
StringBuilder backupCodeInput = new StringBuilder(26);
|
StringBuilder backupCodeInput = new StringBuilder(26);
|
||||||
for (EditText editText : mBackupCodeEditText) {
|
for (EditText editText : mBackupCodeEditText) {
|
||||||
if (editText.getText().length() < 6) {
|
if (editText.getText().length() < 6) {
|
||||||
@@ -413,23 +385,21 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
passphrase = new Passphrase(mPassphraseEditText);
|
passphrase = new Passphrase(mPassphraseEditText);
|
||||||
}
|
}
|
||||||
|
|
||||||
CryptoInputParcel cryptoInputParcel =
|
final int timeToLiveSeconds = mTimeToLiveSpinner.getSelectedTimeToLive();
|
||||||
((PassphraseDialogActivity) getActivity()).mCryptoInputParcel;
|
|
||||||
|
|
||||||
// Early breakout if we are dealing with a symmetric key
|
// Early breakout if we are dealing with a symmetric key
|
||||||
if (mSecretRing == null) {
|
if (mSecretRing == null) {
|
||||||
if (cryptoInputParcel.mCachePassphrase) {
|
if ( ! mRequiredInput.mSkipCaching) {
|
||||||
PassphraseCacheService.addCachedPassphrase(getActivity(),
|
PassphraseCacheService.addCachedPassphrase(getActivity(),
|
||||||
Constants.key.symmetric, Constants.key.symmetric, passphrase,
|
Constants.key.symmetric, Constants.key.symmetric, passphrase,
|
||||||
getString(R.string.passp_cache_notif_pwd));
|
getString(R.string.passp_cache_notif_pwd), timeToLiveSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
finishCaching(passphrase);
|
finishCaching(passphrase);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mInput.setVisibility(View.INVISIBLE);
|
mLayout.setDisplayedChild(1);
|
||||||
mProgress.setVisibility(View.VISIBLE);
|
|
||||||
positive.setEnabled(false);
|
positive.setEnabled(false);
|
||||||
|
|
||||||
new AsyncTask<Void, Void, Boolean>() {
|
new AsyncTask<Void, Void, Boolean>() {
|
||||||
@@ -443,7 +413,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
// never mind
|
// never mind
|
||||||
}
|
}
|
||||||
// make sure this unlocks
|
// make sure this unlocks
|
||||||
return mSecretRing.getSecretKey(mSubKeyId).unlock(passphrase);
|
return mSecretRing.getSecretKey(mRequiredInput.getSubKeyId()).unlock(passphrase);
|
||||||
} catch (PgpGeneralException e) {
|
} catch (PgpGeneralException e) {
|
||||||
Toast.makeText(getActivity(), R.string.error_could_not_extract_private_key,
|
Toast.makeText(getActivity(), R.string.error_could_not_extract_private_key,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
@@ -469,8 +439,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
if (!result) {
|
if (!result) {
|
||||||
mPassphraseEditText.setText("");
|
mPassphraseEditText.setText("");
|
||||||
mPassphraseEditText.setError(getString(R.string.wrong_passphrase));
|
mPassphraseEditText.setError(getString(R.string.wrong_passphrase));
|
||||||
mInput.setVisibility(View.VISIBLE);
|
mLayout.setDisplayedChild(0);
|
||||||
mProgress.setVisibility(View.INVISIBLE);
|
|
||||||
positive.setEnabled(true);
|
positive.setEnabled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -478,21 +447,18 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
// cache the new passphrase as specified in CryptoInputParcel
|
// cache the new passphrase as specified in CryptoInputParcel
|
||||||
Log.d(Constants.TAG, "Everything okay!");
|
Log.d(Constants.TAG, "Everything okay!");
|
||||||
|
|
||||||
CryptoInputParcel cryptoInputParcel
|
if (mRequiredInput.mSkipCaching) {
|
||||||
= ((PassphraseDialogActivity) getActivity()).mCryptoInputParcel;
|
Log.d(Constants.TAG, "Not caching entered passphrase!");
|
||||||
|
} else {
|
||||||
if (cryptoInputParcel.mCachePassphrase) {
|
|
||||||
Log.d(Constants.TAG, "Caching entered passphrase");
|
Log.d(Constants.TAG, "Caching entered passphrase");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PassphraseCacheService.addCachedPassphrase(getActivity(),
|
PassphraseCacheService.addCachedPassphrase(getActivity(),
|
||||||
mSecretRing.getMasterKeyId(), mSubKeyId, passphrase,
|
mSecretRing.getMasterKeyId(), mRequiredInput.getSubKeyId(), passphrase,
|
||||||
mSecretRing.getPrimaryUserIdWithFallback());
|
mSecretRing.getPrimaryUserIdWithFallback(), timeToLiveSeconds);
|
||||||
} catch (PgpKeyNotFoundException e) {
|
} catch (PgpKeyNotFoundException e) {
|
||||||
Log.e(Constants.TAG, "adding of a passphrase failed", e);
|
Log.e(Constants.TAG, "adding of a passphrase failed", e);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Log.d(Constants.TAG, "Not caching entered passphrase!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
finishCaching(passphrase);
|
finishCaching(passphrase);
|
||||||
@@ -508,13 +474,14 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CryptoInputParcel inputParcel =
|
CryptoInputParcel inputParcel = getArguments().getParcelable(EXTRA_CRYPTO_INPUT);
|
||||||
((PassphraseDialogActivity) getActivity()).mCryptoInputParcel;
|
// noinspection ConstantConditions, we handle the non-null case in PassphraseDialogActivity.onCreate()
|
||||||
inputParcel.mPassphrase = passphrase;
|
inputParcel.mPassphrase = passphrase;
|
||||||
if (mServiceIntent != null) {
|
|
||||||
CryptoInputParcelCacheService.addCryptoInputParcel(getActivity(), mServiceIntent,
|
Intent serviceIntent = getArguments().getParcelable(EXTRA_SERVICE_INTENT);
|
||||||
inputParcel);
|
if (serviceIntent != null) {
|
||||||
getActivity().setResult(RESULT_OK, mServiceIntent);
|
CryptoInputParcelCacheService.addCryptoInputParcel(getActivity(), serviceIntent, inputParcel);
|
||||||
|
getActivity().setResult(RESULT_OK, serviceIntent);
|
||||||
} else {
|
} else {
|
||||||
// also return passphrase back to activity
|
// also return passphrase back to activity
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
@@ -29,6 +32,7 @@ import android.content.Intent;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
@@ -49,13 +53,10 @@ import org.sufficientlysecure.keychain.R;
|
|||||||
import org.sufficientlysecure.keychain.compatibility.AppCompatPreferenceActivity;
|
import org.sufficientlysecure.keychain.compatibility.AppCompatPreferenceActivity;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
import org.sufficientlysecure.keychain.ui.util.ThemeChanger;
|
import org.sufficientlysecure.keychain.ui.util.ThemeChanger;
|
||||||
import org.sufficientlysecure.keychain.ui.widget.IntegerListPreference;
|
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
import org.sufficientlysecure.keychain.util.Preferences;
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SettingsActivity extends AppCompatPreferenceActivity {
|
public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||||
|
|
||||||
public static final int REQUEST_CODE_KEYSERVER_PREF = 0x00007005;
|
public static final int REQUEST_CODE_KEYSERVER_PREF = 0x00007005;
|
||||||
@@ -103,6 +104,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
Toolbar toolbar = (Toolbar) toolbarContainer.findViewById(R.id.toolbar);
|
Toolbar toolbar = (Toolbar) toolbarContainer.findViewById(R.id.toolbar);
|
||||||
|
|
||||||
toolbar.setTitle(R.string.title_preferences);
|
toolbar.setTitle(R.string.title_preferences);
|
||||||
|
// noinspection deprecation, TODO use alternative in API level 21
|
||||||
toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp));
|
toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp));
|
||||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -195,23 +197,19 @@ 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);
|
||||||
|
|
||||||
initializePassphraseCacheTtl(
|
findPreference(Constants.Pref.PASSPHRASE_CACHE_TTLS)
|
||||||
(IntegerListPreference) findPreference(Constants.Pref.PASSPHRASE_CACHE_TTL));
|
.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
}
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
Intent intent = new Intent(getActivity(), SettingsCacheTTLActivity.class);
|
||||||
private static void initializePassphraseCacheTtl(
|
intent.putExtra(SettingsCacheTTLActivity.EXTRA_TTL_PREF,
|
||||||
final IntegerListPreference passphraseCacheTtl) {
|
sPreferences.getPassphraseCacheTtl());
|
||||||
passphraseCacheTtl.setValue("" + sPreferences.getPassphraseCacheTtl());
|
startActivity(intent);
|
||||||
passphraseCacheTtl.setSummary(passphraseCacheTtl.getEntry());
|
|
||||||
passphraseCacheTtl
|
|
||||||
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
|
||||||
passphraseCacheTtl.setValue(newValue.toString());
|
|
||||||
passphraseCacheTtl.setSummary(passphraseCacheTtl.getEntry());
|
|
||||||
sPreferences.setPassphraseCacheTtl(Integer.parseInt(newValue.toString()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
initializePassphraseCacheSubs(
|
||||||
|
(CheckBoxPreference) findPreference(Constants.Pref.PASSPHRASE_CACHE_SUBS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,4 +578,15 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
|| ExperimentalPrefsFragment.class.getName().equals(fragmentName)
|
|| ExperimentalPrefsFragment.class.getName().equals(fragmentName)
|
||||||
|| super.isValidFragment(fragmentName);
|
|| super.isValidFragment(fragmentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void initializePassphraseCacheSubs(final CheckBoxPreference mPassphraseCacheSubs) {
|
||||||
|
mPassphraseCacheSubs.setChecked(sPreferences.getPassphraseCacheSubs());
|
||||||
|
mPassphraseCacheSubs.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
mPassphraseCacheSubs.setChecked((Boolean) newValue);
|
||||||
|
sPreferences.setPassphraseCacheSubs((Boolean) newValue);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,199 @@
|
|||||||
|
/*
|
||||||
|
* 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));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -82,6 +82,7 @@ import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
|||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
|
||||||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||||
|
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||||
import org.sufficientlysecure.keychain.ui.ViewKeyFragment.PostponeType;
|
import org.sufficientlysecure.keychain.ui.ViewKeyFragment.PostponeType;
|
||||||
import org.sufficientlysecure.keychain.ui.base.BaseNfcActivity;
|
import org.sufficientlysecure.keychain.ui.base.BaseNfcActivity;
|
||||||
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
||||||
@@ -531,7 +532,10 @@ public class ViewKeyActivity extends BaseNfcActivity implements
|
|||||||
|
|
||||||
if (keyHasPassphrase()) {
|
if (keyHasPassphrase()) {
|
||||||
Intent intent = new Intent(this, PassphraseDialogActivity.class);
|
Intent intent = new Intent(this, PassphraseDialogActivity.class);
|
||||||
intent.putExtra(PassphraseDialogActivity.EXTRA_SUBKEY_ID, mMasterKeyId);
|
RequiredInputParcel requiredInput =
|
||||||
|
RequiredInputParcel.createRequiredDecryptPassphrase(mMasterKeyId, mMasterKeyId);
|
||||||
|
requiredInput.mSkipCaching = true;
|
||||||
|
intent.putExtra(PassphraseDialogActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
||||||
startActivityForResult(intent, requestCode);
|
startActivityForResult(intent, requestCode);
|
||||||
} else {
|
} else {
|
||||||
startBackupActivity();
|
startBackupActivity();
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* 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.widget;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.MatrixCursor;
|
||||||
|
import android.support.v4.widget.SimpleCursorAdapter;
|
||||||
|
import android.support.v7.widget.AppCompatSpinner;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
|
import org.sufficientlysecure.keychain.util.Preferences.CacheTTLPrefs;
|
||||||
|
|
||||||
|
|
||||||
|
public class CacheTTLSpinner extends AppCompatSpinner {
|
||||||
|
|
||||||
|
public CacheTTLSpinner(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
initView(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CacheTTLSpinner(Context context, AttributeSet attrs, int defStyle) {
|
||||||
|
super(context, attrs, defStyle);
|
||||||
|
initView(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView(Context context) {
|
||||||
|
|
||||||
|
CacheTTLPrefs prefs = Preferences.getPreferences(context).getPassphraseCacheTtl();
|
||||||
|
MatrixCursor cursor = new MatrixCursor(new String[] { "_id", "TTL", "description" }, 5);
|
||||||
|
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,
|
||||||
|
new String[] { "description" }, new int[] { R.id.simple_item_text }, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSelectedTimeToLive() {
|
||||||
|
int selectedItemPosition = getSelectedItemPosition();
|
||||||
|
Object item = getAdapter().getItem(selectedItemPosition);
|
||||||
|
return ((Cursor) item).getInt(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -18,9 +18,23 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.util;
|
package org.sufficientlysecure.keychain.util;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.net.Proxy;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
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;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
@@ -28,17 +42,13 @@ import android.support.annotation.NonNull;
|
|||||||
|
|
||||||
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.R;
|
||||||
import org.sufficientlysecure.keychain.service.KeyserverSyncAdapterService;
|
import org.sufficientlysecure.keychain.service.KeyserverSyncAdapterService;
|
||||||
|
|
||||||
import java.net.Proxy;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Singleton Implementation of a Preference Helper
|
* Singleton Implementation of a Preference Helper
|
||||||
*/
|
*/
|
||||||
|
@SuppressLint("CommitPrefEdits")
|
||||||
public class Preferences {
|
public class Preferences {
|
||||||
private static Preferences sPreferences;
|
private static Preferences sPreferences;
|
||||||
private SharedPreferences mSharedPreferences;
|
private SharedPreferences mSharedPreferences;
|
||||||
@@ -90,22 +100,6 @@ public class Preferences {
|
|||||||
editor.commit();
|
editor.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getPassphraseCacheTtl() {
|
|
||||||
int ttl = mSharedPreferences.getInt(Constants.Pref.PASSPHRASE_CACHE_TTL, 180);
|
|
||||||
// fix the value if it was set to "never" in previous versions, which currently is not
|
|
||||||
// supported
|
|
||||||
if (ttl == 0) {
|
|
||||||
ttl = 180;
|
|
||||||
}
|
|
||||||
return (long) ttl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassphraseCacheTtl(int value) {
|
|
||||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
|
||||||
editor.putInt(Constants.Pref.PASSPHRASE_CACHE_TTL, value);
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getPassphraseCacheSubs() {
|
public boolean getPassphraseCacheSubs() {
|
||||||
return mSharedPreferences.getBoolean(Pref.PASSPHRASE_CACHE_SUBS, false);
|
return mSharedPreferences.getBoolean(Pref.PASSPHRASE_CACHE_SUBS, false);
|
||||||
}
|
}
|
||||||
@@ -143,7 +137,7 @@ public class Preferences {
|
|||||||
public String[] getKeyServers() {
|
public String[] getKeyServers() {
|
||||||
String rawData = mSharedPreferences.getString(Constants.Pref.KEY_SERVERS,
|
String rawData = mSharedPreferences.getString(Constants.Pref.KEY_SERVERS,
|
||||||
Constants.Defaults.KEY_SERVERS);
|
Constants.Defaults.KEY_SERVERS);
|
||||||
if (rawData.equals("")) {
|
if ("".equals(rawData)) {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
Vector<String> servers = new Vector<>();
|
Vector<String> servers = new Vector<>();
|
||||||
@@ -308,6 +302,64 @@ public class Preferences {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 * 5, R.string.cache_ttl_five_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);
|
||||||
|
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(60 * 5));
|
||||||
|
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() {
|
||||||
@@ -402,15 +454,19 @@ public class Preferences {
|
|||||||
if (server == null) {
|
if (server == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (server.equals("pool.sks-keyservers.net")) {
|
switch (server) {
|
||||||
// use HKPS!
|
case "pool.sks-keyservers.net":
|
||||||
it.set("hkps://hkps.pool.sks-keyservers.net");
|
// use HKPS!
|
||||||
} else if (server.equals("pgp.mit.edu")) {
|
it.set("hkps://hkps.pool.sks-keyservers.net");
|
||||||
// use HKPS!
|
break;
|
||||||
it.set("hkps://pgp.mit.edu");
|
case "pgp.mit.edu":
|
||||||
} else if (server.equals("subkeys.pgp.net")) {
|
// use HKPS!
|
||||||
// remove, because often down and no HKPS!
|
it.set("hkps://pgp.mit.edu");
|
||||||
it.remove();
|
break;
|
||||||
|
case "subkeys.pgp.net":
|
||||||
|
// remove, because often down and no HKPS!
|
||||||
|
it.remove();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:textColor="@color/md_black_1000"
|
||||||
android:text="@string/label_asymmetric_from"
|
android:text="@string/label_asymmetric_from"
|
||||||
android:paddingRight="8dp"/>
|
android:paddingRight="8dp"/>
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<org.sufficientlysecure.keychain.ui.widget.ToolableViewAnimator
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:custom="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:paddingBottom="16dp"
|
|
||||||
android:paddingLeft="24dp"
|
android:paddingLeft="24dp"
|
||||||
android:paddingRight="24dp"
|
android:paddingRight="24dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
custom:initialView="0">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/input"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
@@ -31,10 +33,33 @@
|
|||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:layout_gravity="center_horizontal" />
|
android:layout_gravity="center_horizontal" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:id="@+id/remember_layout">
|
||||||
|
|
||||||
|
<!-- paddingBottom for spinner alignment -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/remember"
|
||||||
|
android:paddingBottom="1dp"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Medium" />
|
||||||
|
|
||||||
|
<org.sufficientlysecure.keychain.ui.widget.CacheTTLSpinner
|
||||||
|
android:id="@+id/ttl_spinner"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
</org.sufficientlysecure.keychain.ui.widget.CacheTTLSpinner>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/progress"
|
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -57,4 +82,4 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</org.sufficientlysecure.keychain.ui.widget.ToolableViewAnimator>
|
||||||
33
OpenKeychain/src/main/res/layout/settings_cache_ttl.xml
Normal file
33
OpenKeychain/src/main/res/layout/settings_cache_ttl.xml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/toolbar_include"
|
||||||
|
layout="@layout/toolbar_standalone" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:text="@string/settings_cache_select_three"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View style="@style/Divider"/>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/settings_cache_ttl_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?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" />
|
||||||
29
OpenKeychain/src/main/res/layout/settings_cache_ttl_item.xml
Normal file
29
OpenKeychain/src/main/res/layout/settings_cache_ttl_item.xml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="?listPreferredItemHeight"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:background="?selectableItemBackground">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/ttl_selected"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/ttl_title"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:text="One Hour"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
17
OpenKeychain/src/main/res/layout/simple_item.xml
Normal file
17
OpenKeychain/src/main/res/layout/simple_item.xml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/simple_item_text"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Medium"
|
||||||
|
android:padding="8dp"
|
||||||
|
tools:text="itemtext" />
|
||||||
|
</LinearLayout>
|
||||||
@@ -1,34 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<string-array name="passphrase_cache_ttl_entries" translatable="false">
|
|
||||||
<item>@string/choice_15secs</item>
|
|
||||||
<item>@string/choice_1min</item>
|
|
||||||
<item>@string/choice_3mins</item>
|
|
||||||
<item>@string/choice_5mins</item>
|
|
||||||
<item>@string/choice_10mins</item>
|
|
||||||
<item>@string/choice_20mins</item>
|
|
||||||
<item>@string/choice_40mins</item>
|
|
||||||
<item>@string/choice_1hour</item>
|
|
||||||
<item>@string/choice_2hours</item>
|
|
||||||
<item>@string/choice_4hours</item>
|
|
||||||
<item>@string/choice_8hours</item>
|
|
||||||
<item>@string/choice_forever</item>
|
|
||||||
</string-array>
|
|
||||||
<string-array name="passphrase_cache_ttl_values" translatable="false">
|
|
||||||
<item>15</item>
|
|
||||||
<item>60</item>
|
|
||||||
<item>180</item>
|
|
||||||
<item>300</item>
|
|
||||||
<item>600</item>
|
|
||||||
<item>1200</item>
|
|
||||||
<item>2400</item>
|
|
||||||
<item>3600</item>
|
|
||||||
<item>7200</item>
|
|
||||||
<item>14400</item>
|
|
||||||
<item>28800</item>
|
|
||||||
<item>-1</item>
|
|
||||||
</string-array>
|
|
||||||
<string-array name="pref_proxy_type_entries" translatable="false">
|
<string-array name="pref_proxy_type_entries" translatable="false">
|
||||||
<item>@string/pref_proxy_type_choice_http</item>
|
<item>@string/pref_proxy_type_choice_http</item>
|
||||||
<item>@string/pref_proxy_type_choice_socks</item>
|
<item>@string/pref_proxy_type_choice_socks</item>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
<string name="title_preferences">"Settings"</string>
|
<string name="title_preferences">"Settings"</string>
|
||||||
<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_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>
|
||||||
@@ -157,7 +158,7 @@
|
|||||||
<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">"Remember time"</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>
|
||||||
@@ -1709,5 +1710,15 @@
|
|||||||
<string name="title_edit_identities">"Edit Identities"</string>
|
<string name="title_edit_identities">"Edit Identities"</string>
|
||||||
<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_five_minutes">"for Five Minutes"</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_three_days">"for Three Days"</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>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<org.sufficientlysecure.keychain.ui.widget.IntegerListPreference
|
<PreferenceScreen
|
||||||
android:entries="@array/passphrase_cache_ttl_entries"
|
android:key="passphraseCacheTtls"
|
||||||
android:entryValues="@array/passphrase_cache_ttl_values"
|
|
||||||
android:key="passphraseCacheTtl"
|
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:title="@string/label_passphrase_cache_ttl" />
|
android:title="@string/label_passphrase_cache_ttl" />
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
|
|||||||
Reference in New Issue
Block a user