Merge "Request hiding IME before starting next activity transition"

This commit is contained in:
TreeHugger Robot
2022-10-31 20:30:58 +00:00
committed by Android (Google) Code Review
4 changed files with 25 additions and 4 deletions

View File

@@ -954,6 +954,9 @@ public class ChooseLockPassword extends SettingsActivity {
return; return;
} }
ConfirmDeviceCredentialUtils.hideImeImmediately(
getActivity().getWindow().getDecorView());
mPasswordEntryInputDisabler.setInputEnabled(false); mPasswordEntryInputDisabler.setInputEnabled(false);
setNextEnabled(false); setNextEnabled(false);

View File

@@ -25,6 +25,11 @@ import android.content.Intent;
import android.content.IntentSender; import android.content.IntentSender;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.UserManager; import android.os.UserManager;
import android.view.View;
import android.view.WindowInsets;
import android.view.WindowInsetsController;
import androidx.annotation.NonNull;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
@@ -67,4 +72,16 @@ public class ConfirmDeviceCredentialUtils {
utils.userPresent(userId); utils.userPresent(userId);
} }
} }
/**
* Request hiding soft-keyboard before animating away credential UI, in case IME
* insets animation get delayed by dismissing animation.
* @param view used to get root {@link WindowInsets} and {@link WindowInsetsController}.
*/
public static void hideImeImmediately(@NonNull View view) {
if (view.isAttachedToWindow()
&& view.getRootWindowInsets().isVisible(WindowInsets.Type.ime())) {
view.getWindowInsetsController().hide(WindowInsets.Type.ime());
}
}
} }

View File

@@ -493,6 +493,9 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
} }
private void startDisappearAnimation(final Intent intent) { private void startDisappearAnimation(final Intent intent) {
ConfirmDeviceCredentialUtils.hideImeImmediately(
getActivity().getWindow().getDecorView());
if (mDisappearing) { if (mDisappearing) {
return; return;
} }

View File

@@ -22,7 +22,6 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button; import android.widget.Button;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@@ -121,9 +120,8 @@ public class SetupChooseLockPassword extends ChooseLockPassword {
forFace, forFace,
forBiometrics); forBiometrics);
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService( ConfirmDeviceCredentialUtils.hideImeImmediately(
Context.INPUT_METHOD_SERVICE); getActivity().getWindow().getDecorView());
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
dialog.show(getFragmentManager()); dialog.show(getFragmentManager());
return; return;