[Android] Rename mediasession browser provider

Geoffrey Métais git at videolan.org
Tue Mar 12 10:10:37 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Mar  8 16:09:43 2019 +0100| [2407372478826ab57c05986f6d7d33f7e49d5b8a] | committer: Geoffrey Métais

Rename mediasession browser provider

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

 vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt |  8 ++++----
 vlc-android/src/org/videolan/vlc/PlaybackService.kt      | 12 ++++++------
 .../{BrowserProvider.java => MediaSessionBrowser.java}   | 16 ++++++++--------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt b/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt
index b9be20f97..6531654b1 100644
--- a/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt
+++ b/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt
@@ -11,7 +11,7 @@ import org.videolan.medialibrary.Tools
 import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.medialibrary.media.MediaWrapper
 import org.videolan.vlc.extensions.ExtensionsManager
-import org.videolan.vlc.media.BrowserProvider
+import org.videolan.vlc.media.MediaSessionBrowser
 import org.videolan.vlc.util.*
 import java.util.*
 import kotlin.math.min
@@ -57,17 +57,17 @@ internal class MediaSessionCallback(private val playbackService: PlaybackService
             val context = playbackService.applicationContext
             val ml = playbackService.medialibrary
             when {
-                mediaId == BrowserProvider.ID_SHUFFLE_ALL -> {
+                mediaId == MediaSessionBrowser.ID_SHUFFLE_ALL -> {
                     val count = context.getFromMl { ml.audioCount }
                     val tracks = withContext(Dispatchers.IO) { ml.audio }
                     playbackService.load(tracks, Random().nextInt(min(count, MEDIALIBRARY_PAGE_SIZE)))
                     if (!playbackService.isShuffling) playbackService.shuffle()
                 }
-                mediaId.startsWith(BrowserProvider.ALBUM_PREFIX) -> {
+                mediaId.startsWith(MediaSessionBrowser.ALBUM_PREFIX) -> {
                     val tracks = context.getFromMl { getAlbum(mediaId.extractId())?.tracks }
                     tracks?.let { playbackService.load(it, 0) }
                 }
-                mediaId.startsWith(BrowserProvider.PLAYLIST_PREFIX) -> {
+                mediaId.startsWith(MediaSessionBrowser.PLAYLIST_PREFIX) -> {
                     val tracks = context.getFromMl { getPlaylist(mediaId.extractId())?.tracks }
                     tracks?.let { playbackService.load(it, 0) }
                 }
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index afa721319..155d47d3f 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -63,7 +63,7 @@ import org.videolan.vlc.gui.helpers.BitmapUtil
 import org.videolan.vlc.gui.helpers.NotificationHelper
 import org.videolan.vlc.gui.video.PopupManager
 import org.videolan.vlc.gui.video.VideoPlayerActivity
-import org.videolan.vlc.media.BrowserProvider
+import org.videolan.vlc.media.MediaSessionBrowser
 import org.videolan.vlc.media.MediaUtils
 import org.videolan.vlc.media.PlaylistManager
 import org.videolan.vlc.util.*
@@ -151,7 +151,7 @@ class PlaybackService : MediaBrowserServiceCompat(), CoroutineScope, LifecycleOw
                 }
                 VLCAppWidgetProvider.ACTION_WIDGET_INIT -> updateWidget()
                 VLCAppWidgetProvider.ACTION_WIDGET_ENABLED , VLCAppWidgetProvider.ACTION_WIDGET_DISABLED -> updateHasWidget()
-                ACTION_CAR_MODE_EXIT -> BrowserProvider.unbindExtensionConnection()
+                ACTION_CAR_MODE_EXIT -> MediaSessionBrowser.unbindExtensionConnection()
                 AudioManager.ACTION_AUDIO_BECOMING_NOISY -> if (detectHeadset) {
                     if (BuildConfig.DEBUG) Log.i(TAG, "Becoming noisy")
                     wasPlaying = isPlaying
@@ -785,7 +785,7 @@ class PlaybackService : MediaBrowserServiceCompat(), CoroutineScope, LifecycleOw
             val coverOnLockscreen = settings.getBoolean("lockscreen_cover", true)
             val bob = MediaMetadataCompat.Builder().apply {
                 putString(MediaMetadataCompat.METADATA_KEY_TITLE, title)
-                putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, BrowserProvider.generateMediaId(media))
+                putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, MediaSessionBrowser.generateMediaId(media))
                 putString(MediaMetadataCompat.METADATA_KEY_GENRE, MediaUtils.getMediaGenre(ctx, media))
                 putLong(MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER, media.trackNumber.toLong())
                 putString(MediaMetadataCompat.METADATA_KEY_ARTIST, MediaUtils.getMediaArtist(ctx, media))
@@ -1024,7 +1024,7 @@ class PlaybackService : MediaBrowserServiceCompat(), CoroutineScope, LifecycleOw
                             .setDescription(Util.getMediaDescription(MediaUtils.getMediaArtist(ctx, media), MediaUtils.getMediaAlbum(ctx, media)))
                             .setIconBitmap(BitmapUtil.getPictureFromCache(media))
                             .setMediaUri(media.uri)
-                            .setMediaId(BrowserProvider.generateMediaId(media))
+                            .setMediaId(MediaSessionBrowser.generateMediaId(media))
                     it.add(MediaSessionCompat.QueueItem(builder.build(), position.toLong()))
                 }
             }
@@ -1244,7 +1244,7 @@ class PlaybackService : MediaBrowserServiceCompat(), CoroutineScope, LifecycleOw
      */
 
     override fun onGetRoot(clientPackageName: String, clientUid: Int, rootHints: Bundle?): MediaBrowserServiceCompat.BrowserRoot? {
-        return if (Permissions.canReadStorage(this at PlaybackService)) MediaBrowserServiceCompat.BrowserRoot(BrowserProvider.ID_ROOT, null) else null
+        return if (Permissions.canReadStorage(this at PlaybackService)) MediaBrowserServiceCompat.BrowserRoot(MediaSessionBrowser.ID_ROOT, null) else null
     }
 
     override fun onLoadChildren(parentId: String, result: MediaBrowserServiceCompat.Result<List<MediaBrowserCompat.MediaItem>>) {
@@ -1258,7 +1258,7 @@ class PlaybackService : MediaBrowserServiceCompat(), CoroutineScope, LifecycleOw
     private fun sendResults(result: MediaBrowserServiceCompat.Result<List<MediaBrowserCompat.MediaItem>>, parentId: String) {
         launch(Dispatchers.IO) {
             try {
-                result.sendResult(BrowserProvider.browse(applicationContext, parentId))
+                result.sendResult(MediaSessionBrowser.browse(applicationContext, parentId))
             } catch (ignored: RuntimeException) {} //bitmap parcelization can fail
         }
     }
diff --git a/vlc-android/src/org/videolan/vlc/media/BrowserProvider.java b/vlc-android/src/org/videolan/vlc/media/MediaSessionBrowser.java
similarity index 97%
rename from vlc-android/src/org/videolan/vlc/media/BrowserProvider.java
rename to vlc-android/src/org/videolan/vlc/media/MediaSessionBrowser.java
index 721fecec5..b85d7c23b 100644
--- a/vlc-android/src/org/videolan/vlc/media/BrowserProvider.java
+++ b/vlc-android/src/org/videolan/vlc/media/MediaSessionBrowser.java
@@ -1,8 +1,8 @@
 /*
  * ************************************************************************
- *  BrowserProvider.java
+ *  MediaSessionBrowser.java
  * *************************************************************************
- *  Copyright © 2016 VLC authors and VideoLAN
+ *  Copyright © 2016-2019 VLC authors and VideoLAN
  *  Author: Geoffrey Métais
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -59,9 +59,9 @@ import androidx.annotation.NonNull;
 import androidx.annotation.WorkerThread;
 
 
-public class BrowserProvider implements ExtensionManagerService.ExtensionManagerActivity {
+public class MediaSessionBrowser implements ExtensionManagerService.ExtensionManagerActivity {
 
-    private static final String TAG = "VLC/BrowserProvider";
+    private static final String TAG = "VLC/MediaSessionBrowser";
 
     private static final Bitmap DEFAULT_AUDIO_COVER = BitmapFactory.decodeResource(VLCApplication.getAppResources(), R.drawable.ic_menu_audio);
     private static String BASE_DRAWABLE_URI;
@@ -328,10 +328,10 @@ public class BrowserProvider implements ExtensionManagerService.ExtensionManager
         extensionLock.release();
     }
 
-    private static BrowserProvider instance;
-    private static BrowserProvider getInstance() {
+    private static MediaSessionBrowser instance;
+    private static MediaSessionBrowser getInstance() {
         if (instance == null)
-            instance = new BrowserProvider();
+            instance = new MediaSessionBrowser();
         return instance;
     }
 
@@ -340,7 +340,7 @@ public class BrowserProvider implements ExtensionManagerService.ExtensionManager
             @Override
             public void onServiceConnected(ComponentName name, IBinder service) {
                 sExtensionManagerService = ((ExtensionManagerService.LocalBinder)service).getService();
-                sExtensionManagerService.setExtensionManagerActivity(BrowserProvider.getInstance());
+                sExtensionManagerService.setExtensionManagerActivity(MediaSessionBrowser.getInstance());
                 extensionLock.release();
             }
             @Override



More information about the Android mailing list