Skip to content

Commit

Permalink
Error messages in LoginActivity persist after orientation change. (#1407
Browse files Browse the repository at this point in the history
)
  • Loading branch information
knight-shade authored and neslihanturan committed Apr 30, 2018
1 parent 3c2cc26 commit 0223c5a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/src/main/java/fr/free/nrw/commons/auth/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public class LoginActivity extends AccountAuthenticatorActivity {
private LoginTextWatcher textWatcher = new LoginTextWatcher();

private Boolean loginCurrentlyInProgress = false;
private Boolean errorMessageShown = false;
private String resultantError;
private static final String RESULTANT_ERROR = "resultantError";
private static final String ERROR_MESSAGE_SHOWN = "errorMessageShown";
private static final String LOGING_IN = "logingIn";

@Override
Expand Down Expand Up @@ -217,6 +221,8 @@ private void handleLogin(String username, String password, String result) {
handlePassResult(username, password);
} else {
loginCurrentlyInProgress = false;
errorMessageShown = true;
resultantError = result;
handleOtherResults(result);
}
}
Expand Down Expand Up @@ -343,15 +349,22 @@ public MenuInflater getMenuInflater() {
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(LOGING_IN, loginCurrentlyInProgress);
outState.putBoolean(ERROR_MESSAGE_SHOWN, errorMessageShown);
outState.putString(RESULTANT_ERROR, resultantError);
}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
loginCurrentlyInProgress = savedInstanceState.getBoolean(LOGING_IN, false);
errorMessageShown = savedInstanceState.getBoolean(ERROR_MESSAGE_SHOWN, false);
if(loginCurrentlyInProgress){
performLogin();
}
if(errorMessageShown){
resultantError = savedInstanceState.getString(RESULTANT_ERROR);
handleOtherResults(resultantError);
}
}

public void askUserForTwoFactorAuth() {
Expand All @@ -363,7 +376,9 @@ public void askUserForTwoFactorAuth() {

public void showMessageAndCancelDialog(@StringRes int resId) {
showMessage(resId, R.color.secondaryDarkColor);
progressDialog.cancel();
if(progressDialog != null){
progressDialog.cancel();
}
}

public void showSuccessAndDismissDialog() {
Expand Down

0 comments on commit 0223c5a

Please sign in to comment.