From d6e05f61ac6499274c26992c56fcc414d72dd0c1 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Wed, 13 May 2026 22:27:55 +0200 Subject: [PATCH 1/7] add "Enforce e2ee" switch --- .../securesms/relay/EditRelayActivity.java | 11 +++++++++++ src/main/res/layout/activity_edittransport.xml | 15 +++++++++++++-- src/main/res/values/strings.xml | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/thoughtcrime/securesms/relay/EditRelayActivity.java b/src/main/java/org/thoughtcrime/securesms/relay/EditRelayActivity.java index 6a9c09d39..49b9702cb 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; @@ -111,6 +112,12 @@ public class EditRelayActivity extends BaseActionBarActivity smtpSecurity = findViewById(R.id.smtp_security); certCheck = findViewById(R.id.cert_check); + SwitchCompat enforceE2eeSwitch = findViewById(R.id.enforce_e2ee_switch); + enforceE2eeSwitch.setOnCheckedChangeListener( + (b, isChecked) -> { + // TODO: use new core API to set the config + }); + String addr = getIntent().getStringExtra(EXTRA_ADDR); EnteredLoginParam config = null; try { @@ -173,6 +180,10 @@ public class EditRelayActivity extends BaseActionBarActivity boolean expandAdvanced = false; int intVal; + intVal = 0; // TODO: get the current "enforce_e2ee" value + enforceE2eeSwitch.setChecked(intVal == 1); + expandAdvanced = expandAdvanced || intVal == 1; + if (config != null) { // configured emailInput.setText(config.addr); if (!TextUtils.isEmpty(config.addr)) { diff --git a/src/main/res/layout/activity_edittransport.xml b/src/main/res/layout/activity_edittransport.xml index 5bb29d8e4..01bf583be 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" /> + + + app:layout_constraintTop_toBottomOf="@id/enforce_e2ee_switch" /> Used for sending Hide from Contacts Hidden from contacts + Enforce Encryption 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. From 6f547dfb66ac912c97668249e4b0483e7718125a Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 22 May 2026 16:41:10 +0200 Subject: [PATCH 2/7] fix: hide 'encryption' switch if unexpanded --- .../res/layout/activity_edittransport.xml | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/res/layout/activity_edittransport.xml b/src/main/res/layout/activity_edittransport.xml index 01bf583be..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, enforce_e2ee" /> + 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/advanced_text" /> + + + app:layout_constraintTop_toBottomOf="@id/enforce_e2ee_switch" /> From cef68171873de4b69a0c32ce8fad48fcffae44da Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 22 May 2026 16:44:48 +0200 Subject: [PATCH 3/7] make clear, the 'encryption' setting affects all relays --- src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 9245ca1c3..a3b01fabb 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -708,7 +708,7 @@ Used for sending Hide from Contacts Hidden from contacts - Enforce Encryption + 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. From 74f6853815ffd0b41fdbf15539f0afb667c20f69 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 22 May 2026 17:28:17 +0200 Subject: [PATCH 4/7] use correct flag from core --- .../java/org/thoughtcrime/securesms/connect/DcHelper.java | 1 + .../org/thoughtcrime/securesms/relay/EditRelayActivity.java | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) 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 49b9702cb..4f8c14377 100644 --- a/src/main/java/org/thoughtcrime/securesms/relay/EditRelayActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/relay/EditRelayActivity.java @@ -115,7 +115,7 @@ public class EditRelayActivity extends BaseActionBarActivity SwitchCompat enforceE2eeSwitch = findViewById(R.id.enforce_e2ee_switch); enforceE2eeSwitch.setOnCheckedChangeListener( (b, isChecked) -> { - // TODO: use new core API to set the config + getContext(this).setConfigInt(DcHelper.CONFIG_FORCE_ENCRYPTION, isChecked ? 1 : 0); }); String addr = getIntent().getStringExtra(EXTRA_ADDR); @@ -180,9 +180,9 @@ public class EditRelayActivity extends BaseActionBarActivity boolean expandAdvanced = false; int intVal; - intVal = 0; // TODO: get the current "enforce_e2ee" value + intVal = getContext(this).getConfigInt(DcHelper.CONFIG_FORCE_ENCRYPTION); enforceE2eeSwitch.setChecked(intVal == 1); - expandAdvanced = expandAdvanced || intVal == 1; + expandAdvanced = expandAdvanced || intVal == 0; if (config != null) { // configured emailInput.setText(config.addr); From 40faa3d43e64207a12acaf26e3bdf5891e6fa33c Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 22 May 2026 17:50:35 +0200 Subject: [PATCH 5/7] allow cancel without chaning encryption setting --- .../securesms/relay/EditRelayActivity.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/thoughtcrime/securesms/relay/EditRelayActivity.java b/src/main/java/org/thoughtcrime/securesms/relay/EditRelayActivity.java index 4f8c14377..6d4e7dff2 100644 --- a/src/main/java/org/thoughtcrime/securesms/relay/EditRelayActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/relay/EditRelayActivity.java @@ -76,6 +76,7 @@ public class EditRelayActivity extends BaseActionBarActivity Spinner imapSecurity; Spinner smtpSecurity; Spinner certCheck; + private SwitchCompat enforceE2eeSwitch; Rpc rpc; int accId; @@ -111,12 +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); - - SwitchCompat enforceE2eeSwitch = findViewById(R.id.enforce_e2ee_switch); - enforceE2eeSwitch.setOnCheckedChangeListener( - (b, isChecked) -> { - getContext(this).setConfigInt(DcHelper.CONFIG_FORCE_ENCRYPTION, isChecked ? 1 : 0); - }); + enforceE2eeSwitch = findViewById(R.id.enforce_e2ee_switch); String addr = getIntent().getStringExtra(EXTRA_ADDR); EnteredLoginParam config = null; @@ -511,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(); From 6dfccdab845ebe53b5c80bc9b5efb0f82688e5db Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 22 May 2026 17:52:34 +0200 Subject: [PATCH 6/7] update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ed69596c..0c4beb598 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 From f98a5178b373aee3ed3595815638d4253899b295 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 22 May 2026 17:55:27 +0200 Subject: [PATCH 7/7] update advanced login hint --- src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index a3b01fabb..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