add option to toggle self-encrypt for files
This commit is contained in:
parent
3ea7eb3b2b
commit
285184d7c6
|
@ -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);
|
||||
|
|
|
@ -35,6 +35,12 @@
|
|||
android:orderInCategory="1"
|
||||
android:checkable="true" />
|
||||
|
||||
<item
|
||||
android:id="@+id/check_enable_self_encrypt"
|
||||
android:title="@string/label_enable_self_encrypt"
|
||||
android:orderInCategory="1"
|
||||
android:checkable="true" />
|
||||
|
||||
<item
|
||||
android:id="@+id/check_encrypt_filenames"
|
||||
android:title="@string/label_encrypt_filenames"
|
||||
|
|
|
@ -187,6 +187,7 @@
|
|||
<string name="label_selected_smartpgp_authority_title">"Selected authority"</string>
|
||||
<string name="label_preferred">"preferred"</string>
|
||||
<string name="label_enable_compression">"Enable compression"</string>
|
||||
<string name="label_enable_self_encrypt">"Encrypt to signer"</string>
|
||||
<string name="label_encrypt_filenames">"Encrypt filenames"</string>
|
||||
<string name="label_hidden_recipients">"Hide recipients"</string>
|
||||
<string name="label_smartpgp_verify">SmartPGP: Verify certificates</string>
|
||||
|
@ -1603,6 +1604,8 @@
|
|||
<string name="snack_armor_off">"Output encoded as Binary."</string>
|
||||
<string name="snack_compression_on">"Compression <b>enabled</b>."</string>
|
||||
<string name="snack_compression_off">"Compression <b>disabled</b>."</string>
|
||||
<string name="snack_self_encrypt_on">"Encrypt to signer <b>enabled</b>."</string>
|
||||
<string name="snack_self_encrypt_off">"Encrypt to signer <b>disabled</b>."</string>
|
||||
<string name="error_loading_keys">"Error loading keys!"</string>
|
||||
<string name="error_empty_log">"(error, empty log)"</string>
|
||||
<string name="error_reading_text">"Could not read input to decrypt!"</string>
|
||||
|
|
Loading…
Reference in a new issue