[Android] Allow UPnP folders to be added as favorites on TV

Persi Persu git at videolan.org
Wed Sep 4 15:39:03 CEST 2019


vlc-android | branch: 3.2.x | Persi Persu <persi.persu at gmail.com> | Sat Aug 24 13:19:03 2019 +0200| [4572957241c68bd4cc7066a4e69deaaeabd9fd1c] | committer: Nicolas Pomepuy

Allow UPnP folders to be added as favorites on TV

Apply suggestion to vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.kt

(cherry picked from commit a761d60a94241773cf1e6d4fe6fc62fd9980cde7)

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

 .../src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.kt        | 1 +
 vlc-android/src/org/videolan/vlc/util/Constants.kt                     | 1 +
 vlc-android/src/org/videolan/vlc/util/FileUtils.kt                     | 3 ++-
 vlc-android/src/org/videolan/vlc/viewmodels/tv/MainTvModel.kt          | 1 +
 4 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.kt
index fcc81a103..b308b1a2e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.kt
@@ -69,6 +69,7 @@ class VerticalGridActivity : BaseTvActivity(), BrowserActivityInterface {
                 if (uri == null) uri = intent.getParcelableExtra(KEY_URI)
 
                 val item = if (uri == null) null else MLServiceLocator.getAbstractMediaWrapper(uri)
+                if (item != null && intent.hasExtra(FAVORITE_TITLE)) item.title = intent.getStringExtra(FAVORITE_TITLE)
 
                 fragment = FileBrowserTvFragment.newInstance(TYPE_NETWORK, item)
             } else if (type == HEADER_DIRECTORIES) {
diff --git a/vlc-android/src/org/videolan/vlc/util/Constants.kt b/vlc-android/src/org/videolan/vlc/util/Constants.kt
index d39c7d1cb..68a91dc31 100644
--- a/vlc-android/src/org/videolan/vlc/util/Constants.kt
+++ b/vlc-android/src/org/videolan/vlc/util/Constants.kt
@@ -123,6 +123,7 @@ const val CATEGORY = "category"
 const val ITEM = "item"
 const val KEY_GROUP = "key_group"
 const val KEY_FOLDER = "key_folder"
+const val FAVORITE_TITLE = "favorite_title"
 
 // Items updates
 const val UPDATE_SELECTION = 0
diff --git a/vlc-android/src/org/videolan/vlc/util/FileUtils.kt b/vlc-android/src/org/videolan/vlc/util/FileUtils.kt
index e24207c7f..f159fd1f7 100644
--- a/vlc-android/src/org/videolan/vlc/util/FileUtils.kt
+++ b/vlc-android/src/org/videolan/vlc/util/FileUtils.kt
@@ -294,7 +294,8 @@ object FileUtils {
         val scheme = mw.uri.scheme
         return (TextUtils.equals(scheme, "file") || TextUtils.equals(scheme, "smb")
                 || TextUtils.equals(scheme, "nfs") || TextUtils.equals(scheme, "ftp")
-                || TextUtils.equals(scheme, "ftps") || TextUtils.equals(scheme, "sftp"))
+                || TextUtils.equals(scheme, "ftps") || TextUtils.equals(scheme, "sftp")
+                || TextUtils.equals(scheme, "upnp"))
     }
 
     @WorkerThread
diff --git a/vlc-android/src/org/videolan/vlc/viewmodels/tv/MainTvModel.kt b/vlc-android/src/org/videolan/vlc/viewmodels/tv/MainTvModel.kt
index ed6c39324..64e213746 100644
--- a/vlc-android/src/org/videolan/vlc/viewmodels/tv/MainTvModel.kt
+++ b/vlc-android/src/org/videolan/vlc/viewmodels/tv/MainTvModel.kt
@@ -219,6 +219,7 @@ class MainTvModel(app: Application) : AndroidViewModel(app), AbstractMedialibrar
                 item.type == AbstractMediaWrapper.TYPE_DIR -> {
                     val intent = Intent(activity, VerticalGridActivity::class.java)
                     intent.putExtra(MainTvActivity.BROWSER_TYPE, if ("file" == item.uri.scheme) HEADER_DIRECTORIES else HEADER_NETWORK)
+                    intent.putExtra(FAVORITE_TITLE, item.title)
                     intent.data = item.uri
                     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
                     activity.startActivity(intent)



More information about the Android mailing list