Added showing stars in unified widget

master
M66B 1 month ago
parent 661037a367
commit 6ba6c15fd9

@ -63,6 +63,7 @@ public class ActivityWidgetUnified extends ActivityBase {
private CheckBox cbUnseen;
private CheckBox cbShowUnseen;
private CheckBox cbFlagged;
private CheckBox cbShowFlagged;
private CheckBox cbDayNight;
private CheckBox cbHighlight;
private ViewButtonColor btnHighlight;
@ -110,6 +111,7 @@ public class ActivityWidgetUnified extends ActivityBase {
boolean unseen = prefs.getBoolean("widget." + appWidgetId + ".unseen", false);
boolean show_unseen = prefs.getBoolean("widget." + appWidgetId + ".show_unseen", true);
boolean flagged = prefs.getBoolean("widget." + appWidgetId + ".flagged", false);
boolean show_flagged = prefs.getBoolean("widget." + appWidgetId + ".show_flagged", false);
boolean daynight = prefs.getBoolean("widget." + appWidgetId + ".daynight", false);
boolean highlight = prefs.getBoolean("widget." + appWidgetId + ".highlight", false);
int highlight_color = prefs.getInt("widget." + appWidgetId + ".highlight_color", Color.TRANSPARENT);
@ -139,6 +141,7 @@ public class ActivityWidgetUnified extends ActivityBase {
cbUnseen = findViewById(R.id.cbUnseen);
cbShowUnseen = findViewById(R.id.cbShowUnseen);
cbFlagged = findViewById(R.id.cbFlagged);
cbShowFlagged = findViewById(R.id.cbShowFlagged);
cbDayNight = findViewById(R.id.cbDayNight);
cbHighlight = findViewById(R.id.cbHighlight);
btnHighlight = findViewById(R.id.btnHighlight);
@ -170,6 +173,15 @@ public class ActivityWidgetUnified extends ActivityBase {
}
});
cbFlagged.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
cbShowFlagged.setEnabled(!isChecked);
}
});
cbShowFlagged.setVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.S ? View.GONE : View.VISIBLE);
cbDayNight.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -306,6 +318,7 @@ public class ActivityWidgetUnified extends ActivityBase {
editor.putBoolean("widget." + appWidgetId + ".show_unseen", cbShowUnseen.isChecked());
editor.putBoolean("widget." + appWidgetId + ".daynight", cbDayNight.isChecked());
editor.putBoolean("widget." + appWidgetId + ".flagged", cbFlagged.isChecked());
editor.putBoolean("widget." + appWidgetId + ".show_flagged", cbShowFlagged.isChecked());
editor.putBoolean("widget." + appWidgetId + ".highlight", cbHighlight.isChecked());
editor.putInt("widget." + appWidgetId + ".highlight_color", btnHighlight.getColor());
editor.putBoolean("widget." + appWidgetId + ".semi", cbSemiTransparent.isChecked());
@ -436,6 +449,8 @@ public class ActivityWidgetUnified extends ActivityBase {
cbShowUnseen.setChecked(show_unseen);
cbShowUnseen.setEnabled(cbUnseen.isChecked());
cbFlagged.setChecked(flagged);
cbShowFlagged.setChecked(show_flagged);
cbShowFlagged.setEnabled(!flagged);
cbDayNight.setChecked(daynight);
cbDayNight.setVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.S ? View.GONE : View.VISIBLE);
cbHighlight.setChecked(highlight);

@ -59,6 +59,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
private boolean unseen;
private boolean show_unseen;
private boolean flagged;
private boolean show_flagged;
private boolean daynight;
private boolean highlight;
private int highlight_color;
@ -77,6 +78,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
private int colorWidgetForeground;
private int colorWidgetUnread;
private int colorWidgetRead;
private int colorFlagged;
private int colorSeparator;
private boolean pro;
private boolean hasColor;
@ -112,6 +114,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
unseen = prefs.getBoolean("widget." + appWidgetId + ".unseen", false);
show_unseen = prefs.getBoolean("widget." + appWidgetId + ".show_unseen", true);
flagged = prefs.getBoolean("widget." + appWidgetId + ".flagged", false);
show_flagged = prefs.getBoolean("widget." + appWidgetId + ".show_flagged", false);
daynight = prefs.getBoolean("widget." + appWidgetId + ".daynight", false);
highlight = prefs.getBoolean("widget." + appWidgetId + ".highlight", false);
highlight_color = prefs.getInt("widget." + appWidgetId + ".highlight_color", Color.TRANSPARENT);
@ -149,6 +152,8 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
} else
colorWidgetUnread = colorWidgetForeground;
colorFlagged = ContextCompat.getColor(context, lum > 0.7f ? R.color.lightYellowAccent : R.color.darkYellowAccent);
pro = ActivityBilling.isPro(context);
DB db = DB.getInstance(context);
@ -325,6 +330,14 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
views.setTextColor(R.id.tvNotes, message.notes_color == null ? colorWidgetRead : message.notes_color);
views.setViewVisibility(R.id.tvNotes, message.notes == null ? View.GONE : View.VISIBLE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
views.setImageViewResource(R.id.ivFlagged, message.ui_flagged ? R.drawable.baseline_star_24 : R.drawable.twotone_star_border_24);
views.setColorStateList(R.id.ivFlagged, "setImageTintList",
ColorStateList.valueOf(message.ui_flagged ? colorFlagged : colorSeparator));
views.setViewVisibility(R.id.ivFlagged, !flagged && show_flagged ? View.VISIBLE : View.GONE);
} else
views.setViewVisibility(R.id.ivFlagged, View.GONE);
views.setViewVisibility(R.id.separator, separators ? View.VISIBLE : View.GONE);
views.setViewVisibility(idAccount, account < 0 && !allColors && account_name ? View.VISIBLE : View.GONE);

@ -77,6 +77,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbShowUnseen" />
<CheckBox
android:id="@+id/cbShowFlagged"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_widget_show_flagged"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbFlagged" />
<CheckBox
android:id="@+id/cbDayNight"
android:layout_width="wrap_content"
@ -85,7 +95,7 @@
android:checked="true"
android:text="@string/title_widget_day_night"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbFlagged" />
app:layout_constraintTop_toBottomOf="@id/cbShowFlagged" />
<CheckBox
android:id="@+id/cbHighlight"

@ -30,6 +30,7 @@
android:layout_width="36dp"
android:layout_height="match_parent"
android:layout_marginEnd="3dp"
android:layout_weight="0"
android:adjustViewBounds="true"
android:paddingTop="3dp"
android:paddingBottom="3dp"
@ -39,6 +40,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:paddingTop="6dp"
android:paddingBottom="6dp">
@ -123,6 +125,17 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:textColorPrimary" />
</LinearLayout>
<ImageView
android:id="@+id/ivFlagged"
android:layout_width="24dp"
android:layout_height="match_parent"
android:layout_marginStart="3dp"
android:layout_weight="0"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:src="@drawable/twotone_star_24"
android:tint="?android:textColorPrimary" />
</LinearLayout>
<FrameLayout

@ -2490,6 +2490,7 @@
<string name="title_widget_unseen">Unread messages only</string>
<string name="title_widget_show_unseen">Show as unread</string>
<string name="title_widget_flagged">Starred messages only</string>
<string name="title_widget_show_flagged">Show stars</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>

Loading…
Cancel
Save