From f2e4b69466d35d8629ca98bb175be9f9888b0a57 Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Sat, 25 Jul 2020 07:00:53 +0300 Subject: [PATCH] Another part of UI improvements for Android TV - focus will be hidden right after start of a video; fullscreen works like this too - back button will not needed to be pressed one more time like before - prev & next buttons for playqueue will be hidden with play/pause button before video be ready to play --- .../fragments/detail/VideoDetailFragment.java | 3 ++- .../java/org/schabi/newpipe/player/MainPlayer.java | 3 +++ .../org/schabi/newpipe/player/VideoPlayerImpl.java | 7 +++++-- .../res/layout-large-land/fragment_video_detail.xml | 12 ++++++------ 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 1d83094dc..6c459ffe9 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -2158,8 +2158,9 @@ public class VideoDetailFragment /** * That's for Android TV support. Move focus from main fragment to the player or back * based on what is currently selected + * * @param toMain if true than the main fragment will be focused or the player otherwise - * */ + */ private void moveFocusToMainFragment(final boolean toMain) { final ViewGroup mainFragment = requireActivity().findViewById(R.id.fragment_holder); // Hamburger button steels a focus even under bottomSheet diff --git a/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java index 53296d915..703be346e 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java @@ -163,6 +163,9 @@ public final class MainPlayer extends Service { // from one stream to a new stream not smooth playerImpl.getPlayer().stop(false); playerImpl.setRecovery(); + // Android TV will handle back button in case controls will be visible + // (one more additional unneeded click while the player is hidden) + playerImpl.hideControls(0, 0); // Notification shows information about old stream but if a user selects // a stream from backStack it's not actual anymore // So we should hide the notification at all. diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java index 8a4f7fdc5..d2eb591f4 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -253,9 +253,12 @@ public class VideoPlayerImpl extends VideoPlayer getRootView().setVisibility(View.VISIBLE); initPopup(); initPopupCloseOverlay(); + playPauseButton.requestFocus(); } else { getRootView().setVisibility(View.VISIBLE); initVideoPlayer(); + // Android TV: without it focus will frame the whole player + playPauseButton.requestFocus(); } onPlay(); @@ -1057,10 +1060,10 @@ public class VideoPlayerImpl extends VideoPlayer private void animatePlayButtons(final boolean show, final int duration) { animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, show, duration); - if (playQueue.getIndex() > 0) { + if (playQueue.getIndex() > 0 || !show) { animateView(playPreviousButton, AnimationUtils.Type.SCALE_AND_ALPHA, show, duration); } - if (playQueue.getIndex() + 1 < playQueue.getStreams().size()) { + if (playQueue.getIndex() + 1 < playQueue.getStreams().size() || !show) { animateView(playNextButton, AnimationUtils.Type.SCALE_AND_ALPHA, show, duration); } diff --git a/app/src/main/res/layout-large-land/fragment_video_detail.xml b/app/src/main/res/layout-large-land/fragment_video_detail.xml index 95d2f3c00..f69832b81 100644 --- a/app/src/main/res/layout-large-land/fragment_video_detail.xml +++ b/app/src/main/res/layout-large-land/fragment_video_detail.xml @@ -153,12 +153,12 @@ tools:visibility="visible" /> - +