From 8b6ac00a1bd9ba5080e1fd5d3b5021d98711db88 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Tue, 16 May 2017 16:16:25 -0700 Subject: [PATCH] Adding an option to change the shadow size Change-Id: I8ec810c5cf06852771247af5f1d717f41079c4f5 --- res/drawable-v24/ic_info_shadow.xml | 3 ++- res/drawable-v24/ic_remove_shadow.xml | 3 ++- res/drawable-v24/ic_uninstall_shadow.xml | 3 ++- res/values/attrs.xml | 1 + res/values/dimens.xml | 2 +- .../launcher3/graphics/ShadowDrawable.java | 15 +++------------ 6 files changed, 11 insertions(+), 16 deletions(-) diff --git a/res/drawable-v24/ic_info_shadow.xml b/res/drawable-v24/ic_info_shadow.xml index 9bd7e16d0b..1fe2c46b4b 100644 --- a/res/drawable-v24/ic_info_shadow.xml +++ b/res/drawable-v24/ic_info_shadow.xml @@ -15,4 +15,5 @@ --> + android:src="@drawable/ic_info_no_shadow" + android:elevation="@dimen/drop_target_shadow_elevation" /> diff --git a/res/drawable-v24/ic_remove_shadow.xml b/res/drawable-v24/ic_remove_shadow.xml index 16a630e5fa..48abc10b3b 100644 --- a/res/drawable-v24/ic_remove_shadow.xml +++ b/res/drawable-v24/ic_remove_shadow.xml @@ -15,4 +15,5 @@ --> + android:src="@drawable/ic_remove_no_shadow" + android:elevation="@dimen/drop_target_shadow_elevation" /> diff --git a/res/drawable-v24/ic_uninstall_shadow.xml b/res/drawable-v24/ic_uninstall_shadow.xml index 2532157abc..b441b0e7b6 100644 --- a/res/drawable-v24/ic_uninstall_shadow.xml +++ b/res/drawable-v24/ic_uninstall_shadow.xml @@ -15,4 +15,5 @@ --> + android:src="@drawable/ic_uninstall_no_shadow" + android:elevation="@dimen/drop_target_shadow_elevation" /> diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 18759f817c..807d08af23 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -114,5 +114,6 @@ + diff --git a/res/values/dimens.xml b/res/values/dimens.xml index b0f64a604d..958cb6bc87 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -104,6 +104,7 @@ 14dp 14sp + 2dp 30dp @@ -138,7 +139,6 @@ 2dp 4dp 2dp - 4dp 8dp diff --git a/src/com/android/launcher3/graphics/ShadowDrawable.java b/src/com/android/launcher3/graphics/ShadowDrawable.java index 5e76649ca3..5f4fc6cc71 100644 --- a/src/com/android/launcher3/graphics/ShadowDrawable.java +++ b/src/com/android/launcher3/graphics/ShadowDrawable.java @@ -46,6 +46,7 @@ public class ShadowDrawable extends Drawable { private final ShadowDrawableState mState; + @SuppressWarnings("unused") public ShadowDrawable() { this(new ShadowDrawableState()); } @@ -98,17 +99,6 @@ public class ShadowDrawable extends Drawable { return mState.mIntrinsicWidth; } - /** - * Sets the color for the generated shadow - */ - public void setShadowColor(int color) { - if (mState.mShadowColor != color) { - mState.mShadowColor = color; - mState.mLastDrawnBitmap = null; - invalidateSelf(); - } - } - private void regenerateBitmapCache() { Bitmap bitmap = Bitmap.createBitmap(mState.mIntrinsicWidth, mState.mIntrinsicHeight, Bitmap.Config.ARGB_8888); @@ -154,7 +144,8 @@ public class ShadowDrawable extends Drawable { } mState.mShadowColor = a.getColor( R.styleable.ShadowDrawable_android_shadowColor, Color.BLACK); - mState.mShadowSize = r.getDimensionPixelSize(R.dimen.drawable_shadow_size); + mState.mShadowSize = a.getDimensionPixelSize( + R.styleable.ShadowDrawable_android_elevation, 0); mState.mIntrinsicHeight = d.getIntrinsicHeight() + 2 * mState.mShadowSize; mState.mIntrinsicWidth = d.getIntrinsicWidth() + 2 * mState.mShadowSize;