From 520ac2e935e432b6fd412436760a5996af960428 Mon Sep 17 00:00:00 2001 From: Stypox Date: Tue, 27 Jul 2021 10:31:25 +0200 Subject: [PATCH] Fix bottom sheet state after automatic fullscreen --- .../newpipe/fragments/detail/VideoDetailFragment.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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 759ec3546..8a5008aed 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 @@ -1109,6 +1109,14 @@ public final class VideoDetailFragment && PlayerHelper.isStartMainPlayerFullscreenEnabled(requireContext()) && !DeviceUtils.isLandscape(requireContext()) && PlayerHelper.globalScreenOrientationLocked(requireContext())) { + // Make sure the bottom sheet turns out expanded. When this code kicks in the bottom + // sheet could not have fully expanded yet, and thus be in the STATE_SETTLING state. + // When the activity is rotated, and its state is saved and then restored, the bottom + // sheet would forget what it was doing, since even if STATE_SETTLING is restored, it + // doesn't tell which state it was settling to, and thus the bottom sheet settles to + // STATE_COLLAPSED. This can be solved by manually setting the state that will be + // restored (i.e. bottomSheetState) to STATE_EXPANDED. + bottomSheetState = BottomSheetBehavior.STATE_EXPANDED; // toggle landscape in order to open directly in fullscreen onScreenRotationButtonClicked(); }