#635 - Reset password input field and refocus if coming back from cancelling authentication

This commit is contained in:
Joshua Soberg 2021-02-04 20:26:20 -05:00
parent 75bc10e1aa
commit d814dab8a8

View file

@ -23,6 +23,7 @@
package org.shadowice.flocke.andotp.Activities; package org.shadowice.flocke.andotp.Activities;
import android.app.Fragment; import android.app.Fragment;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -44,6 +45,7 @@ import android.view.View;
import android.view.ViewStub; import android.view.ViewStub;
import android.view.WindowManager.LayoutParams; import android.view.WindowManager.LayoutParams;
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;
import android.widget.ProgressBar; import android.widget.ProgressBar;
@ -193,12 +195,23 @@ public class AuthenticateActivity extends BaseActivity
private void checkBackgroundTask() { private void checkBackgroundTask() {
TaskFragment taskFragment = findTaskFragment(); TaskFragment taskFragment = findTaskFragment();
if (taskFragment != null && !taskFragment.task.isCanceled()) { if (taskFragment != null) {
taskFragment.task.setCallback(this::handleResult); if (taskFragment.task.isCanceled()) {
setupUiForTaskState(true); resetPasswordInput();
} else {
taskFragment.task.setCallback(this::handleResult);
setupUiForTaskState(true);
}
} }
} }
private void resetPasswordInput() {
passwordInput.setText("");
passwordInput.requestFocus();
InputMethodManager keyboard = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
keyboard.showSoftInput(passwordInput, 0);
}
@Nullable @Nullable
private TaskFragment findTaskFragment() { private TaskFragment findTaskFragment() {
return (TaskFragment) getFragmentManager().findFragmentByTag(TAG_TASK_FRAGMENT); return (TaskFragment) getFragmentManager().findFragmentByTag(TAG_TASK_FRAGMENT);