Skip to content

Commit e227921

Browse files
committed
tweak avatar corner radius for issue pockethub#21
The radius is actually fixed at 3 dip for all avatar sizes (similar to what happens on the site at the moment). This looks ok to me at the sizes I've viewed so far, including the 16dp 'assigned' avatar - the rounding is more subtle.
1 parent 5c77965 commit e227921

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

app/src/main/java/com/github/mobile/android/util/AvatarHelper.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@
3838
*/
3939
public class AvatarHelper {
4040

41-
private static final int RADIUS = 8;
41+
private static final float CORNER_RADIUS_IN_DIP = 3;
4242

4343
private static final String TAG = "GHAU";
4444
private final static Pattern gravatarIdWithinUrl = Pattern.compile("/avatar/(\\p{XDigit}{32})");
4545

46-
@Inject
47-
private Resources resources;
46+
private final Resources resources;
4847

4948
@Inject
5049
@Named("gravatarStore")
@@ -61,6 +60,15 @@ public ImageSession<String, Bitmap> load(Integer imageSize) {
6160
}
6261
});
6362

63+
private final float cornerRadius;
64+
65+
@Inject
66+
public AvatarHelper(Resources resources) {
67+
this.resources = resources;
68+
cornerRadius = CORNER_RADIUS_IN_DIP * resources.getDisplayMetrics().density;
69+
}
70+
71+
6472
/**
6573
* Sets the image on the ImageView to the user's avatar.
6674
*
@@ -89,7 +97,7 @@ public ScaledAndRoundedAvatarGenerator(int sizeInPixels) {
8997

9098
public Drawable convert(Bitmap bitmap) {
9199
Bitmap scaledBitmap = createScaledBitmap(bitmap, sizeInPixels, sizeInPixels, true);
92-
return new BitmapDrawable(resources, roundCornersAndOverlayOnWhite(scaledBitmap, RADIUS));
100+
return new BitmapDrawable(resources, roundCornersAndOverlayOnWhite(scaledBitmap, cornerRadius));
93101
}
94102

95103
}

app/src/main/java/com/github/mobile/android/util/Image.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public static void setImage(final File image, final ImageView view) {
168168
* @param radius
169169
* @return rounded corner bitmap
170170
*/
171-
public static Bitmap roundCornersAndOverlayOnWhite(final Bitmap source, final int radius) {
171+
public static Bitmap roundCornersAndOverlayOnWhite(final Bitmap source, final float radius) {
172172
int width = source.getWidth();
173173
int height = source.getHeight();
174174

0 commit comments

Comments
 (0)