diff --git a/res/values/strings.xml b/res/values/strings.xml index 7173d4d13..90e838762 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -446,6 +446,8 @@ Webxdc content shared in this chat will appear here. Media Preview Send Message + %1$s changed their address from %2$s to %3$s + You changed your email address.\n\nContacts using Delta Chat will automatically replace you in the groups you send a message to.\n\nIf possible, set up your old email provider to forward all emails to your new email address. diff --git a/src/org/thoughtcrime/securesms/RegistrationActivity.java b/src/org/thoughtcrime/securesms/RegistrationActivity.java index e16421385..5140a0462 100644 --- a/src/org/thoughtcrime/securesms/RegistrationActivity.java +++ b/src/org/thoughtcrime/securesms/RegistrationActivity.java @@ -61,10 +61,13 @@ import org.thoughtcrime.securesms.util.task.ProgressDialogAsyncTask; import org.thoughtcrime.securesms.util.views.ProgressDialog; import java.lang.ref.WeakReference; +import java.util.Locale; import java.util.concurrent.ExecutionException; public class RegistrationActivity extends BaseActionBarActivity implements DcEventCenter.DcEventDelegate { + private static final String AEAP_BLOG_LINK = "https://delta.chat/550/en/2022-07-10-aeap"; + private enum VerificationType { EMAIL, SERVER, @@ -233,23 +236,20 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve int id = item.getItemId(); if (id == R.id.do_register) { - // "log in" button clicked - even if oauth2DeclinedByUser is true, - // we will ask for oauth2 to allow reverting the decision. - checkOauth2start().addListener(new ListenableFuture.Listener() { - @Override - public void onSuccess(Boolean oauth2started) { - if(!oauth2started) { - updateProviderInfo(); - onLogin(); - } - } - - @Override - public void onFailure(ExecutionException e) { - updateProviderInfo(); - onLogin(); - } - }); + String oldAddr = DcHelper.getSelfAddr(this); + String newAddr = emailInput.getText().toString(); + if (!TextUtils.isEmpty(oldAddr) + && !TextUtils.equals(oldAddr.toLowerCase(Locale.ROOT), newAddr.toLowerCase(Locale.ROOT))) { + // Tell the user about AEAP if they are about to change their address + new AlertDialog.Builder(this) + .setMessage(R.string.aeap_explanation) + .setNeutralButton(R.string.more_info_desktop, (d, w) -> IntentUtils.showBrowserIntent(this, AEAP_BLOG_LINK)) + .setNegativeButton(R.string.cancel, (d, w) -> {}) + .setPositiveButton(R.string.perm_continue, (d, w) -> do_register()) + .show(); + } else { + do_register(); + } return true; } else if (id == android.R.id.home) { // handle close button click here @@ -259,6 +259,26 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve return super.onOptionsItemSelected(item); } + private void do_register() { + // "log in" button clicked - even if oauth2DeclinedByUser is true, + // we will ask for oauth2 to allow reverting the decision. + checkOauth2start().addListener(new ListenableFuture.Listener() { + @Override + public void onSuccess(Boolean oauth2started) { + if(!oauth2started) { + updateProviderInfo(); + onLogin(); + } + } + + @Override + public void onFailure(ExecutionException e) { + updateProviderInfo(); + onLogin(); + } + }); + } + @Override public void onDestroy() { super.onDestroy(); diff --git a/src/org/thoughtcrime/securesms/connect/DcHelper.java b/src/org/thoughtcrime/securesms/connect/DcHelper.java index 8f68315a7..e1e15cdc4 100644 --- a/src/org/thoughtcrime/securesms/connect/DcHelper.java +++ b/src/org/thoughtcrime/securesms/connect/DcHelper.java @@ -39,6 +39,7 @@ public class DcHelper { private static final String TAG = DcHelper.class.getSimpleName(); public static final String CONFIG_ADDRESS = "addr"; + public static final String CONFIG_CONFIGURED_ADDRESS = "configured_addr"; public static final String CONFIG_MAIL_SERVER = "mail_server"; public static final String CONFIG_MAIL_USER = "mail_user"; public static final String CONFIG_MAIL_PASSWORD = "mail_pw"; @@ -97,6 +98,10 @@ public class DcHelper { return dcContext.isConfigured() == 1; } + public static String getSelfAddr(Context context) { + DcContext dcContext = getContext(context); + return dcContext.getConfig(CONFIG_CONFIGURED_ADDRESS); + } public static int getInt(Context context, String key) { DcContext dcContext = getContext(context); @@ -207,6 +212,8 @@ public class DcHelper { // cmp. https://github.com/deltachat/deltachat-android/issues/2187 dcContext.setStockTranslation(120, context.getString(R.string.qrshow_join_group_hint).replace("\"", "")); dcContext.setStockTranslation(121, context.getString(R.string.connectivity_not_connected)); + dcContext.setStockTranslation(122, context.getString(R.string.aeap_addr_changed)); + dcContext.setStockTranslation(123, context.getString(R.string.aeap_explanation)); } public static File getImexDir() { diff --git a/src/org/thoughtcrime/securesms/util/task/ProgressDialogAsyncTask.java b/src/org/thoughtcrime/securesms/util/task/ProgressDialogAsyncTask.java index 9349f867d..1f3f30fd8 100644 --- a/src/org/thoughtcrime/securesms/util/task/ProgressDialogAsyncTask.java +++ b/src/org/thoughtcrime/securesms/util/task/ProgressDialogAsyncTask.java @@ -45,7 +45,11 @@ public abstract class ProgressDialogAsyncTask extends @Override protected void onPostExecute(Result result) { - if (progress != null) progress.dismiss(); + try { + if (progress != null) progress.dismiss(); + } catch(Exception e) { + e.printStackTrace(); + } } protected Context getContext() {