From 33382a65791cd6dc39bb6c5128f750feb871228c Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 5 Jul 2023 12:08:24 +0200 Subject: [PATCH] Added option to use the identity color for the bottom action bar --- .../java/eu/faircode/email/FragmentCompose.java | 12 ++++++++++-- .../eu/faircode/email/FragmentOptionsSend.java | 12 +++++++++++- app/src/main/res/layout/fragment_options_send.xml | 14 +++++++++++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index a45b7b3fbe..c93d6d5df3 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -290,6 +290,7 @@ public class FragmentCompose extends FragmentBase { private boolean media = true; private boolean compact = false; private int zoom = 0; + private boolean nav_color; private boolean lt_enabled; private boolean lt_auto; @@ -355,6 +356,7 @@ public class FragmentCompose extends FragmentBase { media = prefs.getBoolean("compose_media", true); compact = prefs.getBoolean("compose_compact", false); zoom = prefs.getInt("compose_zoom", compact ? 0 : 1); + nav_color = prefs.getBoolean("send_nav_color", false); lt_enabled = LanguageTool.isEnabled(context); lt_auto = LanguageTool.isAuto(context); @@ -7680,16 +7682,22 @@ public class FragmentCompose extends FragmentBase { private AdapterView.OnItemSelectedListener identitySelected = new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { - EntityIdentity identity = (EntityIdentity) parent.getAdapter().getItem(position); + final Context context = view.getContext(); + TupleIdentityEx identity = (TupleIdentityEx) parent.getAdapter().getItem(position); int at = (identity == null ? -1 : identity.email.indexOf('@')); etExtra.setHint(at < 0 ? null : identity.email.substring(0, at)); tvDomain.setText(at < 0 ? null : identity.email.substring(at)); grpExtra.setVisibility(identity != null && identity.sender_extra ? View.VISIBLE : View.GONE); + if (identity != null && nav_color) { + Integer color = (identity.color == null ? identity.accountColor : identity.color); + bottom_navigation.setBackgroundColor(color == null + ? Helper.resolveColor(context, R.attr.colorPrimary) : color); + } + Spanned signature = null; if (identity != null && !TextUtils.isEmpty(identity.signature)) { - final Context context = getContext(); Document d = HtmlHelper.sanitizeCompose(context, identity.signature, true); signature = HtmlHelper.fromDocument(context, d, new HtmlHelper.ImageGetterEx() { @Override diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java index 07db2eede7..70b98d985a 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java @@ -72,6 +72,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc private SwitchCompat swAutoIdentity; private Button btnLocalContacts; private SwitchCompat swSendChips; + private SwitchCompat swNavColor; private SwitchCompat swSendReminders; private SwitchCompat swSendPending; private SwitchCompat swAutoSaveParagraph; @@ -121,7 +122,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc private final static String[] RESET_OPTIONS = new String[]{ "keyboard", "keyboard_no_fullscreen", "suggest_names", "suggest_sent", "suggested_received", "suggest_frequently", "auto_identity", - "send_reminders", "send_chips", "send_pending", + "send_reminders", "send_chips", "send_nav_color", "send_pending", "auto_save_paragraph", "auto_save_dot", "discard_delete", "send_delayed", "answer_single", "answer_action", @@ -158,6 +159,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc swAutoIdentity = view.findViewById(R.id.swAutoIdentity); btnLocalContacts = view.findViewById(R.id.btnLocalContacts); swSendChips = view.findViewById(R.id.swSendChips); + swNavColor = view.findViewById(R.id.swNavColor); swSendReminders = view.findViewById(R.id.swSendReminders); swSendPending = view.findViewById(R.id.swSendPending); swAutoSaveParagraph = view.findViewById(R.id.swAutoSaveParagraph); @@ -302,6 +304,13 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc } }); + swNavColor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("send_nav_color", checked).apply(); + } + }); + swSendReminders.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -748,6 +757,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc swAutoIdentity.setChecked(prefs.getBoolean("auto_identity", false)); swAutoIdentity.setEnabled(swSuggestSent.isChecked() || swSuggestReceived.isChecked()); swSendChips.setChecked(prefs.getBoolean("send_chips", true)); + swNavColor.setChecked(prefs.getBoolean("send_nav_color", false)); swSendReminders.setChecked(prefs.getBoolean("send_reminders", true)); swSendPending.setChecked(prefs.getBoolean("send_pending", true)); swAutoSaveParagraph.setChecked(prefs.getBoolean("auto_save_paragraph", true)); diff --git a/app/src/main/res/layout/fragment_options_send.xml b/app/src/main/res/layout/fragment_options_send.xml index 96544d4710..ac1acc10d7 100644 --- a/app/src/main/res/layout/fragment_options_send.xml +++ b/app/src/main/res/layout/fragment_options_send.xml @@ -232,6 +232,18 @@ app:layout_constraintTop_toBottomOf="@id/btnLocalContacts" app:switchPadding="12dp" /> + + Sort suggested addresses on frequency of use Alternative reply/forward prefix Show address bubbles + Use the identity color for the bottom action bar Show reminders Delay sending messages Create a new draft message for shared addresses and files