Skip to content

Commit

Permalink
[Bottom Sheet] Update expanded corner removal to check if sheet view …
Browse files Browse the repository at this point in the history
…is actually at top of screen

PiperOrigin-RevId: 524275157
  • Loading branch information
dsn5ft authored and drchen committed Apr 17, 2023
1 parent 884a454 commit 1c01e82
Showing 1 changed file with 11 additions and 4 deletions.
Expand Up @@ -1444,10 +1444,8 @@ private float calculateInterpolationWithCornersRemoved() {
&& viewRef.get() != null
&& VERSION.SDK_INT >= VERSION_CODES.S) {
V view = viewRef.get();
int[] location = new int[2];
view.getLocationOnScreen(location);
// Only use device corner radius if sheet is touching top of screen.
if (location[1] == 0) {
if (isAtTopOfScreen()) {
final WindowInsets insets = view.getRootWindowInsets();
if (insets != null) {
float topLeftInterpolation =
Expand Down Expand Up @@ -1477,9 +1475,18 @@ private float calculateCornerInterpolation(
return 0;
}

private boolean isAtTopOfScreen() {
if (viewRef == null || viewRef.get() == null) {
return false;
}
int[] location = new int[2];
viewRef.get().getLocationOnScreen(location);
return location[1] == 0;
}

private boolean isExpandedAndShouldRemoveCorners() {
// Only remove corners when it's full screen.
return state == STATE_EXPANDED && (shouldRemoveExpandedCorners || getExpandedOffset() == 0);
return state == STATE_EXPANDED && (shouldRemoveExpandedCorners || isAtTopOfScreen());
}

private int calculatePeekHeight() {
Expand Down

0 comments on commit 1c01e82

Please sign in to comment.