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

Commit c4f2e10d authored by Joe Bolinger's avatar Joe Bolinger Committed by Automerger Merge Worker
Browse files

Merge "Add visual feedback on UDFPS enrollment help." into sc-qpr1-dev am: 3ac7cfd3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15676724

Change-Id: I2af5a4e59812a7f8ab12ef0f889b4b6de54ec731
parents c346dab8 3ac7cfd3
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -189,7 +189,8 @@
    <!-- UDFPS colors -->
    <color name="udfps_enroll_icon">#000000</color>                         <!-- 100% black -->
    <color name="udfps_moving_target_fill">#cc4285f4</color>                <!-- 80% blue -->
    <color name="udfps_enroll_progress">#ff669DF6</color>                   <!-- 100% blue -->
    <color name="udfps_enroll_progress">#ff669DF6</color>                   <!-- blue 400 -->
    <color name="udfps_enroll_progress_help">#ffEE675C</color>              <!-- red 400 -->

    <!-- Logout button -->
    <color name="logout_button_bg_color">#ccffffff</color>
+4 −0
Original line number Diff line number Diff line
@@ -143,6 +143,10 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
        mProgressDrawable.onLastStepAcquired();
    }

    void onEnrollmentHelp() {
        mProgressDrawable.onEnrollmentHelp();
    }

    @Override
    public void draw(@NonNull Canvas canvas) {
        mProgressDrawable.draw(canvas);
+4 −1
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ public class UdfpsEnrollHelper {
    interface Listener {
        void onEnrollmentProgress(int remaining, int totalSteps);
        void onLastStepAcquired();
        void onEnrollmentHelp();
    }

    @NonNull private final Context mContext;
@@ -138,7 +139,9 @@ public class UdfpsEnrollHelper {
    }

    void onEnrollmentHelp() {

        if (mListener != null) {
            mListener.onEnrollmentHelp();
        }
    }

    void setListener(Listener listener) {
+57 −2
Original line number Diff line number Diff line
@@ -16,7 +16,9 @@

package com.android.systemui.biometrics;

import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator;
import android.annotation.ColorInt;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
@@ -46,6 +48,11 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
    @NonNull private final Paint mProgressPaint;

    @Nullable private ValueAnimator mProgressAnimator;
    @Nullable private ValueAnimator mProgressShowingHelpAnimator;
    @Nullable private ValueAnimator mProgressHidingHelpAnimator;
    @ColorInt private final int mProgressColor;
    @ColorInt private final int mProgressHelpColor;
    private final int mShortAnimationDuration;
    private float mProgress;
    private int mRotation; // After last step, rotate the progress bar once
    private boolean mLastStepAcquired;
@@ -55,6 +62,11 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
        mContext = context;
        mParent = parent;

        mShortAnimationDuration = context.getResources()
                .getInteger(com.android.internal.R.integer.config_shortAnimTime);
        mProgressColor = context.getColor(R.color.udfps_enroll_progress);
        mProgressHelpColor = context.getColor(R.color.udfps_enroll_progress_help);

        mBackgroundCirclePaint = new Paint();
        mBackgroundCirclePaint.setStrokeWidth(Utils.dpToPixels(context, PROGRESS_BAR_THICKNESS_DP));
        mBackgroundCirclePaint.setColor(context.getColor(R.color.white_disabled));
@@ -74,7 +86,7 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
        // Progress should not be color extracted
        mProgressPaint = new Paint();
        mProgressPaint.setStrokeWidth(Utils.dpToPixels(context, PROGRESS_BAR_THICKNESS_DP));
        mProgressPaint.setColor(context.getColor(R.color.udfps_enroll_progress));
        mProgressPaint.setColor(mProgressColor);
        mProgressPaint.setAntiAlias(true);
        mProgressPaint.setStyle(Paint.Style.STROKE);
        mProgressPaint.setStrokeCap(Paint.Cap.ROUND);
@@ -92,7 +104,9 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
            return;
        }

        long animationDuration = 150;
        long animationDuration = mShortAnimationDuration;

        hideEnrollmentHelp();

        if (progress == 1.f) {
            animationDuration = 400;
@@ -128,6 +142,47 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
        mLastStepAcquired = true;
    }

    void onEnrollmentHelp() {
        if (mProgressShowingHelpAnimator != null || mProgressAnimator == null) {
            return; // already showing or at 0% (no progress bar visible)
        }

        if (mProgressHidingHelpAnimator != null && mProgressHidingHelpAnimator.isRunning()) {
            mProgressHidingHelpAnimator.cancel();
        }
        mProgressHidingHelpAnimator = null;

        mProgressShowingHelpAnimator = getProgressColorAnimator(
                mProgressPaint.getColor(), mProgressHelpColor);
        mProgressShowingHelpAnimator.start();
    }

    private void hideEnrollmentHelp() {
        if (mProgressHidingHelpAnimator != null || mProgressShowingHelpAnimator == null) {
            return; // already hidden or help never shown
        }

        if (mProgressShowingHelpAnimator != null && mProgressShowingHelpAnimator.isRunning()) {
            mProgressShowingHelpAnimator.cancel();
        }
        mProgressShowingHelpAnimator = null;

        mProgressHidingHelpAnimator = getProgressColorAnimator(
                mProgressPaint.getColor(), mProgressColor);
        mProgressHidingHelpAnimator.start();
    }

    private ValueAnimator getProgressColorAnimator(@ColorInt int from, @ColorInt int to) {
        final ValueAnimator animator = ValueAnimator.ofObject(
                ArgbEvaluator.getInstance(), from, to);
        animator.setDuration(mShortAnimationDuration);
        animator.addUpdateListener(animation -> {
            mProgressPaint.setColor((int) animation.getAnimatedValue());
            mParent.invalidateSelf();
        });
        return animator;
    }

    @Override
    public void draw(@NonNull Canvas canvas) {
        canvas.save();
+4 −0
Original line number Diff line number Diff line
@@ -64,4 +64,8 @@ public class UdfpsEnrollView extends UdfpsAnimationView {
    void onLastStepAcquired() {
        mHandler.post(mFingerprintDrawable::onLastStepAcquired);
    }

    void onEnrollmentHelp() {
        mHandler.post(mFingerprintDrawable::onEnrollmentHelp);
    }
}
Loading