From 8397ba603c9eacbd095a15478d60d5f7b85845a8 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Thu, 25 Apr 2013 10:33:08 -0700 Subject: [PATCH] CircleFramedDrawable incorrectly has implicit dependency on the hosting view size. CircleFramedDrawable was trying to draw itself as big as the hosting view by looking at the canvas size. However, due to inconsistent API behavior for the cases with and without hardware acceleration the canvas size returns the size of clipped canvas or the size of the entire canvas, respectively. While we should fix the inconsistent API behavior, it is not correct for a lower level component to know about the higher level one, i.e. a drawable trying to infer the size of the hosting view. The hosting view should set the size of the drawable. This change removes the dependency on the host view size and if one wants to enlarge the drawable, he/she should just set the scale. bug:8671059 Change-Id: Idc572da7dff60fd10cb37d3c3eca27aac2c0a21f --- src/com/android/settings/users/CircleFramedDrawable.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/com/android/settings/users/CircleFramedDrawable.java b/src/com/android/settings/users/CircleFramedDrawable.java index 7af25089de4..671cfbe2a59 100644 --- a/src/com/android/settings/users/CircleFramedDrawable.java +++ b/src/com/android/settings/users/CircleFramedDrawable.java @@ -123,12 +123,10 @@ class CircleFramedDrawable extends Drawable { @Override public void draw(Canvas canvas) { - // clear background - final float outside = Math.min(canvas.getWidth(), canvas.getHeight()); - final float inside = mScale * outside; - final float pad = (outside - inside) / 2f; + final float inside = mScale * mSize; + final float pad = (mSize - inside) / 2f; - mDstRect.set(pad, pad, outside - pad, outside - pad); + mDstRect.set(pad, pad, mSize - pad, mSize - pad); canvas.drawBitmap(mBitmap, mSrcRect, mDstRect, null); mFrameRect.set(mDstRect);