From 9fc3fa16bbb89609bf76f7bc811f36685711d024 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 30 Apr 2022 08:24:54 +0200 Subject: [PATCH] Added widget option to disable separator lines --- .../eu/faircode/email/ActivityWidgetUnified.java | 5 +++++ .../main/java/eu/faircode/email/WidgetUnified.java | 3 +++ .../email/WidgetUnifiedRemoteViewsFactory.java | 4 ++++ app/src/main/res/layout/activity_widget_unified.xml | 12 +++++++++++- app/src/main/res/values/strings.xml | 1 + 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityWidgetUnified.java b/app/src/main/java/eu/faircode/email/ActivityWidgetUnified.java index 1fcc40f30a..7c48b9e105 100644 --- a/app/src/main/java/eu/faircode/email/ActivityWidgetUnified.java +++ b/app/src/main/java/eu/faircode/email/ActivityWidgetUnified.java @@ -57,6 +57,7 @@ public class ActivityWidgetUnified extends ActivityBase { private CheckBox cbUnseen; private CheckBox cbFlagged; private CheckBox cbHighlight; + private CheckBox cbSeparatorLines; private CheckBox cbSemiTransparent; private ViewButtonColor btnColor; private Spinner spFontSize; @@ -91,6 +92,7 @@ public class ActivityWidgetUnified extends ActivityBase { 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 separators = prefs.getBoolean("widget." + appWidgetId + ".separators", true); 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); @@ -107,6 +109,7 @@ public class ActivityWidgetUnified extends ActivityBase { cbUnseen = findViewById(R.id.cbUnseen); cbFlagged = findViewById(R.id.cbFlagged); cbHighlight = findViewById(R.id.cbHighlight); + cbSeparatorLines = findViewById(R.id.cbSeparatorLines); cbSemiTransparent = findViewById(R.id.cbSemiTransparent); btnColor = findViewById(R.id.btnColor); spFontSize = findViewById(R.id.spFontSize); @@ -177,6 +180,7 @@ public class ActivityWidgetUnified extends ActivityBase { 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 + ".separators", cbSeparatorLines.isChecked()); editor.putBoolean("widget." + appWidgetId + ".semi", cbSemiTransparent.isChecked()); editor.putInt("widget." + appWidgetId + ".background", btnColor.getColor()); editor.putInt("widget." + appWidgetId + ".font", tinyOut(font)); @@ -297,6 +301,7 @@ public class ActivityWidgetUnified extends ActivityBase { cbUnseen.setChecked(unseen); cbFlagged.setChecked(flagged); cbHighlight.setChecked(highlight); + cbSeparatorLines.setChecked(separators); cbSemiTransparent.setChecked(semi); btnColor.setColor(background); spFontSize.setSelection(tinyIn(font)); diff --git a/app/src/main/java/eu/faircode/email/WidgetUnified.java b/app/src/main/java/eu/faircode/email/WidgetUnified.java index 5ffec8e513..a8c83a8837 100644 --- a/app/src/main/java/eu/faircode/email/WidgetUnified.java +++ b/app/src/main/java/eu/faircode/email/WidgetUnified.java @@ -49,6 +49,7 @@ public class WidgetUnified extends AppWidgetProvider { long account = prefs.getLong("widget." + appWidgetId + ".account", -1L); long folder = prefs.getLong("widget." + appWidgetId + ".folder", -1L); String type = prefs.getString("widget." + appWidgetId + ".type", null); + boolean separators = prefs.getBoolean("widget." + appWidgetId + ".separators", true); 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); @@ -168,6 +169,8 @@ public class WidgetUnified extends AppWidgetProvider { : R.drawable.twotone_edit_24_white); } + views.setViewVisibility(R.id.separator, separators ? View.VISIBLE : View.GONE); + int dp6 = Helper.dp2pixels(context, 6); views.setViewPadding(R.id.content, dp6, 0, dp6, 0); diff --git a/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java b/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java index 278e4b0d1a..0fad0a0032 100644 --- a/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java +++ b/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java @@ -59,6 +59,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot private boolean unseen; private boolean flagged; private boolean highlight; + private boolean separators; private boolean semi; private int background; private int font; @@ -101,6 +102,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot unseen = prefs.getBoolean("widget." + appWidgetId + ".unseen", false); flagged = prefs.getBoolean("widget." + appWidgetId + ".flagged", false); highlight = prefs.getBoolean("widget." + appWidgetId + ".highlight", false); + separators = prefs.getBoolean("widget." + appWidgetId + ".separators", true); semi = prefs.getBoolean("widget." + appWidgetId + ".semi", true); background = prefs.getInt("widget." + appWidgetId + ".background", Color.TRANSPARENT); font = prefs.getInt("widget." + appWidgetId + ".font", 0); @@ -239,7 +241,9 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot views.setTextColor(idTime, textColor); views.setTextColor(idSubject, textColor); views.setTextColor(idAccount, textColor); + views.setInt(R.id.separator, "setBackgroundColor", colorSeparator); + views.setViewVisibility(R.id.separator, separators ? View.VISIBLE : View.GONE); views.setViewVisibility(idAccount, account < 0 ? View.VISIBLE : View.GONE); diff --git a/app/src/main/res/layout/activity_widget_unified.xml b/app/src/main/res/layout/activity_widget_unified.xml index 22d046dbcc..7c40ab64bd 100644 --- a/app/src/main/res/layout/activity_widget_unified.xml +++ b/app/src/main/res/layout/activity_widget_unified.xml @@ -87,6 +87,16 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/cbHighlight" /> + + + app:layout_constraintTop_toBottomOf="@id/cbSeparatorLines" /> The highlight color can be selected in the display settings Text size Padding size + Show separator lines Semi transparent background Show refresh messages button Show compose new message button