[Android] Replace sort order by unicode char and get rid of (desc) strings

Nicolas Pomepuy git at videolan.org
Tue Apr 28 15:52:41 CEST 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Apr 28 12:06:31 2020 +0200| [8b4700d224e33039739e64c309dbc83755b91fc4] | committer: Geoffrey Métais

Replace sort order by unicode char and get rid of (desc) strings

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

 .../resources/src/main/res/values/strings.xml      |  9 -------
 .../src/org/videolan/vlc/gui/helpers/UiTools.kt    | 28 +++++++++++-----------
 2 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 29b3274d2..9a389d65d 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -8,23 +8,14 @@
     <string name="other">Other</string>
     <string name="sortby">Sort by…</string>
     <string name="sortby_name">Name</string>
-    <string name="sortby_name_desc">Name (desc)</string>
     <string name="sortby_filename">File name</string>
-    <string name="sortby_filename_desc">File name (desc)</string>
     <string name="sortby_artist_name">Artist name</string>
-    <string name="sortby_artist_name_desc">Artist name (desc)</string>
     <string name="sortby_album_name">Album name</string>
-    <string name="sortby_album_name_desc">Album name (desc)</string>
     <string name="sortby_length">Length</string>
-    <string name="sortby_length_desc">Length (desc)</string>
     <string name="sortby_date">Date</string>
-    <string name="sortby_date_desc">Date (desc)</string>
     <string name="sortby_last_modified_date">Recently added</string>
-    <string name="sortby_last_modified_date_desc">Recently added (desc)</string>
     <string name="sortby_media_number">Media number</string>
-    <string name="sortby_media_number_desc">Media number (desc)</string>
     <string name="sortby_number">Nb tracks</string>
