mirror of
https://github.com/M66B/FairEmail.git
synced 2025-12-30 09:31:11 +01:00
Added identicons
This commit is contained in:
@@ -26,6 +26,7 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
@@ -112,9 +113,12 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
||||
|
||||
private boolean contacts;
|
||||
private boolean avatars;
|
||||
private boolean identicons;
|
||||
private boolean compact;
|
||||
private boolean debug;
|
||||
|
||||
private int dp24;
|
||||
|
||||
private SelectionTracker<Long> selectionTracker = null;
|
||||
|
||||
private DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.LONG, SimpleDateFormat.LONG);
|
||||
@@ -276,14 +280,23 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
||||
pbLoading.setVisibility(View.GONE);
|
||||
|
||||
boolean photo = false;
|
||||
if (avatars && message.avatar != null) {
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
InputStream is = ContactsContract.Contacts.openContactPhotoInputStream(resolver, Uri.parse(message.avatar));
|
||||
if (is != null) {
|
||||
photo = true;
|
||||
ivAvatar.setImageDrawable(Drawable.createFromStream(is, "avatar"));
|
||||
if (avatars) {
|
||||
if (message.avatar != null) {
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
InputStream is = ContactsContract.Contacts.openContactPhotoInputStream(resolver, Uri.parse(message.avatar));
|
||||
if (is != null) {
|
||||
photo = true;
|
||||
ivAvatar.setImageDrawable(Drawable.createFromStream(is, "avatar"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!photo && identicons) {
|
||||
if (message.from.length > 0)
|
||||
ivAvatar.setImageBitmap(Identicon.generate(((InternetAddress) message.from[0]).getAddress(), dp24, 5));
|
||||
else
|
||||
ivAvatar.setImageDrawable(null);
|
||||
photo = true;
|
||||
}
|
||||
ivAvatar.setVisibility(photo ? View.VISIBLE : View.GONE);
|
||||
|
||||
vwColor.setBackgroundColor(message.accountColor == null ? Color.TRANSPARENT : message.accountColor);
|
||||
@@ -1391,8 +1404,11 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
||||
this.contacts = (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS)
|
||||
== PackageManager.PERMISSION_GRANTED);
|
||||
this.avatars = (prefs.getBoolean("avatars", true) && this.contacts);
|
||||
this.identicons = prefs.getBoolean("identicons", true);
|
||||
this.compact = prefs.getBoolean("compact", false);
|
||||
this.debug = prefs.getBoolean("debug", false);
|
||||
|
||||
this.dp24 = Math.round(24 * Resources.getSystem().getDisplayMetrics().density);
|
||||
}
|
||||
|
||||
private static final DiffUtil.ItemCallback<TupleMessageEx> DIFF_CALLBACK =
|
||||
|
||||
Reference in New Issue
Block a user