summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/res/values/config.xml2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java29
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java16
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java35
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java31
5 files changed, 90 insertions, 23 deletions
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 2871d06d8f8e..d774c551b547 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -331,7 +331,7 @@
<!-- Nav bar button default ordering/layout -->
<string name="config_navBarLayout" translatable="false">left[.5W],back[1WC];home;recent[1WC],right[.5W]</string>
<string name="config_navBarLayoutQuickstep" translatable="false">back[1.7WC];home;contextual[1.7WC]</string>
- <string name="config_navBarLayoutHandle" translatable="false">start_contextual[.1WC];home_handle;ime_switcher[.1WC]</string>
+ <string name="config_navBarLayoutHandle" translatable="false">start_contextual[40AC];home_handle;ime_switcher[40AC]</string>
<bool name="quick_settings_show_full_alarm">false</bool>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java
index 963fc54ecd2d..7ab8da9d2561 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java
@@ -84,6 +84,8 @@ public class NavigationBarInflaterView extends FrameLayout
public static final String KEY_CODE_END = ")";
private static final String WEIGHT_SUFFIX = "W";
private static final String WEIGHT_CENTERED_SUFFIX = "WC";
+ private static final String ABSOLUTE_SUFFIX = "A";
+ private static final String ABSOLUTE_VERTICAL_CENTERED_SUFFIX = "C";
private final List<NavBarButtonProvider> mPlugins = new ArrayList<>();
@@ -353,17 +355,20 @@ public class NavigationBarInflaterView extends FrameLayout
String sizeStr = extractSize(buttonSpec);
if (sizeStr == null) return v;
- if (sizeStr.contains(WEIGHT_SUFFIX)) {
+ if (sizeStr.contains(WEIGHT_SUFFIX) || sizeStr.contains(ABSOLUTE_SUFFIX)) {
// To support gravity, wrap in RelativeLayout and apply gravity to it.
// Children wanting to use gravity must be smaller then the frame.
- float weight = Float.parseFloat(sizeStr.substring(0, sizeStr.indexOf(WEIGHT_SUFFIX)));
ReverseRelativeLayout frame = new ReverseRelativeLayout(mContext);
LayoutParams childParams = new LayoutParams(v.getLayoutParams());
// Compute gravity to apply
int gravity = (landscape) ? (start ? Gravity.TOP : Gravity.BOTTOM)
: (start ? Gravity.START : Gravity.END);
- if (sizeStr.endsWith(WEIGHT_CENTERED_SUFFIX)) gravity = Gravity.CENTER;
+ if (sizeStr.endsWith(WEIGHT_CENTERED_SUFFIX)) {
+ gravity = Gravity.CENTER;
+ } else if (sizeStr.endsWith(ABSOLUTE_VERTICAL_CENTERED_SUFFIX)) {
+ gravity = Gravity.CENTER_VERTICAL;
+ }
// Set default gravity, flipped if needed in reversed layouts (270 RTL and 90 LTR)
frame.setDefaultGravity(gravity);
@@ -371,8 +376,16 @@ public class NavigationBarInflaterView extends FrameLayout
frame.addView(v, childParams);
- // Use weighting to set the width of the frame
- frame.setLayoutParams(new LinearLayout.LayoutParams(0, MATCH_PARENT, weight));
+ if (sizeStr.contains(WEIGHT_SUFFIX)) {
+ // Use weighting to set the width of the frame
+ float weight = Float.parseFloat(
+ sizeStr.substring(0, sizeStr.indexOf(WEIGHT_SUFFIX)));
+ frame.setLayoutParams(new LinearLayout.LayoutParams(0, MATCH_PARENT, weight));
+ } else {
+ int width = (int) convertDpToPx(mContext,
+ Float.parseFloat(sizeStr.substring(0, sizeStr.indexOf(ABSOLUTE_SUFFIX))));
+ frame.setLayoutParams(new LinearLayout.LayoutParams(width, MATCH_PARENT));
+ }
// Ensure ripples can be drawn outside bounds
frame.setClipChildren(false);
@@ -490,8 +503,6 @@ public class NavigationBarInflaterView extends FrameLayout
}
}
-
-
private void clearViews() {
if (mButtonDispatchers != null) {
for (int i = 0; i < mButtonDispatchers.size(); i++) {
@@ -508,6 +519,10 @@ public class NavigationBarInflaterView extends FrameLayout
}
}
+ private static float convertDpToPx(Context context, float dp) {
+ return dp * context.getResources().getDisplayMetrics().density;
+ }
+
@Override
public void onPluginConnected(NavBarButtonProvider plugin, Context context) {
mPlugins.add(plugin);
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 2bfc311f1bd4..568de63b0112 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java
@@ -34,7 +34,6 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
-import android.graphics.RectF;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.Drawable;
import android.util.FloatProperty;
@@ -79,7 +78,6 @@ public class KeyButtonDrawable extends Drawable {
private final Paint mIconPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
private final Paint mShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
- private final Paint mOvalBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
private final ShadowDrawableState mState;
private AnimatedVectorDrawable mAnimatedDrawable;
@@ -101,7 +99,6 @@ public class KeyButtonDrawable extends Drawable {
mAnimatedDrawable = (AnimatedVectorDrawable) mState.mChildState.newDrawable().mutate();
setDrawableBounds(mAnimatedDrawable);
}
- mOvalBgPaint.setColor(mState.mDarkColor);
}
public void setDarkIntensity(float intensity) {
@@ -215,6 +212,15 @@ public class KeyButtonDrawable extends Drawable {
return mState.mBaseWidth + (mState.mShadowSize + Math.abs(mState.mShadowOffsetX)) * 2;
}
+ /** Return if the drawable has oval background. */
+ public boolean hasOvalBg() {
+ return mState.mHasOvalBg;
+ }
+
+ public int getDarkColor() {
+ return mState.mDarkColor;
+ }
+
public boolean canAnimate() {
return mState.mSupportsAnimation;
}
@@ -244,10 +250,6 @@ public class KeyButtonDrawable extends Drawable {
return;
}
- if (mState.mHasOvalBg) {
- canvas.drawOval(new RectF(bounds), mOvalBgPaint);
- }
-
if (mAnimatedDrawable != null) {
mAnimatedDrawable.draw(canvas);
} else {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java
index 8b869969e215..0db76ecf67fb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java
@@ -73,6 +73,13 @@ public class KeyButtonRipple extends Drawable {
private final HashSet<Animator> mRunningAnimations = new HashSet<>();
private final ArrayList<Animator> mTmpArray = new ArrayList<>();
+ public enum Type {
+ OVAL,
+ ROUNDED_RECT
+ }
+
+ private Type mType = Type.ROUNDED_RECT;
+
public KeyButtonRipple(Context ctx, View targetView) {
mMaxWidth = ctx.getResources().getDimensionPixelSize(R.dimen.key_button_ripple_max_width);
mTargetView = targetView;
@@ -86,6 +93,10 @@ public class KeyButtonRipple extends Drawable {
mDelayTouchFeedback = delay;
}
+ public void setType(Type type) {
+ mType = type;
+ }
+
private Paint getRipplePaint() {
if (mRipplePaint == null) {
mRipplePaint = new Paint();
@@ -111,9 +122,15 @@ public class KeyButtonRipple extends Drawable {
final float ry = horizontal ? cy : radius;
final float corner = horizontal ? cy : cx;
- canvas.drawRoundRect(cx - rx, cy - ry,
- cx + rx, cy + ry,
- corner, corner, p);
+ if (mType == Type.ROUNDED_RECT) {
+ canvas.drawRoundRect(cx - rx, cy - ry, cx + rx, cy + ry, corner, corner, p);
+ } else {
+ canvas.save();
+ canvas.translate(cx, cy);
+ float r = Math.min(rx, ry);
+ canvas.drawOval(-r, -r, r, r, p);
+ canvas.restore();
+ }
}
}
@@ -148,8 +165,16 @@ public class KeyButtonRipple extends Drawable {
private void drawHardware(RecordingCanvas c) {
if (mDrawingHardwareGlow) {
- c.drawRoundRect(mLeftProp, mTopProp, mRightProp, mBottomProp, mRxProp, mRyProp,
- mPaintProp);
+ if (mType == Type.ROUNDED_RECT) {
+ c.drawRoundRect(mLeftProp, mTopProp, mRightProp, mBottomProp, mRxProp, mRyProp,
+ mPaintProp);
+ } else {
+ CanvasProperty<Float> cx = CanvasProperty.createFloat(getBounds().width() / 2);
+ CanvasProperty<Float> cy = CanvasProperty.createFloat(getBounds().height() / 2);
+ int d = Math.min(getBounds().width(), getBounds().height());
+ CanvasProperty<Float> r = CanvasProperty.createFloat(1.0f * d / 2);
+ c.drawCircle(cx, cy, r, mPaintProp);
+ }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
index 41fa34608ee8..22a0b991ffae 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
@@ -25,6 +25,8 @@ import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.hardware.input.InputManager;
@@ -76,6 +78,8 @@ public class KeyButtonView extends ImageView implements ButtonInterface {
private final OverviewProxyService mOverviewProxyService;
private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
private final InputManager mInputManager;
+ private final Paint mOvalBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
+ private boolean mHasOvalBg = false;
private final Runnable mCheckLongPress = new Runnable() {
public void run() {
@@ -127,6 +131,7 @@ public class KeyButtonView extends ImageView implements ButtonInterface {
mOverviewProxyService = Dependency.get(OverviewProxyService.class);
mInputManager = manager;
setBackground(mRipple);
+ setWillNotDraw(false);
forceHasOverlappingRendering(false);
}
@@ -357,7 +362,14 @@ public class KeyButtonView extends ImageView implements ButtonInterface {
public void setDarkIntensity(float darkIntensity) {
Drawable drawable = getDrawable();
if (drawable != null) {
- ((KeyButtonDrawable) getDrawable()).setDarkIntensity(darkIntensity);
+ KeyButtonDrawable keyButtonDrawable = (KeyButtonDrawable) drawable;
+ keyButtonDrawable.setDarkIntensity(darkIntensity);
+ mHasOvalBg = keyButtonDrawable.hasOvalBg();
+ if (mHasOvalBg) {
+ mOvalBgPaint.setColor(keyButtonDrawable.getDarkColor());
+ }
+ mRipple.setType(keyButtonDrawable.hasOvalBg() ? KeyButtonRipple.Type.OVAL
+ : KeyButtonRipple.Type.ROUNDED_RECT);
// Since we reuse the same drawable for multiple views, we need to invalidate the view
// manually.
@@ -372,9 +384,22 @@ public class KeyButtonView extends ImageView implements ButtonInterface {
}
@Override
+ public void draw(Canvas canvas) {
+ if (mHasOvalBg) {
+ canvas.save();
+ int cx = (getLeft() + getRight()) / 2;
+ int cy = (getTop() + getBottom()) / 2;
+ canvas.translate(cx, cy);
+ int d = Math.min(getWidth(), getHeight());
+ int r = d / 2;
+ canvas.drawOval(-r, -r, r, r, mOvalBgPaint);
+ canvas.restore();
+ }
+ super.draw(canvas);
+ }
+
+ @Override
public void setVertical(boolean vertical) {
mIsVertical = vertical;
}
}
-
-