mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 06:43:56 +01:00 
			
		
		
		
	Error messages in LoginActivity persist after orientation change. (#1407)
This commit is contained in:
		
							parent
							
								
									3c2cc26d3b
								
							
						
					
					
						commit
						0223c5ab76
					
				
					 1 changed files with 16 additions and 1 deletions
				
			
		|  | @ -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 | ||||
|  | @ -217,6 +221,8 @@ public class LoginActivity extends AccountAuthenticatorActivity { | |||
|             handlePassResult(username, password); | ||||
|         } else { | ||||
|             loginCurrentlyInProgress = false; | ||||
|             errorMessageShown = true; | ||||
|             resultantError = result; | ||||
|             handleOtherResults(result); | ||||
|         } | ||||
|     } | ||||
|  | @ -343,15 +349,22 @@ public class LoginActivity extends AccountAuthenticatorActivity { | |||
|     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() { | ||||
|  | @ -363,7 +376,9 @@ public class LoginActivity extends AccountAuthenticatorActivity { | |||
| 
 | ||||
|     public void showMessageAndCancelDialog(@StringRes int resId) { | ||||
|         showMessage(resId, R.color.secondaryDarkColor); | ||||
|         progressDialog.cancel(); | ||||
|         if(progressDialog != null){ | ||||
|             progressDialog.cancel(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public void showSuccessAndDismissDialog() { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Abhishek Poonia
						Abhishek Poonia