Skip to content

Commit 37815a3

Browse files
alex-signalnicholas-signal
authored andcommitted
Fix bug with cut off avatars.
1 parent b55ba67 commit 37815a3

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

app/src/main/java/org/thoughtcrime/securesms/components/AvatarImageView.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import androidx.annotation.NonNull;
1313
import androidx.annotation.Nullable;
1414
import androidx.annotation.Px;
15+
import androidx.appcompat.widget.AppCompatImageView;
1516
import androidx.fragment.app.FragmentActivity;
1617

1718
import com.bumptech.glide.Glide;
@@ -54,7 +55,7 @@
5455
import java.util.List;
5556
import java.util.Objects;
5657

57-
public final class AvatarImageView extends ShapeableImageView {
58+
public final class AvatarImageView extends AppCompatImageView {
5859

5960
private static final int SIZE_LARGE = 1;
6061
private static final int SIZE_SMALL = 2;
@@ -77,12 +78,15 @@ public final class AvatarImageView extends ShapeableImageView {
7778

7879

7980
public AvatarImageView(Context context) {
80-
super(context);
81-
initialize(context, null);
81+
this(context, null);
8282
}
8383

8484
public AvatarImageView(Context context, AttributeSet attrs) {
85-
super(context, attrs);
85+
this(context, attrs, 0);
86+
}
87+
88+
public AvatarImageView(Context context, @Nullable AttributeSet attrs, int defStyle) {
89+
super(context, attrs, defStyle);
8690
initialize(context, attrs);
8791
}
8892

@@ -96,16 +100,9 @@ public void initialize(@NonNull Context context, @Nullable AttributeSet attrs) {
96100
typedArray.recycle();
97101
}
98102

99-
unknownRecipientDrawable = new FallbackAvatarDrawable(context, new FallbackAvatar.Resource.Person(AvatarColor.UNKNOWN));
103+
unknownRecipientDrawable = new FallbackAvatarDrawable(context, new FallbackAvatar.Resource.Person(AvatarColor.UNKNOWN)).circleCrop();
100104
blurred = false;
101105
chatColors = null;
102-
103-
setShapeAppearanceModel(ShapeAppearanceModel.builder().setAllCorners(new RoundedCornerTreatment()).setAllCornerSizes(new RelativeCornerSize(0.5f)).build());
104-
}
105-
106-
@Override
107-
public void setClipBounds(Rect clipBounds) {
108-
super.setClipBounds(clipBounds);
109106
}
110107

111108
@Override
@@ -198,7 +195,7 @@ private void setAvatar(@NonNull RequestManager requestManager, @Nullable Recipie
198195
};
199196
}
200197

201-
Drawable fallback = new FallbackAvatarDrawable(getContext(), activeFallbackPhotoProvider.getFallbackAvatar(recipient));
198+
Drawable fallback = new FallbackAvatarDrawable(getContext(), activeFallbackPhotoProvider.getFallbackAvatar(recipient)).circleCrop();
202199

203200
if (fixedSizeTarget != null) {
204201
requestManager.clear(fixedSizeTarget);
@@ -267,7 +264,7 @@ private void setAvatarClickHandler(@NonNull final Recipient recipient, boolean q
267264

268265
public void setImageBytesForGroup(@Nullable byte[] avatarBytes, @NonNull AvatarColor color)
269266
{
270-
Drawable fallback = new FallbackAvatarDrawable(getContext(), new FallbackAvatar.Resource.Group(color));
267+
Drawable fallback = new FallbackAvatarDrawable(getContext(), new FallbackAvatar.Resource.Group(color)).circleCrop();
271268

272269
Glide.with(this)
273270
.load(avatarBytes)

0 commit comments

Comments
 (0)