diff --git a/app/src/main/java/eu/faircode/email/ActivityWidgetUnified.java b/app/src/main/java/eu/faircode/email/ActivityWidgetUnified.java index 7c48b9e105..15e10db892 100644 --- a/app/src/main/java/eu/faircode/email/ActivityWidgetUnified.java +++ b/app/src/main/java/eu/faircode/email/ActivityWidgetUnified.java @@ -32,6 +32,7 @@ import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.CheckBox; +import android.widget.CompoundButton; import android.widget.Spinner; import android.widget.TextView; @@ -57,6 +58,7 @@ public class ActivityWidgetUnified extends ActivityBase { private CheckBox cbUnseen; private CheckBox cbFlagged; private CheckBox cbHighlight; + private ViewButtonColor btnHighlight; private CheckBox cbSeparatorLines; private CheckBox cbSemiTransparent; private ViewButtonColor btnColor; @@ -92,6 +94,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); + int highlight_color = prefs.getInt("widget." + appWidgetId + ".highlight_color", Color.TRANSPARENT); 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); @@ -109,6 +112,7 @@ public class ActivityWidgetUnified extends ActivityBase { cbUnseen = findViewById(R.id.cbUnseen); cbFlagged = findViewById(R.id.cbFlagged); cbHighlight = findViewById(R.id.cbHighlight); + btnHighlight = findViewById(R.id.btnHighlight); cbSeparatorLines = findViewById(R.id.cbSeparatorLines); cbSemiTransparent = findViewById(R.id.cbSemiTransparent); btnColor = findViewById(R.id.btnColor); @@ -123,6 +127,43 @@ public class ActivityWidgetUnified extends ActivityBase { final Intent resultValue = new Intent(); resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); + cbHighlight.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + btnHighlight.setVisibility(checked ? View.VISIBLE : View.GONE); + } + }); + + btnHighlight.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + int editTextColor = Helper.resolveColor(ActivityWidgetUnified.this, android.R.attr.editTextColor); + + ColorPickerDialogBuilder + .with(ActivityWidgetUnified.this) + .setTitle(R.string.title_advanced_highlight_color) + .showColorEdit(true) + .setColorEditTextColor(editTextColor) + .wheelType(ColorPickerView.WHEEL_TYPE.FLOWER) + .density(6) + .lightnessSliderOnly() + .setPositiveButton(android.R.string.ok, new ColorPickerClickListener() { + @Override + public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) { + btnHighlight.setColor(selectedColor); + } + }) + .setNegativeButton(R.string.title_reset, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + btnHighlight.setColor(Color.TRANSPARENT); + } + }) + .build() + .show(); + } + }); + btnColor.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -180,6 +221,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.putInt("widget." + appWidgetId + ".highlight_color", btnHighlight.getColor()); editor.putBoolean("widget." + appWidgetId + ".separators", cbSeparatorLines.isChecked()); editor.putBoolean("widget." + appWidgetId + ".semi", cbSemiTransparent.isChecked()); editor.putInt("widget." + appWidgetId + ".background", btnColor.getColor()); @@ -301,6 +343,8 @@ public class ActivityWidgetUnified extends ActivityBase { cbUnseen.setChecked(unseen); cbFlagged.setChecked(flagged); cbHighlight.setChecked(highlight); + btnHighlight.setVisibility(highlight ? View.VISIBLE : View.GONE); + btnHighlight.setColor(highlight_color); cbSeparatorLines.setChecked(separators); cbSemiTransparent.setChecked(semi); btnColor.setColor(background); diff --git a/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java b/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java index 0fad0a0032..a03f2d5de1 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 int highlight_color; private boolean separators; private boolean semi; private int background; @@ -102,6 +103,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); + highlight_color = prefs.getInt("widget." + appWidgetId + ".highlight_color", Color.TRANSPARENT); separators = prefs.getBoolean("widget." + appWidgetId + ".separators", true); semi = prefs.getBoolean("widget." + appWidgetId + ".semi", true); background = prefs.getInt("widget." + appWidgetId + ".background", Color.TRANSPARENT); @@ -125,8 +127,12 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot colorSeparator = ContextCompat.getColor(context, R.color.darkColorSeparator); } - int highlight_color = prefs.getInt("highlight_color", colorWidgetForeground); - colorWidgetUnread = ColorUtils.setAlphaComponent(highlight_color, 255); + if (highlight) { + if (highlight_color == Color.TRANSPARENT) + highlight_color = prefs.getInt("highlight_color", colorWidgetForeground); + colorWidgetUnread = ColorUtils.setAlphaComponent(highlight_color, 255); + } else + colorWidgetUnread = colorWidgetForeground; pro = ActivityBilling.isPro(context); diff --git a/app/src/main/res/layout/activity_widget_unified.xml b/app/src/main/res/layout/activity_widget_unified.xml index 7c40ab64bd..cef5cc27be 100644 --- a/app/src/main/res/layout/activity_widget_unified.xml +++ b/app/src/main/res/layout/activity_widget_unified.xml @@ -75,15 +75,16 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/cbFlagged" /> - @@ -95,7 +96,7 @@ android:checked="true" android:text="@string/title_widget_separator_lines" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@id/tvHighlightHint" /> + app:layout_constraintTop_toBottomOf="@id/btnHighlight" /> Unified inbox folders Unread messages only Starred messages only - The highlight color can be selected in the display settings Text size Padding size Show separator lines