mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-06 17:13:23 +02:00
Added widget contact avatars option
This commit is contained in:
@@ -64,6 +64,7 @@ public class ActivityWidgetUnified extends ActivityBase {
|
||||
private ViewButtonColor btnColor;
|
||||
private Spinner spFontSize;
|
||||
private Spinner spPadding;
|
||||
private CheckBox cbAvatars;
|
||||
private CheckBox cbRefresh;
|
||||
private CheckBox cbCompose;
|
||||
private Button btnSave;
|
||||
@@ -102,6 +103,7 @@ public class ActivityWidgetUnified extends ActivityBase {
|
||||
int padding = prefs.getInt("widget." + appWidgetId + ".padding", 0);
|
||||
boolean refresh = prefs.getBoolean("widget." + appWidgetId + ".refresh", false);
|
||||
boolean compose = prefs.getBoolean("widget." + appWidgetId + ".compose", false);
|
||||
boolean avatars = prefs.getBoolean("widget." + appWidgetId + ".avatars", false);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setSubtitle(R.string.title_widget_title_list);
|
||||
@@ -118,6 +120,7 @@ public class ActivityWidgetUnified extends ActivityBase {
|
||||
btnColor = findViewById(R.id.btnColor);
|
||||
spFontSize = findViewById(R.id.spFontSize);
|
||||
spPadding = findViewById(R.id.spPadding);
|
||||
cbAvatars = findViewById(R.id.cbAvatars);
|
||||
cbRefresh = findViewById(R.id.cbRefresh);
|
||||
cbCompose = findViewById(R.id.cbCompose);
|
||||
btnSave = findViewById(R.id.btnSave);
|
||||
@@ -227,6 +230,7 @@ public class ActivityWidgetUnified extends ActivityBase {
|
||||
editor.putInt("widget." + appWidgetId + ".background", btnColor.getColor());
|
||||
editor.putInt("widget." + appWidgetId + ".font", tinyOut(font));
|
||||
editor.putInt("widget." + appWidgetId + ".padding", tinyOut(padding));
|
||||
editor.putBoolean("widget." + appWidgetId + ".avatars", cbAvatars.isChecked());
|
||||
editor.putBoolean("widget." + appWidgetId + ".refresh", cbRefresh.isChecked());
|
||||
editor.putBoolean("widget." + appWidgetId + ".compose", cbCompose.isChecked());
|
||||
editor.putInt("widget." + appWidgetId + ".version", BuildConfig.VERSION_CODE);
|
||||
@@ -350,6 +354,7 @@ public class ActivityWidgetUnified extends ActivityBase {
|
||||
btnColor.setColor(background);
|
||||
spFontSize.setSelection(tinyIn(font));
|
||||
spPadding.setSelection(tinyIn(padding));
|
||||
cbAvatars.setChecked(avatars);
|
||||
cbRefresh.setChecked(refresh);
|
||||
cbCompose.setChecked(compose);
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
|
||||
private int background;
|
||||
private int font;
|
||||
private int padding;
|
||||
private boolean avatars;
|
||||
private boolean prefer_contact;
|
||||
private boolean only_contact;
|
||||
private boolean distinguish_contacts;
|
||||
@@ -100,6 +101,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
|
||||
subject_top = prefs.getBoolean("subject_top", false);
|
||||
subject_italic = prefs.getBoolean("subject_italic", true);
|
||||
color_stripe = prefs.getBoolean("color_stripe", true);
|
||||
|
||||
account = prefs.getLong("widget." + appWidgetId + ".account", -1L);
|
||||
folder = prefs.getLong("widget." + appWidgetId + ".folder", -1L);
|
||||
unseen = prefs.getBoolean("widget." + appWidgetId + ".unseen", false);
|
||||
@@ -111,6 +113,8 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
|
||||
background = prefs.getInt("widget." + appWidgetId + ".background", Color.TRANSPARENT);
|
||||
font = prefs.getInt("widget." + appWidgetId + ".font", 0);
|
||||
padding = prefs.getInt("widget." + appWidgetId + ".padding", 0);
|
||||
avatars = prefs.getBoolean("widget." + appWidgetId + ".avatars", false);
|
||||
|
||||
prefer_contact = prefs.getBoolean("prefer_contact", false);
|
||||
only_contact = prefs.getBoolean("only_contact", false);
|
||||
distinguish_contacts = prefs.getBoolean("distinguish_contacts", false);
|
||||
@@ -214,6 +218,12 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
|
||||
views.setInt(R.id.stripe, "setBackgroundColor", colorBackground);
|
||||
views.setViewVisibility(R.id.stripe, hasColor && color_stripe ? View.VISIBLE : View.GONE);
|
||||
|
||||
if (avatars) {
|
||||
ContactInfo[] info = ContactInfo.get(context, message.account, null, message.bimi_selector, message.from);
|
||||
views.setImageViewBitmap(R.id.avatar, info.length == 0 ? null : info[0].getPhotoBitmap());
|
||||
}
|
||||
views.setViewVisibility(R.id.avatar, avatars ? View.VISIBLE : View.GONE);
|
||||
|
||||
Address[] recipients = ContactInfo.fillIn(message.from, prefer_contact, only_contact);
|
||||
boolean known = (distinguish_contacts && ContactInfo.getLookupUri(message.from) != null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user