Skip to content

Commit

Permalink
[BottomSheet] Changed bottom gesture inset handling to ensure a minim…
Browse files Browse the repository at this point in the history
…um peek height with a buffer built in, instead of always adding the inset to the peek height (when gesture nav is enabled)

PiperOrigin-RevId: 325866040
  • Loading branch information
dsn5ft authored and wcshi committed Aug 11, 2020
1 parent b12c5c5 commit 0df7724
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ public abstract static class BottomSheetCallback {
/** Minimum peek height permitted. */
private int peekHeightMin;

/** Peek height gesture inset buffer to ensure enough swipeable space. */
private int peekHeightGestureInsetBuffer;

/** True if Behavior has a non-null value for the @shapeAppearance attribute */
private boolean shapeThemingEnabled;

Expand Down Expand Up @@ -275,6 +278,10 @@ public BottomSheetBehavior() {}

public BottomSheetBehavior(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);

peekHeightGestureInsetBuffer =
context.getResources().getDimensionPixelSize(R.dimen.mtrl_min_touch_target_size);

TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BottomSheetBehavior_Layout);
this.shapeThemingEnabled = a.hasValue(R.styleable.BottomSheetBehavior_Layout_shapeAppearance);
boolean hasBackgroundTint = a.hasValue(R.styleable.BottomSheetBehavior_Layout_backgroundTint);
Expand Down Expand Up @@ -1127,7 +1134,10 @@ private int calculatePeekHeight() {
if (peekHeightAuto) {
return Math.max(peekHeightMin, parentHeight - parentWidth * 9 / 16);
}
return peekHeight + (gestureInsetBottomIgnored ? 0 : gestureInsetBottom);
if (!gestureInsetBottomIgnored && gestureInsetBottom > 0) {
return Math.max(peekHeight, gestureInsetBottom + peekHeightGestureInsetBuffer);
}
return peekHeight;
}

private void calculateCollapsedOffset() {
Expand Down

0 comments on commit 0df7724

Please sign in to comment.