Remove frame and shadow from CircleFramedDrawable
Also change the size the circled icon is drawn into to a 40dp by 40dp rect.
Bug: 18198624
Change-Id: I66d919a2f35ede614a90a423d2967a4c3bc18169
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 6517ffe..678e05f 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -919,7 +919,8 @@
return CircleFramedDrawable.getInstance(context, icon);
}
}
- return UserIcons.getDefaultUserIcon(user.id, /* light= */ false);
+ return CircleFramedDrawable.getInstance(context, UserIcons.convertToBitmap(
+ UserIcons.getDefaultUserIcon(user.id, /* light= */ false)));
}
/**
diff --git a/src/com/android/settings/drawable/CircleFramedDrawable.java b/src/com/android/settings/drawable/CircleFramedDrawable.java
index 97c96a0..31b8922 100644
--- a/src/com/android/settings/drawable/CircleFramedDrawable.java
+++ b/src/com/android/settings/drawable/CircleFramedDrawable.java
@@ -42,45 +42,22 @@
private final Bitmap mBitmap;
private final int mSize;
private final Paint mPaint;
- private final float mShadowRadius;
- private final float mStrokeWidth;
- private final int mFrameColor;
- private final int mHighlightColor;
- private final int mFrameShadowColor;
private float mScale;
- private Path mFramePath;
private Rect mSrcRect;
private RectF mDstRect;
- private RectF mFrameRect;
- private boolean mPressed;
public static CircleFramedDrawable getInstance(Context context, Bitmap icon) {
Resources res = context.getResources();
float iconSize = res.getDimension(R.dimen.circle_avatar_size);
- float strokeWidth = res.getDimension(R.dimen.circle_avatar_frame_stroke_width);
- float shadowRadius = res.getDimension(R.dimen.circle_avatar_frame_shadow_radius);
- int frameColor = res.getColor(R.color.circle_avatar_frame_color);
- int frameShadowColor = res.getColor(R.color.circle_avatar_frame_shadow_color);
- int highlightColor = res.getColor(R.color.circle_avatar_frame_pressed_color);
- CircleFramedDrawable instance = new CircleFramedDrawable(icon,
- (int) iconSize, frameColor, strokeWidth, frameShadowColor, shadowRadius,
- highlightColor);
+ CircleFramedDrawable instance = new CircleFramedDrawable(icon, (int) iconSize);
return instance;
}
- public CircleFramedDrawable(Bitmap icon, int size,
- int frameColor, float strokeWidth,
- int frameShadowColor, float shadowRadius,
- int highlightColor) {
+ public CircleFramedDrawable(Bitmap icon, int size) {
super();
mSize = size;
- mShadowRadius = shadowRadius;
- mFrameColor = frameColor;
- mFrameShadowColor = frameShadowColor;
- mStrokeWidth = strokeWidth;
- mHighlightColor = highlightColor;
mBitmap = Bitmap.createBitmap(mSize, mSize, Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(mBitmap);
@@ -91,8 +68,6 @@
final Rect cropRect = new Rect((width - square) / 2, (height - square) / 2, square, square);
final RectF circleRect = new RectF(0f, 0f, mSize, mSize);
- circleRect.inset(mStrokeWidth / 2f, mStrokeWidth / 2f);
- circleRect.inset(mShadowRadius, mShadowRadius);
final Path fillPath = new Path();
fillPath.addArc(circleRect, 0f, 360f);
@@ -117,8 +92,6 @@
mSrcRect = new Rect(0, 0, mSize, mSize);
mDstRect = new RectF(0, 0, mSize, mSize);
- mFrameRect = new RectF(mDstRect);
- mFramePath = new Path();
}
@Override
@@ -128,28 +101,6 @@
mDstRect.set(pad, pad, mSize - pad, mSize - pad);
canvas.drawBitmap(mBitmap, mSrcRect, mDstRect, null);
-
- mFrameRect.set(mDstRect);
- mFrameRect.inset(mStrokeWidth / 2f, mStrokeWidth / 2f);
- mFrameRect.inset(mShadowRadius, mShadowRadius);
-
- mFramePath.reset();
- mFramePath.addArc(mFrameRect, 0f, 360f);
-
- // white frame
- if (mPressed) {
- mPaint.setStyle(Paint.Style.FILL);
- mPaint.setColor(Color.argb((int) (0.33f * 255),
- Color.red(mHighlightColor),
- Color.green(mHighlightColor),
- Color.blue(mHighlightColor)));
- canvas.drawPath(mFramePath, mPaint);
- }
- mPaint.setStrokeWidth(mStrokeWidth);
- mPaint.setStyle(Paint.Style.STROKE);
- mPaint.setColor(mPressed ? mHighlightColor : mFrameColor);
- mPaint.setShadowLayer(mShadowRadius, 0f, 0f, mFrameShadowColor);
- canvas.drawPath(mFramePath, mPaint);
}
public void setScale(float scale) {
@@ -160,10 +111,6 @@
return mScale;
}
- public void setPressed(boolean pressed) {
- mPressed = pressed;
- }
-
@Override
public int getOpacity() {
return PixelFormat.TRANSLUCENT;