Search in sources :

Example 1 with RequireScrollMixin

use of com.google.android.setupdesign.template.RequireScrollMixin in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class FaceEnrollIntroduction method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mFaceManager = Utils.getFaceManagerOrNull(this);
    mFaceFeatureProvider = FeatureFactory.getFactory(getApplicationContext()).getFaceFeatureProvider();
    mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
    if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
        mFooterBarMixin.setSecondaryButton(new FooterButton.Builder(this).setText(R.string.security_settings_face_enroll_introduction_no_thanks).setListener(this::onSkipButtonClick).setButtonType(FooterButton.ButtonType.SKIP).setTheme(R.style.SudGlifButton_Secondary).build());
    } else {
        mFooterBarMixin.setSecondaryButton(new FooterButton.Builder(this).setText(R.string.security_settings_face_enroll_introduction_no_thanks).setListener(this::onCancelButtonClick).setButtonType(FooterButton.ButtonType.CANCEL).setTheme(R.style.SudGlifButton_Secondary).build());
    }
    FooterButton.Builder nextButtonBuilder = new FooterButton.Builder(this).setText(R.string.security_settings_face_enroll_introduction_agree).setButtonType(FooterButton.ButtonType.NEXT).setTheme(R.style.SudGlifButton_Primary);
    if (maxFacesEnrolled()) {
        nextButtonBuilder.setListener(this::onNextButtonClick);
        mFooterBarMixin.setPrimaryButton(nextButtonBuilder.build());
    } else {
        final FooterButton agreeButton = nextButtonBuilder.build();
        mFooterBarMixin.setPrimaryButton(agreeButton);
        final RequireScrollMixin requireScrollMixin = getLayout().getMixin(RequireScrollMixin.class);
        requireScrollMixin.requireScrollWithButton(this, agreeButton, R.string.security_settings_face_enroll_introduction_more, button -> {
            onNextButtonClick(button);
        });
    }
    final TextView footer2 = findViewById(R.id.face_enroll_introduction_footer_part_2);
    final int footer2TextResource = mFaceFeatureProvider.isAttentionSupported(getApplicationContext()) ? R.string.security_settings_face_enroll_introduction_footer_part_2 : R.string.security_settings_face_settings_footer_attention_not_supported;
    footer2.setText(footer2TextResource);
    if (FaceUnlockUtils.hasMotoFaceUnlock() && mHasPassword && mToken != null) {
        openMotoFaceUnlock();
    }
}
Also used : FooterButton(com.google.android.setupcompat.template.FooterButton) FooterBarMixin(com.google.android.setupcompat.template.FooterBarMixin) TextView(android.widget.TextView) RequireScrollMixin(com.google.android.setupdesign.template.RequireScrollMixin)

Example 2 with RequireScrollMixin

use of com.google.android.setupdesign.template.RequireScrollMixin in project android_packages_apps_Settings by omnirom.

the class BiometricEnrollIntroduction method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mConfirmingCredentials = savedInstanceState.getBoolean(KEY_CONFIRMING_CREDENTIALS);
    }
    Intent intent = getIntent();
    if (intent.getStringExtra(WizardManagerHelper.EXTRA_THEME) == null) {
        // Put the theme in the intent so it gets propagated to other activities in the flow
        intent.putExtra(WizardManagerHelper.EXTRA_THEME, SetupWizardUtils.getThemeString(intent));
    }
    mBiometricUnlockDisabledByAdmin = isDisabledByAdmin();
    setContentView(getLayoutResource());
    mParentalConsentRequired = ParentalControlsUtils.parentConsentRequired(this, getModality()) != null;
    if (mBiometricUnlockDisabledByAdmin && !mParentalConsentRequired) {
        setHeaderText(getHeaderResDisabledByAdmin());
    } else {
        setHeaderText(getHeaderResDefault());
    }
    mErrorText = getErrorTextView();
    mUserManager = UserManager.get(this);
    updatePasswordQuality();
    if (!mConfirmingCredentials) {
        if (!mHasPassword) {
            // No password registered, launch into enrollment wizard.
            mConfirmingCredentials = true;
            launchChooseLock();
        } else if (!BiometricUtils.containsGatekeeperPasswordHandle(getIntent()) && mToken == null) {
            // It's possible to have a token but mLaunchedConfirmLock == false, since
            // ChooseLockGeneric can pass us a token.
            mConfirmingCredentials = true;
            launchConfirmLock(getConfirmLockTitleResId());
        }
    }
    final GlifLayout layout = getLayout();
    mFooterBarMixin = layout.getMixin(FooterBarMixin.class);
    mFooterBarMixin.setPrimaryButton(getPrimaryFooterButton());
    mFooterBarMixin.setSecondaryButton(getSecondaryFooterButton(), true);
    mFooterBarMixin.getSecondaryButton().setVisibility(View.INVISIBLE);
    final RequireScrollMixin requireScrollMixin = layout.getMixin(RequireScrollMixin.class);
    requireScrollMixin.requireScrollWithButton(this, getPrimaryFooterButton(), getMoreButtonTextRes(), this::onNextButtonClick);
    requireScrollMixin.setOnRequireScrollStateChangedListener(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);
        }
    });
}
Also used : GlifLayout(com.google.android.setupdesign.GlifLayout) FooterBarMixin(com.google.android.setupcompat.template.FooterBarMixin) Intent(android.content.Intent) RequireScrollMixin(com.google.android.setupdesign.template.RequireScrollMixin)

Aggregations

FooterBarMixin (com.google.android.setupcompat.template.FooterBarMixin)2 RequireScrollMixin (com.google.android.setupdesign.template.RequireScrollMixin)2 Intent (android.content.Intent)1 TextView (android.widget.TextView)1 FooterButton (com.google.android.setupcompat.template.FooterButton)1 GlifLayout (com.google.android.setupdesign.GlifLayout)1