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

Commit e301d595 authored by Curtis Belmonte's avatar Curtis Belmonte
Browse files

Fix face/fingerprint consent primary footer button logic

Currently, the primary footer button on the face and fingerprint enroll
consent pages reads "I agree" even before the user has scrolled to the
bottom of the screen. This commit fixes the issue so that "More" is
displayed until the user scrolls to the bottom. The remaining logic is
left intact.

Test: Manual:
1. Start face or fingerprint enrollment
2. Confirm primary button shows "More" and secondary button is hidden
3. Press the "More" button or scroll to the bottom of the screen
4. Ensure primary button shows "I agree" and secondary shows "No thanks"

Fixes: 189268868
Change-Id: I02fa47d1de83bd5b5d82c733495ae579cbd2d6c6
parent ad84b3dd
Loading
Loading
Loading
Loading
+30 −36
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;

import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
@@ -36,11 +37,12 @@ import com.android.settings.SetupWizardUtils;
import com.android.settings.password.ChooseLockGeneric;
import com.android.settings.password.ChooseLockSettingsHelper;

import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.GlifLayout;
import com.google.android.setupdesign.span.LinkSpan;
import com.google.android.setupdesign.template.RequireScrollMixin;
import com.google.android.setupdesign.template.RequireScrollMixin.OnRequireScrollStateChangedListener;
import com.google.android.setupdesign.util.DynamicColorPalette;

/**
@@ -183,32 +185,26 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
            }
        }

        FooterButton primaryButton = getPrimaryFooterButton();
        FooterButton secondaryButton = getSecondaryFooterButton();
        if (primaryButton == null) {
            Log.d(TAG, "getPrimaryFooterButton() was null");
            return;
        }

        if (secondaryButton == null) {
            Log.d(TAG, "getSecondaryFooterButton() was null");
            return;
        }

        // Setup scroll mixin
        final RequireScrollMixin requireScrollMixin = getLayout().getMixin(
                RequireScrollMixin.class);
        requireScrollMixin.requireScrollWithButton(this, primaryButton, getScrollCompletedText(),
                this::onNextButtonClick);
        final GlifLayout layout = getLayout();
        mFooterBarMixin = layout.getMixin(FooterBarMixin.class);
        mFooterBarMixin.setPrimaryButton(getPrimaryFooterButton());
        mFooterBarMixin.setSecondaryButton(getSecondaryFooterButton(), true /* usePrimaryStyle */);
        mFooterBarMixin.getSecondaryButton().setVisibility(View.INVISIBLE);

        secondaryButton.setVisibility(View.INVISIBLE);
        final RequireScrollMixin requireScrollMixin = layout.getMixin(RequireScrollMixin.class);
        requireScrollMixin.requireScrollWithButton(this, getPrimaryFooterButton(),
                getMoreButtonTextRes(), this::onNextButtonClick);
        requireScrollMixin.setOnRequireScrollStateChangedListener(
                new OnRequireScrollStateChangedListener() {
                    @Override
                    public void onRequireScrollStateChanged(boolean scrollNeeded) {
                        if (!scrollNeeded && secondaryButton.getVisibility() == View.INVISIBLE) {
                            secondaryButton.setVisibility(View.VISIBLE);
                        }
                scrollNeeded -> {
                    // Update text of primary button from "More" to "Agree".
                    final int primaryButtonTextRes = scrollNeeded
                            ? getMoreButtonTextRes()
                            : getAgreeButtonTextRes();
                    getPrimaryFooterButton().setText(this, primaryButtonTextRes);

                    // Show secondary button once scroll is completed.
                    if (!scrollNeeded) {
                        getSecondaryFooterButton().setVisibility(View.VISIBLE);
                    }
                });
    }
@@ -367,17 +363,15 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
        return mIconColorFilter;
    }

    @Nullable
    protected FooterButton getPrimaryFooterButton() {
        return null;
    }
    @NonNull
    protected abstract FooterButton getPrimaryFooterButton();

    @Nullable
    protected FooterButton getSecondaryFooterButton() {
        return null;
    }
    @NonNull
    protected abstract FooterButton getSecondaryFooterButton();

    protected int getScrollCompletedText() {
        return R.string.security_settings_face_enroll_introduction_more;
    }
    @StringRes
    protected abstract int getAgreeButtonTextRes();

    @StringRes
    protected abstract int getMoreButtonTextRes();
}
+26 −17
Original line number Diff line number Diff line
@@ -26,6 +26,10 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;

import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.biometrics.BiometricEnrollIntroduction;
@@ -34,7 +38,6 @@ import com.android.settings.overlay.FeatureFactory;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settingslib.RestrictedLockUtilsInternal;

