add option to toggle self-encrypt for text
This commit is contained in:
@@ -131,6 +131,7 @@ public final class Constants {
|
|||||||
public static final String FILE_USE_COMPRESSION = "useFileCompression";
|
public static final String FILE_USE_COMPRESSION = "useFileCompression";
|
||||||
public static final String FILE_SELF_ENCRYPT = "fileSelfEncrypt";
|
public static final String FILE_SELF_ENCRYPT = "fileSelfEncrypt";
|
||||||
public static final String TEXT_USE_COMPRESSION = "useTextCompression";
|
public static final String TEXT_USE_COMPRESSION = "useTextCompression";
|
||||||
|
public static final String TEXT_SELF_ENCRYPT = "textSelfEncrypt";
|
||||||
public static final String USE_ARMOR = "useArmor";
|
public static final String USE_ARMOR = "useArmor";
|
||||||
// proxy settings
|
// proxy settings
|
||||||
public static final String USE_NORMAL_PROXY = "useNormalProxy";
|
public static final String USE_NORMAL_PROXY = "useNormalProxy";
|
||||||
|
|||||||
@@ -59,11 +59,13 @@ public class EncryptTextFragment
|
|||||||
|
|
||||||
public static final String ARG_TEXT = "text";
|
public static final String ARG_TEXT = "text";
|
||||||
public static final String ARG_USE_COMPRESSION = "use_compression";
|
public static final String ARG_USE_COMPRESSION = "use_compression";
|
||||||
|
public static final String ARG_SELF_ENCRYPT = "self_encrypt";
|
||||||
public static final String ARG_RETURN_PROCESS_TEXT = "return_process_text";
|
public static final String ARG_RETURN_PROCESS_TEXT = "return_process_text";
|
||||||
|
|
||||||
private boolean mShareAfterEncrypt;
|
private boolean mShareAfterEncrypt;
|
||||||
private boolean mReturnProcessTextAfterEncrypt;
|
private boolean mReturnProcessTextAfterEncrypt;
|
||||||
private boolean mUseCompression;
|
private boolean mUseCompression;
|
||||||
|
private boolean mSelfEncrypt;
|
||||||
private boolean mHiddenRecipients = false;
|
private boolean mHiddenRecipients = false;
|
||||||
|
|
||||||
private String mMessage = "";
|
private String mMessage = "";
|
||||||
@@ -128,6 +130,7 @@ public class EncryptTextFragment
|
|||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putBoolean(ARG_USE_COMPRESSION, mUseCompression);
|
outState.putBoolean(ARG_USE_COMPRESSION, mUseCompression);
|
||||||
|
outState.putBoolean(ARG_SELF_ENCRYPT, mSelfEncrypt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -142,13 +145,18 @@ public class EncryptTextFragment
|
|||||||
|
|
||||||
Bundle args = savedInstanceState == null ? getArguments() : savedInstanceState;
|
Bundle args = savedInstanceState == null ? getArguments() : savedInstanceState;
|
||||||
|
|
||||||
mUseCompression = args.getBoolean(ARG_USE_COMPRESSION, true);
|
|
||||||
if (args.containsKey(ARG_USE_COMPRESSION)) {
|
if (args.containsKey(ARG_USE_COMPRESSION)) {
|
||||||
mUseCompression = args.getBoolean(ARG_USE_COMPRESSION, true);
|
mUseCompression = args.getBoolean(ARG_USE_COMPRESSION, true);
|
||||||
} else {
|
} else {
|
||||||
mUseCompression = prefs.getTextUseCompression();
|
mUseCompression = prefs.getTextUseCompression();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.containsKey(ARG_SELF_ENCRYPT)) {
|
||||||
|
mSelfEncrypt = args.getBoolean(ARG_SELF_ENCRYPT, true);
|
||||||
|
} else {
|
||||||
|
mSelfEncrypt = prefs.getTextSelfEncrypt();
|
||||||
|
}
|
||||||
|
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -159,6 +167,7 @@ public class EncryptTextFragment
|
|||||||
inflater.inflate(R.menu.encrypt_text_fragment, menu);
|
inflater.inflate(R.menu.encrypt_text_fragment, menu);
|
||||||
|
|
||||||
menu.findItem(R.id.check_enable_compression).setChecked(mUseCompression);
|
menu.findItem(R.id.check_enable_compression).setChecked(mUseCompression);
|
||||||
|
menu.findItem(R.id.check_enable_self_encrypt).setChecked(mSelfEncrypt);
|
||||||
|
|
||||||
if (mReturnProcessTextAfterEncrypt) {
|
if (mReturnProcessTextAfterEncrypt) {
|
||||||
menu.findItem(R.id.encrypt_paste).setVisible(true);
|
menu.findItem(R.id.encrypt_paste).setVisible(true);
|
||||||
@@ -174,6 +183,10 @@ public class EncryptTextFragment
|
|||||||
toggleEnableCompression(item, !item.isChecked());
|
toggleEnableCompression(item, !item.isChecked());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case R.id.check_enable_self_encrypt: {
|
||||||
|
toggleEnableSelfEncrypt(item, !item.isChecked());
|
||||||
|
break;
|
||||||
|
}
|
||||||
// case R.id.check_hidden_recipients: {
|
// case R.id.check_hidden_recipients: {
|
||||||
// mHiddenRecipients = item.isChecked();
|
// mHiddenRecipients = item.isChecked();
|
||||||
// notifyUpdate();
|
// notifyUpdate();
|
||||||
@@ -203,6 +216,28 @@ public class EncryptTextFragment
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()).setTextSelfEncrypt(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(EncryptTextFragment.this, false);
|
||||||
|
}
|
||||||
|
}, R.string.btn_save_default).show(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void toggleEnableCompression(MenuItem item, final boolean compress) {
|
public void toggleEnableCompression(MenuItem item, final boolean compress) {
|
||||||
|
|
||||||
mUseCompression = compress;
|
mUseCompression = compress;
|
||||||
@@ -264,7 +299,7 @@ public class EncryptTextFragment
|
|||||||
|
|
||||||
data.setEncryptionMasterKeyIds(encryptionKeyIds);
|
data.setEncryptionMasterKeyIds(encryptionKeyIds);
|
||||||
data.setSignatureMasterKeyId(signingKeyId);
|
data.setSignatureMasterKeyId(signingKeyId);
|
||||||
if (signingKeyId != Constants.key.none) {
|
if (signingKeyId != Constants.key.none && mSelfEncrypt) {
|
||||||
data.setAdditionalEncryptId(signingKeyId);
|
data.setAdditionalEncryptId(signingKeyId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -217,6 +217,16 @@ public class Preferences {
|
|||||||
return mSharedPreferences.getBoolean(Pref.TEXT_USE_COMPRESSION, true);
|
return mSharedPreferences.getBoolean(Pref.TEXT_USE_COMPRESSION, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTextSelfEncrypt(boolean selfEncrypt) {
|
||||||
|
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||||
|
editor.putBoolean(Pref.TEXT_SELF_ENCRYPT, selfEncrypt);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getTextSelfEncrypt() {
|
||||||
|
return mSharedPreferences.getBoolean(Pref.TEXT_SELF_ENCRYPT, true);
|
||||||
|
}
|
||||||
|
|
||||||
public String getTheme() {
|
public String getTheme() {
|
||||||
return mSharedPreferences.getString(Pref.THEME, Pref.Theme.LIGHT);
|
return mSharedPreferences.getString(Pref.THEME, Pref.Theme.LIGHT);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,12 @@
|
|||||||
android:checked="true"
|
android:checked="true"
|
||||||
android:checkable="true" />
|
android:checkable="true" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/check_enable_self_encrypt"
|
||||||
|
android:title="@string/label_enable_self_encrypt"
|
||||||
|
android:orderInCategory="1"
|
||||||
|
android:checked="true"
|
||||||
|
android:checkable="true" />
|
||||||
<!--<item-->
|
<!--<item-->
|
||||||
<!--android:id="@+id/check_hidden_recipients"-->
|
<!--android:id="@+id/check_hidden_recipients"-->
|
||||||
<!--android:title="@string/label_hidden_recipients"-->
|
<!--android:title="@string/label_hidden_recipients"-->
|
||||||
|
|||||||
Reference in New Issue
Block a user