From 6c496c20cba12adac5cba83ce8a41068fc9d452a Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 1 Sep 2024 20:53:17 +0200 Subject: [PATCH] Update prev/next icon --- .../eu/faircode/email/FragmentMessages.java | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index d0c0180402..8589eacf6b 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -1440,14 +1440,6 @@ public class FragmentMessages extends FragmentBase } }); - if (prefs.getBoolean("updown", true)) { - boolean reversed = prefs.getBoolean("reversed", false); - bottom_navigation.getMenu().findItem(R.id.action_prev) - .setIcon(reversed ? R.drawable.twotone_north_24 : R.drawable.twotone_south_24); - bottom_navigation.getMenu().findItem(R.id.action_next) - .setIcon(reversed ? R.drawable.twotone_south_24 : R.drawable.twotone_north_24); - } - bottom_navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { @@ -2030,6 +2022,7 @@ public class FragmentMessages extends FragmentBase ibSnoozed.setVisibility(View.GONE); bottom_navigation.getMenu().findItem(R.id.action_prev).setEnabled(false); bottom_navigation.getMenu().findItem(R.id.action_next).setEnabled(false); + updateNavPrevNext(); bottom_navigation.setVisibility(actionbar && viewType == AdapterMessage.ViewType.THREAD ? View.INVISIBLE : View.GONE); grpReady.setVisibility(View.GONE); pbWait.setVisibility(View.VISIBLE); @@ -2084,6 +2077,7 @@ public class FragmentMessages extends FragmentBase prev = id; bottom_navigation.getMenu().findItem(R.id.action_prev).setEnabled(prev != null); bottom_navigation.getMenu().findItem(R.id.action_next).setEnabled(next != null); + updateNavPrevNext(); } @Override @@ -2095,6 +2089,7 @@ public class FragmentMessages extends FragmentBase next = id; bottom_navigation.getMenu().findItem(R.id.action_prev).setEnabled(prev != null); bottom_navigation.getMenu().findItem(R.id.action_next).setEnabled(next != null); + updateNavPrevNext(); } @Override @@ -7967,6 +7962,29 @@ public class FragmentMessages extends FragmentBase return false; } + private void updateNavPrevNext() { + MenuItem prev = bottom_navigation.getMenu().findItem(R.id.action_prev); + MenuItem next = bottom_navigation.getMenu().findItem(R.id.action_next); + + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + if (prefs.getBoolean("updown", true)) { + boolean reversed = prefs.getBoolean("reversed", false); + prev.setIcon(prev.isEnabled() + ? (reversed ? R.drawable.twotone_north_24 : R.drawable.twotone_south_24) + : R.drawable.twotone_horizontal_rule_24); + next.setIcon(next.isEnabled() + ? (reversed ? R.drawable.twotone_south_24 : R.drawable.twotone_north_24) + : R.drawable.twotone_horizontal_rule_24); + } else { + prev.setIcon(prev.isEnabled() + ? R.drawable.twotone_play_arrow_back_24 + : R.drawable.twotone_horizontal_rule_24); + next.setIcon(next.isEnabled() + ? R.drawable.twotone_play_arrow_24 + : R.drawable.twotone_horizontal_rule_24); + } + } + private void updateCompose() { if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;