From 4aa7112adb3c5ebda4abca7903840163037548f2 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 27 Jun 2021 08:40:39 +0200 Subject: [PATCH] Added option to use card color as tabular background color --- .../faircode/email/FragmentDialogTheme.java | 20 ++++++++++++------- .../eu/faircode/email/FragmentOptions.java | 3 ++- .../email/FragmentOptionsDisplay.java | 14 ++++++++++++- .../res/layout/fragment_options_display.xml | 18 +++++++++-------- app/src/main/res/values/strings.xml | 4 ++-- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogTheme.java b/app/src/main/java/eu/faircode/email/FragmentDialogTheme.java index 86f19615fe..4382a77933 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogTheme.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogTheme.java @@ -255,18 +255,24 @@ public class FragmentDialogTheme extends FragmentDialogBase { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean cards = prefs.getBoolean("cards", true); boolean beige = prefs.getBoolean("beige", true); + boolean tabular_card_bg = prefs.getBoolean("tabular_card_bg", false); String theme = prefs.getString("theme", "blue_orange_system"); boolean dark = Helper.isDarkTheme(context); boolean solarized = (theme != null && theme.startsWith("solarized")); - if (compose) { - if (cards && (!dark || solarized)) - view.setBackgroundColor(Helper.resolveColor(context, R.attr.colorCardBackground)); + if (cards) { + if (compose) { + if (!dark || solarized) + view.setBackgroundColor(Helper.resolveColor(context, R.attr.colorCardBackground)); + } else { + if (!dark && !solarized) + view.setBackgroundColor(ContextCompat.getColor(context, beige + ? R.color.lightColorBackground_cards_beige + : R.color.lightColorBackground_cards)); + } } else { - if (cards && !dark && !solarized) - view.setBackgroundColor(ContextCompat.getColor(context, beige - ? R.color.lightColorBackground_cards_beige - : R.color.lightColorBackground_cards)); + if (tabular_card_bg) + view.setBackgroundColor(Helper.resolveColor(context, R.attr.colorCardBackground)); } } } diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index d915283e8b..805c813e5c 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -88,7 +88,8 @@ public class FragmentOptions extends FragmentBase { "first", "app_support", "notify_archive", "message_swipe", "message_select", "folder_actions", "folder_sync", "subscriptions", "check_authentication", "check_reply_domain", "send_pending", - "portrait2", "landscape", "landscape3", "startup", "cards", "beige", "shadow_unread", + "portrait2", "landscape", "landscape3", "startup", + "cards", "beige", "tabular_card_bg", "shadow_unread", "indentation", "date", "date_bold", "threading", "threading_unread", "highlight_unread", "highlight_color", "color_stripe", "avatars", "gravatars", "favicons", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold", diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java index dcc86d9eb2..14603944e0 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java @@ -64,6 +64,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer private Spinner spStartup; private SwitchCompat swCards; private SwitchCompat swBeige; + private SwitchCompat swTabularBackground; private SwitchCompat swShadow; private SwitchCompat swDate; private SwitchCompat swDateBold; @@ -145,7 +146,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer private NumberFormat NF = NumberFormat.getNumberInstance(); private final static String[] RESET_OPTIONS = new String[]{ - "theme", "startup", "cards", "beige", "shadow_unread", + "theme", "startup", "cards", "beige", "tabular_card_bg", "shadow_unread", "date", "date_bold", "navbar_colorize", "portrait2", "landscape", "landscape3", "threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_color", "highlight_unread", "highlight_color", "color_stripe", @@ -175,6 +176,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer spStartup = view.findViewById(R.id.spStartup); swCards = view.findViewById(R.id.swCards); swBeige = view.findViewById(R.id.swBeige); + swTabularBackground = view.findViewById(R.id.swTabularCardBackground); swShadow = view.findViewById(R.id.swShadow); swDate = view.findViewById(R.id.swDate); swDateBold = view.findViewById(R.id.swDateBold); @@ -281,6 +283,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { prefs.edit().putBoolean("cards", checked).apply(); swBeige.setEnabled(checked); + swTabularBackground.setEnabled(!checked); swShadow.setEnabled(checked); swIndentation.setEnabled(checked); } @@ -294,6 +297,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer } }); + swTabularBackground.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("tabular_card_bg", checked).apply(); + } + }); + swShadow.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -933,8 +943,10 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swCards.setChecked(prefs.getBoolean("cards", true)); swBeige.setChecked(prefs.getBoolean("beige", true)); + swTabularBackground.setChecked(prefs.getBoolean("tabular_card_bg", false)); swShadow.setChecked(prefs.getBoolean("shadow_unread", false)); swBeige.setEnabled(swCards.isChecked()); + swTabularBackground.setEnabled(!swCards.isChecked()); swShadow.setEnabled(swCards.isChecked()); swDate.setChecked(prefs.getBoolean("date", true)); swDateBold.setChecked(prefs.getBoolean("date_bold", false)); diff --git a/app/src/main/res/layout/fragment_options_display.xml b/app/src/main/res/layout/fragment_options_display.xml index c198b734a7..9ee209031b 100644 --- a/app/src/main/res/layout/fragment_options_display.xml +++ b/app/src/main/res/layout/fragment_options_display.xml @@ -136,6 +136,7 @@ android:id="@+id/swBeige" android:layout_width="0dp" android:layout_height="wrap_content" + android:layout_marginStart="12dp" android:layout_marginTop="12dp" android:checked="true" android:text="@string/title_advanced_cards_beige" @@ -144,28 +145,29 @@ app:layout_constraintTop_toBottomOf="@id/swCards" app:switchPadding="12dp" /> - + app:layout_constraintTop_toBottomOf="@id/swBeige" + app:switchPadding="12dp" /> Show navigation menu in landscape mode by default Show on start screen Use card style instead of tabular style - Use beige background when using card style + Use beige background when using card style (light themes only) + Use card color as background color when using tabular style Use shadow for unread messages when using card style Group by date Show date in bold @@ -622,7 +623,6 @@ Switching to a more compact layout and changing the message text size can be done in the top action bar menu in the message view Long press any folder in the folder list to add or remove it from the list of unified folders - Light themes only Messages are only grouped by date if they are sorted by time Whether this works depends on the Android version and variant This will split the screen into parts