[Android] Allow copying a stream link in the playlist screen

Nicolas Pomepuy git at videolan.org
Thu Nov 25 06:35:26 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Nov 24 10:00:12 2021 +0100| [1e8afa424b45dea6ee97a24d1911695e19828efc] | committer: Nicolas Pomepuy

Allow copying a stream link in the playlist screen

Fixes #2260

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

 .../resources/src/main/java/org/videolan/resources/Constants.kt  | 2 +-
 .../vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt     | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 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 a0b21fe4b..6d9468aef 100644
--- a/application/resources/src/main/java/org/videolan/resources/Constants.kt
+++ b/application/resources/src/main/java/org/videolan/resources/Constants.kt
@@ -221,7 +221,7 @@ const val CTX_VIDEO_FLAGS = CTX_APPEND or CTX_PLAY_NEXT or CTX_DELETE or CTX_DOW
 const val CTX_TRACK_FLAGS = CTX_APPEND or CTX_PLAY_NEXT or CTX_DELETE or CTX_INFORMATION or CTX_PLAY_ALL or CTX_ADD_TO_PLAYLIST or CTX_SET_RINGTONE or CTX_SHARE or CTX_GO_TO_FOLDER
 const val CTX_AUDIO_FLAGS = CTX_PLAY or CTX_APPEND or CTX_PLAY_NEXT or CTX_ADD_TO_PLAYLIST or CTX_INFORMATION
 const val CTX_PLAYLIST_ALBUM_FLAGS = CTX_AUDIO_FLAGS or CTX_DELETE
-const val CTX_PLAYLIST_ITEM_FLAGS = CTX_APPEND or CTX_PLAY_NEXT or CTX_ADD_TO_PLAYLIST or CTX_INFORMATION or CTX_DELETE or CTX_SET_RINGTONE or CTX_SHARE
+const val CTX_PLAYLIST_ITEM_FLAGS = CTX_APPEND or CTX_PLAY_NEXT or CTX_ADD_TO_PLAYLIST or CTX_INFORMATION or CTX_DELETE or CTX_SET_RINGTONE
 const val CTX_VIDEO_GROUP_FLAGS = CTX_APPEND or CTX_MARK_ALL_AS_PLAYED
 const val CTX_FOLDER_FLAGS = CTX_PLAY or CTX_APPEND or CTX_ADD_TO_PLAYLIST or CTX_MARK_ALL_AS_PLAYED
 
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt
index 984a27e46..1e9dd85bc 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt
@@ -43,12 +43,14 @@ import androidx.recyclerview.widget.ItemTouchHelper
 import androidx.recyclerview.widget.LinearLayoutManager
 import androidx.recyclerview.widget.RecyclerView
 import com.google.android.material.bottomsheet.BottomSheetBehavior
+import com.google.android.material.snackbar.Snackbar
 import kotlinx.coroutines.*
 import org.videolan.medialibrary.interfaces.Medialibrary
 import org.videolan.medialibrary.interfaces.media.MediaWrapper
 import org.videolan.medialibrary.interfaces.media.Playlist
 import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.resources.*
+import org.videolan.tools.copy
 import org.videolan.tools.isStarted
 import org.videolan.vlc.BuildConfig
 import org.videolan.vlc.R
@@ -252,7 +254,8 @@ open class PlaylistActivity : AudioPlayerContainerActivity(), IEventsHandler<Med
         if (actionMode == null) {
             var flags = CTX_PLAYLIST_ITEM_FLAGS
             (item as? MediaWrapper)?.let { media ->
-                if (media.type == MediaWrapper.TYPE_STREAM || (media.type == MediaWrapper.TYPE_ALL && isSchemeHttpOrHttps(media.uri.scheme))) flags = flags or CTX_RENAME
+                if (media.type == MediaWrapper.TYPE_STREAM || (media.type == MediaWrapper.TYPE_ALL && isSchemeHttpOrHttps(media.uri.scheme))) flags = flags or CTX_RENAME or CTX_COPY
+                else  flags = flags or CTX_SHARE
             }
             showContext(this, this, position, item.title, flags)
         }
@@ -389,6 +392,10 @@ open class PlaylistActivity : AudioPlayerContainerActivity(), IEventsHandler<Med
                     }
                 }
             }
+            CTX_COPY -> {
+                copy(media.title, media.location)
+                Snackbar.make(window.decorView.findViewById(android.R.id.content), R.string.url_copied_to_clipboard, Snackbar.LENGTH_LONG).show()
+            }
         }
 
     }



More information about the Android mailing list