[Android] Auto fill playlist name when creating from a folder
Nicolas Pomepuy
git at videolan.org
Wed Jun 5 14:32:58 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Jun 5 14:43:36 2024 +0200| [7ae96ff62727fcbabeabd1a9351b17d7ddb5b6ca] | committer: Duncan McNamara
Auto fill playlist name when creating from a folder
Fixes #3071
> https://code.videolan.org/videolan/vlc-android/commit/7ae96ff62727fcbabeabd1a9351b17d7ddb5b6ca
---
.../src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt | 8 ++++----
.../src/org/videolan/vlc/gui/browser/MainBrowserFragment.kt | 4 ++--
.../src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.kt | 2 ++
.../vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt | 4 ++--
4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
index 648f433d2d..4851ca31e9 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
@@ -656,12 +656,12 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
}
R.id.folder_add_playlist -> {
- currentMedia?.let { requireActivity().addToPlaylistAsync(it.uri.toString()) }
+ currentMedia?.let { requireActivity().addToPlaylistAsync(it.uri.toString(), defaultTitle = it.title) }
true
}
R.id.subfolders_add_playlist -> {
- currentMedia?.let { requireActivity().addToPlaylistAsync(it.uri.toString(), true) }
+ currentMedia?.let { requireActivity().addToPlaylistAsync(it.uri.toString(), true, defaultTitle = it.title) }
true
}
@@ -836,11 +836,11 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
}
CTX_ADD_FOLDER_PLAYLIST -> {
- requireActivity().addToPlaylistAsync(mw.uri.toString(), false)
+ requireActivity().addToPlaylistAsync(mw.uri.toString(), false, mw.title)
}
CTX_ADD_FOLDER_AND_SUB_PLAYLIST -> {
- requireActivity().addToPlaylistAsync(mw.uri.toString(), true)
+ requireActivity().addToPlaylistAsync(mw.uri.toString(), true, mw.title)
}
else -> {}
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/MainBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/MainBrowserFragment.kt
index b969cd9d2a..28cb873897 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/MainBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/MainBrowserFragment.kt
@@ -407,8 +407,8 @@ class MainBrowserFragment : BaseFragment(), View.OnClickListener, CtxActionRecei
when (option) {
CTX_PLAY -> MediaUtils.openMedia(activity, mw)
CTX_FAV_REMOVE -> lifecycleScope.launch(Dispatchers.IO) { browserFavRepository.deleteBrowserFav(mw.uri) }
- CTX_ADD_FOLDER_PLAYLIST -> requireActivity().addToPlaylistAsync(mw.uri.toString(), false)
- CTX_ADD_FOLDER_AND_SUB_PLAYLIST -> requireActivity().addToPlaylistAsync(mw.uri.toString(), true)
+ CTX_ADD_FOLDER_PLAYLIST -> requireActivity().addToPlaylistAsync(mw.uri.toString(), false, mw.title)
+ CTX_ADD_FOLDER_AND_SUB_PLAYLIST -> requireActivity().addToPlaylistAsync(mw.uri.toString(), true, mw.title)
CTX_FAV_EDIT -> showAddServerDialog(mw)
else -> {}
}
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.kt
index d68ba05e35..e3cfe976e3 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.kt
@@ -142,6 +142,7 @@ class SavePlaylistDialog : VLCBottomSheetDialogFragment(), View.OnClickListener,
binding = DialogPlaylistBinding.inflate(layoutInflater, container, false)
binding.isLoading = isLoading
binding.filesText = filesText
+ binding.dialogPlaylistName.editText?.setText(requireArguments().getString(KEY_DEFAULT_TITLE) ?: "")
return binding.root
}
@@ -344,6 +345,7 @@ class SavePlaylistDialog : VLCBottomSheetDialogFragment(), View.OnClickListener,
const val KEY_NEW_TRACKS = "PLAYLIST_NEW_TRACKS"
const val KEY_FOLDER = "PLAYLIST_FROM_FOLDER"
const val KEY_SUB_FOLDERS = "PLAYLIST_FOLDER_ADD_SUBFOLDERS"
+ const val KEY_DEFAULT_TITLE = "DEFAULT_TITLE"
const val SELECTED_PLAYLIST = "SELECTED_PLAYLIST"
}
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
index f536efad8b..03c5dcd02f 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
@@ -481,11 +481,11 @@ object UiTools {
}
}
- fun FragmentActivity.addToPlaylistAsync(parent: String, includeSubfolders: Boolean = false) {
+ fun FragmentActivity.addToPlaylistAsync(parent: String, includeSubfolders: Boolean = false, defaultTitle:String = "") {
if (!isStarted()) return
val savePlaylistDialog = SavePlaylistDialog()
savePlaylistDialog.arguments = bundleOf(SavePlaylistDialog.KEY_FOLDER to parent,
- SavePlaylistDialog.KEY_SUB_FOLDERS to includeSubfolders)
+ SavePlaylistDialog.KEY_SUB_FOLDERS to includeSubfolders, SavePlaylistDialog.KEY_DEFAULT_TITLE to defaultTitle)
savePlaylistDialog.show(supportFragmentManager, "fragment_add_to_playlist")
}
More information about the Android
mailing list