Added widget option to disable separator lines

This commit is contained in:
M66B 2022-04-30 08:24:54 +02:00
parent 1d66c3426b
commit 9fc3fa16bb
5 changed files with 24 additions and 1 deletions

View File

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

View File

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

View File

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

View File

@ -87,6 +87,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbHighlight" />
<CheckBox
android:id="@+id/cbSeparatorLines"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_widget_separator_lines"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHighlightHint" />
<CheckBox
android:id="@+id/cbSemiTransparent"
android:layout_width="wrap_content"
@ -95,7 +105,7 @@
android:checked="true"
android:text="@string/title_widget_semi_transparent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHighlightHint" />
app:layout_constraintTop_toBottomOf="@id/cbSeparatorLines" />
<eu.faircode.email.ViewButtonColor
android:id="@+id/btnColor"

View File

@ -1929,6 +1929,7 @@
<string name="title_widget_highlight_remark">The highlight color can be selected in the display settings</string>
<string name="title_widget_font_size">Text size</string>
<string name="title_widget_padding">Padding size</string>
<string name="title_widget_separator_lines">Show separator lines</string>
<string name="title_widget_semi_transparent">Semi transparent background</string>
<string name="title_widget_refresh">Show refresh messages button</string>
<string name="title_widget_compose">Show compose new message button</string>