Added color stripe to unified inbox widget

This commit is contained in:
M66B 2020-05-15 15:32:58 +02:00
parent 2aa012a12d
commit 2b8d531d2c
6 changed files with 76 additions and 48 deletions

2
FAQ.md
View File

@ -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.

View File

@ -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)" +

View File

@ -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());
}
});

View File

@ -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;
}

View File

@ -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<TupleMessageWidget> 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));

View File

@ -2,62 +2,75 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/llMessage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="6dp"
android:paddingBottom="6dp">
android:layout_height="wrap_content"
android:orientation="horizontal">
<FrameLayout
android:id="@+id/stripe"
android:layout_width="3dp"
android:layout_height="match_parent"
android:background="@android:color/darker_gray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:layout_marginStart="3dp"
android:orientation="vertical"
android:paddingTop="6dp"
android:paddingBottom="6dp">
<TextView
android:id="@+id/tvFrom"
android:layout_width="0dp"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="From"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="@color/colorWidgetForeground" />
android:orientation="horizontal">
<TextView
android:id="@+id/tvTime"
android:layout_width="wrap_content"
<TextView
android:id="@+id/tvFrom"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="From"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="@color/colorWidgetForeground" />
<TextView
android:id="@+id/tvTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:maxLines="1"
android:text="12:34"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="@color/colorWidgetForeground" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:maxLines="1"
android:text="12:34"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="@color/colorWidgetForeground" />
</LinearLayout>
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tvSubject"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="Subject"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="@color/colorWidgetForeground" />
<TextView
android:id="@+id/tvSubject"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="Subject"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="@color/colorWidgetForeground" />
<TextView
android:id="@+id/tvAccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:maxLines="1"
android:text="Account"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="@color/colorWidgetForeground" />
<TextView
android:id="@+id/tvAccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:maxLines="1"
android:text="Account"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="@color/colorWidgetForeground" />
</LinearLayout>
</LinearLayout>
</LinearLayout>