Skip to content

Add option to sort songs by date modified - #231

Open
DarkPhoenix42 wants to merge 1 commit into
PixelPlayerHQ:mainfrom
DarkPhoenix42:feat/sort-by-date-modified
Open

DarkPhoenix42 wants to merge 1 commit into
PixelPlayerHQ:mainfrom
DarkPhoenix42:feat/sort-by-date-modified

Conversation

@DarkPhoenix42

@DarkPhoenix42 DarkPhoenix42 commented Nov 11, 2026 •

Copy link
Copy Markdown

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:

  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:

What Changed

  • SortOption: Added SongDateModified, SongDateModifiedAsc, FolderSongDateModified, and FolderSongDateModifiedAsc. Paired ascending and descending options under common method keys (song_date_modified, folder_song_date_modified) for seamless direction flipping. Registered in SONGS, FOLDER_SONGS, LibraryTabId.Songs, and PlaylistDetailScreen.
  • MusicDao: Added song_date_modified and song_date_modified_asc ordering branches to getSongIdsSorted, getSongsPaginated, and getSongsPage. Queries order by media_store_date_modified, gracefully falling back to date_added / 1000 (normalizing milliseconds to seconds) for cloud streams (Navidrome/Jellyfin) or unindexed tracks where media_store_date_modified <= 0.
  • SongEntity.toSongInternal: Populates Song.dateModified by converting media_store_date_modified from seconds to epoch milliseconds (falling back to this.dateAdded if 0), ensuring in-memory comparators and domain models operate on consistent units.
  • FolderSongSort: Added newestModifiedFirst and oldestModifiedFirst comparators tied to Song.dateModified, with secondary tie-breakers falling back to titleAscending.
  • PlaylistViewModel: Added SongDateModified and SongDateModifiedAsc sorting branches for playlist tracks.
  • strings_sort.xml: Added sort_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:testDebugUnitTest passes
  • SortOptionTest: Verified method key pairing, direction flipping for modified sorts, storage key uniqueness across lists, and verified default directions match between the
    Songs tab and Folder songs (asserting 7 distinct methods).
  • FolderSongSortTest: Verified FolderSongDateModified defaults to newest first and ascending flips it; verified tie-breaking preserves secondary title/id ordering when
    modification timestamps collide.
  • tested on motorola g54 5G (running PixelOS, Android 16)

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.
Copilot AI balanced review requested due to automatic review settings November 11, 2026 18:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@greptile-apps

greptile-apps Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Adds Date Modified sorting in both directions across Songs, folder songs, and playlist details.

  • Song lists can now sort by when their files were modified.

Reviews (1) · Last reviewed commit: "Add option to sort songs by date modifie..." · Reviewed by Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants