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

Commit ba8bc8e9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix UDFPS enrollment shadow" into sc-dev

parents 421ce84d a5f7aadf
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -52,4 +52,18 @@ public abstract class UdfpsAnimation extends Drawable {
    public void setAlpha(int alpha) {
        mFingerprintDrawable.setAlpha(alpha);
    }

    /**
     * @return The amount of padding that's needed on each side of the sensor, in pixels.
     */
    public int getPaddingX() {
        return 0;
    }

    /**
     * @return The amount of padding that's needed on each side of the sensor, in pixels.
     */
    public int getPaddingY() {
        return 0;
    }
}
+15 −0
Original line number Diff line number Diff line
@@ -70,6 +70,9 @@ public class UdfpsAnimationEnroll extends UdfpsAnimation {

    @Override
    public void draw(@NonNull Canvas canvas) {
        canvas.save();
        canvas.translate(getPaddingX(), getPaddingY());

        final boolean isNightMode = (mContext.getResources().getConfiguration().uiMode
                & Configuration.UI_MODE_NIGHT_YES) != 0;
        if (!isNightMode) {
@@ -78,6 +81,18 @@ public class UdfpsAnimationEnroll extends UdfpsAnimation {
            }
        }
        mFingerprintDrawable.draw(canvas);

        canvas.restore();
    }

    @Override
    public int getPaddingX() {
        return (int) Math.ceil(SHADOW_RADIUS);
    }

    @Override
    public int getPaddingY() {
        return (int) Math.ceil(SHADOW_RADIUS);
    }

    @Override
+11 −7
Original line number Diff line number Diff line
@@ -242,12 +242,15 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
        }
    }

    private WindowManager.LayoutParams computeLayoutParams() {
    private WindowManager.LayoutParams computeLayoutParams(@Nullable UdfpsAnimation animation) {
        final int paddingX = animation != null ? animation.getPaddingX() : 0;
        final int paddingY = animation != null ? animation.getPaddingY() : 0;

        // Default dimensions assume portrait mode.
        mCoreLayoutParams.x = mSensorProps.sensorLocationX - mSensorProps.sensorRadius;
        mCoreLayoutParams.y = mSensorProps.sensorLocationY - mSensorProps.sensorRadius;
        mCoreLayoutParams.height = 2 * mSensorProps.sensorRadius;
        mCoreLayoutParams.width = 2 * mSensorProps.sensorRadius;
        mCoreLayoutParams.x = mSensorProps.sensorLocationX - mSensorProps.sensorRadius - paddingX;
        mCoreLayoutParams.y = mSensorProps.sensorLocationY - mSensorProps.sensorRadius - paddingY;
        mCoreLayoutParams.height = 2 * mSensorProps.sensorRadius + 2 * paddingX;
        mCoreLayoutParams.width = 2 * mSensorProps.sensorRadius + 2 * paddingY;

        Point p = new Point();
        // Gets the size based on the current rotation of the display.
@@ -289,8 +292,9 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
            if (!mIsOverlayShowing) {
                try {
                    Log.v(TAG, "showUdfpsOverlay | adding window");
                    mView.setUdfpsAnimation(getUdfpsAnimationForReason(reason));
                    mWindowManager.addView(mView, computeLayoutParams());
                    final UdfpsAnimation animation = getUdfpsAnimationForReason(reason);
                    mView.setUdfpsAnimation(animation);
                    mWindowManager.addView(mView, computeLayoutParams(animation));
                    mView.setOnTouchListener(mOnTouchListener);
                    mIsOverlayShowing = true;
                } catch (RuntimeException e) {
+0 −1
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ public class UdfpsView extends FrameLayout implements DozeReceiver, UdfpsIllumin
    @NonNull private final RectF mSensorRect;
    @NonNull private final Paint mDebugTextPaint;


    // Used to obtain the sensor location.
    @NonNull private FingerprintSensorPropertiesInternal mSensorProps;