From 16fbb7623189f5866abf8e5fa3f3ec79ed582efc Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 26 Mar 2020 17:53:11 +0100 Subject: [PATCH] Added option to use account color for action bar --- .../eu/faircode/email/FragmentMessages.java | 17 +++++++++++++---- .../java/eu/faircode/email/FragmentOptions.java | 2 +- .../faircode/email/FragmentOptionsDisplay.java | 14 +++++++++++++- .../res/layout/fragment_options_display.xml | 13 ++++++++++++- app/src/main/res/values/strings.xml | 1 + 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index e3880c1546..0c1c4e70fb 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -259,6 +259,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. private boolean swipenav; private boolean seekbar; private boolean actionbar; + private boolean actionbar_color; private boolean autoexpand; private boolean autoclose; private String onclose; @@ -371,6 +372,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. threading = prefs.getBoolean("threading", true); seekbar = prefs.getBoolean("seekbar", false); actionbar = prefs.getBoolean("actionbar", true); + actionbar_color = prefs.getBoolean("actionbar_color", false); autoexpand = prefs.getBoolean("autoexpand", true); autoclose = prefs.getBoolean("autoclose", true); onclose = (autoclose ? null : prefs.getString("onclose", null)); @@ -4015,17 +4017,21 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. new SimpleTask() { @Override protected Boolean[] onExecute(Context context, Bundle args) { - long account = args.getLong("account"); + long aid = args.getLong("account"); String thread = args.getString("thread"); long id = args.getLong("id"); DB db = DB.getInstance(context); - EntityFolder trash = db.folder().getFolderByType(account, EntityFolder.TRASH); - EntityFolder archive = db.folder().getFolderByType(account, EntityFolder.ARCHIVE); + EntityAccount account = db.account().getAccount(aid); + if (account != null && account.color != null) + args.putInt("color", account.color); + + EntityFolder trash = db.folder().getFolderByType(aid, EntityFolder.TRASH); + EntityFolder archive = db.folder().getFolderByType(aid, EntityFolder.ARCHIVE); List messages = db.message().getMessagesByThread( - account, thread, threading ? null : id, null); + aid, thread, threading ? null : id, null); boolean trashable = false; boolean snoozable = false; @@ -4061,6 +4067,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. @Override protected void onExecuted(Bundle args, Boolean[] data) { + if (actionbar_color && args.containsKey("color")) + bottom_navigation.setBackgroundColor(args.getInt("color")); + bottom_navigation.setTag(data[0]); bottom_navigation.getMenu().findItem(R.id.action_delete).setVisible(data[1]); bottom_navigation.getMenu().findItem(R.id.action_snooze).setVisible(data[2]); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index 7910b2ddeb..b008a8fd19 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -52,7 +52,7 @@ public class FragmentOptions extends FragmentBase { "keywords_header", "flags", "flags_background", "preview", "preview_italic", "preview_lines", "addresses", "button_archive_trash", "button_move", "attachments_alt", "contrast", "monospaced", "text_color", "text_size", - "inline_images", "collapse_quotes", "seekbar", "actionbar", "navbar_colorize", + "inline_images", "collapse_quotes", "seekbar", "actionbar", "actionbar_color", "navbar_colorize", "autoscroll", "swipenav", "autoexpand", "autoclose", "onclose", "quick_filter", "quick_scroll", "experiments", "debug", diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java index 9f615281fe..abe80ec85a 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java @@ -67,6 +67,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer private SwitchCompat swIndentation; private SwitchCompat swSeekbar; private SwitchCompat swActionbar; + private SwitchCompat swActionbarColor; private SwitchCompat swHighlightUnread; private SwitchCompat swColorStripe; @@ -114,7 +115,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer private final static String[] RESET_OPTIONS = new String[]{ "theme", "startup", "cards", "date", "navbar_colorize", "landscape", "landscape3", - "threading", "indentation", "seekbar", "actionbar", + "threading", "indentation", "seekbar", "actionbar", "actionbar_color", "highlight_unread", "color_stripe", "avatars", "gravatars", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold", "name_email", "prefer_contact", "distinguish_contacts", @@ -149,6 +150,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swIndentation = view.findViewById(R.id.swIndentation); swSeekbar = view.findViewById(R.id.swSeekbar); swActionbar = view.findViewById(R.id.swActionbar); + swActionbarColor = view.findViewById(R.id.swActionbarColor); swHighlightUnread = view.findViewById(R.id.swHighlightUnread); swColorStripe = view.findViewById(R.id.swColorStripe); @@ -282,6 +284,14 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { prefs.edit().putBoolean("actionbar", checked).apply(); + swActionbarColor.setEnabled(checked); + } + }); + + swActionbarColor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("actionbar_color", checked).apply(); } }); @@ -691,6 +701,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swIndentation.setEnabled(swCards.isChecked()); swSeekbar.setChecked(prefs.getBoolean("seekbar", false)); swActionbar.setChecked(prefs.getBoolean("actionbar", true)); + swActionbarColor.setChecked(prefs.getBoolean("actionbar_color", false)); + swActionbarColor.setEnabled(swActionbar.isChecked()); swHighlightUnread.setChecked(prefs.getBoolean("highlight_unread", true)); swColorStripe.setChecked(prefs.getBoolean("color_stripe", true)); diff --git a/app/src/main/res/layout/fragment_options_display.xml b/app/src/main/res/layout/fragment_options_display.xml index 5cf467d669..9572deaade 100644 --- a/app/src/main/res/layout/fragment_options_display.xml +++ b/app/src/main/res/layout/fragment_options_display.xml @@ -240,6 +240,17 @@ app:layout_constraintTop_toBottomOf="@id/swSeekbar" app:switchPadding="12dp" /> + + + app:layout_constraintTop_toBottomOf="@+id/swActionbarColor" /> Automatically show inline images Show relative conversation position with a dot Show conversation action bar + Use account color as background color for conversation action bar Colorize the Android navigation bar Double \'back\' to exit