1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-22 02:53:09 +01:00

Fix restoring orientation in onBack

This commit is contained in:
Stypox 2021-09-19 19:09:11 +02:00
parent 9346f9b0f3
commit 7667b2ce59
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23

View File

@ -742,20 +742,19 @@ public final class VideoDetailFragment
&& player.getPlayQueue() != null
&& player.videoPlayerSelected()
&& player.getPlayQueue().previous()) {
return true;
return true; // no code here, as previous() was used in the if
}
// That means that we are on the start of the stack,
// return false to let the MainActivity handle the onBack
if (stack.size() <= 1) {
restoreDefaultOrientation();
return false;
return false; // let MainActivity handle the onBack (e.g. to minimize the mini player)
}
// Remove top
stack.pop();
// Get stack item from the new top
assert stack.peek() != null;
setupFromHistoryItem(stack.peek());
setupFromHistoryItem(Objects.requireNonNull(stack.peek()));
return true;
}
@ -1432,17 +1431,15 @@ public final class VideoDetailFragment
//////////////////////////////////////////////////////////////////////////*/
private void restoreDefaultOrientation() {
if (!isPlayerAvailable() || !player.videoPlayerSelected() || activity == null) {
return;
}
if (isPlayerAvailable() && player.videoPlayerSelected()) {
toggleFullscreenIfInFullscreenMode();
}
// This will show systemUI and pause the player.
// User can tap on Play button and video will be in fullscreen mode again
// Note for tablet: trying to avoid orientation changes since it's not easy
// to physically rotate the tablet every time
if (!DeviceUtils.isTablet(activity)) {
if (activity != null && !DeviceUtils.isTablet(activity)) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
}