From ed408b209499c05c73278debf9cabe8ffb4ab697 Mon Sep 17 00:00:00 2001 From: Stypox Date: Tue, 31 Aug 2021 11:28:34 +0200 Subject: [PATCH] Move fullscreen-related comments to javadocs --- .../fragments/detail/VideoDetailFragment.java | 19 +++++++++++++++---- .../org/schabi/newpipe/player/Player.java | 10 ++++++---- 2 files changed, 21 insertions(+), 8 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 6e94d2d0d..ecf235abc 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 @@ -1104,9 +1104,14 @@ public final class VideoDetailFragment } } + /** + * Opens the video player, in fullscreen if needed. In order to open fullscreen, the activity + * is toggled to landscape orientation (which will then cause fullscreen mode). + * + * @param directlyFullscreenIfApplicable whether to open fullscreen if we are not already + * in landscape and screen orientation is locked + */ public void openVideoPlayer(final boolean directlyFullscreenIfApplicable) { - // Toggle to landscape orientation (which will then cause fullscreen mode) if we are not - // already in landscape and screen orientation is locked. if (directlyFullscreenIfApplicable && !DeviceUtils.isLandscape(requireContext()) && PlayerHelper.globalScreenOrientationLocked(requireContext())) { @@ -1130,9 +1135,15 @@ public final class VideoDetailFragment } } + /** + * If the option to start directly fullscreen is enabled, calls + * {@link #openVideoPlayer(boolean)} with {@code directlyFullscreenIfApplicable = true}, so that + * if the user is not already in landscape and he has screen orientation locked the activity + * rotates and fullscreen starts. Otherwise, if the option to start directly fullscreen is + * disabled, calls {@link #openVideoPlayer(boolean)} with {@code directlyFullscreenIfApplicable + * = false}, hence preventing it from going directly fullscreen. + */ public void openVideoPlayerAutoFullscreen() { - // if the option to start directly fullscreen is enabled, openVideoPlayer will be called - // with directlyFullscreenIfApplicable=true and therefore open fullscreen if applicable openVideoPlayer(PlayerHelper.isStartMainPlayerFullscreenEnabled(requireContext())); } diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index 63c31e082..dd5468f69 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -747,16 +747,18 @@ public final class Player implements NavigationHelper.sendPlayerStartedEvent(context); } + /** + * Open fullscreen on tablets where the option to have the main player start automatically in + * fullscreen mode is on. Rotating the device to landscape is already done in {@link + * VideoDetailFragment#openVideoPlayer(boolean)} when the thumbnail is clicked, and that's + * enough for phones, but not for tablets since the mini player can be also shown in landscape. + */ private void directlyOpenFullscreenIfNeeded() { if (fragmentListener != null && PlayerHelper.isStartMainPlayerFullscreenEnabled(service) && DeviceUtils.isTablet(service) && videoPlayerSelected() && PlayerHelper.globalScreenOrientationLocked(service)) { - // Open fullscreen on tablets where the option to have the main player start - // automatically in fullscreen mode is on. Rotating the device to landscape is already - // done in VideoDetailFragment when the thumbnail is clicked, and that's enough for - // phones, but not for tablets since the mini player can be also shown in landscape. fragmentListener.onScreenRotationButtonClicked(); } }