summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-07-27 10:21:50 -0700
committerSunny Goyal <sunnygoyal@google.com>2017-07-27 10:26:37 -0700
commit6d1e9a1012262b64646c6f765d3d9179c1700cac (patch)
treed5c0305f2158a004a0cda56a561e28370689d20e
parent20d27e513c9a5d8b40c1f9e64c05f5294f280794 (diff)
downloadandroid_packages_apps_Trebuchet-6d1e9a1012262b64646c6f765d3d9179c1700cac.tar.gz
android_packages_apps_Trebuchet-6d1e9a1012262b64646c6f765d3d9179c1700cac.tar.bz2
android_packages_apps_Trebuchet-6d1e9a1012262b64646c6f765d3d9179c1700cac.zip
Moving GradientView background alpha to resources
Bug: 63072570 Change-Id: Ie982a5a33ece72942ebee79e4eb81f83da7b31c4
-rw-r--r--res/values/config.xml2
-rw-r--r--src/com/android/launcher3/graphics/GradientView.java17
2 files changed, 10 insertions, 9 deletions
diff --git a/res/values/config.xml b/res/values/config.xml
index e9c62a783..e7ec0a0b1 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -9,6 +9,8 @@
<bool name="is_large_tablet">false</bool>
<bool name="allow_rotation">false</bool>
+ <integer name="extracted_color_gradient_alpha">191</integer>
+
<!-- A string pointer to the original app name string. This allows derived projects to
easily override the app name without providing all translations -->
<string name="derived_app_name" translatable="false">@string/app_name</string>
diff --git a/src/com/android/launcher3/graphics/GradientView.java b/src/com/android/launcher3/graphics/GradientView.java
index 678396df1..5455b43ec 100644
--- a/src/com/android/launcher3/graphics/GradientView.java
+++ b/src/com/android/launcher3/graphics/GradientView.java
@@ -27,6 +27,7 @@ import android.graphics.RectF;
import android.graphics.Shader;
import android.support.v4.graphics.ColorUtils;
import android.util.AttributeSet;
+import android.util.DisplayMetrics;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Interpolator;
@@ -46,7 +47,6 @@ public class GradientView extends View implements WallpaperColorInfo.OnChangeLis
private static final int DEFAULT_COLOR = Color.WHITE;
private static final int ALPHA_MASK_HEIGHT_DP = 500;
private static final int ALPHA_MASK_WIDTH_DP = 2;
- private static final int ALPHA_COLORS = 0xBF;
private static final boolean DEBUG = false;
private final Bitmap mAlphaGradientMask;
@@ -62,7 +62,7 @@ public class GradientView extends View implements WallpaperColorInfo.OnChangeLis
private final Paint mPaintNoScrim = new Paint();
private float mProgress;
private final int mMaskHeight, mMaskWidth;
- private final Context mAppContext;
+ private final int mAlphaColors;
private final Paint mDebugPaint = DEBUG ? new Paint() : null;
private final Interpolator mAccelerator = new AccelerateInterpolator();
private final float mAlphaStart;
@@ -71,15 +71,14 @@ public class GradientView extends View implements WallpaperColorInfo.OnChangeLis
public GradientView(Context context, AttributeSet attrs) {
super(context, attrs);
- this.mAppContext = context.getApplicationContext();
- this.mMaskHeight = Utilities.pxFromDp(ALPHA_MASK_HEIGHT_DP,
- mAppContext.getResources().getDisplayMetrics());
- this.mMaskWidth = Utilities.pxFromDp(ALPHA_MASK_WIDTH_DP,
- mAppContext.getResources().getDisplayMetrics());
+ DisplayMetrics dm = getResources().getDisplayMetrics();
+ this.mMaskHeight = Utilities.pxFromDp(ALPHA_MASK_HEIGHT_DP, dm);
+ this.mMaskWidth = Utilities.pxFromDp(ALPHA_MASK_WIDTH_DP, dm);
Launcher launcher = Launcher.getLauncher(context);
this.mAlphaStart = launcher.getDeviceProfile().isVerticalBarLayout() ? 0 : 100;
this.mScrimColor = Themes.getAttrColor(context, R.attr.allAppsScrimColor);
this.mWallpaperColorInfo = WallpaperColorInfo.getInstance(launcher);
+ mAlphaColors = getResources().getInteger(R.integer.extracted_color_gradient_alpha);
updateColors();
mAlphaGradientMask = createDitheredAlphaMask();
}
@@ -104,9 +103,9 @@ public class GradientView extends View implements WallpaperColorInfo.OnChangeLis
private void updateColors() {
this.mColor1 = ColorUtils.setAlphaComponent(mWallpaperColorInfo.getMainColor(),
- ALPHA_COLORS);
+ mAlphaColors);
this.mColor2 = ColorUtils.setAlphaComponent(mWallpaperColorInfo.getSecondaryColor(),
- ALPHA_COLORS);
+ mAlphaColors);
if (mWidth + mHeight > 0) {
createRadialShader();
}