From 066ace1b8897229445c0fb3515156ef70bdb05e2 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Mon, 5 Nov 2018 11:08:31 -0800 Subject: Replacing setAlphaComponent with setAlphaComponentBound for better animation interpolation setAlphaComponent throws expetion for invalid range, which can cause brashes in overshoot interpolation Bug: 118390004 Change-Id: Ic9c5ff3d660eba353b982c4c47ccfaf329b3e296 --- src/com/android/launcher3/graphics/IconPalette.java | 4 +++- src/com/android/launcher3/graphics/WorkspaceAndHotseatScrim.java | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/com/android/launcher3/graphics') diff --git a/src/com/android/launcher3/graphics/IconPalette.java b/src/com/android/launcher3/graphics/IconPalette.java index cda07c31a..3d4a1001a 100644 --- a/src/com/android/launcher3/graphics/IconPalette.java +++ b/src/com/android/launcher3/graphics/IconPalette.java @@ -16,6 +16,8 @@ package com.android.launcher3.graphics; +import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound; + import android.app.Notification; import android.content.Context; import android.graphics.Color; @@ -147,7 +149,7 @@ public class IconPalette { } public static int getMutedColor(int color, float whiteScrimAlpha) { - int whiteScrim = ColorUtils.setAlphaComponent(Color.WHITE, (int) (255 * whiteScrimAlpha)); + int whiteScrim = setColorAlphaBound(Color.WHITE, (int) (255 * whiteScrimAlpha)); return ColorUtils.compositeColors(whiteScrim, color); } } diff --git a/src/com/android/launcher3/graphics/WorkspaceAndHotseatScrim.java b/src/com/android/launcher3/graphics/WorkspaceAndHotseatScrim.java index 23d647b44..66f9dbfcd 100644 --- a/src/com/android/launcher3/graphics/WorkspaceAndHotseatScrim.java +++ b/src/com/android/launcher3/graphics/WorkspaceAndHotseatScrim.java @@ -19,6 +19,8 @@ package com.android.launcher3.graphics; import static android.content.Intent.ACTION_SCREEN_OFF; import static android.content.Intent.ACTION_USER_PRESENT; +import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound; + import android.animation.ObjectAnimator; import android.content.BroadcastReceiver; import android.content.Context; @@ -174,7 +176,7 @@ public class WorkspaceAndHotseatScrim implements canvas.clipRect(mHighlightRect, Region.Op.DIFFERENCE); } - canvas.drawColor(ColorUtils.setAlphaComponent(mFullScrimColor, mScrimAlpha)); + canvas.drawColor(setColorAlphaBound(mFullScrimColor, mScrimAlpha)); canvas.restore(); } @@ -303,7 +305,7 @@ public class WorkspaceAndHotseatScrim implements LinearGradient lg = new LinearGradient(0, 0, 0, gradientHeight, new int[]{ 0x00FFFFFF, - ColorUtils.setAlphaComponent(Color.WHITE, (int) (0xFF * 0.95)), + setColorAlphaBound(Color.WHITE, (int) (0xFF * 0.95)), 0xFFFFFFFF}, new float[]{0f, 0.8f, 1f}, Shader.TileMode.CLAMP); -- cgit v1.2.3