Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set bottom padding of the main fragment when the mini player is visible #4134

Merged
merged 1 commit into from
Aug 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2176,6 +2176,30 @@ private void moveFocusToMainFragment(final boolean toMain) {
}
}

/**
* 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();
Expand All @@ -2186,6 +2210,7 @@ private void setupBottomPlayer() {
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);
Expand All @@ -2203,12 +2228,14 @@ public void onStateChanged(@NonNull final View bottomSheet, final int newState)
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
Expand Down