Skip to content

Commit e5115d8

Browse files
committed
Fix opening directly fullscreen on tablets
1 parent 2e9856c commit e5115d8

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ public void openVideoPlayer(final boolean directlyFullscreenIfApplicable) {
11091109
&& PlayerHelper.isStartMainPlayerFullscreen(requireContext())
11101110
&& !DeviceUtils.isLandscape(requireContext())
11111111
&& PlayerHelper.globalScreenOrientationLocked(requireContext())) {
1112-
// open directly in fullscreen TODO does it work for large-land layouts?
1112+
// toggle landscape in order to open directly in fullscreen
11131113
onScreenRotationButtonClicked();
11141114
}
11151115

app/src/main/java/org/schabi/newpipe/player/Player.java

+17
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,9 @@ public void handleIntent(@NonNull final Intent intent) {
620620
return;
621621
}
622622

623+
// needed for tablets, check the function for a better explanation
624+
directlyOpenFullscreenIfNeeded();
625+
623626
final PlaybackParameters savedParameters = retrievePlaybackParametersFromPrefs(this);
624627
final float playbackSpeed = savedParameters.speed;
625628
final float playbackPitch = savedParameters.pitch;
@@ -742,6 +745,20 @@ && isPlaybackResumeEnabled(this)
742745
NavigationHelper.sendPlayerStartedEvent(context);
743746
}
744747

748+
private void directlyOpenFullscreenIfNeeded() {
749+
if (fragmentListener != null
750+
&& PlayerHelper.isStartMainPlayerFullscreen(service)
751+
&& DeviceUtils.isTablet(service)
752+
&& videoPlayerSelected()
753+
&& PlayerHelper.globalScreenOrientationLocked(service)) {
754+
// Open fullscreen on tablets where the option to have the main player start
755+
// automatically in fullscreen mode is on. Rotating the device to landscape is already
756+
// done in VideoDetailFragment when the thumbnail is clicked, and that's enough for
757+
// phones, but not for tablets since the mini player can be also shown in landscape.
758+
fragmentListener.onScreenRotationButtonClicked();
759+
}
760+
}
761+
745762
private void initPlayback(@NonNull final PlayQueue queue,
746763
@RepeatMode final int repeatMode,
747764
final float playbackSpeed,

app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java

+1-9
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,7 @@ public static void openVideoDetailFragment(@NonNull final Context context,
366366
if (switchingPlayers) {
367367
// Situation when user switches from players to main player. All needed data is
368368
// here, we can start watching (assuming newQueue equals playQueue).
369-
370-
// Starting directly in fullscreen if the previous player type was popup.
371-
if (playerType == MainPlayer.PlayerType.POPUP
372-
&& !DeviceUtils.isLandscape(context)
373-
&& PlayerHelper.globalScreenOrientationLocked(context)) {
374-
detailFragment.onScreenRotationButtonClicked();
375-
}
376-
// pass false to directlyFullscreenIfApplicable since that's handled just above here
377-
detailFragment.openVideoPlayer(false);
369+
detailFragment.openVideoPlayer(true);
378370
} else {
379371
detailFragment.selectAndLoadVideo(serviceId, url, title, playQueue);
380372
}

0 commit comments

Comments
 (0)