Repository navigation
Add option to sort songs by date modified - #231
Open
DarkPhoenix42 wants to merge 1 commit into
Open
DarkPhoenix42 wants to merge 1 commit into
DarkPhoenix42 wants to merge 1 commit into
Conversation
Android's MediaStore DATE_ADDED column records when an audio file was first indexed into Android's system database rather than its actual filesystem creation or modification date. Relying solely on DATE_ADDED might have some flaws, some of which are: 1. Sync Tools & Non-Chronological Transfers: Synchronization utilities like Syncthing and rsync preserve the source file's modification timestamp (mtime), but transfer files in arbitrary alphabetical or network-chunk order. Consequently, DATE_ADDED reflects the random sequence in which files completed downloading rather than when the music was acquired. 2. Library Migrations & Cache Rescans: Moving to a new phone, restoring backups, moving files across storage volumes, or clearing Media Storage wipes the index and might assign the same timestamp to multiple songs in a single batch as it re-indexes. Hence, this change adds a "Date Modified" sort option across the Songs tab, Folder views, and Playlist details.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
[Medium impact] The PR appears safe to merge; no actionable issues were found.
|
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.
Why
Android's MediaStore DATE_ADDED column records when an audio file was first indexed into Android's system database rather than its actual filesystem creation or modification date. Relying solely on DATE_ADDED might have some flaws, some of which are:
Sync Tools & Non-Chronological Transfers: Synchronization utilities like Syncthing and rsync preserve the source file's modification timestamp (mtime), but transfer files in arbitrary alphabetical or network-chunk order. Consequently, DATE_ADDED reflects the random sequence in which files completed downloading rather than when the music was acquired.
Library Migrations & Cache Rescans: Moving to a new phone, restoring backups, moving files across storage volumes, or clearing Media Storage wipes the index and might assign the same timestamp to multiple songs in a single batch as it re-indexes.
Hence, this change adds a "Date Modified" sort option across the Songs tab, Folder views, and Playlist details:
What Changed
SortOption: AddedSongDateModified,SongDateModifiedAsc,FolderSongDateModified, andFolderSongDateModifiedAsc. Paired ascending and descending options under common method keys (song_date_modified,folder_song_date_modified) for seamless direction flipping. Registered inSONGS,FOLDER_SONGS,LibraryTabId.Songs, andPlaylistDetailScreen.MusicDao: Addedsong_date_modifiedandsong_date_modified_ascordering branches togetSongIdsSorted,getSongsPaginated, andgetSongsPage. Queries order bymedia_store_date_modified, gracefully falling back todate_added / 1000(normalizing milliseconds to seconds) for cloud streams (Navidrome/Jellyfin) or unindexed tracks wheremedia_store_date_modified <= 0.SongEntity.toSongInternal: PopulatesSong.dateModifiedby convertingmedia_store_date_modifiedfrom seconds to epoch milliseconds (falling back tothis.dateAddedif 0), ensuring in-memory comparators and domain models operate on consistent units.FolderSongSort: AddednewestModifiedFirstandoldestModifiedFirstcomparators tied toSong.dateModified, with secondary tie-breakers falling back totitleAscending.PlaylistViewModel: AddedSongDateModifiedandSongDateModifiedAscsorting branches for playlist tracks.strings_sort.xml: Addedsort_method_date_modified("Date Modified") across English and all 12 localized string files (ar,de,es,fr,in,it,ko,nb,ru,tr,vi,zh-rCN).Testing
./gradlew :app:compileDebugKotlin :app:lintDebug :app:testDebugUnitTestpassesSortOptionTest: Verified method key pairing, direction flipping for modified sorts, storage key uniqueness across lists, and verified default directions match between theSongs tab and Folder songs (asserting 7 distinct methods).
FolderSongSortTest: VerifiedFolderSongDateModifieddefaults to newest first and ascending flips it; verified tie-breaking preserves secondary title/id ordering whenmodification timestamps collide.