import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.span.LinkSpan;
@@ -50,6 +53,8 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {

    private FaceManager mFaceManager;
    private FaceFeatureProvider mFaceFeatureProvider;
    @Nullable private FooterButton mPrimaryFooterButton;
    @Nullable private FooterButton mSecondaryFooterButton;

    @Override
    protected void onCancelButtonClick(View view) {
@@ -207,38 +212,42 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
    }

    @Override
    @NonNull
    protected FooterButton getPrimaryFooterButton() {
        if (mFooterBarMixin == null) {
            mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
        }

        if (mFooterBarMixin.getPrimaryButton() == null) {
            final FooterButton nextButtonBuilder = new FooterButton.Builder(this)
        if (mPrimaryFooterButton == null) {
            mPrimaryFooterButton = new FooterButton.Builder(this)
                    .setText(R.string.security_settings_face_enroll_introduction_agree)
                    .setButtonType(FooterButton.ButtonType.OPT_IN)
                    .setListener(this::onNextButtonClick)
                    .setTheme(R.style.SudGlifButton_Primary)
                    .build();
            mFooterBarMixin.setPrimaryButton(nextButtonBuilder);
        }
        return mFooterBarMixin.getPrimaryButton();
        return mPrimaryFooterButton;
    }

    @Override
    @NonNull
    protected FooterButton getSecondaryFooterButton() {
        if (mFooterBarMixin == null) {
            mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
        }

        if (mFooterBarMixin.getSecondaryButton() == null) {
            final FooterButton noThanksButton = new FooterButton.Builder(this)
        if (mSecondaryFooterButton == null) {
            mSecondaryFooterButton = new FooterButton.Builder(this)
                    .setText(R.string.security_settings_face_enroll_introduction_no_thanks)
                    .setListener(this::onSkipButtonClick)
                    .setButtonType(FooterButton.ButtonType.NEXT)
                    .setTheme(R.style.SudGlifButton_Primary)
                    .build();
            mFooterBarMixin.setSecondaryButton(noThanksButton, true /* usePrimaryStyle */);
        }
        return mFooterBarMixin.getSecondaryButton();
        return mSecondaryFooterButton;
    }

    @Override
    @StringRes
    protected int getAgreeButtonTextRes() {
        return R.string.security_settings_fingerprint_enroll_introduction_agree;
    }

    @Override
    @StringRes
    protected int getMoreButtonTextRes() {
        return R.string.security_settings_face_enroll_introduction_more;
    }
}
+22 −18
Original line number Diff line number Diff line
@@ -27,6 +27,10 @@ import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;

import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.biometrics.BiometricEnrollIntroduction;
@@ -35,7 +39,6 @@ import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settingslib.HelpUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;

import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupdesign.span.LinkSpan;

@@ -46,6 +49,8 @@ public class FingerprintEnrollIntroduction extends BiometricEnrollIntroduction {
    private static final String TAG = "FingerprintIntro";

    private FingerprintManager mFingerprintManager;
    @Nullable private FooterButton mPrimaryFooterButton;
    @Nullable private FooterButton mSecondaryFooterButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
@@ -194,43 +199,42 @@ public class FingerprintEnrollIntroduction extends BiometricEnrollIntroduction {
    }

    @Override
    @NonNull
    protected FooterButton getPrimaryFooterButton() {
        if (mFooterBarMixin == null) {
            mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
        }

        if (mFooterBarMixin.getPrimaryButton() == null) {
            final FooterButton nextButtonBuilder = new FooterButton.Builder(this)
        if (mPrimaryFooterButton == null) {
            mPrimaryFooterButton = new FooterButton.Builder(this)
                    .setText(R.string.security_settings_fingerprint_enroll_introduction_agree)
                    .setListener(this::onNextButtonClick)
                    .setButtonType(FooterButton.ButtonType.OPT_IN)
                    .setTheme(R.style.SudGlifButton_Primary)
                    .build();
            mFooterBarMixin.setPrimaryButton(nextButtonBuilder);
        }
        return mFooterBarMixin.getPrimaryButton();
        return mPrimaryFooterButton;
    }

    @Override
    @NonNull
    protected FooterButton getSecondaryFooterButton() {
        if (mFooterBarMixin == null) {
            mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
        }

        if (mFooterBarMixin.getSecondaryButton() == null) {
            final FooterButton noThanksButton = new FooterButton.Builder(this)
        if (mSecondaryFooterButton == null) {
            mSecondaryFooterButton = new FooterButton.Builder(this)
                    .setText(getNegativeButtonTextId())
                    .setListener(this::onSkipButtonClick)
                    .setButtonType(FooterButton.ButtonType.NEXT)
                    .setTheme(R.style.SudGlifButton_Primary)
                    .build();
            mFooterBarMixin.setSecondaryButton(noThanksButton, true /* usePrimaryStyle */);
        }
        return mFooterBarMixin.getSecondaryButton();
        return mSecondaryFooterButton;
    }

    @Override
    @StringRes
    protected int getAgreeButtonTextRes() {
        return R.string.security_settings_fingerprint_enroll_introduction_agree;
    }

    @Override
    protected int getScrollCompletedText() {
    @StringRes
    protected int getMoreButtonTextRes() {
        return R.string.security_settings_face_enroll_introduction_more;
    }
}