From d486080152fcd3d428a30e7571e9ca211b27b84e Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 3 Aug 2024 08:19:49 +0200 Subject: [PATCH] Added account color dot option --- .../eu/faircode/email/AdapterMessage.java | 20 ++++++++++---- .../java/eu/faircode/email/ApplicationEx.java | 9 +++++++ .../eu/faircode/email/FragmentOptions.java | 2 +- .../email/FragmentOptionsDisplay.java | 24 ++++++++++------- .../WidgetUnifiedRemoteViewsFactory.java | 2 +- .../res/layout/fragment_options_display.xml | 26 +++++++++++++------ .../res/layout/include_message_compact.xml | 10 ++++++- .../res/layout/include_message_normal.xml | 10 ++++++- app/src/main/res/values/strings.xml | 8 +++++- 9 files changed, 84 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 9b5f7f02b1..862bc4bf9a 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -46,6 +46,7 @@ import android.graphics.Paint; import android.graphics.Rect; import android.graphics.Typeface; import android.graphics.drawable.Drawable; +import android.graphics.drawable.GradientDrawable; import android.graphics.text.LineBreaker; import android.net.Uri; import android.os.Build; @@ -271,7 +272,7 @@ public class AdapterMessage extends RecyclerView.Adapter= Build.VERSION_CODES.O && !BuildConfig.DEBUG) editor.remove("background_service"); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index 776c51241a..36f4afc494 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -149,7 +149,7 @@ public class FragmentOptions extends FragmentBase { "hide_toolbar", "edge_to_edge", "nav_categories", "nav_last_sync", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "show_unexposed", "indentation", "date", "date_week", "date_fixed", "date_bold", "date_time", "threading", "threading_unread", "show_filtered", - "highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide", + "highlight_unread", "highlight_color", "account_color", "color_stripe_wide", "avatars", "bimi", "gravatars", "libravatars", "favicons", "favicons_partial", "favicons_manifest", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold", "authentication", "authentication_indicator", diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java index 0377647b34..25748310a2 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java @@ -111,7 +111,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer private SwitchCompat swHighlightUnread; private ViewButtonColor btnHighlightColor; - private SwitchCompat swColorStripe; + private Spinner spAccountColor; private SwitchCompat swColorStripeWide; private SwitchCompat swAvatars; private ImageButton ibBimi; @@ -220,7 +220,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer "portrait2", "portrait2c", "landscape", "close_pane", "column_width", "hide_toolbar", "edge_to_edge", "nav_options", "nav_categories", "nav_last_sync", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "show_unexposed", "threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_swap", "actionbar_color", - "highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide", + "highlight_unread", "highlight_color", "account_color", "color_stripe_wide", "avatars", "bimi", "bimi_vmc", "gravatars", "libravatars", "favicons", "favicons_partial", "favicons_manifest", "ddg_icons", "favicons_dmarc", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold", "email_format", "prefer_contact", "only_contact", "distinguish_contacts", "show_recipients", "reverse_addresses", @@ -294,7 +294,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swHighlightUnread = view.findViewById(R.id.swHighlightUnread); btnHighlightColor = view.findViewById(R.id.btnHighlightColor); - swColorStripe = view.findViewById(R.id.swColorStripe); + spAccountColor = view.findViewById(R.id.spAccountColor); swColorStripeWide = view.findViewById(R.id.swColorStripeWide); swAvatars = view.findViewById(R.id.swAvatars); swBimi = view.findViewById(R.id.swBimi); @@ -801,11 +801,17 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer } }); - swColorStripe.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + spAccountColor.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { - prefs.edit().putBoolean("color_stripe", checked).apply(); - //swColorStripeWide.setEnabled(checked); + public void onItemSelected(AdapterView parent, View view, int position, long id) { + prefs.edit().putInt("account_color", position).apply(); + swColorStripeWide.setEnabled(position == 1); + WidgetUnified.updateData(getContext()); + } + + @Override + public void onNothingSelected(AdapterView parent) { + prefs.edit().remove("account_color").apply(); WidgetUnified.updateData(getContext()); } }); @@ -1640,9 +1646,9 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer btnHighlightColor.setColor(prefs.getInt("highlight_color", Helper.resolveColor(getContext(), R.attr.colorUnreadHighlight))); - swColorStripe.setChecked(prefs.getBoolean("color_stripe", true)); + spAccountColor.setSelection(prefs.getInt("account_color", 1)); swColorStripeWide.setChecked(prefs.getBoolean("color_stripe_wide", false)); - //swColorStripeWide.setEnabled(swColorStripe.isChecked()); + swColorStripeWide.setEnabled(spAccountColor.getSelectedItemPosition() == 1); swAvatars.setChecked(prefs.getBoolean("avatars", true)); swBimi.setChecked(prefs.getBoolean("bimi", false)); swBimiVmc.setChecked(prefs.getBoolean("bimi_vmc", false)); diff --git a/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java b/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java index 4059a92271..41dc17ac90 100644 --- a/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java +++ b/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java @@ -105,7 +105,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot threading = prefs.getBoolean("threading", true); subject_top = prefs.getBoolean("subject_top", false); subject_italic = prefs.getBoolean("subject_italic", true); - color_stripe = prefs.getBoolean("color_stripe", true); + color_stripe = (prefs.getInt("account_color", 1) > 0); account = prefs.getLong("widget." + appWidgetId + ".account", -1L); folder = prefs.getLong("widget." + appWidgetId + ".folder", -1L); diff --git a/app/src/main/res/layout/fragment_options_display.xml b/app/src/main/res/layout/fragment_options_display.xml index 0bcd41bcd7..4c02d1a3ce 100644 --- a/app/src/main/res/layout/fragment_options_display.xml +++ b/app/src/main/res/layout/fragment_options_display.xml @@ -869,28 +869,38 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swHighlightUnread" /> - + app:layout_constraintTop_toBottomOf="@id/btnHighlightColor" /> + + + + + + Show number of unread messages in conversations Left/right indent received/sent messages in conversations Highlight unread messages - Show color stripe + Show a color stripe or color dot Use wide color stripe Show contact photos Show Brand Indicators for Message Identification (BIMI) @@ -2887,6 +2887,12 @@ Extra large + + None + Stripe + Dot + + reply reply_all