[Android] Fix the now playing action when in PiP mode
Nicolas Pomepuy
git at videolan.org
Wed Oct 21 09:02:40 CEST 2020
vlc-android | branch: 3.3.x | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Sep 10 15:39:58 2020 +0200| [e396405fec93288dc1b1994fcc815842c79238e6] | committer: Nicolas Pomepuy
Fix the now playing action when in PiP mode
(cherry picked from commit 770992eadbcc9326584f97122a29c2247729f503)
> https://code.videolan.org/videolan/vlc-android/commit/e396405fec93288dc1b1994fcc815842c79238e6
---
.../resources/src/main/java/org/videolan/resources/Constants.kt | 1 +
.../src/main/java/org/videolan/television/ui/CardPresenter.kt | 2 +-
.../src/main/java/org/videolan/television/ui/MainTvFragment.kt | 3 +++
.../src/main/java/org/videolan/television/viewmodel/MainTvModel.kt | 5 ++++-
application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt | 2 +-
5 files changed, 10 insertions(+), 3 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 c348584024..780c5fb215 100644
--- a/application/resources/src/main/java/org/videolan/resources/Constants.kt
+++ b/application/resources/src/main/java/org/videolan/resources/Constants.kt
@@ -130,6 +130,7 @@ const val CATEGORY_ALBUMS = 22L
const val CATEGORY_GENRES = 23L
const val CATEGORY_SONGS = 24L
const val CATEGORY_VIDEOS = 25L
+const val CATEGORY_NOW_PLAYING_PIP = 26L
const val CATEGORY = "category"
const val ITEM = "item"
diff --git a/application/television/src/main/java/org/videolan/television/ui/CardPresenter.kt b/application/television/src/main/java/org/videolan/television/ui/CardPresenter.kt
index da4fd07b04..d6185fed50 100644
--- a/application/television/src/main/java/org/videolan/television/ui/CardPresenter.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/CardPresenter.kt
@@ -170,7 +170,7 @@ class CardPresenter(private val context: Activity, private val isPoster: Boolean
holder.updateCardViewImage(sDefaultCardImage)
}
}
- if (item is DummyItem && item.id == CATEGORY_NOW_PLAYING) {
+ if (item is DummyItem && (item.id == CATEGORY_NOW_PLAYING || item.id == CATEGORY_NOW_PLAYING_PIP)) {
val badge = AnimatedVectorDrawableCompat.create(context, R.drawable.anim_now_playing)!!
holder.cardView.badgeImage = badge
badge.registerAnimationCallback(object : Animatable2Compat.AnimationCallback() {
diff --git a/application/television/src/main/java/org/videolan/television/ui/MainTvFragment.kt b/application/television/src/main/java/org/videolan/television/ui/MainTvFragment.kt
index 833c58b477..6c132a119c 100644
--- a/application/television/src/main/java/org/videolan/television/ui/MainTvFragment.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/MainTvFragment.kt
@@ -53,6 +53,7 @@ import org.videolan.television.viewmodel.MainTvModel.Companion.getMainTvModel
import org.videolan.vlc.donations.BillingStatus
import org.videolan.vlc.donations.VLCBilling
import org.videolan.vlc.gui.helpers.UiTools.showDonations
+import org.videolan.vlc.gui.video.VideoPlayerActivity
private const val TAG = "VLC/MainTvFragment"
@@ -322,6 +323,8 @@ class MainTvFragment : BrowseSupportFragment(), OnItemViewSelectedListener, OnIt
HEADER_NOW_PLAYING -> {
if ((item as DummyItem).id == CATEGORY_NOW_PLAYING) { //NOW PLAYING CARD
activity.startActivity(Intent(activity, AudioPlayerActivity::class.java))
+ } else if (item.id == CATEGORY_NOW_PLAYING_PIP) { //NOW PLAYING CARD in PiP Mode
+ activity.startActivity(Intent(activity, VideoPlayerActivity::class.java))
}
}
else -> {
diff --git a/application/television/src/main/java/org/videolan/television/viewmodel/MainTvModel.kt b/application/television/src/main/java/org/videolan/television/viewmodel/MainTvModel.kt
index 64f713ae8b..087a5fc9a1 100644
--- a/application/television/src/main/java/org/videolan/television/viewmodel/MainTvModel.kt
+++ b/application/television/src/main/java/org/videolan/television/viewmodel/MainTvModel.kt
@@ -181,7 +181,10 @@ class MainTvModel(app: Application) : AndroidViewModel(app), Medialibrary.OnMedi
val list = mutableListOf<MediaLibraryItem>()
PlaybackService.instance?.run {
currentMediaWrapper?.let {
- DummyItem(CATEGORY_NOW_PLAYING, it.title, it.artist).apply { setArtWork(coverArt) }
+ if (this.playlistManager.player.isVideoPlaying())
+ DummyItem(CATEGORY_NOW_PLAYING_PIP, it.title, it.artist).apply { setArtWork(coverArt) }
+ else
+ DummyItem(CATEGORY_NOW_PLAYING, it.title, it.artist).apply { setArtWork(coverArt) }
}
}?.let { list.add(0, it) }
(nowPlaying as MutableLiveData).value = list
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 d5db36bfd6..377617d38c 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
@@ -697,7 +697,7 @@ fun getTvIconRes(mediaLibraryItem: MediaLibraryItem) = when (mediaLibraryItem.it
HEADER_SERVER -> R.drawable.ic_menu_network_add_big
HEADER_STREAM -> R.drawable.ic_menu_stream_big
HEADER_PLAYLISTS -> R.drawable.ic_menu_playlist_big
- HEADER_MOVIES -> R.drawable.ic_browser_movie_big
+ HEADER_MOVIES, CATEGORY_NOW_PLAYING_PIP -> R.drawable.ic_browser_movie_big
HEADER_TV_SHOW -> R.drawable.ic_browser_tvshow_big
ID_SETTINGS -> R.drawable.ic_menu_preferences_big
ID_ABOUT_TV, ID_LICENCE -> R.drawable.ic_default_cone
More information about the Android
mailing list