Added widget/unified option to highlight unread messages

This commit is contained in:
M66B 2022-04-26 09:57:42 +02:00
parent 6ed5562ce6
commit cf5dbff674
4 changed files with 27 additions and 2 deletions

View File

@ -56,6 +56,7 @@ public class ActivityWidgetUnified extends ActivityBase {
private Spinner spFolder;
private CheckBox cbUnseen;
private CheckBox cbFlagged;
private CheckBox cbHighlight;
private CheckBox cbSemiTransparent;
private ViewButtonColor btnColor;
private Spinner spFontSize;
@ -89,6 +90,7 @@ public class ActivityWidgetUnified extends ActivityBase {
long folder = prefs.getLong("widget." + appWidgetId + ".folder", -1L);
boolean unseen = prefs.getBoolean("widget." + appWidgetId + ".unseen", false);
boolean flagged = prefs.getBoolean("widget." + appWidgetId + ".flagged", false);
boolean highlight = prefs.getBoolean("widget." + appWidgetId + ".highlight", false);
boolean semi = prefs.getBoolean("widget." + appWidgetId + ".semi", true);
int background = prefs.getInt("widget." + appWidgetId + ".background", Color.TRANSPARENT);
int font = prefs.getInt("widget." + appWidgetId + ".font", 0);
@ -104,6 +106,7 @@ public class ActivityWidgetUnified extends ActivityBase {
spFolder = findViewById(R.id.spFolder);
cbUnseen = findViewById(R.id.cbUnseen);
cbFlagged = findViewById(R.id.cbFlagged);
cbHighlight = findViewById(R.id.cbHighlight);
cbSemiTransparent = findViewById(R.id.cbSemiTransparent);
btnColor = findViewById(R.id.btnColor);
spFontSize = findViewById(R.id.spFontSize);
@ -173,6 +176,7 @@ public class ActivityWidgetUnified extends ActivityBase {
editor.putString("widget." + appWidgetId + ".type", folder == null ? null : folder.type);
editor.putBoolean("widget." + appWidgetId + ".unseen", cbUnseen.isChecked());
editor.putBoolean("widget." + appWidgetId + ".flagged", cbFlagged.isChecked());
editor.putBoolean("widget." + appWidgetId + ".highlight", cbHighlight.isChecked());
editor.putBoolean("widget." + appWidgetId + ".semi", cbSemiTransparent.isChecked());
editor.putInt("widget." + appWidgetId + ".background", btnColor.getColor());
editor.putInt("widget." + appWidgetId + ".font", tinyOut(font));
@ -292,6 +296,7 @@ public class ActivityWidgetUnified extends ActivityBase {
// Initialize
cbUnseen.setChecked(unseen);
cbFlagged.setChecked(flagged);
cbHighlight.setChecked(highlight);
cbSemiTransparent.setChecked(semi);
btnColor.setColor(background);
spFontSize.setSelection(tinyIn(font));

View File

@ -659,6 +659,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) {
prefs.edit().putInt("highlight_color", selectedColor).apply();
btnHighlightColor.setColor(selectedColor);
WidgetUnified.updateData(context);
}
})
.setNegativeButton(R.string.title_reset, new DialogInterface.OnClickListener() {
@ -666,6 +667,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
public void onClick(DialogInterface dialog, int which) {
prefs.edit().remove("highlight_color").apply();
btnHighlightColor.setColor(Helper.resolveColor(context, R.attr.colorAccent));
WidgetUnified.updateData(context);
}
});

View File

@ -29,6 +29,7 @@ import android.os.Build;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.text.style.UnderlineSpan;
import android.util.TypedValue;
@ -57,6 +58,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
private long account;
private boolean unseen;
private boolean flagged;
private boolean highlight;
private boolean semi;
private int background;
private int font;
@ -66,6 +68,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
private boolean distinguish_contacts;
private int colorStripeWidth;
private int colorWidgetForeground;
private int colorUnreadHighlight;
private int colorWidgetRead;
private int colorSeparator;
private boolean pro;
@ -97,6 +100,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
folder = prefs.getLong("widget." + appWidgetId + ".folder", -1L);
unseen = prefs.getBoolean("widget." + appWidgetId + ".unseen", false);
flagged = prefs.getBoolean("widget." + appWidgetId + ".flagged", false);
highlight = prefs.getBoolean("widget." + appWidgetId + ".highlight", false);
semi = prefs.getBoolean("widget." + appWidgetId + ".semi", true);
background = prefs.getInt("widget." + appWidgetId + ".background", Color.TRANSPARENT);
font = prefs.getInt("widget." + appWidgetId + ".font", 0);
@ -109,6 +113,8 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
this.colorStripeWidth = Helper.dp2pixels(context, color_stripe_wide ? 12 : 6);
colorWidgetForeground = ContextCompat.getColor(context, R.color.colorWidgetForeground);
colorUnreadHighlight = prefs.getInt("highlight_color", Helper.resolveColor(context, R.attr.colorUnreadHighlight));
colorUnreadHighlight = ColorUtils.setAlphaComponent(colorUnreadHighlight, 255);
colorWidgetRead = ContextCompat.getColor(context, R.color.colorWidgetRead);
colorSeparator = ContextCompat.getColor(context, R.color.lightColorSeparator);
@ -227,7 +233,9 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
views.setTextViewText(idSubject, ssSubject);
views.setTextViewText(idAccount, ssAccount);
int textColor = (message.ui_seen ? colorWidgetRead : colorWidgetForeground);
int textColor = (message.ui_seen
? colorWidgetRead
: (highlight ? colorUnreadHighlight : colorWidgetForeground));
views.setTextColor(idFrom, textColor);
views.setTextColor(idTime, textColor);

View File

@ -65,6 +65,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbUnseen" />
<CheckBox
android:id="@+id/cbHighlight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_highlight_unread"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbFlagged" />
<CheckBox
android:id="@+id/cbSemiTransparent"
android:layout_width="wrap_content"
@ -73,7 +83,7 @@
android:checked="true"
android:text="@string/title_widget_semi_transparent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbFlagged" />
app:layout_constraintTop_toBottomOf="@id/cbHighlight" />
<eu.faircode.email.ViewButtonColor
android:id="@+id/btnColor"