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

Commit dd4c8d2d authored by Jason Chang's avatar Jason Chang
Browse files

(1/n) Fix Wrong button color in lockscreen dialog.

Use SUW API ThemeHelper.shouldApplyGlifExpressiveStyle() to update
AlertDialog style.

Flag: EXEMPT use SUW Expressive style API to check

Bug: 390544548

Test: atest SetupSkipDialogTest
Test: build and manually check the UI and its behaviors
Change-Id: I953270f4dc38796c3b64cba8cc3e84c3f4dcc2f2
parent 11b78c6f
Loading
Loading
Loading
Loading
+49 −18
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.settings.Utils;
import com.android.settings.biometrics.BiometricUtils;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;

import com.google.android.material.dialog.MaterialAlertDialogBuilder;
public class SetupSkipDialog extends InstrumentedDialogFragment
        implements DialogInterface.OnClickListener {

@@ -77,14 +78,23 @@ public class SetupSkipDialog extends InstrumentedDialogFragment

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        return onCreateDialogBuilder().create();
        if (BiometricUtils.isExpressiveStyle(getContext(), false)) {
            final MaterialAlertDialogBuilder meterialBuilder =
                    (MaterialAlertDialogBuilder) onCreateDialogBuilder();
            return meterialBuilder.create();
        } else {
            final AlertDialog.Builder alertDialogBuilder =
                    (AlertDialog.Builder) onCreateDialogBuilder();
            return alertDialogBuilder.create();
        }
    }

    private AlertDialog.Builder getBiometricsBuilder(
    @SuppressWarnings("TypeParameterUnusedInFormals")
    private <T>  T getBiometricsBuilder(
            @LockPatternUtils.CredentialType int credentialType, boolean isSuw, boolean hasFace,
            boolean hasFingerprint) {
        final boolean isFaceSupported = hasFace && (!isSuw || BiometricUtils.isFaceSupportedInSuw(
                getContext()));
        final boolean isFaceSupported = hasFace && (!isSuw
                || BiometricUtils.isFaceSupportedInSuw(getContext()));
        final int msgResId;
        final int screenLockResId;
        switch (credentialType) {
@@ -102,16 +112,27 @@ public class SetupSkipDialog extends InstrumentedDialogFragment
                msgResId = getPinSkipMessageRes(hasFace && isFaceSupported, hasFingerprint);
                break;
        }
        return new AlertDialog.Builder(getContext())

        if (BiometricUtils.isExpressiveStyle(getContext(), false)) {
            return (T) new MaterialAlertDialogBuilder(getContext())
                    .setPositiveButton(R.string.skip_lock_screen_dialog_button_label, this)
                    .setNegativeButton(R.string.cancel_lock_screen_dialog_button_label, this)
                    .setTitle(getSkipSetupTitle(screenLockResId, hasFingerprint,
                            hasFace && isFaceSupported))
                    .setMessage(msgResId);
        }  else {
            return (T) new AlertDialog.Builder(getContext())
                    .setPositiveButton(R.string.skip_lock_screen_dialog_button_label, this)
                    .setNegativeButton(R.string.cancel_lock_screen_dialog_button_label, this)
                    .setTitle(getSkipSetupTitle(screenLockResId, hasFingerprint,
                            hasFace && isFaceSupported))
                    .setMessage(msgResId);
        }
    }

    @NonNull
    public AlertDialog.Builder onCreateDialogBuilder() {
    @SuppressWarnings("TypeParameterUnusedInFormals")
    public <T>  T onCreateDialogBuilder() {
        Bundle args = getArguments();
        final boolean isSuw = args.getBoolean(EXTRA_KEY_IS_SUW);
        final boolean forBiometrics = args.getBoolean(EXTRA_KEY_FOR_BIOMETRICS);
@@ -126,13 +147,23 @@ public class SetupSkipDialog extends InstrumentedDialogFragment
            return getBiometricsBuilder(credentialType, isSuw, hasFace, hasFingerprint);
        }

        return new AlertDialog.Builder(getContext())
        final int msg = args.getBoolean(ARG_FRP_SUPPORTED)
                ? R.string.lock_screen_intro_skip_dialog_text_frp
                : R.string.lock_screen_intro_skip_dialog_text;
        if (BiometricUtils.isExpressiveStyle(getContext(), false)) {
            return (T) new MaterialAlertDialogBuilder(getContext())
                    .setPositiveButton(R.string.skip_anyway_button_label, this)
                    .setNegativeButton(R.string.go_back_button_label, this)
                    .setTitle(R.string.lock_screen_intro_skip_title)
                    .setMessage(msg);

        } else  {
            return (T) new AlertDialog.Builder(getContext())
                    .setPositiveButton(R.string.skip_anyway_button_label, this)
                    .setNegativeButton(R.string.go_back_button_label, this)
                    .setTitle(R.string.lock_screen_intro_skip_title)
                .setMessage(args.getBoolean(ARG_FRP_SUPPORTED) ?
                        R.string.lock_screen_intro_skip_dialog_text_frp :
                        R.string.lock_screen_intro_skip_dialog_text);
                    .setMessage(msg);
        }
    }

    @StringRes