[Android] Add a "go to album artist" context sheet item
Nicolas Pomepuy
git at videolan.org
Wed Nov 20 06:47:53 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Sep 16 10:08:11 2024 +0200| [eac87684e050196b8fe1ebae3d97e2369d1d868f] | committer: Duncan McNamara
Add a "go to album artist" context sheet item
> https://code.videolan.org/videolan/vlc-android/commit/eac87684e050196b8fe1ebae3d97e2369d1d868f
---
application/resources/src/main/res/values/strings.xml | 1 +
.../src/org/videolan/vlc/gui/HeaderMediaListActivity.kt | 15 ++++++++++++++-
.../src/org/videolan/vlc/gui/audio/BaseAudioBrowser.kt | 10 ++++++++++
.../src/org/videolan/vlc/gui/dialogs/ContextSheet.kt | 1 +
.../src/org/videolan/vlc/util/ContextOption.kt | 3 ++-
5 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index bb40d79ea1..0f652fdae2 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -1016,6 +1016,7 @@
<string name="go_to_folder">Browse parent</string>
<string name="go_to_album">Go to album</string>
<string name="go_to_artist">Go to artist</string>
+ <string name="go_to_album_artist">Go to album artist</string>
<string name="create_shortcut">Create a launcher shortcut</string>
<string name="no_sub_renderer">Subtitles are not yet supported while casting</string>
<string name="enqueuing">Loading your media</string>
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
index ac47fe5ec9..068a5ad595 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
@@ -368,7 +368,11 @@ open class HeaderMediaListActivity : AudioPlayerContainerActivity(), IEventsHand
if (item.isFavorite) add(CTX_FAV_REMOVE) else add(CTX_FAV_ADD)
if (media.type == MediaWrapper.TYPE_STREAM || (media.type == MediaWrapper.TYPE_ALL && isSchemeHttpOrHttps(media.uri.scheme)))
addAll(CTX_COPY, CTX_RENAME)
- if (media.type == MediaWrapper.TYPE_AUDIO) add(CTX_GO_TO_ARTIST)
+ if (media.type == MediaWrapper.TYPE_AUDIO) {
+ add(CTX_GO_TO_ARTIST)
+ if (BuildConfig.DEBUG) Log.d("CtxPrep", "Artist id is: ${media.artistId}, album artist is: ${media.albumArtistId}")
+ if (media.artistId != media.albumArtistId) add(CTX_GO_TO_ALBUM_ARTIST)
+ }
else add(CTX_SHARE)
}
showContext(this, this, position, media, flags)
@@ -511,6 +515,15 @@ open class HeaderMediaListActivity : AudioPlayerContainerActivity(), IEventsHand
i.flags = i.flags or Intent.FLAG_ACTIVITY_NO_HISTORY
startActivity(i)
}
+ CTX_GO_TO_ALBUM_ARTIST -> lifecycleScope.launch(Dispatchers.IO) {
+ val artist = (media as MediaWrapper).getAlbumArtistWrapper()
+ val i = Intent(this at HeaderMediaListActivity, SecondaryActivity::class.java)
+ i.putExtra(SecondaryActivity.KEY_FRAGMENT, SecondaryActivity.ALBUMS_SONGS)
+ i.putExtra(AudioBrowserFragment.TAG_ITEM, artist)
+ i.putExtra(ARTIST_FROM_ALBUM, true)
+ i.flags = i.flags or Intent.FLAG_ACTIVITY_NO_HISTORY
+ startActivity(i)
+ }
else -> {}
}
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.kt
index 8d9fe60ce1..d852bea936 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.kt
@@ -387,6 +387,7 @@ abstract class BaseAudioBrowser<T : MedialibraryViewModel> : MediaBrowserFragmen
MediaLibraryItem.TYPE_MEDIA -> {
createCtxTrackFlags().apply {
if ((item as? MediaWrapper)?.isFavorite == true) add(CTX_FAV_REMOVE) else add(CTX_FAV_ADD)
+ if ((item as? MediaWrapper)?.artistId != (item as? MediaWrapper)?.albumArtistId) add(CTX_GO_TO_ALBUM_ARTIST)
}
}
MediaLibraryItem.TYPE_ARTIST -> {
@@ -461,6 +462,15 @@ abstract class BaseAudioBrowser<T : MedialibraryViewModel> : MediaBrowserFragmen
i.flags = i.flags or Intent.FLAG_ACTIVITY_NO_HISTORY
startActivity(i)
}
+ CTX_GO_TO_ALBUM_ARTIST -> lifecycleScope.launch(Dispatchers.IO) {
+ val artist = (media as MediaWrapper).getAlbumArtistWrapper()
+ val i = Intent(requireActivity(), SecondaryActivity::class.java)
+ i.putExtra(SecondaryActivity.KEY_FRAGMENT, SecondaryActivity.ALBUMS_SONGS)
+ i.putExtra(AudioBrowserFragment.TAG_ITEM, artist)
+ i.putExtra(ARTIST_FROM_ALBUM, true)
+ i.flags = i.flags or Intent.FLAG_ACTIVITY_NO_HISTORY
+ startActivity(i)
+ }
CTX_DELETE -> removeItem(media)
CTX_APPEND -> MediaUtils.appendMedia(requireActivity(), media.tracks)
CTX_PLAY_NEXT -> MediaUtils.insertNext(requireActivity(), media.tracks)
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 98d3c95af4..e1d02e9731 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
@@ -121,6 +121,7 @@ class ContextSheet : VLCBottomSheetDialogFragment() {
if (flags.contains(CTX_INFORMATION)) add(Simple(CTX_INFORMATION, getString(R.string.info), R.drawable.ic_information))
if (flags.contains(CTX_GO_TO_ALBUM)) add(Simple(CTX_GO_TO_ALBUM, getString(R.string.go_to_album), R.drawable.ic_album))
if (flags.contains(CTX_GO_TO_ARTIST)) add(Simple(CTX_GO_TO_ARTIST, getString(R.string.go_to_artist), R.drawable.ic_no_artist))
+ if (flags.contains(CTX_GO_TO_ALBUM_ARTIST)) add(Simple(CTX_GO_TO_ALBUM_ARTIST, getString(R.string.go_to_album_artist), R.drawable.ic_no_artist))
if (flags.contains(CTX_ADD_TO_PLAYLIST)) add(Simple(CTX_ADD_TO_PLAYLIST, getString(R.string.add_to_playlist), R.drawable.ic_add_to_playlist))
if (flags.contains(CTX_SET_RINGTONE) && AndroidDevices.isPhone) add(Simple(CTX_SET_RINGTONE, getString(R.string.set_song), R.drawable.ic_set_ringtone))
if (flags.contains(CTX_FAV_ADD)) add(Simple(CTX_FAV_ADD, getString(R.string.favorites_add), R.drawable.ic_fav_add))
diff --git a/application/vlc-android/src/org/videolan/vlc/util/ContextOption.kt b/application/vlc-android/src/org/videolan/vlc/util/ContextOption.kt
index f3b8098406..e597f13fb9 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/ContextOption.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/ContextOption.kt
@@ -61,7 +61,8 @@ enum class ContextOption : Flag {
CTX_STOP_AFTER_THIS,
CTX_UNGROUP,
CTX_GO_TO_ALBUM,
- CTX_GO_TO_ARTIST;
+ CTX_GO_TO_ARTIST,
+ CTX_GO_TO_ALBUM_ARTIST;
override fun toLong() = 1L shl this.ordinal
More information about the Android
mailing list