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

Commit dab94ba4 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:...

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

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

Change-Id: Ic123bafc520a441c4e36679845fc68887e362e2c
parents 1b0b6325 8e67ea45
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -189,7 +189,8 @@
    <!-- UDFPS colors -->
    <!-- UDFPS colors -->
    <color name="udfps_enroll_icon">#000000</color>                         <!-- 100% black -->
    <color name="udfps_enroll_icon">#000000</color>                         <!-- 100% black -->
    <color name="udfps_moving_target_fill">#cc4285f4</color>                <!-- 80% blue -->
    <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 -->
    <!-- Logout button -->
    <color name="logout_button_bg_color">#ccffffff</color>
    <color name="logout_button_bg_color">#ccffffff</color>
+4 −0
Original line number Original line Diff line number Diff line
@@ -143,6 +143,10 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
        mProgressDrawable.onLastStepAcquired();
        mProgressDrawable.onLastStepAcquired();
    }
    }


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

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


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


    void onEnrollmentHelp() {
    void onEnrollmentHelp() {

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


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


package com.android.systemui.biometrics;
package com.android.systemui.biometrics;


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


    @Nullable private ValueAnimator mProgressAnimator;
    @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 float mProgress;
    private int mRotation; // After last step, rotate the progress bar once
    private int mRotation; // After last step, rotate the progress bar once
    private boolean mLastStepAcquired;
    private boolean mLastStepAcquired;
@@ -55,6 +62,11 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
        mContext = context;
        mContext = context;
        mParent = parent;
        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 = new Paint();
        mBackgroundCirclePaint.setStrokeWidth(Utils.dpToPixels(context, PROGRESS_BAR_THICKNESS_DP));
        mBackgroundCirclePaint.setStrokeWidth(Utils.dpToPixels(context, PROGRESS_BAR_THICKNESS_DP));
        mBackgroundCirclePaint.setColor(context.getColor(R.color.white_disabled));
        mBackgroundCirclePaint.setColor(context.getColor(R.color.white_disabled));
@@ -74,7 +86,7 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
        // Progress should not be color extracted
        // Progress should not be color extracted
        mProgressPaint = new Paint();
        mProgressPaint = new Paint();
        mProgressPaint.setStrokeWidth(Utils.dpToPixels(context, PROGRESS_BAR_THICKNESS_DP));
        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.setAntiAlias(true);
        mProgressPaint.setStyle(Paint.Style.STROKE);
        mProgressPaint.setStyle(Paint.Style.STROKE);
        mProgressPaint.setStrokeCap(Paint.Cap.ROUND);
        mProgressPaint.setStrokeCap(Paint.Cap.ROUND);
@@ -92,7 +104,9 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
            return;
            return;
        }
        }


        long animationDuration = 150;
        long animationDuration = mShortAnimationDuration;

        hideEnrollmentHelp();


        if (progress == 1.f) {
        if (progress == 1.f) {
            animationDuration = 400;
            animationDuration = 400;
@@ -128,6 +142,47 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
        mLastStepAcquired = true;
        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
    @Override
    public void draw(@NonNull Canvas canvas) {
    public void draw(@NonNull Canvas canvas) {
        canvas.save();
        canvas.save();
+4 −0
Original line number Original line Diff line number Diff line
@@ -64,4 +64,8 @@ public class UdfpsEnrollView extends UdfpsAnimationView {
    void onLastStepAcquired() {
    void onLastStepAcquired() {
        mHandler.post(mFingerprintDrawable::onLastStepAcquired);
        mHandler.post(mFingerprintDrawable::onLastStepAcquired);
    }
    }

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