Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6b24857 authored by prochinwang's avatar prochinwang Committed by Prochin Wang
Browse files

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.

bug:191181054
Test: SUW
Test: make -j RunSettingsRoboTests

Change-Id: I229b190de5e6dc714bbb8408e91c363e90b18f30
parent 416a24d8
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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;
            }
+12 −1
Original line number Diff line number Diff line
@@ -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;
        }
    }

+6 −0
Original line number Diff line number Diff line
@@ -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