diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f1533a06..5cb1aa993 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ * Allow to open links in messages via actions in TalkBack menu * Allow to open map if user clicks "Location streaming enabled" system message * Allow to disable incoming calls notifications +* Add an option to process unencrypted messages; by default, only encrypted messages can be sent or received * Fix: do not accidentally set draft in chats that don't allow sending messages * Fix swipe navigation between tabs in RTL languages * Remove legacy option diff --git a/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java b/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java index cc6352644..de2635bdf 100644 --- a/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java +++ b/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java @@ -55,6 +55,7 @@ public class DcHelper { public static final String CONFIG_PRIVATE_TAG = "private_tag"; public static final String CONFIG_STATS_SENDING = "stats_sending"; public static final String CONFIG_STATS_ID = "stats_id"; + public static final String CONFIG_FORCE_ENCRYPTION = "force_encryption"; public static DcContext getContext(@NonNull Context context) { return ApplicationContext.getInstance(context).getDcContext(); diff --git a/src/main/java/org/thoughtcrime/securesms/relay/EditRelayActivity.java b/src/main/java/org/thoughtcrime/securesms/relay/EditRelayActivity.java index 6a9c09d39..6d4e7dff2 100644 --- a/src/main/java/org/thoughtcrime/securesms/relay/EditRelayActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/relay/EditRelayActivity.java @@ -23,6 +23,7 @@ import androidx.annotation.IdRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.widget.SwitchCompat; import androidx.constraintlayout.widget.Group; import chat.delta.rpc.Rpc; import chat.delta.rpc.RpcException; @@ -75,6 +76,7 @@ public class EditRelayActivity extends BaseActionBarActivity Spinner imapSecurity; Spinner smtpSecurity; Spinner certCheck; + private SwitchCompat enforceE2eeSwitch; Rpc rpc; int accId; @@ -110,6 +112,7 @@ public class EditRelayActivity extends BaseActionBarActivity imapSecurity = findViewById(R.id.imap_security); smtpSecurity = findViewById(R.id.smtp_security); certCheck = findViewById(R.id.cert_check); + enforceE2eeSwitch = findViewById(R.id.enforce_e2ee_switch); String addr = getIntent().getStringExtra(EXTRA_ADDR); EnteredLoginParam config = null; @@ -173,6 +176,10 @@ public class EditRelayActivity extends BaseActionBarActivity boolean expandAdvanced = false; int intVal; + intVal = getContext(this).getConfigInt(DcHelper.CONFIG_FORCE_ENCRYPTION); + enforceE2eeSwitch.setChecked(intVal == 1); + expandAdvanced = expandAdvanced || intVal == 0; + if (config != null) { // configured emailInput.setText(config.addr); if (!TextUtils.isEmpty(config.addr)) { @@ -500,9 +507,12 @@ public class EditRelayActivity extends BaseActionBarActivity param.smtpPassword = getParam(R.id.smtp_password_text, false); param.certificateChecks = certificateChecksFromInt(certCheck.getSelectedItemPosition()); + final String forceEncryption = enforceE2eeSwitch.isChecked() ? "1" : "0"; + new Thread( () -> { try { + rpc.setConfig(accId, DcHelper.CONFIG_FORCE_ENCRYPTION, forceEncryption); rpc.addOrUpdateTransport(accId, param); DcHelper.getEventCenter(this).endCaptureNextError(); progressDialog.dismiss(); diff --git a/src/main/res/layout/activity_edittransport.xml b/src/main/res/layout/activity_edittransport.xml index 5bb29d8e4..be91d3795 100644 --- a/src/main/res/layout/activity_edittransport.xml +++ b/src/main/res/layout/activity_edittransport.xml @@ -129,7 +129,7 @@ android:visibility="gone" tools:visibility="visible" app:constraint_referenced_ids="inbox, imap_login, imap_server, imap_port, imap_security_label, imap_security, outbox_view_spacer_top, - outbox, smtp_login, smtp_password, smtp_server, smtp_port, smtp_security_label, smtp_security, cert_check_label, cert_check, view_log_button" /> + outbox, smtp_login, smtp_password, smtp_server, smtp_port, smtp_security_label, smtp_security, cert_check_label, cert_check, view_log_button, enforce_e2ee_switch" /> + + + app:layout_constraintTop_toBottomOf="@id/enforce_e2ee_switch" /> diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 44070ea7e..a52b7b6ca 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -673,7 +673,7 @@ Secure Decentralized Chat Scan Invitation Code Log In - This login is for advanced users:\n\n• Do not use an address you\'re using in another app.\n\n• Classic email server allow chats without end-to-end encryption marked by a mail icon. + This login is for advanced users.\n\nDo not use an address you\'re using in another app. Inbox IMAP Login Name IMAP Server @@ -708,6 +708,7 @@ Used for sending Hide from Contacts Hidden from contacts + Enforce Encryption for All Relays Messages are received on all relays.\n\n⚠️ If you change anything here, make sure all your devices run at least version 2.47.0. Otherwise older devices may miss messages.