diff --git a/FAQ.md b/FAQ.md index 7e10be6df6..253f713918 100644 --- a/FAQ.md +++ b/FAQ.md @@ -2483,7 +2483,7 @@ Checking *Remove tracking parameters* will remove all [UTM parameters](https://e The widget is designed to look good on most home/launcher screens by making it monochrome and by using a half transparent background. This way the widget will nicely blend in, while still being properly readable. -Adding (account) colors will cause problems with some backgrounds and will cause readability problems, which is why this won't be added. +Adding colors will cause problems with some backgrounds and will cause readability problems, which is why this won't be added. Due to Android limitations it is not possible to dynamically set the opacity of the background and to have rounded corners at the same time. diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index c38cf40a8d..ced2bc1e02 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -460,12 +460,14 @@ public interface DaoMessage { @Query("SELECT message.*" + ", account.name AS accountName" + + ", COALESCE(identity.color, folder.color, account.color) AS accountColor" + ", SUM(1 - message.ui_seen) AS unseen" + ", COUNT(message.id) - SUM(message.ui_flagged) AS unflagged" + ", MAX(message.received) AS dummy" + " FROM message" + " JOIN account_view AS account ON account.id = message.account" + " JOIN folder_view AS folder ON folder.id = message.folder" + + " LEFT JOIN identity ON identity.id = message.identity" + " WHERE account.`synchronize`" + " AND (:account IS NULL OR account.id = :account)" + " AND ((:folder IS NULL AND folder.unified) OR folder.id = :folder)" + diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java index 5f1c7a608f..7c8ec5f6ea 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java @@ -312,6 +312,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { prefs.edit().putBoolean("color_stripe", checked).apply(); + WidgetUnified.updateData(getContext()); } }); diff --git a/app/src/main/java/eu/faircode/email/TupleMessageWidget.java b/app/src/main/java/eu/faircode/email/TupleMessageWidget.java index ba7838993e..778507db2f 100644 --- a/app/src/main/java/eu/faircode/email/TupleMessageWidget.java +++ b/app/src/main/java/eu/faircode/email/TupleMessageWidget.java @@ -21,6 +21,7 @@ package eu.faircode.email; public class TupleMessageWidget extends EntityMessage { public String accountName; + public Integer accountColor; public int unseen; public int unflagged; } diff --git a/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java b/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java index cc61314a4c..b8d51632f2 100644 --- a/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java +++ b/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java @@ -45,12 +45,14 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot private boolean threading; private boolean subject_top; private boolean subject_italic; + private boolean color_stripe; private long folder; private long account; private boolean unseen; private boolean flagged; private int colorWidgetForeground; private int colorWidgetRead; + private int colorSeparator; private boolean pro; private List messages = new ArrayList<>(); @@ -74,12 +76,14 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot threading = prefs.getBoolean("threading", true); 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); flagged = prefs.getBoolean("widget." + appWidgetId + ".flagged", false); colorWidgetForeground = ContextCompat.getColor(context, R.color.colorWidgetForeground); colorWidgetRead = ContextCompat.getColor(context, R.color.colorWidgetRead); + colorSeparator = ContextCompat.getColor(context, R.color.lightColorSeparator); pro = ActivityBilling.isPro(context); @@ -128,6 +132,13 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot thread.putExtra("id", message.id); views.setOnClickFillInIntent(R.id.llMessage, thread); + int colorBackground = + (message.accountColor == null || !ActivityBilling.isPro(context) + ? colorSeparator : message.accountColor); + + views.setInt(R.id.stripe, "setBackgroundColor", colorBackground); + views.setViewVisibility(R.id.stripe, account < 0 && color_stripe ? View.VISIBLE : View.GONE); + SpannableString ssFrom = new SpannableString(pro ? MessageHelper.formatAddressesShort(message.from) : context.getString(R.string.title_pro_feature)); diff --git a/app/src/main/res/layout/item_widget_unified.xml b/app/src/main/res/layout/item_widget_unified.xml index af3e0e2234..d2665ad954 100644 --- a/app/src/main/res/layout/item_widget_unified.xml +++ b/app/src/main/res/layout/item_widget_unified.xml @@ -2,62 +2,75 @@ + android:layout_height="wrap_content" + android:orientation="horizontal"> + + + android:layout_marginStart="3dp" + android:orientation="vertical" + android:paddingTop="6dp" + android:paddingBottom="6dp"> - - - - + android:orientation="horizontal"> - + - - - + + + + android:orientation="horizontal"> + + + + + \ No newline at end of file