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

Commit 2e344a1e authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "Replace UDFPS circle with FP icon"

parents ba2a484b a6acf80e
Loading
Loading
Loading
Loading
+59 −0
Original line number Diff line number Diff line
<!--
    Copyright (C) 2020 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="32dp"
        android:height="32dp"
        android:tint="?attr/wallpaperTextColor"
        android:alpha=".75"
        android:viewportHeight="32.0"
        android:viewportWidth="32.0">
    <path
        android:fillColor="#ffffff"
        android:pathData="M23.7,5.9c-0.1,0.0 -0.2,0.0 -0.3,-0.1C21.0,4.5 18.6,3.9 16.0,3.9c-2.5,0.0
         -4.6,0.6 -6.9,1.9C8.8,6.0 8.3,5.9 8.1,5.5C7.9,5.2 8.0,4.7 8.4,4.5c2.5,-1.4 4.9,-2.1 7.7,
         -2.1c2.8,0.0 5.4,0.7 8.0,2.1c0.4,0.2 0.5,0.6 0.3,1.0C24.2,5.7 24.0,5.9 23.7,5.9z" />
    <path
        android:fillColor="#ffffff"
        android:pathData="M5.3,13.2c-0.1,0.0 -0.3,0.0 -0.4,-0.1c-0.3,-0.2 -0.4,-0.7 -0.2,-1.0c1.3,
        -1.9 2.9,-3.4 4.9,-4.5c4.1,-2.2 9.3,-2.2 13.4,0.0c1.9,1.1 3.6,2.5 4.9,4.4c0.2,0.3 0.1,0.8
        -0.2,1.0c-0.3,0.2 -0.8,0.1 -1.0,-0.2c-1.2,-1.7 -2.6,-3.0 -4.3,-4.0c-3.7,-2.0 -8.3,-2.0
         -12.0,0.0c-1.7,0.9 -3.2,2.3 -4.3,4.0C5.7,13.1 5.5,13.2 5.3,13.2z" />
    <path
        android:fillColor="#ffffff"
        android:pathData="M13.3,29.6c-0.2,0.0 -0.4,-0.1 -0.5,-0.2c-1.1,-1.2 -1.7,-2.0 -2.6,
        -3.6c-0.9,-1.7 -1.4,-3.7 -1.4,-5.9c0.0,-4.1 3.3,-7.4 7.4,-7.4c4.1,0.0 7.4,3.3 7.4,7.4c0.0,
        0.4 -0.3,0.7 -0.7,0.7s-0.7,-0.3 -0.7,-0.7c0.0,-3.3 -2.7,-5.9 -5.9,-5.9c-3.3,0.0 -5.9,
        2.7 -5.9,5.9c0.0,2.0 0.4,3.8 1.2,5.2c0.8,1.6 1.4,2.2 2.4,3.3c0.3,0.3 0.3,0.8 0.0,1.0
        C13.7,29.5 13.5,29.6 13.3,29.6z" />
    <path
        android:fillColor="#ffffff"
        android:pathData="M22.6,27.1c-1.6,0.0 -2.9,-0.4 -4.1,-1.2c-1.9,-1.4 -3.1,-3.6 -3.1,
        -6.0c0.0,-0.4 0.3,-0.7 0.7,-0.7s0.7,0.3 0.7,0.7c0.0,1.9 0.9,3.7 2.5,4.8c0.9,0.6 1.9,
        1.0 3.2,1.0c0.3,0.0 0.8,0.0 1.3,-0.1c0.4,-0.1 0.8,0.2 0.8,0.6c0.1,0.4 -0.2,0.8 -0.6,
        0.8C23.4,27.1 22.8,27.1 22.6,27.1z" />
    <path
        android:fillColor="#ffffff"
        android:pathData="M20.0,29.9c-0.1,0.0 -0.1,0.0 -0.2,0.0c-2.1,-0.6 -3.4,-1.4 -4.8,-2.9c-1.8,
        -1.9 -2.8,-4.4 -2.8,-7.1c0.0,-2.2 1.8,-4.1 4.1,-4.1c2.2,0.0 4.1,1.8 4.1,4.1c0.0,1.4 1.2,
        2.6 2.6,2.6c1.4,0.0 2.6,-1.2 2.6,-2.6c0.0,-5.1 -4.2,-9.3 -9.3,-9.3c-3.6,0.0 -6.9,2.1 -8.4,
        5.4C7.3,17.1 7.0,18.4 7.0,19.8c0.0,1.1 0.1,2.7 0.9,4.9c0.1,0.4 -0.1,0.8 -0.4,0.9c-0.4,
        0.1 -0.8,-0.1 -0.9,-0.4c-0.6,-1.8 -0.9,-3.6 -0.9,-5.4c0.0,-1.6 0.3,-3.1 0.9,-4.4c1.7,
        -3.8 5.6,-6.3 9.8,-6.3c5.9,0.0 10.7,4.8 10.7,10.7c0.0,2.2 -1.8,4.1 -4.1,4.1s-4.0,
        -1.8 -4.0,-4.1c0.0,-1.4 -1.2,-2.6 -2.6,-2.6c-1.4,0.0 -2.6,1.2 -2.6,2.6c0.0,2.3 0.9,
        4.5 2.4,6.1c1.2,1.3 2.4,2.0 4.2,2.5c0.4,0.1 0.6,0.5 0.5,0.9C20.6,29.7 20.3,29.9 20.0,
        29.9z" />
