Skip to content

Commit a25c198

Browse files
dsandlerAndroid (Google) Code Review
authored andcommitted
Merge "Properly center and scale the navkey glow." into jb-dev
2 parents 8147653 + 3fd0e1a commit a25c198

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class KeyButtonView extends ImageView {
5252
int mCode;
5353
int mTouchSlop;
5454
Drawable mGlowBG;
55+
int mGlowWidth, mGlowHeight;
5556
float mGlowAlpha = 0f, mGlowScale = 1f, mDrawingAlpha = 1f;
5657
boolean mSupportsLongpress = true;
5758
RectF mRect = new RectF(0f,0f,0f,0f);
@@ -89,6 +90,8 @@ public KeyButtonView(Context context, AttributeSet attrs, int defStyle) {
8990
mGlowBG = a.getDrawable(R.styleable.KeyButtonView_glowBackground);
9091
if (mGlowBG != null) {
9192
setDrawingAlpha(BUTTON_QUIESCENT_ALPHA);
93+
mGlowWidth = mGlowBG.getIntrinsicWidth();
94+
mGlowHeight = mGlowBG.getIntrinsicHeight();
9295
}
9396

9497
a.recycle();
@@ -103,8 +106,12 @@ protected void onDraw(Canvas canvas) {
103106
canvas.save();
104107
final int w = getWidth();
105108
final int h = getHeight();
109+
final float aspect = (float)mGlowWidth / mGlowHeight;
110+
final int drawW = (int)(h*aspect);
111+
final int drawH = h;
112+
final int margin = (drawW-w)/2;
106113
canvas.scale(mGlowScale, mGlowScale, w*0.5f, h*0.5f);
107-
mGlowBG.setBounds(0, 0, w, h);
114+
mGlowBG.setBounds(-margin, 0, drawW-margin, drawH);
108115
mGlowBG.setAlpha((int)(mDrawingAlpha * mGlowAlpha * 255));
109116
mGlowBG.draw(canvas);
110117
canvas.restore();

0 commit comments

Comments
 (0)