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
This commit is contained in:
@@ -51,10 +51,6 @@
|
|||||||
<color name="setup_wizard_wifi_color_dark">#ff00e4ff</color>
|
<color name="setup_wizard_wifi_color_dark">#ff00e4ff</color>
|
||||||
<color name="setup_wizard_wifi_color_light">#ff0096a6</color>
|
<color name="setup_wizard_wifi_color_light">#ff0096a6</color>
|
||||||
|
|
||||||
<color name="circle_avatar_frame_color">#ffffffff</color>
|
|
||||||
<color name="circle_avatar_frame_shadow_color">#80000000</color>
|
|
||||||
<color name="circle_avatar_frame_pressed_color">#ffffffff</color>
|
|
||||||
|
|
||||||
<color name="lock_pattern_background">#00000000</color>
|
<color name="lock_pattern_background">#00000000</color>
|
||||||
<color name="lock_pattern_view_regular_color">#ff37474f</color>
|
<color name="lock_pattern_view_regular_color">#ff37474f</color>
|
||||||
<color name="lock_pattern_view_success_color">@color/theme_accent</color>
|
<color name="lock_pattern_view_success_color">@color/theme_accent</color>
|
||||||
|
@@ -72,9 +72,7 @@
|
|||||||
|
|
||||||
<dimen name="pager_tabs_padding">0dp</dimen>
|
<dimen name="pager_tabs_padding">0dp</dimen>
|
||||||
|
|
||||||
<dimen name="circle_avatar_size">48dp</dimen>
|
<dimen name="circle_avatar_size">40dp</dimen>
|
||||||
<dimen name="circle_avatar_frame_stroke_width">1dp</dimen>
|
|
||||||
<dimen name="circle_avatar_frame_shadow_radius">3dp</dimen>
|
|
||||||
|
|
||||||
<!-- Minimum width for the popup for updating a user's photo. -->
|
<!-- Minimum width for the popup for updating a user's photo. -->
|
||||||
<dimen name="update_user_photo_popup_min_width">300dip</dimen>
|
<dimen name="update_user_photo_popup_min_width">300dip</dimen>
|
||||||
|
@@ -919,7 +919,8 @@ public final class Utils {
|
|||||||
return CircleFramedDrawable.getInstance(context, icon);
|
return CircleFramedDrawable.getInstance(context, icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return UserIcons.getDefaultUserIcon(user.id, /* light= */ false);
|
return CircleFramedDrawable.getInstance(context, UserIcons.convertToBitmap(
|
||||||
|
UserIcons.getDefaultUserIcon(user.id, /* light= */ false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -42,45 +42,22 @@ public class CircleFramedDrawable extends Drawable {
|
|||||||
private final Bitmap mBitmap;
|
private final Bitmap mBitmap;
|
||||||
private final int mSize;
|
private final int mSize;
|
||||||
private final Paint mPaint;
|
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 float mScale;
|
||||||
private Path mFramePath;
|
|
||||||
private Rect mSrcRect;
|
private Rect mSrcRect;
|
||||||
private RectF mDstRect;
|
private RectF mDstRect;
|
||||||
private RectF mFrameRect;
|
|
||||||
private boolean mPressed;
|
|
||||||
|
|
||||||
public static CircleFramedDrawable getInstance(Context context, Bitmap icon) {
|
public static CircleFramedDrawable getInstance(Context context, Bitmap icon) {
|
||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
float iconSize = res.getDimension(R.dimen.circle_avatar_size);
|
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,
|
CircleFramedDrawable instance = new CircleFramedDrawable(icon, (int) iconSize);
|
||||||
(int) iconSize, frameColor, strokeWidth, frameShadowColor, shadowRadius,
|
|
||||||
highlightColor);
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CircleFramedDrawable(Bitmap icon, int size,
|
public CircleFramedDrawable(Bitmap icon, int size) {
|
||||||
int frameColor, float strokeWidth,
|
|
||||||
int frameShadowColor, float shadowRadius,
|
|
||||||
int highlightColor) {
|
|
||||||
super();
|
super();
|
||||||
mSize = size;
|
mSize = size;
|
||||||
mShadowRadius = shadowRadius;
|
|
||||||
mFrameColor = frameColor;
|
|
||||||
mFrameShadowColor = frameShadowColor;
|
|
||||||
mStrokeWidth = strokeWidth;
|
|
||||||
mHighlightColor = highlightColor;
|
|
||||||
|
|
||||||
mBitmap = Bitmap.createBitmap(mSize, mSize, Bitmap.Config.ARGB_8888);
|
mBitmap = Bitmap.createBitmap(mSize, mSize, Bitmap.Config.ARGB_8888);
|
||||||
final Canvas canvas = new Canvas(mBitmap);
|
final Canvas canvas = new Canvas(mBitmap);
|
||||||
@@ -91,8 +68,6 @@ public class CircleFramedDrawable extends Drawable {
|
|||||||
|
|
||||||
final Rect cropRect = new Rect((width - square) / 2, (height - square) / 2, square, square);
|
final Rect cropRect = new Rect((width - square) / 2, (height - square) / 2, square, square);
|
||||||
final RectF circleRect = new RectF(0f, 0f, mSize, mSize);
|
final RectF circleRect = new RectF(0f, 0f, mSize, mSize);
|
||||||
circleRect.inset(mStrokeWidth / 2f, mStrokeWidth / 2f);
|
|
||||||
circleRect.inset(mShadowRadius, mShadowRadius);
|
|
||||||
|
|
||||||
final Path fillPath = new Path();
|
final Path fillPath = new Path();
|
||||||
fillPath.addArc(circleRect, 0f, 360f);
|
fillPath.addArc(circleRect, 0f, 360f);
|
||||||
@@ -117,8 +92,6 @@ public class CircleFramedDrawable extends Drawable {
|
|||||||
|
|
||||||
mSrcRect = new Rect(0, 0, mSize, mSize);
|
mSrcRect = new Rect(0, 0, mSize, mSize);
|
||||||
mDstRect = new RectF(0, 0, mSize, mSize);
|
mDstRect = new RectF(0, 0, mSize, mSize);
|
||||||
mFrameRect = new RectF(mDstRect);
|
|
||||||
mFramePath = new Path();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -128,28 +101,6 @@ public class CircleFramedDrawable extends Drawable {
|
|||||||
|
|
||||||
mDstRect.set(pad, pad, mSize - pad, mSize - pad);
|
mDstRect.set(pad, pad, mSize - pad, mSize - pad);
|
||||||
canvas.drawBitmap(mBitmap, mSrcRect, mDstRect, null);
|
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) {
|
public void setScale(float scale) {
|
||||||
@@ -160,10 +111,6 @@ public class CircleFramedDrawable extends Drawable {
|
|||||||
return mScale;
|
return mScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPressed(boolean pressed) {
|
|
||||||
mPressed = pressed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOpacity() {
|
public int getOpacity() {
|
||||||
return PixelFormat.TRANSLUCENT;
|
return PixelFormat.TRANSLUCENT;
|
||||||
|
Reference in New Issue
Block a user