From fdb6cee76c4121e4059ccef4195058e9aa2f2e3a Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 31 Jan 2020 23:21:50 +0100 Subject: [PATCH] only ask once for oauth2 on focus changes, however, always ask on 'log in' button --- .../securesms/RegistrationActivity.java | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/org/thoughtcrime/securesms/RegistrationActivity.java b/src/org/thoughtcrime/securesms/RegistrationActivity.java index 1eef2896b..d1a0a0925 100644 --- a/src/org/thoughtcrime/securesms/RegistrationActivity.java +++ b/src/org/thoughtcrime/securesms/RegistrationActivity.java @@ -213,6 +213,8 @@ 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) { @@ -255,19 +257,23 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve switch (type) { case EMAIL: verifyEmail(inputEditText); - checkOauth2start().addListener(new ListenableFuture.Listener() { - @Override - public void onSuccess(Boolean oauth2started) { - if(!oauth2started) { + if (!oauth2DeclinedByUser) { + checkOauth2start().addListener(new ListenableFuture.Listener() { + @Override + public void onSuccess(Boolean oauth2started) { + if (!oauth2started) { + updateProviderInfo(); + } + } + + @Override + public void onFailure(ExecutionException e) { updateProviderInfo(); } - } - - @Override - public void onFailure(ExecutionException e) { - updateProviderInfo(); - } - }); + }); + } else { + updateProviderInfo(); + } break; case SERVER: verifyServer(inputEditText); @@ -281,6 +287,11 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve private long oauth2Requested = 0; + // this flag is set, if the user has declined oauth2 at some point; + // if so, we won't bother em on focus changes again, + // however, to allow reverting the decision, we will always ask on clicking the login button. + private boolean oauth2DeclinedByUser = false; + // 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. @@ -300,6 +311,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve .setTitle(R.string.login_info_oauth2_title) .setMessage(R.string.login_info_oauth2_text) .setNegativeButton(R.string.login_manually, (dialog, which)->{ + oauth2DeclinedByUser = true; oauth2started.set(false); }) .setPositiveButton(R.string.perm_continue, (dialog, which)-> {