Skip to content

Commit

Permalink
Move fullscreen-related comments to javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Stypox committed Aug 31, 2021
1 parent ab97f48 commit b8f16d0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1104,9 +1104,14 @@ private void openPopupPlayer(final boolean append) {
}
}

/**
* 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())) {
Expand All @@ -1130,9 +1135,15 @@ public void openVideoPlayer(final boolean directlyFullscreenIfApplicable) {
}
}

/**
* 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.isStartMainPlayerFullscreen(requireContext()));
}

Expand Down
10 changes: 6 additions & 4 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -746,16 +746,18 @@ && isPlaybackResumeEnabled(this)
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.isStartMainPlayerFullscreen(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();
}
}
Expand Down

0 comments on commit b8f16d0

Please sign in to comment.