-    <string name="sortby_number_desc">Nb tracks (desc)</string>
     <string name="searchable_hint">Search…</string>
     <string name="history">History</string>
 
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
index ce743a199..1a0e40828 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
@@ -411,19 +411,19 @@ object UiTools {
         val sort = provider.sort
         val desc = provider.desc
         var item: MenuItem? = menu.findItem(R.id.ml_menu_sortby_name)
-        item?.setTitle(if (sort == Medialibrary.SORT_ALPHA && !desc) R.string.sortby_name_desc else R.string.sortby_name)
+        item?.title = "${provider.context.getString(R.string.sortby_name)} ${if (sort == Medialibrary.SORT_ALPHA && !desc) "▼" else ""}"
         item = menu.findItem(R.id.ml_menu_sortby_filename)
-        item?.setTitle(if (sort == Medialibrary.SORT_FILENAME && !desc) R.string.sortby_filename_desc else R.string.sortby_filename)
+        item?.title = "${provider.context.getString(R.string.sortby_filename)} ${if (sort == Medialibrary.SORT_FILENAME && !desc) "▼" else ""}"
         item = menu.findItem(R.id.ml_menu_sortby_artist_name)
-        item?.setTitle(if (sort == Medialibrary.SORT_ARTIST && !desc) R.string.sortby_artist_name_desc else R.string.sortby_artist_name)
+        item?.title = "${provider.context.getString(R.string.sortby_artist_name)} ${if (sort == Medialibrary.SORT_ARTIST && !desc) "▼" else ""}"
         item = menu.findItem(R.id.ml_menu_sortby_album_name)
-        item?.setTitle(if (sort == Medialibrary.SORT_ALBUM && !desc) R.string.sortby_album_name_desc else R.string.sortby_album_name)
+        item?.title = "${provider.context.getString(R.string.sortby_album_name)} ${if (sort == Medialibrary.SORT_ALBUM && !desc) "▼" else ""}"
         item = menu.findItem(R.id.ml_menu_sortby_length)
-        item?.setTitle(if (sort == Medialibrary.SORT_DURATION && !desc) R.string.sortby_length_desc else R.string.sortby_length)
+        item?.title = "${provider.context.getString(R.string.sortby_length)} ${if (sort == Medialibrary.SORT_DURATION && !desc) "▼" else ""}"
         item = menu.findItem(R.id.ml_menu_sortby_date)
-        item?.setTitle(if (sort == Medialibrary.SORT_RELEASEDATE && !desc) R.string.sortby_date_desc else R.string.sortby_date)
+        item?.title = "${provider.context.getString(R.string.sortby_date)} ${if (sort == Medialibrary.SORT_RELEASEDATE && !desc) "▼" else ""}"
         item = menu.findItem(R.id.ml_menu_sortby_last_modified)
-        item?.setTitle(if (sort == Medialibrary.SORT_LASTMODIFICATIONDATE && !desc) R.string.sortby_last_modified_date_desc else R.string.sortby_last_modified_date)
+        item?.title = "${provider.context.getString(R.string.sortby_last_modified_date)} ${if (sort == Medialibrary.SORT_LASTMODIFICATIONDATE && !desc) "▼" else ""}"
         //        item = menu.findItem(R.id.ml_menu_sortby_number); TODO sort by track number
         //        if (item != null) item.setTitle(sort == Medialibrary.SORT_ && !desc ? R.string.sortby_number_desc : R.string.sortby_number);
 
@@ -435,19 +435,19 @@ object UiTools {
         val sort = model.sort
         val desc = model.desc
         var item: MenuItem? = menu.findItem(R.id.ml_menu_sortby_name)
-        item?.setTitle(if (sort == Medialibrary.SORT_ALPHA && !desc) R.string.sortby_name_desc else R.string.sortby_name)
+        item?.title = "${sortable.requireContext().getString(R.string.sortby_name)} ${if (sort == Medialibrary.SORT_ALPHA && !desc) "▼" else ""}"
         item = menu.findItem(R.id.ml_menu_sortby_filename)
-        item?.setTitle(if (sort == Medialibrary.SORT_FILENAME && !desc) R.string.sortby_filename_desc else R.string.sortby_filename)
+        item?.title = "${sortable.requireContext().getString(R.string.sortby_filename)} ${if (sort == Medialibrary.SORT_FILENAME && !desc) "▼" else ""}"
         item = menu.findItem(R.id.ml_menu_sortby_artist_name)
-        item?.setTitle(if (sort == Medialibrary.SORT_ARTIST && !desc) R.string.sortby_artist_name_desc else R.string.sortby_artist_name)
+        item?.title = "${sortable.requireContext().getString(R.string.sortby_artist_name)} ${if (sort == Medialibrary.SORT_ARTIST && !desc) "▼" else ""}"
         item = menu.findItem(R.id.ml_menu_sortby_album_name)
-        item?.setTitle(if (sort == Medialibrary.SORT_ALBUM && !desc) R.string.sortby_album_name_desc else R.string.sortby_album_name)
+        item?.title = "${sortable.requireContext().getString(R.string.sortby_album_name)} ${if (sort == Medialibrary.SORT_ALBUM && !desc) "▼" else ""}"
         item = menu.findItem(R.id.ml_menu_sortby_length)
-        item?.setTitle(if (sort == Medialibrary.SORT_DURATION && !desc) R.string.sortby_length_desc else R.string.sortby_length)
+        item?.title = "${sortable.requireContext().getString(R.string.sortby_length)} ${if (sort == Medialibrary.SORT_DURATION && !desc) "▼" else ""}"
         item = menu.findItem(R.id.ml_menu_sortby_date)
-        item?.setTitle(if (sort == Medialibrary.SORT_RELEASEDATE && !desc) R.string.sortby_date_desc else R.string.sortby_date)
+        item?.title = "${sortable.requireContext().getString(R.string.sortby_date)} ${if (sort == Medialibrary.SORT_RELEASEDATE && !desc) "▼" else ""}"
         item = menu.findItem(R.id.ml_menu_sortby_last_modified)
-        item?.setTitle(if (sort == Medialibrary.SORT_RELEASEDATE && !desc) R.string.sortby_last_modified_date_desc else R.string.sortby_last_modified_date)
+        item?.title = "${sortable.requireContext().getString(R.string.sortby_last_modified_date)} ${if (sort == Medialibrary.SORT_RELEASEDATE && !desc) "▼" else ""}"
         //        item = menu.findItem(R.id.ml_menu_sortby_number); TODO sort by track number
         //        if (item != null) item.setTitle(sort == Medialibrary.SORT_ && !desc ? R.string.sortby_number_desc : R.string.sortby_number);
 



More information about the Android mailing list