Login Bugs removed

This commit is contained in:
Caesar2011
2018-12-19 15:46:12 +01:00
parent 4d22613672
commit 8160ef12b1
4 changed files with 13 additions and 7 deletions

View File

@@ -158,14 +158,15 @@ public class MainActivity extends AppCompatActivity
super.onResume(); super.onResume();
log.d("onResume", isPaused, isLoggedInBeforePause); log.d("onResume", isPaused, isLoggedInBeforePause);
if (isPaused) { if (isPaused) {
getKVV().account().reset();
getKVV().account().restoreOnlineLogin(isRestored -> { getKVV().account().restoreOnlineLogin(isRestored -> {
log.d("onResume", isRestored); log.d("onResume", isRestored);
updateNavigation(); updateNavigation();
if (isRestored && !isLoggedInBeforePause) if (isRestored && !isLoggedInBeforePause)
changeFragment(getDefaultFragmentAfterLogin()); changeFragment(getDefaultFragmentAfterLogin());
else if (!isRestored && isLoggedInBeforePause) else if (!isRestored && isLoggedInBeforePause) {
changeFragment(getDefaultFragmentAfterLogin()); getKVV().account().logout(false);
changeFragment(getDefaultFragmentAfterLogout());
}
}); });
} }
isPaused = false; isPaused = false;

View File

@@ -28,6 +28,7 @@ public class Login extends HTTPService {
this.mListener = listener; this.mListener = listener;
} }
@Deprecated
public void reset() { public void reset() {
mToken = null; mToken = null;
mLoginPending = false; mLoginPending = false;
@@ -47,7 +48,7 @@ public class Login extends HTTPService {
//} //}
public void restoreOnlineLogin(BooleanInterface callback) { public void restoreOnlineLogin(BooleanInterface callback) {
if (mLoginPending || mToken != null) { if (mLoginPending) {
callback.run(false); callback.run(false);
return; return;
} }
@@ -131,7 +132,6 @@ public class Login extends HTTPService {
return; return;
CustomAccountManager manager = mListener.getAccountManager(); CustomAccountManager manager = mListener.getAccountManager();
manager.doInvalidateToken(AccountGeneral.ACCOUNT_TYPE, AccountGeneral.AUTHTOKEN_TYPE_KVV, ignored -> { manager.doInvalidateToken(AccountGeneral.ACCOUNT_TYPE, AccountGeneral.AUTHTOKEN_TYPE_KVV, ignored -> {
reset();
log.d("try restore", ignored); log.d("try restore", ignored);
restoreOnlineLogin(isRestored -> { restoreOnlineLogin(isRestored -> {
log.d("restore", isRestored, mToken); log.d("restore", isRestored, mToken);

View File

@@ -7,6 +7,7 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.LoaderManager.LoaderCallbacks; import android.app.LoaderManager.LoaderCallbacks;
import android.content.Context;
import android.content.CursorLoader; import android.content.CursorLoader;
import android.content.Intent; import android.content.Intent;
import android.content.Loader; import android.content.Loader;
@@ -19,6 +20,7 @@ import android.provider.ContactsContract;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
@@ -137,6 +139,9 @@ public class FUAuthenticatorActivity extends AccountAuthenticatorActivity implem
* errors are presented and no actual login attempt is made. * errors are presented and no actual login attempt is made.
*/ */
private void attemptLogin() { private void attemptLogin() {
InputMethodManager inputManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputManager != null && getCurrentFocus() != null)
inputManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
if (mAuthTask != null) { if (mAuthTask != null) {
return; return;
} }

View File

@@ -77,8 +77,8 @@ public class CustomAccountManager {
} }
public void getTokenByType(String accountType, String authTokenType, @Nullable StringInterface callback) { public void getTokenByType(String accountType, String authTokenType, @Nullable StringInterface callback) {
Account account = mAccountManager.getAccountsByType(accountType)[0]; //Account account = mAccountManager.getAccountsByType(accountType)[0];
mAccountManager.getAuthToken(account, authTokenType, null, true, accountManagerFuture -> { mAccountManager.getAuthTokenByFeatures(accountType, authTokenType, null, mActivityInterface.get(), null, null, accountManagerFuture -> {
try { try {
Bundle bnd = accountManagerFuture.getResult(); Bundle bnd = accountManagerFuture.getResult();
final String authtoken = bnd.getString(AccountManager.KEY_AUTHTOKEN); final String authtoken = bnd.getString(AccountManager.KEY_AUTHTOKEN);