mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-05 00:23:09 +02:00
Added widget/unified option to highlight unread messages
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user