From 3e2a58c839e2395f1ca52f3b270e749c6bcecfef Mon Sep 17 00:00:00 2001 From: TransZAllen <49811617+TransZAllen@users.noreply.github.com> Date: Tue, 28 Apr 2026 15:53:20 +0800 Subject: [PATCH] [History sort mode] Fix inconsistent History title when opened from sidebar When the History page was opened from the sidebar, onResume() always reset the top bar title to "History", regardless of the selected sort mode. Now, show the current sort mode instead. Also the sort mode to string resource mapping is moved into StatisticSortMode, so new modes can be added without changing displaySortMode(). --- .../history/StatisticsPlaylistFragment.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java index 43b7f1c0d..33da13b23 100644 --- a/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java @@ -102,7 +102,7 @@ public class StatisticsPlaylistFragment public void onResume() { super.onResume(); if (activity != null) { - setTitle(activity.getString(R.string.title_activity_history)); + displaySortMode(sortMode); } } @@ -384,9 +384,24 @@ public class StatisticsPlaylistFragment return new SinglePlayQueue(streamInfoItems, index); } + private void displaySortMode(final StatisticSortMode mode) { + final int resourceIdOfSortMode = mode.getResourceId(); + setTitle(getString(resourceIdOfSortMode)); + } + private enum StatisticSortMode { - LAST_PLAYED, - MOST_PLAYED, + LAST_PLAYED(R.string.title_last_played), + MOST_PLAYED(R.string.title_most_played); + + private final int resourceId; + + StatisticSortMode(final int theResourceId) { + this.resourceId = theResourceId; + } + + int getResourceId() { + return resourceId; + } } }