From be462abccfbc9e08aa3ad182445c43cfd52cb269 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 31 Jan 2020 22:55:00 +0100 Subject: [PATCH] streamline oauth2 start an remove update-provider-info side-effect --- .../securesms/RegistrationActivity.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/org/thoughtcrime/securesms/RegistrationActivity.java b/src/org/thoughtcrime/securesms/RegistrationActivity.java index 93de9fce9..b31bd1ef9 100644 --- a/src/org/thoughtcrime/securesms/RegistrationActivity.java +++ b/src/org/thoughtcrime/securesms/RegistrationActivity.java @@ -217,12 +217,14 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve @Override public void onSuccess(Boolean oauth2started) { if(!oauth2started) { + updateProviderInfo(); onLogin(); } } @Override public void onFailure(ExecutionException e) { + updateProviderInfo(); onLogin(); } }); @@ -247,12 +249,25 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve } private void focusListener(View view, boolean focused, VerificationType type) { + if (!focused) { TextInputEditText inputEditText = (TextInputEditText) view; switch (type) { case EMAIL: verifyEmail(inputEditText); - checkOauth2start(); + checkOauth2start().addListener(new ListenableFuture.Listener() { + @Override + public void onSuccess(Boolean oauth2started) { + if(!oauth2started) { + updateProviderInfo(); + } + } + + @Override + public void onFailure(ExecutionException e) { + updateProviderInfo(); + } + }); break; case SERVER: verifyServer(inputEditText); @@ -266,6 +281,9 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve private long oauth2Requested = 0; + // this function checks if oauth2 is available for a given email address + // and and asks the user if one wants to start oauth2. + // the function returns the future "true" if oauth2 was started and "false" otherwise. private ListenableFuture checkOauth2start() { SettableFuture oauth2started = new SettableFuture<>(); @@ -282,7 +300,6 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve .setTitle(R.string.login_info_oauth2_title) .setMessage(R.string.login_info_oauth2_text) .setNegativeButton(R.string.cancel, (dialog, which)->{ - updateProviderInfo(); oauth2started.set(false); }) .setPositiveButton(R.string.perm_continue, (dialog, which)-> { @@ -294,12 +311,10 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve .setCancelable(false) .show(); } else { - updateProviderInfo(); oauth2started.set(false); } } else { - updateProviderInfo(); oauth2started.set(false); }