Get high res version of contact photo
This commit is contained in:
1 parent
502a0b5376
commit
b662ff6c49
3 files changed
+7
-6
No files matched your search
@@ -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) {
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user