1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-03-01 01:06:11 +00:00

Scale contact images

This commit is contained in:
M66B 2024-07-10 17:39:54 +02:00
parent 2b4fdd6180
commit 9c9dd8e739

View file

@ -103,6 +103,7 @@ public class ContactInfo {
private static Map<String, Lookup> emailLookup = new ConcurrentHashMap<>();
private static final Map<String, ContactInfo> emailContactInfo = new HashMap<>();
private static final int CONTACT_ICON_SIZE = 64; // dp
private static final int GENERATED_ICON_SIZE = 48; // dp
private static final int FAVICON_ICON_SIZE = 64; // dp
private static final int FAVICON_CONNECT_TIMEOUT = 5 * 1000; // milliseconds
@ -320,11 +321,12 @@ public class ContactInfo {
long contactId = cursor.getLong(colContactId);
String lookupKey = cursor.getString(colLookupKey);
Uri lookupUri = ContactsContract.Contacts.getLookupUri(contactId, lookupKey);
int px = Helper.dp2pixels(context, CONTACT_ICON_SIZE);
if (avatars)
try (InputStream is = ContactsContract.Contacts.openContactPhotoInputStream(
resolver, lookupUri, false)) {
info.bitmap = BitmapFactory.decodeStream(is);
info.bitmap = ImageHelper.getScaledBitmap(is, lookupUri.toString(), null, px);
info.type = "contact";
} catch (Throwable ex) {
Log.e(ex);