Scale contact images

pull/215/head
M66B 1 year ago
parent 2b4fdd6180
commit 9c9dd8e739

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

Loading…
Cancel
Save