Fixes orientation change canceling the ongoing login process.

Fixes #1294
This commit is contained in:
knightshade 2018-03-13 16:11:28 +05:30
parent f03407c35f
commit 57a2ce20cd

View file

@ -83,6 +83,9 @@ public class LoginActivity extends AccountAuthenticatorActivity {
private AppCompatDelegate delegate;
private LoginTextWatcher textWatcher = new LoginTextWatcher();
private Boolean loginCurrentlyInProgress = false;
private static final String LOGING_IN = "logingIn";
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(Utils.isDarkTheme(this) ? R.style.DarkAppTheme : R.style.LightAppTheme);
@ -175,6 +178,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
}
private void performLogin() {
loginCurrentlyInProgress = true;
Timber.d("Login to start!");
final String username = canonicializeUsername(usernameEdit.getText().toString());
final String password = passwordEdit.getText().toString();
@ -205,6 +209,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
if (result.equals("PASS")) {
handlePassResult(username, password);
} else {
loginCurrentlyInProgress = false;
handleOtherResults(result);
}
}
@ -327,6 +332,21 @@ public class LoginActivity extends AccountAuthenticatorActivity {
return getDelegate().getMenuInflater();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(LOGING_IN, loginCurrentlyInProgress);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
loginCurrentlyInProgress = savedInstanceState.getBoolean(LOGING_IN, false);
if(loginCurrentlyInProgress){
performLogin();
}
}
public void askUserForTwoFactorAuth() {
progressDialog.dismiss();
twoFactorContainer.setVisibility(VISIBLE);