@@ -248,6 +248,7 @@ && isAutoplayEnabled()
248248 autoPlayEnabled = true ; // forcefully start playing
249249 openVideoPlayerAutoFullscreen ();
250250 }
251+ updateOverlayPlayQueueButtonVisibility ();
251252 }
252253
253254 @ Override
@@ -337,6 +338,8 @@ public void onResume() {
337338
338339 activity .sendBroadcast (new Intent (ACTION_VIDEO_FRAGMENT_RESUMED ));
339340
341+ updateOverlayPlayQueueButtonVisibility ();
342+
340343 setupBrightness ();
341344
342345 if (tabSettingsChanged ) {
@@ -639,19 +642,7 @@ protected void initViews(final View rootView, final Bundle savedInstanceState) {
639642 ? View .VISIBLE
640643 : View .GONE
641644 );
642-
643- if (DeviceUtils .isTv (getContext ())) {
644- // remove ripple effects from detail controls
645- final int transparent = ContextCompat .getColor (requireContext (),
646- R .color .transparent_background_color );
647- binding .detailControlsPlaylistAppend .setBackgroundColor (transparent );
648- binding .detailControlsBackground .setBackgroundColor (transparent );
649- binding .detailControlsPopup .setBackgroundColor (transparent );
650- binding .detailControlsDownload .setBackgroundColor (transparent );
651- binding .detailControlsShare .setBackgroundColor (transparent );
652- binding .detailControlsOpenInBrowser .setBackgroundColor (transparent );
653- binding .detailControlsPlayWithKodi .setBackgroundColor (transparent );
654- }
645+ accommodateForTvAndDesktopMode ();
655646 }
656647
657648 @ Override
@@ -1820,6 +1811,14 @@ public void onQueueUpdate(final PlayQueue queue) {
18201811 + title + "], playQueue = [" + playQueue + "]" );
18211812 }
18221813
1814+ // Register broadcast receiver to listen to playQueue changes
1815+ // and hide the overlayPlayQueueButton when the playQueue is empty / destroyed.
1816+ if (playQueue != null && playQueue .getBroadcastReceiver () != null ) {
1817+ playQueue .getBroadcastReceiver ().subscribe (
1818+ event -> updateOverlayPlayQueueButtonVisibility ()
1819+ );
1820+ }
1821+
18231822 // This should be the only place where we push data to stack.
18241823 // It will allow to have live instance of PlayQueue with actual information about
18251824 // deleted/added items inside Channel/Playlist queue and makes possible to have
@@ -1926,6 +1925,7 @@ public void onServiceStopped() {
19261925 currentInfo .getUploaderName (),
19271926 currentInfo .getThumbnailUrl ());
19281927 }
1928+ updateOverlayPlayQueueButtonVisibility ();
19291929 }
19301930
19311931 @ Override
@@ -2106,6 +2106,30 @@ private void setupBrightness() {
21062106 }
21072107 }
21082108
2109+ /**
2110+ * Make changes to the UI to accommodate for better usability on bigger screens such as TVs
2111+ * or in Android's desktop mode (DeX etc).
2112+ */
2113+ private void accommodateForTvAndDesktopMode () {
2114+ if (DeviceUtils .isTv (getContext ())) {
2115+ // remove ripple effects from detail controls
2116+ final int transparent = ContextCompat .getColor (requireContext (),
2117+ R .color .transparent_background_color );
2118+ binding .detailControlsPlaylistAppend .setBackgroundColor (transparent );
2119+ binding .detailControlsBackground .setBackgroundColor (transparent );
2120+ binding .detailControlsPopup .setBackgroundColor (transparent );
2121+ binding .detailControlsDownload .setBackgroundColor (transparent );
2122+ binding .detailControlsShare .setBackgroundColor (transparent );
2123+ binding .detailControlsOpenInBrowser .setBackgroundColor (transparent );
2124+ binding .detailControlsPlayWithKodi .setBackgroundColor (transparent );
2125+ }
2126+ if (DeviceUtils .isDesktopMode (getContext ())) {
2127+ // Remove the "hover" overlay (since it is visible on all mouse events and interferes
2128+ // with the video content being played)
2129+ binding .detailThumbnailRootLayout .setForeground (null );
2130+ }
2131+ }
2132+
21092133 private void checkLandscape () {
21102134 if ((!player .isPlaying () && player .getPlayQueue () != playQueue )
21112135 || player .getPlayQueue () == null ) {
@@ -2392,6 +2416,18 @@ public void onSlide(@NonNull final View bottomSheet, final float slideOffset) {
23922416 });
23932417 }
23942418
2419+ private void updateOverlayPlayQueueButtonVisibility () {
2420+ final boolean isPlayQueueEmpty =
2421+ player == null // no player => no play queue :)
2422+ || player .getPlayQueue () == null
2423+ || player .getPlayQueue ().isEmpty ();
2424+ if (binding != null ) {
2425+ // binding is null when rotating the device...
2426+ binding .overlayPlayQueueButton .setVisibility (
2427+ isPlayQueueEmpty ? View .GONE : View .VISIBLE );
2428+ }
2429+ }
2430+
23952431 private void updateOverlayData (@ Nullable final String overlayTitle ,
23962432 @ Nullable final String uploader ,
23972433 @ Nullable final String thumbnailUrl ) {
0 commit comments