diff options
| -rw-r--r-- | packages/SystemUI/res/layout/udfps_view.xml | 4 | ||||
| -rw-r--r-- | packages/SystemUI/res/values/attrs.xml | 2 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java | 27 |
3 files changed, 17 insertions, 16 deletions
diff --git a/packages/SystemUI/res/layout/udfps_view.xml b/packages/SystemUI/res/layout/udfps_view.xml index 732758a2ded2..31a33fbfc308 100644 --- a/packages/SystemUI/res/layout/udfps_view.xml +++ b/packages/SystemUI/res/layout/udfps_view.xml @@ -5,6 +5,6 @@ android:id="@+id/udfps_view" android:layout_width="match_parent" android:layout_height="match_parent" - systemui:sensorRadius="140px" - systemui:sensorMarginBottom="630px" + systemui:sensorRadius="130px" + systemui:sensorCenterY="1636px" systemui:sensorTouchAreaCoefficient="0.5"/> diff --git a/packages/SystemUI/res/values/attrs.xml b/packages/SystemUI/res/values/attrs.xml index 84dbd60b799d..a62502965dd2 100644 --- a/packages/SystemUI/res/values/attrs.xml +++ b/packages/SystemUI/res/values/attrs.xml @@ -159,7 +159,7 @@ <declare-styleable name="UdfpsView"> <attr name="sensorRadius" format="dimension"/> - <attr name="sensorMarginBottom" format="dimension"/> + <attr name="sensorCenterY" format="dimension"/> <attr name="sensorPressureCoefficient" format="float"/> <attr name="sensorTouchAreaCoefficient" format="float"/> </declare-styleable> diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java index 36353fa96956..d7e91384f049 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java @@ -53,12 +53,10 @@ public class UdfpsView extends View implements DozeReceiver, private final Paint mScrimPaint; private final Paint mDebugTextPaint; - private float mSensorX; - private float mSensorY; private final RectF mSensorRect; private final Paint mSensorPaint; private final float mSensorRadius; - private final float mSensorMarginBottom; + private final float mSensorCenterY; private final float mSensorTouchAreaCoefficient; private final int mMaxBurnInOffsetX; private final int mMaxBurnInOffsetY; @@ -66,6 +64,10 @@ public class UdfpsView extends View implements DozeReceiver, private final Rect mTouchableRegion; private final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsListener; + // This is calculated from the screen's dimensions at runtime, as opposed to mSensorCenterY, + // which is defined in layout.xml + private float mSensorCenterX; + // AOD anti-burn-in offsets private float mInterpolatedDarkAmount; private float mBurnInOffsetX; @@ -84,7 +86,7 @@ public class UdfpsView extends View implements DozeReceiver, if (!a.hasValue(R.styleable.UdfpsView_sensorRadius)) { throw new IllegalArgumentException("UdfpsView must contain sensorRadius"); } - if (!a.hasValue(R.styleable.UdfpsView_sensorMarginBottom)) { + if (!a.hasValue(R.styleable.UdfpsView_sensorCenterY)) { throw new IllegalArgumentException("UdfpsView must contain sensorMarginBottom"); } if (!a.hasValue(R.styleable.UdfpsView_sensorTouchAreaCoefficient)) { @@ -92,7 +94,7 @@ public class UdfpsView extends View implements DozeReceiver, "UdfpsView must contain sensorTouchAreaCoefficient"); } mSensorRadius = a.getDimension(R.styleable.UdfpsView_sensorRadius, 0f); - mSensorMarginBottom = a.getDimension(R.styleable.UdfpsView_sensorMarginBottom, 0f); + mSensorCenterY = a.getDimension(R.styleable.UdfpsView_sensorCenterY, 0f); mSensorTouchAreaCoefficient = a.getFloat( R.styleable.UdfpsView_sensorTouchAreaCoefficient, 0f); } finally { @@ -163,10 +165,9 @@ public class UdfpsView extends View implements DozeReceiver, final int h = getLayoutParams().height; final int w = getLayoutParams().width; mScrimRect.set(0 /* left */, 0 /* top */, w, h); - mSensorX = w / 2f; - mSensorY = h - mSensorMarginBottom - mSensorRadius; - mSensorRect.set(mSensorX - mSensorRadius, mSensorY - mSensorRadius, - mSensorX + mSensorRadius, mSensorY + mSensorRadius); + mSensorCenterX = w / 2f; + mSensorRect.set(mSensorCenterX - mSensorRadius, mSensorCenterY - mSensorRadius, + mSensorCenterX + mSensorRadius, mSensorCenterY + mSensorRadius); // Sets mTouchableRegion with rounded up values from mSensorRect. mSensorRect.roundOut(mTouchableRegion); @@ -210,10 +211,10 @@ public class UdfpsView extends View implements DozeReceiver, } boolean isValidTouch(float x, float y, float pressure) { - return x > (mSensorX - mSensorRadius * mSensorTouchAreaCoefficient) - && x < (mSensorX + mSensorRadius * mSensorTouchAreaCoefficient) - && y > (mSensorY - mSensorRadius * mSensorTouchAreaCoefficient) - && y < (mSensorY + mSensorRadius * mSensorTouchAreaCoefficient); + return x > (mSensorCenterX - mSensorRadius * mSensorTouchAreaCoefficient) + && x < (mSensorCenterX + mSensorRadius * mSensorTouchAreaCoefficient) + && y > (mSensorCenterY - mSensorRadius * mSensorTouchAreaCoefficient) + && y < (mSensorCenterY + mSensorRadius * mSensorTouchAreaCoefficient); } void setScrimAlpha(int alpha) { |