[Android] Set list layout as the default content style for Android Auto

Robert Stone git at videolan.org
Wed Mar 9 12:24:51 UTC 2022


vlc-android | branch: master | Robert Stone <rhstone at gmail.com> | Tue Mar  8 21:34:33 2022 -0800| [ecc8ca626fd542286005bde597508cc38b561c5c] | committer: Robert Stone

Set list layout as the default content style for Android Auto

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

 .../resources/src/main/java/org/videolan/resources/Constants.kt   | 1 +
 application/vlc-android/src/org/videolan/vlc/PlaybackService.kt   | 2 +-
 .../vlc-android/src/org/videolan/vlc/media/MediaSessionBrowser.kt | 8 +++-----
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/application/resources/src/main/java/org/videolan/resources/Constants.kt b/application/resources/src/main/java/org/videolan/resources/Constants.kt
index 655aa13a6..f0f21efc4 100644
--- a/application/resources/src/main/java/org/videolan/resources/Constants.kt
+++ b/application/resources/src/main/java/org/videolan/resources/Constants.kt
@@ -83,6 +83,7 @@ const val EXTRA_MEDIA_SEARCH_SUPPORTED = "android.media.browse.SEARCH_SUPPORTED"
 const val TABS_OPT_IN_HINT = "android.media.browse.AUTO_TABS_OPT_IN_HINT"
 const val CONTENT_STYLE_LIST_ITEM_HINT_VALUE = 1
 const val CONTENT_STYLE_GRID_ITEM_HINT_VALUE = 2
+const val CONTENT_STYLE_CATEGORY_ITEM_HINT_VALUE = 3
 
 // MediaParsingService
 const val ACTION_INIT = "medialibrary_init"
diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index e4a3d8e60..126339bf0 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -1662,7 +1662,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner, CoroutineSc
                     "com.google.android.googlequicksearchbox" -> MediaSessionBrowser.ID_ROOT_NO_TABS
                     else -> MediaSessionBrowser.ID_ROOT
                 }
-                val extras = MediaSessionBrowser.getContentStyle(CONTENT_STYLE_LIST_ITEM_HINT_VALUE, CONTENT_STYLE_LIST_ITEM_HINT_VALUE).apply {
+                val extras = MediaSessionBrowser.getContentStyle().apply {
                     putBoolean(TABS_OPT_IN_HINT, true)
                     putBoolean(EXTRA_MEDIA_SEARCH_SUPPORTED, true)
                 }
diff --git a/application/vlc-android/src/org/videolan/vlc/media/MediaSessionBrowser.kt b/application/vlc-android/src/org/videolan/vlc/media/MediaSessionBrowser.kt
index 9a759313b..b380ee62b 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/MediaSessionBrowser.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/MediaSessionBrowser.kt
@@ -62,7 +62,6 @@ import org.videolan.vlc.media.MediaUtils.getMediaDescription
 import org.videolan.vlc.media.MediaUtils.getMediaSubtitle
 import org.videolan.vlc.util.ThumbnailsProvider
 import org.videolan.vlc.util.isSchemeStreaming
-import java.util.*
 import java.util.concurrent.Semaphore
 
 /**
@@ -349,7 +348,7 @@ class MediaSessionBrowser : ExtensionManagerActivity {
                                 .setMediaId(ID_ALBUM)
                                 .setTitle(res.getString(R.string.albums))
                                 .setIconUri(MENU_ALBUM_ICON)
-                                .setExtras(if (ml.albumsCount <= MAX_RESULT_SIZE) getContentStyle(CONTENT_STYLE_GRID_ITEM_HINT_VALUE, CONTENT_STYLE_LIST_ITEM_HINT_VALUE) else null)
+                                .setExtras(if (ml.albumsCount <= MAX_RESULT_SIZE) getContentStyle(CONTENT_STYLE_GRID_ITEM_HINT_VALUE) else null)
                                 .build()
                         results.add(MediaBrowserCompat.MediaItem(albumsMediaDesc, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE))
                         //Tracks
@@ -378,8 +377,7 @@ class MediaSessionBrowser : ExtensionManagerActivity {
                     ID_ALBUM -> {
                         val albums = ml.getAlbums(Medialibrary.SORT_ALPHA, false, false)
                         albums.sortWith(MediaComparators.ANDROID_AUTO)
-                        if (page == null && albums.size > MAX_RESULT_SIZE) return paginateLibrary(albums, parentIdUri, MENU_ALBUM_ICON,
-                                    getContentStyle(CONTENT_STYLE_GRID_ITEM_HINT_VALUE, CONTENT_STYLE_LIST_ITEM_HINT_VALUE))
+                        if (page == null && albums.size > MAX_RESULT_SIZE) return paginateLibrary(albums, parentIdUri, MENU_ALBUM_ICON, getContentStyle(CONTENT_STYLE_GRID_ITEM_HINT_VALUE))
                         list = albums.copyOfRange(pageOffset.coerceAtMost(albums.size), (pageOffset + MAX_RESULT_SIZE).coerceAtMost(albums.size))
                     }
                     ID_TRACK -> {
@@ -684,7 +682,7 @@ class MediaSessionBrowser : ExtensionManagerActivity {
             return results
         }
 
-        fun getContentStyle(browsableHint: Int, playableHint: Int): Bundle {
+        fun getContentStyle(browsableHint: Int = CONTENT_STYLE_LIST_ITEM_HINT_VALUE, playableHint: Int = CONTENT_STYLE_LIST_ITEM_HINT_VALUE): Bundle {
             return Bundle().apply {
                 putBoolean(CONTENT_STYLE_SUPPORTED, true)
                 putInt(CONTENT_STYLE_BROWSABLE_HINT, browsableHint)



More information about the Android mailing list