Added widget/unified option to highlight unread messages

pull/207/head
M66B 2 years ago
parent 6ed5562ce6
commit cf5dbff674

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

@ -659,6 +659,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) { public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) {
prefs.edit().putInt("highlight_color", selectedColor).apply(); prefs.edit().putInt("highlight_color", selectedColor).apply();
btnHighlightColor.setColor(selectedColor); btnHighlightColor.setColor(selectedColor);
WidgetUnified.updateData(context);
} }
}) })
.setNegativeButton(R.string.title_reset, new DialogInterface.OnClickListener() { .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) { public void onClick(DialogInterface dialog, int which) {
prefs.edit().remove("highlight_color").apply(); prefs.edit().remove("highlight_color").apply();
btnHighlightColor.setColor(Helper.resolveColor(context, R.attr.colorAccent)); 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.SpannableString;
import android.text.Spanned; import android.text.Spanned;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan; import android.text.style.StyleSpan;
import android.text.style.UnderlineSpan; import android.text.style.UnderlineSpan;
import android.util.TypedValue; import android.util.TypedValue;
@ -57,6 +58,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
private long account; private long account;
private boolean unseen; private boolean unseen;
private boolean flagged; private boolean flagged;
private boolean highlight;
private boolean semi; private boolean semi;
private int background; private int background;
private int font; private int font;
@ -66,6 +68,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
private boolean distinguish_contacts; private boolean distinguish_contacts;
private int colorStripeWidth; private int colorStripeWidth;
private int colorWidgetForeground; private int colorWidgetForeground;
private int colorUnreadHighlight;
private int colorWidgetRead; private int colorWidgetRead;
private int colorSeparator; private int colorSeparator;
private boolean pro; private boolean pro;
@ -97,6 +100,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
folder = prefs.getLong("widget." + appWidgetId + ".folder", -1L); folder = prefs.getLong("widget." + appWidgetId + ".folder", -1L);
unseen = prefs.getBoolean("widget." + appWidgetId + ".unseen", false); unseen = prefs.getBoolean("widget." + appWidgetId + ".unseen", false);
flagged = prefs.getBoolean("widget." + appWidgetId + ".flagged", false); flagged = prefs.getBoolean("widget." + appWidgetId + ".flagged", false);
highlight = prefs.getBoolean("widget." + appWidgetId + ".highlight", false);
semi = prefs.getBoolean("widget." + appWidgetId + ".semi", true); semi = prefs.getBoolean("widget." + appWidgetId + ".semi", true);
background = prefs.getInt("widget." + appWidgetId + ".background", Color.TRANSPARENT); background = prefs.getInt("widget." + appWidgetId + ".background", Color.TRANSPARENT);
font = prefs.getInt("widget." + appWidgetId + ".font", 0); 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); this.colorStripeWidth = Helper.dp2pixels(context, color_stripe_wide ? 12 : 6);
colorWidgetForeground = ContextCompat.getColor(context, R.color.colorWidgetForeground); 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); colorWidgetRead = ContextCompat.getColor(context, R.color.colorWidgetRead);
colorSeparator = ContextCompat.getColor(context, R.color.lightColorSeparator); colorSeparator = ContextCompat.getColor(context, R.color.lightColorSeparator);
@ -227,7 +233,9 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
views.setTextViewText(idSubject, ssSubject); views.setTextViewText(idSubject, ssSubject);
views.setTextViewText(idAccount, ssAccount); 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(idFrom, textColor);
views.setTextColor(idTime, textColor); views.setTextColor(idTime, textColor);

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

Loading…
Cancel
Save