Move default encrypt/receipt to send settings

pull/162/head
M66B 6 years ago
parent 8c2d9d281b
commit 13e09da162

@ -162,8 +162,9 @@ public class ApplicationEx extends Application {
editor.putBoolean("reversed", true);
editor.remove("swipe_reversed");
}
}
} else if (version < 741)
editor.remove("send_dialog");
if (BuildConfig.DEBUG && false) {
editor.remove("app_support");

@ -91,11 +91,11 @@ public class EntityIdentity {
@NonNull
public Boolean plain_only = false; // obsolete
@NonNull
public Boolean encrypt = false;
public Boolean encrypt = false; // obsolete
@NonNull
public Boolean delivery_receipt = false;
public Boolean delivery_receipt = false; // obsolete
@NonNull
public Boolean read_receipt = false;
public Boolean read_receipt = false; // obsolete
@NonNull
public Boolean store_sent = false; // obsolete
public Long sent_folder = null; // obsolete
@ -179,8 +179,6 @@ public class EntityIdentity {
// not plain_only
json.put("encrypt", encrypt);
json.put("delivery_receipt", delivery_receipt);
json.put("read_receipt", read_receipt);
// not store_sent
// not sent_folder
// not sign_key
@ -229,10 +227,6 @@ public class EntityIdentity {
if (json.has("encrypt"))
identity.encrypt = json.getBoolean("encrypt");
if (json.has("delivery_receipt"))
identity.delivery_receipt = json.getBoolean("delivery_receipt");
if (json.has("read_receipt"))
identity.read_receipt = json.getBoolean("read_receipt");
return identity;
}
@ -263,8 +257,6 @@ public class EntityIdentity {
Objects.equals(this.replyto, other.replyto) &&
Objects.equals(this.bcc, other.bcc) &&
this.encrypt.equals(other.encrypt) &&
this.delivery_receipt.equals(other.delivery_receipt) &&
this.read_receipt.equals(other.read_receipt) &&
Objects.equals(this.tbd, other.tbd) &&
Objects.equals(this.state, other.state) &&
Objects.equals(this.error, other.error) &&

@ -1988,6 +1988,8 @@ public class FragmentCompose extends FragmentBase {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean text_color = prefs.getBoolean("text_color", true);
boolean plain_only = prefs.getBoolean("plain_only", false);
boolean encrypt_default = prefs.getBoolean("encrypt_default", false);
boolean receipt_default = prefs.getBoolean("receipt_default", false);
Log.i("Load draft action=" + action + " id=" + id + " reference=" + reference);
@ -2020,6 +2022,13 @@ public class FragmentCompose extends FragmentBase {
data.draft = new EntityMessage();
data.draft.msgid = EntityMessage.generateMessageId();
if (plain_only)
data.draft.plain_only = true;
if (encrypt_default)
data.draft.encrypt = true;
if (receipt_default)
data.draft.receipt_request = true;
if (ref == null) {
data.draft.thread = data.draft.msgid;
@ -2090,8 +2099,10 @@ public class FragmentCompose extends FragmentBase {
if ("reply_all".equals(action))
data.draft.cc = ref.getAllRecipients(data.identities);
else if ("receipt".equals(action))
else if ("receipt".equals(action)) {
data.draft.receipt = true;
data.draft.receipt_request = false;
}
} else if ("forward".equals(action) || "editasnew".equals(action))
data.draft.thread = data.draft.msgid; // new thread
@ -2130,7 +2141,8 @@ public class FragmentCompose extends FragmentBase {
} else if ("participation".equals(action))
data.draft.subject = status + ": " + ref.subject;
data.draft.plain_only = ref.plain_only;
if (ref.plain_only)
data.draft.plain_only = ref.plain_only;
if (answer > 0) {
EntityAnswer a = db.answer().getAnswer(answer);
@ -2139,9 +2151,6 @@ public class FragmentCompose extends FragmentBase {
}
}
if (plain_only)
data.draft.plain_only = true;
// Select identity matching from address
Address from = null;
EntityIdentity selected = null;
@ -2807,12 +2816,6 @@ public class FragmentCompose extends FragmentBase {
if (draft.to == null && draft.cc == null && draft.bcc == null)
throw new IllegalArgumentException(context.getString(R.string.title_to_missing));
db.message().setMessagePlainOnly(draft.id, identity.plain_only);
db.message().setMessageEncrypt(draft.id, identity.encrypt);
db.message().setMessageReceiptRequest(draft.id, identity.delivery_receipt || identity.read_receipt);
if (TextUtils.isEmpty(draft.subject))
args.putBoolean("remind_subject", true);
@ -3620,6 +3623,10 @@ public class FragmentCompose extends FragmentBase {
cbEncrypt.setChecked(draft.encrypt != null && draft.encrypt);
cbReceipt.setChecked(draft.receipt_request != null && draft.receipt_request);
cbPlainOnly.setVisibility(draft.receipt != null && draft.receipt ? View.GONE : View.VISIBLE);
cbEncrypt.setVisibility(draft.receipt != null && draft.receipt ? View.GONE : View.VISIBLE);
cbReceipt.setVisibility(draft.receipt != null && draft.receipt ? View.GONE : View.VISIBLE);
int priority = (draft.priority == null ? 1 : draft.priority);
spPriority.setTag(priority);
spPriority.setSelection(priority);

@ -108,9 +108,6 @@ public class FragmentIdentity extends FragmentBase {
private TextView etSenderExtra;
private EditText etReplyTo;
private EditText etBcc;
private TextView tvEncryptPro;
private CheckBox cbEncrypt;
private CheckBox cbReceipt;
private Button btnSave;
private ContentLoadingProgressBar pbSave;
@ -188,9 +185,6 @@ public class FragmentIdentity extends FragmentBase {
etSenderExtra = view.findViewById(R.id.etSenderExtra);
etReplyTo = view.findViewById(R.id.etReplyTo);
etBcc = view.findViewById(R.id.etBcc);
tvEncryptPro = view.findViewById(R.id.tvEncryptPro);
cbEncrypt = view.findViewById(R.id.cbEncrypt);
cbReceipt = view.findViewById(R.id.cbReceipt);
btnSave = view.findViewById(R.id.btnSave);
pbSave = view.findViewById(R.id.pbSave);
@ -425,8 +419,6 @@ public class FragmentIdentity extends FragmentBase {
cbInsecure.setVisibility(View.GONE);
tilPassword.setEndIconMode(id < 0 ? END_ICON_PASSWORD_TOGGLE : END_ICON_NONE);
Helper.linkPro(tvEncryptPro);
btnAdvanced.setVisibility(View.GONE);
btnSave.setVisibility(View.GONE);
@ -509,8 +501,6 @@ public class FragmentIdentity extends FragmentBase {
args.putString("sender_extra_regex", etSenderExtra.getText().toString());
args.putString("replyto", etReplyTo.getText().toString().trim());
args.putString("bcc", etBcc.getText().toString().trim());
args.putBoolean("encrypt", cbEncrypt.isChecked());
args.putBoolean("receipt", cbReceipt.isChecked());
args.putLong("account", account == null ? -1 : account.id);
args.putString("host", etHost.getText().toString());
args.putBoolean("starttls", rgEncryption.getCheckedRadioButtonId() == R.id.radio_starttls);
@ -575,8 +565,6 @@ public class FragmentIdentity extends FragmentBase {
String sender_extra_regex = args.getString("sender_extra_regex");
String replyto = args.getString("replyto");
String bcc = args.getString("bcc");
boolean encrypt = args.getBoolean("encrypt");
boolean receipt = args.getBoolean("receipt");
boolean should = args.getBoolean("should");
@ -685,12 +673,6 @@ public class FragmentIdentity extends FragmentBase {
return true;
if (!Objects.equals(identity.bcc, bcc))
return true;
if (!Objects.equals(identity.encrypt, encrypt))
return true;
if (!Objects.equals(identity.delivery_receipt, receipt))
return true;
if (!Objects.equals(identity.read_receipt, receipt))
return true;
if (identity.error != null)
return true;
@ -753,9 +735,6 @@ public class FragmentIdentity extends FragmentBase {
identity.sender_extra_regex = sender_extra_regex;
identity.replyto = replyto;
identity.bcc = bcc;
identity.encrypt = encrypt;
identity.delivery_receipt = receipt;
identity.read_receipt = receipt;
identity.sent_folder = null;
identity.sign_key = null;
identity.error = null;
@ -890,8 +869,6 @@ public class FragmentIdentity extends FragmentBase {
etSenderExtra.setText(identity == null ? null : identity.sender_extra_regex);
etReplyTo.setText(identity == null ? null : identity.replyto);
etBcc.setText(identity == null ? null : identity.bcc);
cbEncrypt.setChecked(identity == null ? false : identity.encrypt);
cbReceipt.setChecked(identity == null ? false : identity.delivery_receipt || identity.read_receipt);
auth = (identity == null ? MailService.AUTH_TYPE_PASSWORD : identity.auth_type);

@ -49,12 +49,14 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private SwitchCompat swAutoResize;
private Spinner spAutoResize;
private TextView tvAutoResize;
private SwitchCompat swEncrypt;
private SwitchCompat swReceipt;
private SwitchCompat swLookupMx;
private Spinner spSendDelayed;
private final static String[] RESET_OPTIONS = new String[]{
"keyboard", "suggest_sent", "suggested_received", "prefix_once", "plain_only", "usenet_signature",
"autoresize", "resize", "lookup_mx", "send_delayed"
"autoresize", "encrypt_default", "receipt_default", "resize", "lookup_mx", "send_delayed"
};
@Override
@ -76,6 +78,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swAutoResize = view.findViewById(R.id.swAutoResize);
spAutoResize = view.findViewById(R.id.spAutoResize);
tvAutoResize = view.findViewById(R.id.tvAutoResize);
swEncrypt = view.findViewById(R.id.swEncrypt);
swReceipt = view.findViewById(R.id.swReceipt);
swLookupMx = view.findViewById(R.id.swLookupMx);
spSendDelayed = view.findViewById(R.id.spSendDelayed);
@ -149,6 +153,20 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
}
});
swEncrypt.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("encrypt_default", checked).apply();
}
});
swReceipt.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("receipt_default", checked).apply();
}
});
swLookupMx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -234,6 +252,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
}
spAutoResize.setEnabled(swAutoResize.isChecked());
swEncrypt.setChecked(prefs.getBoolean("encrypt_default", false));
swReceipt.setChecked(prefs.getBoolean("receipt_default", false));
swLookupMx.setChecked(prefs.getBoolean("lookup_mx", false));
int send_delayed = prefs.getInt("send_delayed", 0);

@ -561,36 +561,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBcc" />
<CheckBox
android:id="@+id/cbEncrypt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_identity_encrypt"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etBcc" />
<TextView
android:id="@+id/tvEncryptPro"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_pro_feature"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbEncrypt" />
<CheckBox
android:id="@+id/cbReceipt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_identity_receipt"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvEncryptPro" />
<Button
android:id="@+id/btnSave"
android:layout_width="wrap_content"
@ -599,7 +569,7 @@
android:tag="disable"
android:text="@string/title_save"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbReceipt" />
app:layout_constraintTop_toBottomOf="@id/etBcc" />
<eu.faircode.email.ContentLoadingProgressBar
android:id="@+id/pbSave"
@ -693,8 +663,6 @@
cbUseIp,tvUseIpHint,
cbSynchronize,cbPrimary,
cbSenderExtra,tvSenderExtra,etSenderExtra,tvSenderExtraHint,
tvReplyTo,etReplyTo,tvBcc,etBcc,
cbEncrypt,tvEncryptPro,
cbReceipt,tvReceipt" />
tvReplyTo,etReplyTo,tvBcc,etBcc" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

@ -135,6 +135,28 @@
app:layout_constraintStart_toEndOf="@id/spAutoResize"
app:layout_constraintTop_toTopOf="@id/spAutoResize" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swEncrypt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_identity_encrypt"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spAutoResize"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swReceipt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_identity_receipt"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swEncrypt"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swLookupMx"
android:layout_width="0dp"
@ -143,7 +165,7 @@
android:text="@string/title_advanced_lookup_mx"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spAutoResize"
app:layout_constraintTop_toBottomOf="@id/swReceipt"
app:switchPadding="12dp" />
<TextView

Loading…
Cancel
Save