add option to toggle self-encrypt for files
This commit is contained in:
@@ -129,6 +129,7 @@ public final class Constants {
|
||||
public static final String USE_NUMKEYPAD_FOR_SECURITY_TOKEN_PIN = "useNumKeypadForYubikeyPin";
|
||||
public static final String ENCRYPT_FILENAMES = "encryptFilenames";
|
||||
public static final String FILE_USE_COMPRESSION = "useFileCompression";
|
||||
public static final String FILE_SELF_ENCRYPT = "fileSelfEncrypt";
|
||||
public static final String TEXT_USE_COMPRESSION = "useTextCompression";
|
||||
public static final String USE_ARMOR = "useArmor";
|
||||
// proxy settings
|
||||
|
||||
@@ -87,6 +87,7 @@ public class EncryptFilesFragment
|
||||
public static final String ARG_DELETE_AFTER_ENCRYPT = "delete_after_encrypt";
|
||||
public static final String ARG_ENCRYPT_FILENAMES = "encrypt_filenames";
|
||||
public static final String ARG_USE_COMPRESSION = "use_compression";
|
||||
public static final String ARG_SELF_ENCRYPT = "self_encrypt";
|
||||
public static final String ARG_USE_ASCII_ARMOR = "use_ascii_armor";
|
||||
public static final String ARG_URIS = "uris";
|
||||
|
||||
@@ -96,6 +97,7 @@ public class EncryptFilesFragment
|
||||
|
||||
private boolean mUseArmor;
|
||||
private boolean mUseCompression;
|
||||
private boolean mSelfEncrypt;
|
||||
private boolean mDeleteAfterEncrypt;
|
||||
private boolean mEncryptFilenames;
|
||||
private boolean mHiddenRecipients = false;
|
||||
@@ -176,6 +178,7 @@ public class EncryptFilesFragment
|
||||
outState.putBoolean(ARG_DELETE_AFTER_ENCRYPT, mDeleteAfterEncrypt);
|
||||
outState.putBoolean(ARG_USE_ASCII_ARMOR, mUseArmor);
|
||||
outState.putBoolean(ARG_USE_COMPRESSION, mUseCompression);
|
||||
outState.putBoolean(ARG_SELF_ENCRYPT, mSelfEncrypt);
|
||||
outState.putBoolean(ARG_ENCRYPT_FILENAMES, mEncryptFilenames);
|
||||
|
||||
outState.putParcelableArrayList(ARG_URIS, mFilesAdapter.getAsArrayList());
|
||||
@@ -202,6 +205,12 @@ public class EncryptFilesFragment
|
||||
mUseCompression = prefs.getFilesUseCompression();
|
||||
}
|
||||
|
||||
if (args.containsKey(ARG_SELF_ENCRYPT)) {
|
||||
mSelfEncrypt = args.getBoolean(ARG_SELF_ENCRYPT, true);
|
||||
} else {
|
||||
mSelfEncrypt = prefs.getFilesEncryptToSelf();
|
||||
}
|
||||
|
||||
if (args.containsKey(ARG_ENCRYPT_FILENAMES)) {
|
||||
mEncryptFilenames = args.getBoolean(ARG_ENCRYPT_FILENAMES, false);
|
||||
} else {
|
||||
@@ -335,6 +344,7 @@ public class EncryptFilesFragment
|
||||
menu.findItem(R.id.check_delete_after_encrypt).setChecked(mDeleteAfterEncrypt);
|
||||
menu.findItem(R.id.check_use_armor).setChecked(mUseArmor);
|
||||
menu.findItem(R.id.check_enable_compression).setChecked(mUseCompression);
|
||||
menu.findItem(R.id.check_enable_self_encrypt).setChecked(mSelfEncrypt);
|
||||
menu.findItem(R.id.check_encrypt_filenames).setChecked(mEncryptFilenames);
|
||||
}
|
||||
|
||||
@@ -372,6 +382,10 @@ public class EncryptFilesFragment
|
||||
toggleEnableCompression(item, !item.isChecked());
|
||||
break;
|
||||
}
|
||||
case R.id.check_enable_self_encrypt: {
|
||||
toggleEnableSelfEncrypt(item, !item.isChecked());
|
||||
break;
|
||||
}
|
||||
case R.id.check_encrypt_filenames: {
|
||||
toggleEncryptFilenamesCheck(item, !item.isChecked());
|
||||
break;
|
||||
@@ -421,6 +435,28 @@ public class EncryptFilesFragment
|
||||
|
||||
}
|
||||
|
||||
public void toggleEnableSelfEncrypt(MenuItem item, final boolean selfEncrypt) {
|
||||
|
||||
mSelfEncrypt = selfEncrypt;
|
||||
item.setChecked(selfEncrypt);
|
||||
|
||||
Notify.create(getActivity(), selfEncrypt
|
||||
? R.string.snack_self_encrypt_on
|
||||
: R.string.snack_self_encrypt_off,
|
||||
Notify.LENGTH_LONG, Style.OK, new ActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
Preferences.getPreferences(getActivity()).setFilesEncryptToSelf(selfEncrypt);
|
||||
Notify.create(getActivity(), selfEncrypt
|
||||
? R.string.snack_self_encrypt_on
|
||||
: R.string.snack_self_encrypt_off,
|
||||
Notify.LENGTH_SHORT, Style.OK, null, R.string.btn_saved)
|
||||
.show(EncryptFilesFragment.this, false);
|
||||
}
|
||||
}, R.string.btn_save_default).show(this);
|
||||
|
||||
}
|
||||
|
||||
public void toggleEnableCompression(MenuItem item, final boolean compress) {
|
||||
|
||||
mUseCompression = compress;
|
||||
@@ -648,7 +684,7 @@ public class EncryptFilesFragment
|
||||
|
||||
data.setEncryptionMasterKeyIds(encryptionKeyIds);
|
||||
data.setSignatureMasterKeyId(signingKeyId);
|
||||
if (signingKeyId != Constants.key.none) {
|
||||
if (signingKeyId != Constants.key.none && mSelfEncrypt) {
|
||||
data.setAdditionalEncryptId(signingKeyId);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -197,6 +197,16 @@ public class Preferences {
|
||||
return mSharedPreferences.getBoolean(Pref.FILE_USE_COMPRESSION, true);
|
||||
}
|
||||
|
||||
public void setFilesEncryptToSelf(boolean selfEncrypt) {
|
||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||
editor.putBoolean(Pref.FILE_SELF_ENCRYPT, selfEncrypt);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public boolean getFilesEncryptToSelf() {
|
||||
return mSharedPreferences.getBoolean(Pref.FILE_SELF_ENCRYPT, true);
|
||||
}
|
||||
|
||||
public void setTextUseCompression(boolean compress) {
|
||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||
editor.putBoolean(Pref.TEXT_USE_COMPRESSION, compress);
|
||||
|
||||
Reference in New Issue
Block a user