[Android] VideoFolderGroups: add context btn to ban folder
Duncan McNamara
git at videolan.org
Wed Sep 6 07:28:29 UTC 2023
vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Fri Jul 7 17:40:05 2023 +0200| [aec4877bd4bc9908755d64da38ecedc282597a50] | committer: Nicolas Pomepuy
VideoFolderGroups: add context btn to ban folder
This is usefull when user after loading their library for the first time
want to remove directories from the index without having to go the
medialibrary folder selection view.
> https://code.videolan.org/videolan/vlc-android/commit/aec4877bd4bc9908755d64da38ecedc282597a50
---
application/resources/assets/images/svg/ic_ctx_hide_source.svg | 1 +
.../resources/src/main/java/org/videolan/resources/Constants.kt | 3 ++-
.../resources/src/main/res/drawable/ic_ctx_hide_source.xml | 9 +++++++++
application/resources/src/main/res/values/strings.xml | 2 ++
.../vlc-android/src/org/videolan/vlc/gui/dialogs/ContextSheet.kt | 2 ++
.../src/org/videolan/vlc/gui/helpers/MedialibraryUtils.kt | 4 ++++
.../src/org/videolan/vlc/gui/video/VideoGridFragment.kt | 6 ++++++
7 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/application/resources/assets/images/svg/ic_ctx_hide_source.svg b/application/resources/assets/images/svg/ic_ctx_hide_source.svg
new file mode 100644
index 0000000000..5b87b6ee6e
--- /dev/null
+++ b/application/resources/assets/images/svg/ic_ctx_hide_source.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><path d="M0,0h24v24H0V0z" fill="none"/></g><g><path d="M2.81,2.81L1.39,4.22l2.27,2.27C2.61,8.07,2,9.96,2,12c0,5.52,4.48,10,10,10c2.04,0,3.93-0.61,5.51-1.66l2.27,2.27 l1.41-1.41L2.81,2.81z M12,20c-4.41,0-8-3.59-8-8c0-1.48,0.41-2.86,1.12-4.06l10.94,10.94C14.86,19.59,13.48,20,12,20z M7.94,5.12 L6.49,3.66C8.07,2.61,9.96,2,12,2c5.52,0,10,4.48,10,10c0,2.04-0.61,3.93-1.66,5.51l-1.46-1.46C19.59,14.86,20,13.48,20,12 c0-4.41-3.59-8-8-8C10.52,4,9.14,4.41,7.94,5.12z"/></g></svg>
\ No newline at end of file
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 d70a0a496e..0d9a5d30ca 100644
--- a/application/resources/src/main/java/org/videolan/resources/Constants.kt
+++ b/application/resources/src/main/java/org/videolan/resources/Constants.kt
@@ -235,6 +235,7 @@ const val CTX_MARK_ALL_AS_PLAYED = 1L shl 37
const val CTX_GO_TO_FOLDER = 1L shl 38
const val CTX_MARK_AS_UNPLAYED = 1L shl 39
const val CTX_ADD_SHORTCUT = 1L shl 40
+const val CTX_BAN_FOLDER = 1L shl 41
const val CTX_VIDEO_FLAGS = CTX_APPEND or CTX_PLAY_NEXT or CTX_DELETE or CTX_DOWNLOAD_SUBTITLES or CTX_INFORMATION or CTX_PLAY or CTX_PLAY_ALL or CTX_PLAY_AS_AUDIO or CTX_ADD_TO_PLAYLIST or CTX_SHARE or CTX_ADD_SHORTCUT
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 or CTX_ADD_SHORTCUT
@@ -242,7 +243,7 @@ const val CTX_AUDIO_FLAGS = CTX_PLAY or CTX_APPEND or CTX_PLAY_NEXT or CTX_ADD_T
const val CTX_PLAYLIST_ALBUM_FLAGS = CTX_AUDIO_FLAGS or CTX_DELETE or CTX_ADD_SHORTCUT
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_ADD_SHORTCUT
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
+const val CTX_FOLDER_FLAGS = CTX_PLAY or CTX_APPEND or CTX_ADD_TO_PLAYLIST or CTX_MARK_ALL_AS_PLAYED or CTX_BAN_FOLDER
//Moviepedia
const val MOVIEPEDIA_MEDIA: String = "moviepedia_media"
diff --git a/application/resources/src/main/res/drawable/ic_ctx_hide_source.xml b/application/resources/src/main/res/drawable/ic_ctx_hide_source.xml
new file mode 100644
index 0000000000..f129731b22
--- /dev/null
+++ b/application/resources/src/main/res/drawable/ic_ctx_hide_source.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="40dp"
+ android:height="40dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#000000"
+ android:pathData="M2.81,2.81L1.39,4.22l2.27,2.27C2.61,8.07 2,9.96 2,12c0,5.52 4.48,10 10,10c2.04,0 3.93,-0.61 5.51,-1.66l2.27,2.27l1.41,-1.41L2.81,2.81zM12,20c-4.41,0 -8,-3.59 -8,-8c0,-1.48 0.41,-2.86 1.12,-4.06l10.94,10.94C14.86,19.59 13.48,20 12,20zM7.94,5.12L6.49,3.66C8.07,2.61 9.96,2 12,2c5.52,0 10,4.48 10,10c0,2.04 -0.61,3.93 -1.66,5.51l-1.46,-1.46C19.59,14.86 20,13.48 20,12c0,-4.41 -3.59,-8 -8,-8C10.52,4 9.14,4.41 7.94,5.12z" />
+</vector>
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index edbc197756..9a7c8b47e2 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -312,6 +312,8 @@
<string name="add_custom_path">Add a custom path</string>
<string name="add_custom_path_description">Enter additional custom directory to scan:</string>
<string name="remove_custom_path">Remove custom path</string>
+ <string name="group_ban_folder">Ban folder from media library</string>
+
<string name="hardware_acceleration">Hardware Acceleration</string>
<string name="hardware_acceleration_summary">Disabled: better stability\nDecoding: may improve performance\nFull: may improve performance further</string>
<string name="hardware_acceleration_disabled">Disabled</string>
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/ContextSheet.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/ContextSheet.kt
index ee4baa1216..84b34defc1 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/ContextSheet.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/ContextSheet.kt
@@ -42,6 +42,7 @@ import org.videolan.resources.CTX_ADD_SCANNED
import org.videolan.resources.CTX_ADD_SHORTCUT
import org.videolan.resources.CTX_ADD_TO_PLAYLIST
import org.videolan.resources.CTX_APPEND
+import org.videolan.resources.CTX_BAN_FOLDER
import org.videolan.resources.CTX_COPY
import org.videolan.resources.CTX_CUSTOM_REMOVE
import org.videolan.resources.CTX_DELETE
@@ -175,6 +176,7 @@ class ContextSheet : VLCBottomSheetDialogFragment() {
if (flags and CTX_MARK_ALL_AS_PLAYED != 0L) add(Simple(CTX_MARK_ALL_AS_PLAYED, getString(R.string.mark_all_as_played), R.drawable.ic_ctx_mark_all_as_played))
if (flags and CTX_GO_TO_FOLDER != 0L) add(Simple(CTX_GO_TO_FOLDER, getString(R.string.go_to_folder), R.drawable.ic_ctx_folder))
if (flags and CTX_CUSTOM_REMOVE != 0L) add(Simple(CTX_CUSTOM_REMOVE, getString(R.string.remove_custom_path), R.drawable.ic_ctx_delete))
+ if (flags and CTX_BAN_FOLDER != 0L) add(Simple(CTX_BAN_FOLDER, getString(R.string.group_ban_folder), R.drawable.ic_ctx_hide_source))
}
inner class ContextAdapter : RecyclerView.Adapter<ContextAdapter.ViewHolder>() {
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/MedialibraryUtils.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/MedialibraryUtils.kt
index f7e797eb09..656a7edd74 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/MedialibraryUtils.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/MedialibraryUtils.kt
@@ -23,6 +23,10 @@ object MedialibraryUtils {
runIO(Runnable { Medialibrary.getInstance().removeFolder(path) })
}
+ fun banDir(path: String) {
+ Medialibrary.getInstance().banFolder(path)
+ }
+
@JvmOverloads
fun addDir(path: String, context: Context = AppContextProvider.appContext) {
val intent = Intent(ACTION_DISCOVER, null, context, MediaParsingService::class.java)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
index ec0d7070c9..455b793ced 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
@@ -57,6 +57,7 @@ import org.videolan.vlc.gui.SecondaryActivity
import org.videolan.vlc.gui.browser.MediaBrowserFragment
import org.videolan.vlc.gui.dialogs.*
import org.videolan.vlc.gui.helpers.ItemOffsetDecoration
+import org.videolan.vlc.gui.helpers.MedialibraryUtils
import org.videolan.vlc.gui.helpers.UiTools
import org.videolan.vlc.gui.helpers.UiTools.addToGroup
import org.videolan.vlc.gui.helpers.UiTools.addToPlaylist
@@ -534,6 +535,7 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
CTX_FAV_ADD, CTX_FAV_REMOVE -> lifecycleScope.launch(Dispatchers.IO) {
media.isFavorite = option == CTX_FAV_ADD
}
+ CTX_BAN_FOLDER -> banFolder(media)
}
is VideoGroup -> when (option) {
CTX_PLAY_ALL -> viewModel.play(position)
@@ -551,6 +553,10 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
}
}
+ private fun banFolder(folder: Folder) {
+ MedialibraryUtils.banDir(folder.mMrl.removePrefix("file://"))
+ }
+
private fun renameGroup(media: VideoGroup) {
val dialog = RenameDialog.newInstance(media)
dialog.setListener { item, name ->
More information about the Android
mailing list