Added selecting widget highlight color

pull/207/head
M66B 3 years ago
parent 9fc3fa16bb
commit 5100c1a41c

@ -32,6 +32,7 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
@ -57,6 +58,7 @@ public class ActivityWidgetUnified extends ActivityBase {
private CheckBox cbUnseen; private CheckBox cbUnseen;
private CheckBox cbFlagged; private CheckBox cbFlagged;
private CheckBox cbHighlight; private CheckBox cbHighlight;
private ViewButtonColor btnHighlight;
private CheckBox cbSeparatorLines; private CheckBox cbSeparatorLines;
private CheckBox cbSemiTransparent; private CheckBox cbSemiTransparent;
private ViewButtonColor btnColor; private ViewButtonColor btnColor;
@ -92,6 +94,7 @@ public class ActivityWidgetUnified extends ActivityBase {
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 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 separators = prefs.getBoolean("widget." + appWidgetId + ".separators", true);
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);
@ -109,6 +112,7 @@ public class ActivityWidgetUnified extends ActivityBase {
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); cbHighlight = findViewById(R.id.cbHighlight);
btnHighlight = findViewById(R.id.btnHighlight);
cbSeparatorLines = findViewById(R.id.cbSeparatorLines); cbSeparatorLines = findViewById(R.id.cbSeparatorLines);
cbSemiTransparent = findViewById(R.id.cbSemiTransparent); cbSemiTransparent = findViewById(R.id.cbSemiTransparent);
btnColor = findViewById(R.id.btnColor); btnColor = findViewById(R.id.btnColor);
@ -123,6 +127,43 @@ public class ActivityWidgetUnified extends ActivityBase {
final Intent resultValue = new Intent(); final Intent resultValue = new Intent();
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); 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() { btnColor.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { 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 + ".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 + ".highlight", cbHighlight.isChecked());
editor.putInt("widget." + appWidgetId + ".highlight_color", btnHighlight.getColor());
editor.putBoolean("widget." + appWidgetId + ".separators", cbSeparatorLines.isChecked()); editor.putBoolean("widget." + appWidgetId + ".separators", cbSeparatorLines.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());
@ -301,6 +343,8 @@ public class ActivityWidgetUnified extends ActivityBase {
cbUnseen.setChecked(unseen); cbUnseen.setChecked(unseen);
cbFlagged.setChecked(flagged); cbFlagged.setChecked(flagged);
cbHighlight.setChecked(highlight); cbHighlight.setChecked(highlight);
btnHighlight.setVisibility(highlight ? View.VISIBLE : View.GONE);
btnHighlight.setColor(highlight_color);
cbSeparatorLines.setChecked(separators); cbSeparatorLines.setChecked(separators);
cbSemiTransparent.setChecked(semi); cbSemiTransparent.setChecked(semi);
btnColor.setColor(background); btnColor.setColor(background);

@ -59,6 +59,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
private boolean unseen; private boolean unseen;
private boolean flagged; private boolean flagged;
private boolean highlight; private boolean highlight;
private int highlight_color;
private boolean separators; private boolean separators;
private boolean semi; private boolean semi;
private int background; private int background;
@ -102,6 +103,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
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); highlight = prefs.getBoolean("widget." + appWidgetId + ".highlight", false);
highlight_color = prefs.getInt("widget." + appWidgetId + ".highlight_color", Color.TRANSPARENT);
separators = prefs.getBoolean("widget." + appWidgetId + ".separators", true); separators = prefs.getBoolean("widget." + appWidgetId + ".separators", true);
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);
@ -125,8 +127,12 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
colorSeparator = ContextCompat.getColor(context, R.color.darkColorSeparator); colorSeparator = ContextCompat.getColor(context, R.color.darkColorSeparator);
} }
int highlight_color = prefs.getInt("highlight_color", colorWidgetForeground); if (highlight) {
colorWidgetUnread = ColorUtils.setAlphaComponent(highlight_color, 255); 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); pro = ActivityBilling.isPro(context);

@ -75,15 +75,16 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbFlagged" /> app:layout_constraintTop_toBottomOf="@id/cbFlagged" />
<eu.faircode.email.FixedTextView <eu.faircode.email.ViewButtonColor
android:id="@+id/tvHighlightHint" android:id="@+id/btnHighlight"
android:layout_width="0dp" style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="6dp" android:layout_marginStart="12dp"
android:text="@string/title_widget_highlight_remark" android:layout_marginTop="12dp"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:paddingHorizontal="6dp"
android:textStyle="italic" android:tag="disable"
app:layout_constraintEnd_toEndOf="parent" android:text="@string/title_advanced_highlight_color"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbHighlight" /> app:layout_constraintTop_toBottomOf="@id/cbHighlight" />
@ -95,7 +96,7 @@
android:checked="true" android:checked="true"
android:text="@string/title_widget_separator_lines" android:text="@string/title_widget_separator_lines"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHighlightHint" /> app:layout_constraintTop_toBottomOf="@id/btnHighlight" />
<CheckBox <CheckBox
android:id="@+id/cbSemiTransparent" android:id="@+id/cbSemiTransparent"

@ -1926,7 +1926,6 @@
<string name="title_widget_folder_unified">Unified inbox folders</string> <string name="title_widget_folder_unified">Unified inbox folders</string>
<string name="title_widget_unseen">Unread messages only</string> <string name="title_widget_unseen">Unread messages only</string>
<string name="title_widget_flagged">Starred messages only</string> <string name="title_widget_flagged">Starred messages only</string>
<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_font_size">Text size</string>
<string name="title_widget_padding">Padding size</string> <string name="title_widget_padding">Padding size</string>
<string name="title_widget_separator_lines">Show separator lines</string> <string name="title_widget_separator_lines">Show separator lines</string>

Loading…
Cancel
Save