diff --git a/res/layout/registration_activity.xml b/res/layout/registration_activity.xml index 27341517c..8e5639a6a 100644 --- a/res/layout/registration_activity.xml +++ b/res/layout/registration_activity.xml @@ -90,7 +90,7 @@ android:layout_height="wrap_content" android:visibility="gone" 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, auth_method_label, auth_method, view_log_button" /> + outbox, smtp_login, smtp_password, smtp_server, smtp_port, smtp_security_label, smtp_security, auth_method_label, auth_method, cert_check_label, cert_check, view_log_button" /> + + + + + app:layout_constraintTop_toBottomOf="@id/cert_check" /> 1 + + @string/automatic + @string/strict + @string/accept_invalid_hostnames + @string/accept_invalid_certificates + + diff --git a/res/values/strings.xml b/res/values/strings.xml index a388eaaf7..3e6d1b7c1 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -328,6 +328,7 @@ Continue with simplified setup? The entered e-mail-address supports a simplified setup (OAuth2).\n\nIn the next step, please allow Delta Chat to act as your Chat with E-Mail app.\n\nThere are no Delta Chat servers, your data stays on your device! For GMail Accounts you need to create an App-Password if you have 2FA enabled. If this setting is not available, you need to enable Less Secure Apps. + Certificate checks Please enter a valid email address Please enter a valid server / IP address Please enter a valid port (1–65535) diff --git a/src/org/thoughtcrime/securesms/RegistrationActivity.java b/src/org/thoughtcrime/securesms/RegistrationActivity.java index 1b70e566a..80d8faeb7 100644 --- a/src/org/thoughtcrime/securesms/RegistrationActivity.java +++ b/src/org/thoughtcrime/securesms/RegistrationActivity.java @@ -67,6 +67,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve Spinner imapSecurity; Spinner smtpSecurity; Spinner authMethod; + Spinner certCheck; @Override public void onCreate(Bundle bundle) { @@ -89,6 +90,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve imapSecurity = findViewById(R.id.imap_security); smtpSecurity = findViewById(R.id.smtp_security); authMethod = findViewById(R.id.auth_method); + certCheck = findViewById(R.id.cert_check); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { @@ -132,26 +134,29 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve smtpServerInput.setText(DcHelper.get(this, CONFIG_SEND_SERVER)); smtpPortInput.setText(DcHelper.get(this, CONFIG_SEND_PORT)); - int server_flags = DcHelper.getInt(this, "server_flags", 0); + int serverFlags = DcHelper.getInt(this, "server_flags", 0); int sel = 0; - if((server_flags&DcContext.DC_LP_IMAP_SOCKET_SSL)!=0) sel = 1; - if((server_flags&DcContext.DC_LP_IMAP_SOCKET_STARTTLS)!=0) sel = 2; - if((server_flags&DcContext.DC_LP_IMAP_SOCKET_PLAIN)!=0) sel = 3; + if((serverFlags&DcContext.DC_LP_IMAP_SOCKET_SSL)!=0) sel = 1; + if((serverFlags&DcContext.DC_LP_IMAP_SOCKET_STARTTLS)!=0) sel = 2; + if((serverFlags&DcContext.DC_LP_IMAP_SOCKET_PLAIN)!=0) sel = 3; imapSecurity.setSelection(sel); sel = 0; - if((server_flags&DcContext.DC_LP_SMTP_SOCKET_SSL)!=0) sel = 1; - if((server_flags&DcContext.DC_LP_SMTP_SOCKET_STARTTLS)!=0) sel = 2; - if((server_flags&DcContext.DC_LP_SMTP_SOCKET_PLAIN)!=0) sel = 3; + if((serverFlags&DcContext.DC_LP_SMTP_SOCKET_SSL)!=0) sel = 1; + if((serverFlags&DcContext.DC_LP_SMTP_SOCKET_STARTTLS)!=0) sel = 2; + if((serverFlags&DcContext.DC_LP_SMTP_SOCKET_PLAIN)!=0) sel = 3; smtpSecurity.setSelection(sel); sel = 0; - if((server_flags&DcContext.DC_LP_AUTH_OAUTH2)!=0) sel = 1; + if((serverFlags&DcContext.DC_LP_AUTH_OAUTH2)!=0) sel = 1; authMethod.setSelection(sel); + + int certCheckFlags = DcHelper.getInt(this, "imap_certificate_checks"); + certCheck.setSelection(certCheckFlags); } - DcHelper.getContext(this).eventCenter.addObserver(this, DcContext.DC_EVENT_CONFIGURE_PROGRESS); + DcHelper.getContext(this).eventCenter.addObserver(DcContext.DC_EVENT_CONFIGURE_PROGRESS, this); } @Override @@ -434,6 +439,9 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve if(authMethod.getSelectedItemPosition()==1) server_flags |= DcContext.DC_LP_AUTH_OAUTH2; DcHelper.getContext(this).setConfigInt("server_flags", server_flags); + DcHelper.getContext(this).setConfigInt("smtp_certificate_checks", certCheck.getSelectedItemPosition()); + DcHelper.getContext(this).setConfigInt("imap_certificate_checks", certCheck.getSelectedItemPosition()); + // calling configure() results in // receiving multiple DC_EVENT_CONFIGURE_PROGRESS events DcHelper.getContext(this).captureNextError();