From e7738c7bc18983ed4f0b27605c5b3fcddd3393c2 Mon Sep 17 00:00:00 2001 From: Niels van Velzen Date: Tue, 29 Oct 2024 21:15:06 +0100 Subject: [PATCH] Sync custom controls with built-in controls in leanback overlay --- .../CustomPlaybackOverlayFragment.java | 18 ++++++++---------- .../overlay/LeanbackOverlayFragment.java | 7 +++++++ .../main/res/layout/vlc_player_interface.xml | 3 +-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/jellyfin/androidtv/ui/playback/CustomPlaybackOverlayFragment.java b/app/src/main/java/org/jellyfin/androidtv/ui/playback/CustomPlaybackOverlayFragment.java index 008c9afff5..72e69ddfce 100644 --- a/app/src/main/java/org/jellyfin/androidtv/ui/playback/CustomPlaybackOverlayFragment.java +++ b/app/src/main/java/org/jellyfin/androidtv/ui/playback/CustomPlaybackOverlayFragment.java @@ -121,7 +121,7 @@ public class CustomPlaybackOverlayFragment extends Fragment implements LiveTvGui private AudioManager mAudioManager; private boolean mFadeEnabled = false; - private boolean mIsVisible = false; + private boolean mIsVisible = true; private boolean mPopupPanelVisible = false; private boolean navigating = false; @@ -168,7 +168,6 @@ public void onCreate(Bundle savedInstanceState) { // setup fade task mHideTask = () -> { if (mIsVisible) { - hide(); leanbackOverlayFragment.hideOverlay(); } }; @@ -203,9 +202,6 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c tvGuideBinding.getRoot().setVisibility(View.GONE); binding.getRoot().setOnTouchListener((v, event) -> { - //if we're not visible, show us - if (!mIsVisible) show(); - //and then manage our fade timer if (mFadeEnabled) startFadeTimer(); @@ -298,7 +294,6 @@ public void onScrollChanged(ObservableHorizontalScrollView scrollView, int x, in // start playing playbackControllerContainer.getValue().getPlaybackController().play(startPos); leanbackOverlayFragment.updatePlayState(); - } @Override @@ -600,9 +595,6 @@ public boolean onKey(View v, int keyCode, KeyEvent event) { playbackControllerContainer.getValue().getPlaybackController().playPause(); return true; } - - //if we're not visible, show us - show(); } //and then manage our fade timer @@ -704,12 +696,18 @@ public void onStop() { } public void show() { + // Already showing! + if (mIsVisible) return; + binding.topPanel.startAnimation(slideDown); mIsVisible = true; binding.skipOverlay.setSkipUiEnabled(!mIsVisible && !mGuideVisible && !mPopupPanelVisible); } public void hide() { + // Can't hide what's already hidden + if (!mIsVisible) return; + mIsVisible = false; binding.topPanel.startAnimation(fadeOut); binding.skipOverlay.setSkipUiEnabled(!mIsVisible && !mGuideVisible && !mPopupPanelVisible); @@ -1211,7 +1209,7 @@ public void setSecondaryTime(long time) { public void setFadingEnabled(boolean value) { mFadeEnabled = value; - if (!mIsVisible) requireActivity().runOnUiThread(this::show); +// if (!mIsVisible) requireActivity().runOnUiThread(this::show); if (mFadeEnabled) { startFadeTimer(); } else { diff --git a/app/src/main/java/org/jellyfin/androidtv/ui/playback/overlay/LeanbackOverlayFragment.java b/app/src/main/java/org/jellyfin/androidtv/ui/playback/overlay/LeanbackOverlayFragment.java index b451db913b..547c10e932 100644 --- a/app/src/main/java/org/jellyfin/androidtv/ui/playback/overlay/LeanbackOverlayFragment.java +++ b/app/src/main/java/org/jellyfin/androidtv/ui/playback/overlay/LeanbackOverlayFragment.java @@ -45,9 +45,16 @@ public void initFromView(CustomPlaybackOverlayFragment customPlaybackOverlayFrag public void showControlsOverlay(boolean runAnimation) { if (shouldShowOverlay) { super.showControlsOverlay(runAnimation); + playerAdapter.getMasterOverlayFragment().show(); } } + @Override + public void hideControlsOverlay(boolean runAnimation) { + super.hideControlsOverlay(runAnimation); + playerAdapter.getMasterOverlayFragment().hide(); + } + public void updateCurrentPosition() { playerAdapter.updateCurrentPosition(); updatePlayState(); diff --git a/app/src/main/res/layout/vlc_player_interface.xml b/app/src/main/res/layout/vlc_player_interface.xml index cc7959ad5c..df3b6e2b2f 100644 --- a/app/src/main/res/layout/vlc_player_interface.xml +++ b/app/src/main/res/layout/vlc_player_interface.xml @@ -64,8 +64,7 @@ android:layout_gravity="center_horizontal|top" android:layout_marginHorizontal="40dp" android:layout_marginTop="20dp" - android:clickable="false" - android:visibility="invisible"> + android:clickable="false">