diff --git a/app/src/main/java/eu/faircode/email/ActivityWidgetUnified.java b/app/src/main/java/eu/faircode/email/ActivityWidgetUnified.java index 15e10db892..627adc8b01 100644 --- a/app/src/main/java/eu/faircode/email/ActivityWidgetUnified.java +++ b/app/src/main/java/eu/faircode/email/ActivityWidgetUnified.java @@ -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); diff --git a/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java b/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java index 244ddb7e38..939763ba9c 100644 --- a/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java +++ b/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java @@ -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); diff --git a/app/src/main/res/layout/activity_widget_unified.xml b/app/src/main/res/layout/activity_widget_unified.xml index 1dc6abda3e..1f5ecde2f4 100644 --- a/app/src/main/res/layout/activity_widget_unified.xml +++ b/app/src/main/res/layout/activity_widget_unified.xml @@ -156,6 +156,16 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvPadding" /> + + + app:layout_constraintTop_toBottomOf="@id/cbAvatars" /> + + Padding size Show separator lines Semi transparent background + Show contact avatars Show refresh messages button Show compose new message button Background color