Add shadow to assistant handles
Test: As nav bar color changes, verify shadow appears when assistant handles are white, and shadow disappears as assistant handles change to dark. Handles become dark in light apps (ex. Gmail), and light in dark apps. (ex. YouTube Music) Bug: 134128794 Change-Id: Iaed844de99ff9465c0ac09a78238d8d08060c7a3
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.systemui;
|
||||
import android.animation.ArgbEvaluator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.RectF;
|
||||
@@ -27,6 +28,7 @@ import android.util.DisplayMetrics;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.internal.graphics.ColorUtils;
|
||||
import com.android.settingslib.Utils;
|
||||
|
||||
/**
|
||||
@@ -107,6 +109,7 @@ public class CornerHandleView extends View {
|
||||
mPaint.setColor((int) ArgbEvaluator.getInstance().evaluate(darkIntensity,
|
||||
mLightColor,
|
||||
mDarkColor));
|
||||
updateShadow();
|
||||
if (getVisibility() == VISIBLE) {
|
||||
invalidate();
|
||||
}
|
||||
@@ -118,6 +121,21 @@ public class CornerHandleView extends View {
|
||||
canvas.drawPath(mPath, mPaint);
|
||||
}
|
||||
|
||||
private void updateShadow() {
|
||||
if (ColorUtils.calculateLuminance(mPaint.getColor()) > 0.7f) {
|
||||
mPaint.setShadowLayer(/** radius */ 5,/** shadowDx */ 0, /** shadowDy */ -1,
|
||||
/** color */ ColorUtils.setAlphaComponent(/** color */ Color.BLACK,
|
||||
/** alpha */ 102));
|
||||
} else {
|
||||
mPaint.setShadowLayer(/** radius */ 0, /** shadowDx */ 0, /** shadowDy */ 0,
|
||||
/** color */ Color.TRANSPARENT);
|
||||
}
|
||||
|
||||
if (getVisibility() == VISIBLE) {
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private static float convertDpToPixel(float dp, Context context) {
|
||||
return dp * ((float) context.getResources().getDisplayMetrics().densityDpi
|
||||
/ DisplayMetrics.DENSITY_DEFAULT);
|
||||
|
||||
Reference in New Issue
Block a user