Merge "To hide the soft input window when press skip button on Skip setup for PIN and face dialog of Set a PIN screen to avoid flash during transition." into sc-dev

This commit is contained in:
Prochin Wang
2021-06-24 09:24:02 +00:00
committed by Android (Google) Code Review
3 changed files with 24 additions and 2 deletions

View File

@@ -22,6 +22,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import androidx.annotation.Nullable;
@@ -112,7 +113,6 @@ public class SetupChooseLockPassword extends ChooseLockPassword {
.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE, false);
final boolean forBiometrics = intent
.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_BIOMETRICS, false);
final SetupSkipDialog dialog = SetupSkipDialog.newInstance(
frpSupported,
/* isPatternMode= */ false,
@@ -120,6 +120,11 @@ public class SetupChooseLockPassword extends ChooseLockPassword {
forFingerprint,
forFace,
forBiometrics);
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
dialog.show(getFragmentManager());
return;
}

View File

@@ -21,6 +21,8 @@ import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
@@ -190,12 +192,21 @@ public class SetupSkipDialog extends InstrumentedDialogFragment
@Override
public void onClick(DialogInterface dialog, int button) {
Activity activity = getActivity();
switch (button) {
case DialogInterface.BUTTON_POSITIVE:
Activity activity = getActivity();
activity.setResult(RESULT_SKIP);
activity.finish();
break;
case DialogInterface.BUTTON_NEGATIVE:
View view = activity.getCurrentFocus();
if(view != null) {
view.requestFocus();
InputMethodManager imm = (InputMethodManager) activity
.getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}
break;
}
}

View File

@@ -24,6 +24,7 @@ import static org.robolectric.RuntimeEnvironment.application;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import androidx.appcompat.app.AlertDialog;
@@ -55,6 +56,7 @@ import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.shadows.ShadowActivity;
import org.robolectric.shadows.ShadowDialog;
import org.robolectric.shadows.ShadowInputMethodManager;
import java.util.Collections;
import java.util.List;
@@ -149,6 +151,9 @@ public class SetupChooseLockPasswordTest {
@Test
public void createActivity_skipButtonInIntroductionStage_shouldBeVisible() {
SetupChooseLockPassword activity = createSetupChooseLockPassword();
final InputMethodManager inputMethodManager = activity
.getSystemService(InputMethodManager.class);
final ShadowInputMethodManager shadowImm = Shadows.shadowOf(inputMethodManager);
final PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
final Button skipOrClearButton =
@@ -159,6 +164,7 @@ public class SetupChooseLockPasswordTest {
skipOrClearButton.performClick();
final AlertDialog chooserDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(chooserDialog).isNotNull();
assertThat(shadowImm.isSoftInputVisible()).isFalse();
}
@Test