From d3d65c8e3a6074a2ca0a697f2c5ebdbe61256783 Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Sat, 15 Aug 2020 20:51:52 +0300 Subject: [PATCH] Set bottom padding of the main fragment when the mini player is visible --- .../fragments/detail/VideoDetailFragment.java | 27 +++++++++++++++++++ 1 file changed, 27 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 66077f3ee..39eb74a58 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 @@ -2176,6 +2176,30 @@ public class VideoDetailFragment } } + /** + * When the mini player exists the view underneath it is not touchable. + * Bottom padding should be equal to the mini player's height in this case + * + * @param showMore whether main fragment should be expanded or not + * */ + private void manageSpaceAtTheBottom(final boolean showMore) { + final int peekHeight = getResources().getDimensionPixelSize(R.dimen.mini_player_height); + final ViewGroup holder = requireActivity().findViewById(R.id.fragment_holder); + final int newBottomPadding; + if (showMore) { + newBottomPadding = 0; + } else { + newBottomPadding = peekHeight; + } + if (holder.getPaddingBottom() == newBottomPadding) { + return; + } + holder.setPadding(holder.getPaddingLeft(), + holder.getPaddingTop(), + holder.getPaddingRight(), + newBottomPadding); + } + private void setupBottomPlayer() { final CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams(); @@ -2186,6 +2210,7 @@ public class VideoDetailFragment bottomSheetBehavior.setState(bottomSheetState); final int peekHeight = getResources().getDimensionPixelSize(R.dimen.mini_player_height); if (bottomSheetState != BottomSheetBehavior.STATE_HIDDEN) { + manageSpaceAtTheBottom(false); bottomSheetBehavior.setPeekHeight(peekHeight); if (bottomSheetState == BottomSheetBehavior.STATE_COLLAPSED) { overlay.setAlpha(MAX_OVERLAY_ALPHA); @@ -2203,12 +2228,14 @@ public class VideoDetailFragment switch (newState) { case BottomSheetBehavior.STATE_HIDDEN: moveFocusToMainFragment(true); + manageSpaceAtTheBottom(true); bottomSheetBehavior.setPeekHeight(0); cleanUp(); break; case BottomSheetBehavior.STATE_EXPANDED: moveFocusToMainFragment(false); + manageSpaceAtTheBottom(false); bottomSheetBehavior.setPeekHeight(peekHeight); // Disable click because overlay buttons located on top of buttons