Enable sorting genres by song count#174
Open
jackbrockley wants to merge 5 commits intotimusus:mainfrom
Open
Conversation
jackbrockley
commented
Jun 15, 2025
Author
There was a problem hiding this comment.
On review, I realise these tests mix the responsibilities of GenreListViewModel and GenreComparator
timusus
pushed a commit
that referenced
this pull request
Nov 11, 2025
This PR adds functionality to sort genres by either name (alphabetically) or by song count (descending). The implementation includes: Features: - Added GenreSortOrder enum (Default, Name, SongCount) - New toolbar menu for genre list with sort options - Sort preference persistence via SortPreferenceManager - Sorting works during media library scanning Implementation: - Updated GenreListViewModel to handle sort order changes - Modified GenreList composable to notify Fragment of sort order updates - Added GenreComparator with name and song count comparators - Created menu_genre_list.xml with sort options - Updated translations for menu strings across all languages Testing: - Added GenreComparatorTest for sort order validation - Added GenreListTest for ViewModel behavior testing - Tests use MockK and coroutines-test for comprehensive coverage Dependencies: - Added mockk (1.14.2) for unit testing - Added kotlinx-coroutines-test (1.10.2) for testing coroutines - Updated dependency versions to match current HEAD Conflict Resolution: - Merged GenreList.kt: Combined HEAD's loading UI with PR's sort callbacks - Merged GenreListFragment.kt: Kept ImmutableList conversion and added sort menu - Merged gradle/libs.versions.toml: Used HEAD versions, added PR test dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a menu to the genre list to enable toggling sorting genres between song count and name (the previous default), and saves the option to shared preferences.
Sorting by song count is useful for finding music from your favorite genres, especially if your music library has many. For this use case, and for the sake of simplicity, the sort is only in descending order.
I manually added some translations for the new menu options, but I'm not sure of their accuracy or if the translations are already managed in some other way.
I added a few unit tests, which require some added libraries, for the sake of my own practise if nothing else.