[Android] Display extensions first in Android-auto
David Papazian
git at videolan.org
Mon Aug 28 09:43:02 CEST 2017
vlc-android | branch: master | David Papazian <david.papazian at metz.supelec.fr> | Fri Aug 25 17:36:20 2017 +0200| [efb27aebaab53fa477ef615e7504cfc00fbff5cf] | committer: Geoffrey Métais
Display extensions first in Android-auto
Signed-off-by: Geoffrey Métais <geoffrey.metais at gmail.com>
> https://code.videolan.org/videolan/vlc-android/commit/efb27aebaab53fa477ef615e7504cfc00fbff5cf
---
.../org/videolan/vlc/media/BrowserProvider.java | 72 +++++++++++-----------
1 file changed, 36 insertions(+), 36 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/media/BrowserProvider.java b/vlc-android/src/org/videolan/vlc/media/BrowserProvider.java
index dd8fc610f..e6d54af15 100644
--- a/vlc-android/src/org/videolan/vlc/media/BrowserProvider.java
+++ b/vlc-android/src/org/videolan/vlc/media/BrowserProvider.java
@@ -125,8 +125,43 @@ public class BrowserProvider implements ExtensionManagerService.ExtensionManager
switch (parentId) {
case ID_ROOT:
+ MediaDescriptionCompat.Builder item = new MediaDescriptionCompat.Builder();
+ //List of Extensions
+ List<ExtensionListing> extensions = ExtensionsManager.getInstance().getExtensions(VLCApplication.getAppContext(), true);
+ for (int i = 0; i < extensions.size(); i++) {
+ ExtensionListing extension = extensions.get(i);
+ if (extension.androidAutoEnabled()
+ && PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext()).getBoolean(ExtensionsManager.EXTENSION_PREFIX + "_" + extension.componentName().getPackageName() + "_" + ExtensionsManager.ANDROID_AUTO_SUFFIX, false)) {
+ item.setMediaId(ExtensionsManager.EXTENSION_PREFIX + "_" + String.valueOf(i))
+ .setTitle(extension.title());
+
+ int iconRes = extension.menuIcon();
+ Bitmap b = null;
+ Resources extensionRes;
+ if (iconRes != 0) {
+ try {
+ extensionRes = VLCApplication.getAppContext()
+ .getPackageManager()
+ .getResourcesForApplication(extension.componentName().getPackageName());
+ b = BitmapFactory.decodeResource(extensionRes, iconRes);
+ } catch (PackageManager.NameNotFoundException e) {
+ }
+ }
+ if (b != null)
+ item.setIconBitmap(b);
+ else
+ try {
+ b = ((BitmapDrawable) VLCApplication.getAppContext().getPackageManager().getApplicationIcon(extension.componentName().getPackageName())).getBitmap();
+ item.setIconBitmap(b);
+ } catch (PackageManager.NameNotFoundException e) {
+ b = BitmapFactory.decodeResource(res, R.drawable.icon);
+ item.setIconBitmap(b);
+ }
+ results.add(new MediaBrowserCompat.MediaItem(item.build(), MediaBrowserCompat.MediaItem.FLAG_BROWSABLE));
+ }
+ }
//Last added
- MediaDescriptionCompat.Builder item = new MediaDescriptionCompat.Builder()
+ item = new MediaDescriptionCompat.Builder()
.setMediaId(ID_LAST_ADDED)
.setTitle(res.getString(R.string.last_added_media))
.setIconUri(Uri.parse(BASE_DRAWABLE_URI+"ic_auto_history_normal"));
@@ -162,41 +197,6 @@ public class BrowserProvider implements ExtensionManagerService.ExtensionManager
.setTitle(res.getString(R.string.genres))
.setIconUri(Uri.parse(BASE_DRAWABLE_URI+"ic_auto_genre_normal"));
results.add(new MediaBrowserCompat.MediaItem(item.build(), MediaBrowserCompat.MediaItem.FLAG_BROWSABLE));
-
- //List of Extensions
- List<ExtensionListing> extensions = ExtensionsManager.getInstance().getExtensions(VLCApplication.getAppContext(), true);
- for (int i = 0; i < extensions.size(); i++) {
- ExtensionListing extension = extensions.get(i);
- if (extension.androidAutoEnabled()
- && PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext()).getBoolean(ExtensionsManager.EXTENSION_PREFIX + "_" + extension.componentName().getPackageName() + "_" + ExtensionsManager.ANDROID_AUTO_SUFFIX, false)) {
- item.setMediaId(ExtensionsManager.EXTENSION_PREFIX + "_" + String.valueOf(i))
- .setTitle(extension.title());
-
- int iconRes = extension.menuIcon();
- Bitmap b = null;
- Resources extensionRes;
- if (iconRes != 0) {
- try {
- extensionRes = VLCApplication.getAppContext()
- .getPackageManager()
- .getResourcesForApplication(extension.componentName().getPackageName());
- b = BitmapFactory.decodeResource(extensionRes, iconRes);
- } catch (PackageManager.NameNotFoundException e) {
- }
- }
- if (b != null)
- item.setIconBitmap(b);
- else
- try {
- b = ((BitmapDrawable) VLCApplication.getAppContext().getPackageManager().getApplicationIcon(extension.componentName().getPackageName())).getBitmap();
- item.setIconBitmap(b);
- } catch (PackageManager.NameNotFoundException e) {
- b = BitmapFactory.decodeResource(res, R.drawable.icon);
- item.setIconBitmap(b);
- }
- results.add(new MediaBrowserCompat.MediaItem(item.build(), MediaBrowserCompat.MediaItem.FLAG_BROWSABLE));
- }
- }
return results;
case ID_LAST_ADDED:
limitSize = true;
More information about the Android
mailing list