aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2015-03-04 15:39:41 +0100
committerDominik Schürmann <dominik@dominikschuermann.de>2015-03-04 15:39:41 +0100
commitb662ff6c49e26d922e982edcaffb14b2c28b07ee (patch)
tree4304f02f25439e2ea408bf27370eb4b5de9903b6
parent502a0b5376993a87d4d249b163156433c7c12053 (diff)
downloadopen-keychain-b662ff6c49e26d922e982edcaffb14b2c28b07ee.tar.gz
open-keychain-b662ff6c49e26d922e982edcaffb14b2c28b07ee.tar.bz2
open-keychain-b662ff6c49e26d922e982edcaffb14b2c28b07ee.zip
Get high res version of contact photo
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EncryptKeyCompletionView.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ContactHelper.java9
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<Long, Void, Bitmap> photoTask =
new AsyncTask<Long, Void, Bitmap>() {
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;
}