Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
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;
Expand Down Expand Up @@ -75,6 +76,7 @@ private enum VerificationType {
Spinner imapSecurity;
Spinner smtpSecurity;
Spinner certCheck;
private SwitchCompat enforceE2eeSwitch;

Rpc rpc;
int accId;
Expand Down Expand Up @@ -110,6 +112,7 @@ public void onCreate(Bundle bundle) {
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;
Expand Down Expand Up @@ -173,6 +176,10 @@ public void afterTextChanged(Editable s) {
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)) {
Expand Down Expand Up @@ -500,9 +507,12 @@ private void setupConfig() {
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();
Expand Down
15 changes: 13 additions & 2 deletions src/main/res/layout/activity_edittransport.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

<ImageView
android:id="@+id/advanced_icon"
Expand Down Expand Up @@ -362,6 +362,17 @@
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
app:layout_constraintTop_toBottomOf="@id/cert_check_label" />

<androidx.appcompat.widget.SwitchCompat
android:id="@+id/enforce_e2ee_switch"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:text="@string/enforce_e2ee"
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
app:layout_constraintTop_toBottomOf="@id/cert_check" />

<TextView
android:id="@+id/view_log_button"
android:layout_width="0dp"
Expand All @@ -375,7 +386,7 @@
android:paddingBottom="32dp"
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
app:layout_constraintTop_toBottomOf="@id/cert_check" />
app:layout_constraintTop_toBottomOf="@id/enforce_e2ee_switch" />

</androidx.constraintlayout.widget.ConstraintLayout>

Expand Down
3 changes: 2 additions & 1 deletion src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@
<string name="welcome_chat_over_email">Secure Decentralized Chat</string>
<string name="scan_invitation_code">Scan Invitation Code</string>
<string name="login_title">Log In</string>
<string name="login_advanced_hint">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.</string>
<string name="login_advanced_hint">This login is for advanced users.\n\nDo not use an address you\'re using in another app.</string>
<string name="login_inbox">Inbox</string>
<string name="login_imap_login">IMAP Login Name</string>
<string name="login_imap_server">IMAP Server</string>
Expand Down Expand Up @@ -708,6 +708,7 @@
<string name="used_for_sending">Used for sending</string>
<string name="hide_from_contacts">Hide from Contacts</string>
<string name="hidden_from_contacts">Hidden from contacts</string>
<string name="enforce_e2ee">Enforce Encryption for All Relays</string>
<!-- Hint for the list of relays -->
<string name="transport_list_hint">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.</string>
<!-- shown if a QR code was scanned that can be used as a relay -->
Expand Down