[Android] Implement Album sort by insertion date

Nicolas Pomepuy git at videolan.org
Sun Mar 13 18:24:54 UTC 2022


vlc-android | branch: 1937-subtitles-in-mkv-video-format-cannot-be-resized | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Mar 10 07:12:01 2022 +0100| [fa5790f3c86b6092b4809d6b48da03e6bd9420b1] | committer: Nicolas Pomepuy

Implement Album sort by insertion date

Fixes #1462

> https://code.videolan.org/videolan/vlc-android/commit/fa5790f3c86b6092b4809d6b48da03e6bd9420b1
---

 application/resources/src/main/res/values/strings.xml               | 1 +
 application/vlc-android/res/menu/activity_option.xml                | 6 ++++++
 application/vlc-android/res/menu/sort_options.xml                   | 3 +++
 .../src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt          | 1 +
 .../src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt        | 4 ++++
 .../src/org/videolan/vlc/providers/medialibrary/AlbumsProvider.kt   | 1 +
 6 files changed, 16 insertions(+)

diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 6c1ee9caf..076454966 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -15,6 +15,7 @@
     <string name="sortby_length">Length</string>
     <string name="sortby_date">Date</string>
     <string name="sortby_last_modified_date">Recently added</string>
+    <string name="sortby_insertion">Insertion date</string>
     <string name="sortby_media_number">Media number</string>
     <string name="sortby_number">Nb tracks</string>
     <string name="searchable_hint">Search…</string>
diff --git a/application/vlc-android/res/menu/activity_option.xml b/application/vlc-android/res/menu/activity_option.xml
index 599369f16..6f06db4dd 100644
--- a/application/vlc-android/res/menu/activity_option.xml
+++ b/application/vlc-android/res/menu/activity_option.xml
@@ -87,6 +87,12 @@
                     android:id="@+id/ml_menu_sortby_last_modified"
                     android:title="@string/sortby_last_modified_date"
                     android:visible="false"/>
+
+            <item
+                    android:orderInCategory="2"
+                    android:id="@+id/ml_menu_sortby_insertion_date"
+                    android:title="@string/sortby_insertion"
+                    android:visible="false"/>
             <item
                     android:orderInCategory="2"
                     android:id="@+id/ml_menu_sortby_number"
diff --git a/application/vlc-android/res/menu/sort_options.xml b/application/vlc-android/res/menu/sort_options.xml
index 43ac3b0fa..dce70d057 100644
--- a/application/vlc-android/res/menu/sort_options.xml
+++ b/application/vlc-android/res/menu/sort_options.xml
@@ -15,6 +15,9 @@
     <item
         android:id="@+id/ml_menu_sortby_last_modified"
         android:title="@string/sortby_last_modified_date" />
+    <item
+        android:id="@+id/ml_menu_sortby_insertion_date"
+        android:title="@string/sortby_insertion" />
     <item
         android:id="@+id/ml_menu_sortby_number"
         android:title="@string/sortby_number" />
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
index df0aee0eb..e766e71ce 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
@@ -249,6 +249,7 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>() {
             menu.findItem(R.id.ml_menu_sortby_length).isVisible = canSortByDuration()
             menu.findItem(R.id.ml_menu_sortby_date).isVisible = canSortByReleaseDate()
             menu.findItem(R.id.ml_menu_sortby_last_modified).isVisible = canSortByLastModified()
+            menu.findItem(R.id.ml_menu_sortby_insertion_date).isVisible = canSortByInsertionDate()
             menu.findItem(R.id.ml_menu_sortby_number).isVisible = false
             menu.findItem(R.id.ml_menu_display_grid).isVisible = !viewModel.providersInCard[currentTab]
             menu.findItem(R.id.ml_menu_display_list).isVisible = viewModel.providersInCard[currentTab]
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
index 124c45d72..da0d29388 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
@@ -175,6 +175,10 @@ abstract class MediaBrowserFragment<T : SortableModel> : BaseFragment(), Filtera
                 sortBy(Medialibrary.SORT_LASTMODIFICATIONDATE)
                 return true
             }
+            R.id.ml_menu_sortby_insertion_date -> {
+                sortBy(Medialibrary.SORT_INSERTIONDATE)
+                return true
+            }
             R.id.ml_menu_sortby_artist_name -> {
                 sortBy(Medialibrary.SORT_ARTIST)
                 return true
diff --git a/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/AlbumsProvider.kt b/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/AlbumsProvider.kt
index 69d1e08b4..59d7337ce 100644
--- a/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/AlbumsProvider.kt
+++ b/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/AlbumsProvider.kt
@@ -40,6 +40,7 @@ class AlbumsProvider(val parent : MediaLibraryItem?, context: Context, model: So
     override fun canSortByDuration() = true
     override fun canSortByReleaseDate() = true
     override fun canSortByArtist() = true
+    override fun canSortByInsertionDate()= true
 
     init {
         sort = Settings.getInstance(context).getInt(sortKey, if (parent is Artist) Medialibrary.SORT_RELEASEDATE else Medialibrary.SORT_DEFAULT)



More information about the Android mailing list