diff --git a/packages/SystemUI/src/com/android/systemui/assist/ui/EdgeLight.java b/packages/SystemUI/src/com/android/systemui/assist/ui/EdgeLight.java index 9ae02c5e3104b..baa3a4a938c13 100644 --- a/packages/SystemUI/src/com/android/systemui/assist/ui/EdgeLight.java +++ b/packages/SystemUI/src/com/android/systemui/assist/ui/EdgeLight.java @@ -16,6 +16,8 @@ package com.android.systemui.assist.ui; +import android.util.Log; + import androidx.annotation.ColorInt; /** @@ -29,9 +31,12 @@ import androidx.annotation.ColorInt; * counter-clockwise. */ public final class EdgeLight { + + private static final String TAG = "EdgeLight"; + @ColorInt private int mColor; - private float mOffset; + private float mStart; private float mLength; /** Copies a list of EdgeLights. */ @@ -45,13 +50,13 @@ public final class EdgeLight { public EdgeLight(@ColorInt int color, float offset, float length) { mColor = color; - mOffset = offset; + mStart = offset; mLength = length; } public EdgeLight(EdgeLight sourceLight) { mColor = sourceLight.getColor(); - mOffset = sourceLight.getOffset(); + mStart = sourceLight.getStart(); mLength = sourceLight.getLength(); } @@ -77,23 +82,41 @@ public final class EdgeLight { } /** - * Returns the current offset, in units of the total device perimeter and measured from the - * bottom-left corner (see class description). + * Sets the endpoints of the edge light, both measured from the bottom-left corner (see class + * description). This is a convenience method to avoid separate setStart and setLength calls. */ - public float getOffset() { - return mOffset; + public void setEndpoints(float start, float end) { + if (start > end) { + Log.e(TAG, String.format("Endpoint must be >= start (add 1 if necessary). Got [%f, %f]", + start, end)); + return; + } + mStart = start; + mLength = end - start; + } + + /** + * Returns the current starting position, in units of the total device perimeter and measured + * from the bottom-left corner (see class description). + */ + public float getStart() { + return mStart; } /** * Sets the current offset, in units of the total device perimeter and measured from the * bottom-left corner (see class description). */ - public void setOffset(float offset) { - mOffset = offset; + public void setStart(float start) { + mStart = start; + } + + public float getEnd() { + return mStart + mLength; } /** Returns the center, measured from the bottom-left corner (see class description). */ public float getCenter() { - return mOffset + (mLength / 2.f); + return mStart + (mLength / 2.f); } } diff --git a/packages/SystemUI/src/com/android/systemui/assist/ui/InvocationLightsView.java b/packages/SystemUI/src/com/android/systemui/assist/ui/InvocationLightsView.java index bb3bd781df66d..570b911cd400b 100644 --- a/packages/SystemUI/src/com/android/systemui/assist/ui/InvocationLightsView.java +++ b/packages/SystemUI/src/com/android/systemui/assist/ui/InvocationLightsView.java @@ -140,10 +140,10 @@ public class InvocationLightsView extends View float rightStart = mGuide.getRegionWidth(PerimeterPathGuide.Region.BOTTOM) + (cornerLengthNormalized - arcOffsetNormalized) * (1 - progress); - setLight(0, leftStart, lightLength); - setLight(1, leftStart + lightLength, lightLength); - setLight(2, rightStart - (lightLength * 2), lightLength); - setLight(3, rightStart - lightLength, lightLength); + setLight(0, leftStart, leftStart + lightLength); + setLight(1, leftStart + lightLength, leftStart + lightLength * 2); + setLight(2, rightStart - (lightLength * 2), rightStart - lightLength); + setLight(3, rightStart - lightLength, rightStart); setVisibility(View.VISIBLE); } invalidate(); @@ -155,7 +155,7 @@ public class InvocationLightsView extends View public void hide() { setVisibility(GONE); for (EdgeLight light : mAssistInvocationLights) { - light.setLength(0); + light.setEndpoints(0, 0); } attemptUnregisterNavBarListener(); } @@ -235,12 +235,11 @@ public class InvocationLightsView extends View } } - protected void setLight(int index, float offset, float length) { + protected void setLight(int index, float start, float end) { if (index < 0 || index >= 4) { Log.w(TAG, "invalid invocation light index: " + index); } - mAssistInvocationLights.get(index).setOffset(offset); - mAssistInvocationLights.get(index).setLength(length); + mAssistInvocationLights.get(index).setEndpoints(start, end); } /** @@ -268,9 +267,11 @@ public class InvocationLightsView extends View } private void renderLight(EdgeLight light, Canvas canvas) { - mGuide.strokeSegment(mPath, light.getOffset(), light.getOffset() + light.getLength()); - mPaint.setColor(light.getColor()); - canvas.drawPath(mPath, mPaint); + if (light.getLength() > 0) { + mGuide.strokeSegment(mPath, light.getStart(), light.getStart() + light.getLength()); + mPaint.setColor(light.getColor()); + canvas.drawPath(mPath, mPaint); + } } private void attemptRegisterNavBarListener() {