From 34edc926b72b9bc458b15b9c1168162fef3ec19b Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 24 Feb 2022 15:20:40 +0100 Subject: [PATCH] Chip avatar circular --- .../java/eu/faircode/email/EditTextMultiAutoComplete.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/EditTextMultiAutoComplete.java b/app/src/main/java/eu/faircode/email/EditTextMultiAutoComplete.java index e278e4c766..0eb7dfa06c 100644 --- a/app/src/main/java/eu/faircode/email/EditTextMultiAutoComplete.java +++ b/app/src/main/java/eu/faircode/email/EditTextMultiAutoComplete.java @@ -200,10 +200,12 @@ public class EditTextMultiAutoComplete extends AppCompatMultiAutoCompleteTextVie final Context context = getContext(); final Resources res = getResources(); final Editable edit = getText(); + final int dp3 = Helper.dp2pixels(context, 3); final int dp24 = Helper.dp2pixels(context, 24); final boolean send_chips = prefs.getBoolean("send_chips", true); boolean generated = prefs.getBoolean("generated_icons", true); boolean identicons = prefs.getBoolean("identicons", false); + boolean circular = prefs.getBoolean("circular", true); final boolean focus = hasFocus(); final int selStart = getSelectionStart(); @@ -273,12 +275,15 @@ public class EditTextMultiAutoComplete extends AppCompatMultiAutoCompleteTextVie Log.e(ex); } - if (bm == null && generated) + if (bm == null && generated && !TextUtils.isEmpty(email)) if (identicons) bm = ImageHelper.generateIdenticon(e, dp24, 5, context); else bm = ImageHelper.generateLetterIcon(e, p, dp24, context); + if (bm != null && circular && !identicons) + bm = ImageHelper.makeCircular(bm, dp3); + Drawable avatar = (bm == null ? null : new BitmapDrawable(res, bm)); String text = (TextUtils.isEmpty(p) ? e : p);