</vector>
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ class UdfpsController implements DozeReceiver {
    @SuppressLint("ClickableViewAccessibility")
    private final UdfpsView.OnTouchListener mOnTouchListener = (v, event) -> {
        UdfpsView view = (UdfpsView) v;
        final boolean isFingerDown = view.isScrimShowing();
        final boolean isFingerDown = view.isShowScrimAndDot();
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_MOVE:
+30 −12
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.text.TextUtils;
import android.util.AttributeSet;
@@ -70,6 +71,7 @@ public class UdfpsView extends View implements DozeReceiver,
    // mInsetsListener to restrict the touchable region and allow the touches outside of the sensor
    // to propagate to the rest of the UI.
    @NonNull private final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsListener;
    @NonNull private final Drawable mFingerprintDrawable;

    // Used to obtain the sensor location.
    @NonNull private FingerprintSensorPropertiesInternal mSensorProps;
@@ -79,7 +81,7 @@ public class UdfpsView extends View implements DozeReceiver,
    private float mBurnInOffsetX;
    private float mBurnInOffsetY;

    private boolean mIsScrimShowing;
    private boolean mShowScrimAndDot;
    private boolean mIsHbmSupported;
    @Nullable private String mDebugMessage;

@@ -112,15 +114,16 @@ public class UdfpsView extends View implements DozeReceiver,
        mSensorPaint = new Paint(0 /* flags */);
        mSensorPaint.setAntiAlias(true);
        mSensorPaint.setColor(Color.WHITE);
        mSensorPaint.setStyle(Paint.Style.STROKE);
        mSensorPaint.setStrokeWidth(SENSOR_OUTLINE_WIDTH);
        mSensorPaint.setShadowLayer(SENSOR_SHADOW_RADIUS, 0, 0, Color.BLACK);
        mSensorPaint.setStyle(Paint.Style.FILL);

        mDebugTextPaint = new Paint();
        mDebugTextPaint.setAntiAlias(true);
        mDebugTextPaint.setColor(Color.BLUE);
        mDebugTextPaint.setTextSize(DEBUG_TEXT_SIZE_PX);

        mFingerprintDrawable = getResources().getDrawable(R.drawable.ic_fingerprint, null);

        mTouchableRegion = new Rect();
        // When the device is rotated, it's important that mTouchableRegion is updated before
        // this listener is called. This listener is usually called shortly after onLayout.
@@ -130,7 +133,7 @@ public class UdfpsView extends View implements DozeReceiver,
            internalInsetsInfo.touchableRegion.set(mTouchableRegion);
        };

        mIsScrimShowing = false;
        mShowScrimAndDot = false;
    }

    void setSensorProperties(@NonNull FingerprintSensorPropertiesInternal properties) {
@@ -181,6 +184,13 @@ public class UdfpsView extends View implements DozeReceiver,
            default:
                // Do nothing to stay in portrait mode.
        }

        int margin =  (int) (mSensorRect.bottom - mSensorRect.top) / 5;
        mFingerprintDrawable.setBounds(
                (int) mSensorRect.left + margin,
                (int) mSensorRect.top + margin,
                (int) mSensorRect.right - margin,
                (int) mSensorRect.bottom - margin);
    }

    @Override
@@ -198,6 +208,8 @@ public class UdfpsView extends View implements DozeReceiver,
        // is finished, mTouchableRegion will be used by mInsetsListener to compute the touch
        // insets.
        mSensorRect.roundOut(mTouchableRegion);


    }

    @Override
@@ -218,7 +230,7 @@ public class UdfpsView extends View implements DozeReceiver,
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        if (mIsScrimShowing && mIsHbmSupported) {
        if (mShowScrimAndDot && mIsHbmSupported) {
            // Only draw the scrim if HBM is supported.
            canvas.drawRect(mScrimRect, mScrimPaint);
        }
@@ -229,7 +241,15 @@ public class UdfpsView extends View implements DozeReceiver,
        if (!TextUtils.isEmpty(mDebugMessage)) {
            canvas.drawText(mDebugMessage, 0, 160, mDebugTextPaint);
        }

        if (mShowScrimAndDot) {
            // draw dot (white circle)
            canvas.drawOval(mSensorRect, mSensorPaint);
        } else {
            // draw fingerprint icon
            mFingerprintDrawable.draw(canvas);
        }

        canvas.restore();
    }

@@ -264,19 +284,17 @@ public class UdfpsView extends View implements DozeReceiver,
        mScrimPaint.setAlpha(alpha);
    }

    boolean isScrimShowing() {
        return mIsScrimShowing;
    boolean isShowScrimAndDot() {
        return mShowScrimAndDot;
    }

    void showScrimAndDot() {
        mIsScrimShowing = true;
        mSensorPaint.setStyle(Paint.Style.FILL);
        mShowScrimAndDot = true;
        invalidate();
    }

    void hideScrimAndDot() {
        mIsScrimShowing = false;
        mSensorPaint.setStyle(Paint.Style.STROKE);
        mShowScrimAndDot = false;
        invalidate();
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
    @Test
    public void fingerDown() throws RemoteException {
        // Configure UdfpsView to accept the ACTION_DOWN event
        when(mUdfpsView.isScrimShowing()).thenReturn(false);
        when(mUdfpsView.isShowScrimAndDot()).thenReturn(false);
        when(mUdfpsView.isValidTouch(anyFloat(), anyFloat(), anyFloat())).thenReturn(true);

        // GIVEN that the overlay is showing