mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	Fix loading issue after upgrade from older version (#1454)
This commit is contained in:
		
							parent
							
								
									3b129a6ea4
								
							
						
					
					
						commit
						8b118b309c
					
				
					 2 changed files with 14 additions and 7 deletions
				
			
		|  | @ -19,7 +19,6 @@ import android.support.v4.content.ContextCompat; | |||
| import android.support.v7.app.AppCompatDelegate; | ||||
| import android.text.Editable; | ||||
| import android.text.TextWatcher; | ||||
| import android.util.Log; | ||||
| import android.view.MenuInflater; | ||||
| import android.view.MenuItem; | ||||
| import android.view.View; | ||||
|  | @ -28,7 +27,6 @@ import android.view.inputmethod.InputMethodManager; | |||
| import android.widget.Button; | ||||
| import android.widget.EditText; | ||||
| import android.widget.TextView; | ||||
| import android.widget.Toast; | ||||
| 
 | ||||
| import java.io.IOException; | ||||
| 
 | ||||
|  | @ -160,7 +158,10 @@ public class LoginActivity extends AccountAuthenticatorActivity { | |||
|             WelcomeActivity.startYourself(this); | ||||
|             prefs.edit().putBoolean("firstrun", false).apply(); | ||||
|         } | ||||
|         if (sessionManager.getCurrentAccount() != null) { | ||||
| 
 | ||||
|         if (sessionManager.getCurrentAccount() != null | ||||
|                 && sessionManager.isUserLoggedIn() | ||||
|                 && sessionManager.getCachedAuthCookie() != null) { | ||||
|             startMainActivity(); | ||||
|         } | ||||
|     } | ||||
|  |  | |||
|  | @ -61,13 +61,11 @@ public class SessionManager { | |||
|     } | ||||
| 
 | ||||
|     public String getAuthCookie() { | ||||
|         boolean isLoggedIn = sharedPreferences.getBoolean("isUserLoggedIn", false); | ||||
| 
 | ||||
|         if (!isLoggedIn) { | ||||
|         if (!isUserLoggedIn()) { | ||||
|             Timber.e("User is not logged in"); | ||||
|             return null; | ||||
|         } else { | ||||
|             String authCookie = sharedPreferences.getString("getAuthCookie", null); | ||||
|             String authCookie = getCachedAuthCookie(); | ||||
|             if (authCookie == null) { | ||||
|                 Timber.e("Auth cookie is null even after login"); | ||||
|             } | ||||
|  | @ -75,6 +73,14 @@ public class SessionManager { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public String getCachedAuthCookie() { | ||||
|         return sharedPreferences.getString("getAuthCookie", null); | ||||
|     } | ||||
| 
 | ||||
|     public boolean isUserLoggedIn() { | ||||
|         return sharedPreferences.getBoolean("isUserLoggedIn", false); | ||||
|     } | ||||
| 
 | ||||
|     public Completable clearAllAccounts() { | ||||
|         AccountManager accountManager = AccountManager.get(context); | ||||
|         Account[] allAccounts = accountManager.getAccountsByType(ACCOUNT_TYPE); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vivek Maskara
						Vivek Maskara