Replace nav bar assets from png to vector drawables (1/2)
Unifying the assets between aosp and pixel while replacing all the image
files per density/orientation with singular xml vector files to simplify
the assets. In addition added a shadow/rotation class to allow these
drawables to be rotated and have a shadow to avoid multiple images of
the same shape in different orientations. Therefore there are a lot of
images deleted replaced by a couple of xml file.
Fixes: 79610337
Fixes: 77731348
Fixes: 65692723
Test: manual
Change-Id: I3fbe2bada815bb98e5ab7e2733f7794054ff649f
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java
index cce9d1c..1a85c47 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java
@@ -17,10 +17,16 @@
package com.android.systemui.statusbar.policy;
import android.annotation.Nullable;
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.view.Gravity;
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.ShadowKeyDrawable;
+
/**
* Drawable for {@link KeyButtonView}s which contains an asset for both normal mode and light
* navigation bar mode.
@@ -29,13 +35,24 @@
private final boolean mHasDarkDrawable;
- public static KeyButtonDrawable create(Drawable lightDrawable,
- @Nullable Drawable darkDrawable) {
+ public static KeyButtonDrawable create(Context lightContext, Drawable lightDrawable,
+ @Nullable Drawable darkDrawable, boolean hasShadow) {
if (darkDrawable != null) {
- return new KeyButtonDrawable(
- new Drawable[] { lightDrawable.mutate(), darkDrawable.mutate() });
+ ShadowKeyDrawable light = new ShadowKeyDrawable(lightDrawable.mutate());
+ ShadowKeyDrawable dark = new ShadowKeyDrawable(darkDrawable.mutate());
+ if (hasShadow) {
+ // Only apply the shadow on the light drawable
+ Resources res = lightContext.getResources();
+ int offsetX = res.getDimensionPixelSize(R.dimen.nav_key_button_shadow_offset_x);
+ int offsetY = res.getDimensionPixelSize(R.dimen.nav_key_button_shadow_offset_y);
+ int radius = res.getDimensionPixelSize(R.dimen.nav_key_button_shadow_radius);
+ int color = lightContext.getColor(R.color.nav_key_button_shadow_color);
+ light.setShadowProperties(offsetX, offsetY, radius, color);
+ }
+ return new KeyButtonDrawable(new Drawable[] { light, dark });
} else {
- return new KeyButtonDrawable(new Drawable[] { lightDrawable.mutate() });
+ return new KeyButtonDrawable(new Drawable[] {
+ new ShadowKeyDrawable(lightDrawable.mutate()) });
}
}
@@ -57,4 +74,13 @@
getDrawable(1).setAlpha((int) (intensity * 255f));
invalidateSelf();
}
+
+ public void setRotation(float degrees) {
+ if (getDrawable(0) instanceof ShadowKeyDrawable) {
+ ((ShadowKeyDrawable) getDrawable(0)).setRotation(degrees);
+ }
+ if (mHasDarkDrawable && getDrawable(1) instanceof ShadowKeyDrawable) {
+ ((ShadowKeyDrawable) getDrawable(1)).setRotation(degrees);
+ }
+ }
}