Adding an option to change the shadow size
Change-Id: I8ec810c5cf06852771247af5f1d717f41079c4f5
This commit is contained in:
@@ -15,4 +15,5 @@
|
|||||||
-->
|
-->
|
||||||
<com.android.launcher3.graphics.ShadowDrawable
|
<com.android.launcher3.graphics.ShadowDrawable
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:src="@drawable/ic_info_no_shadow" />
|
android:src="@drawable/ic_info_no_shadow"
|
||||||
|
android:elevation="@dimen/drop_target_shadow_elevation" />
|
||||||
|
|||||||
@@ -15,4 +15,5 @@
|
|||||||
-->
|
-->
|
||||||
<com.android.launcher3.graphics.ShadowDrawable
|
<com.android.launcher3.graphics.ShadowDrawable
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:src="@drawable/ic_remove_no_shadow" />
|
android:src="@drawable/ic_remove_no_shadow"
|
||||||
|
android:elevation="@dimen/drop_target_shadow_elevation" />
|
||||||
|
|||||||
@@ -15,4 +15,5 @@
|
|||||||
-->
|
-->
|
||||||
<com.android.launcher3.graphics.ShadowDrawable
|
<com.android.launcher3.graphics.ShadowDrawable
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:src="@drawable/ic_uninstall_no_shadow" />
|
android:src="@drawable/ic_uninstall_no_shadow"
|
||||||
|
android:elevation="@dimen/drop_target_shadow_elevation" />
|
||||||
|
|||||||
@@ -114,5 +114,6 @@
|
|||||||
<declare-styleable name="ShadowDrawable">
|
<declare-styleable name="ShadowDrawable">
|
||||||
<attr name="android:src" />
|
<attr name="android:src" />
|
||||||
<attr name="android:shadowColor" />
|
<attr name="android:shadowColor" />
|
||||||
|
<attr name="android:elevation" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -104,6 +104,7 @@
|
|||||||
<!-- Drag padding to add to the bottom of drop targets -->
|
<!-- Drag padding to add to the bottom of drop targets -->
|
||||||
<dimen name="drop_target_drag_padding">14dp</dimen>
|
<dimen name="drop_target_drag_padding">14dp</dimen>
|
||||||
<dimen name="drop_target_text_size">14sp</dimen>
|
<dimen name="drop_target_text_size">14sp</dimen>
|
||||||
|
<dimen name="drop_target_shadow_elevation">2dp</dimen>
|
||||||
|
|
||||||
<!-- the distance an icon must be dragged before button drop targets accept it -->
|
<!-- the distance an icon must be dragged before button drop targets accept it -->
|
||||||
<dimen name="drag_distanceThreshold">30dp</dimen>
|
<dimen name="drag_distanceThreshold">30dp</dimen>
|
||||||
@@ -138,7 +139,6 @@
|
|||||||
<dimen name="blur_size_medium_outline">2dp</dimen>
|
<dimen name="blur_size_medium_outline">2dp</dimen>
|
||||||
<dimen name="blur_size_click_shadow">4dp</dimen>
|
<dimen name="blur_size_click_shadow">4dp</dimen>
|
||||||
<dimen name="click_shadow_high_shift">2dp</dimen>
|
<dimen name="click_shadow_high_shift">2dp</dimen>
|
||||||
<dimen name="drawable_shadow_size">4dp</dimen>
|
|
||||||
|
|
||||||
<!-- Pending widget -->
|
<!-- Pending widget -->
|
||||||
<dimen name="pending_widget_min_padding">8dp</dimen>
|
<dimen name="pending_widget_min_padding">8dp</dimen>
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ public class ShadowDrawable extends Drawable {
|
|||||||
|
|
||||||
private final ShadowDrawableState mState;
|
private final ShadowDrawableState mState;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public ShadowDrawable() {
|
public ShadowDrawable() {
|
||||||
this(new ShadowDrawableState());
|
this(new ShadowDrawableState());
|
||||||
}
|
}
|
||||||
@@ -98,17 +99,6 @@ public class ShadowDrawable extends Drawable {
|
|||||||
return mState.mIntrinsicWidth;
|
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() {
|
private void regenerateBitmapCache() {
|
||||||
Bitmap bitmap = Bitmap.createBitmap(mState.mIntrinsicWidth, mState.mIntrinsicHeight,
|
Bitmap bitmap = Bitmap.createBitmap(mState.mIntrinsicWidth, mState.mIntrinsicHeight,
|
||||||
Bitmap.Config.ARGB_8888);
|
Bitmap.Config.ARGB_8888);
|
||||||
@@ -154,7 +144,8 @@ public class ShadowDrawable extends Drawable {
|
|||||||
}
|
}
|
||||||
mState.mShadowColor = a.getColor(
|
mState.mShadowColor = a.getColor(
|
||||||
R.styleable.ShadowDrawable_android_shadowColor, Color.BLACK);
|
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.mIntrinsicHeight = d.getIntrinsicHeight() + 2 * mState.mShadowSize;
|
||||||
mState.mIntrinsicWidth = d.getIntrinsicWidth() + 2 * mState.mShadowSize;
|
mState.mIntrinsicWidth = d.getIntrinsicWidth() + 2 * mState.mShadowSize;
|
||||||
|
|||||||
Reference in New Issue
Block a user