From b662ff6c49e26d922e982edcaffb14b2c28b07ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 4 Mar 2015 15:39:41 +0100 Subject: [PATCH] Get high res version of contact photo --- .../sufficientlysecure/keychain/ui/ViewKeyActivity.java | 2 +- .../keychain/ui/widget/EncryptKeyCompletionView.java | 2 +- .../sufficientlysecure/keychain/util/ContactHelper.java | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index 94f2bf92b..f90326a7d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -821,7 +821,7 @@ public class ViewKeyActivity extends BaseActivity implements AsyncTask photoTask = new AsyncTask() { protected Bitmap doInBackground(Long... mMasterKeyId) { - return ContactHelper.photoFromMasterKeyId(getContentResolver(), mMasterKeyId[0]); + return ContactHelper.loadPhotoByMasterKeyId(getContentResolver(), mMasterKeyId[0], true); } protected void onPostExecute(Bitmap photo) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EncryptKeyCompletionView.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EncryptKeyCompletionView.java index 48648f2cf..d20e2bc99 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EncryptKeyCompletionView.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EncryptKeyCompletionView.java @@ -90,7 +90,7 @@ public class EncryptKeyCompletionView extends TokenCompleteTextView { } private void setImageByKey(ImageView view, EncryptionKey key) { - Bitmap photo = ContactHelper.photoFromMasterKeyId(getContext().getContentResolver(), key.getKeyId()); + Bitmap photo = ContactHelper.getCachedPhotoByMasterKeyId(getContext().getContentResolver(), key.getKeyId()); if (photo != null) { view.setImageBitmap(photo); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ContactHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ContactHelper.java index 2f868912b..215cde1b7 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ContactHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ContactHelper.java @@ -245,17 +245,18 @@ public class ContactHelper { return null; } - public static Bitmap photoFromMasterKeyId(ContentResolver contentResolver, long masterKeyId) { + public static Bitmap getCachedPhotoByMasterKeyId(ContentResolver contentResolver, long masterKeyId) { if (masterKeyId == -1) { return null; } if (!photoCache.containsKey(masterKeyId)) { - photoCache.put(masterKeyId, loadPhotoFromMasterKeyId(contentResolver, masterKeyId)); + photoCache.put(masterKeyId, loadPhotoByMasterKeyId(contentResolver, masterKeyId, false)); } return photoCache.get(masterKeyId); } - private static Bitmap loadPhotoFromMasterKeyId(ContentResolver contentResolver, long masterKeyId) { + public static Bitmap loadPhotoByMasterKeyId(ContentResolver contentResolver, long masterKeyId, + boolean highRes) { if (masterKeyId == -1) { return null; } @@ -267,7 +268,7 @@ public class ContactHelper { Uri rawContactUri = ContentUris.withAppendedId(ContactsContract.RawContacts.CONTENT_URI, rawContactId); Uri contactUri = ContactsContract.RawContacts.getContactLookupUri(contentResolver, rawContactUri); InputStream photoInputStream = - ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, contactUri); + ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, contactUri, highRes); if (photoInputStream == null) { return null; }