Merge "Fix ringer drawer area being touchable while the drawer is closed." into sc-dev

This commit is contained in:
Josh Tsuji
2021-05-20 21:27:29 +00:00
committed by Android (Google) Code Review

View File

@@ -315,9 +315,23 @@ public class VolumeDialogImpl implements VolumeDialog,
final View view = mDialogView.getChildAt(i); final View view = mDialogView.getChildAt(i);
final int[] locInWindow = new int[2]; final int[] locInWindow = new int[2];
view.getLocationInWindow(locInWindow); view.getLocationInWindow(locInWindow);
float x = locInWindow[0];
float y = locInWindow[1];
// The ringer and rows container has extra height at the top to fit the expanded ringer
// drawer. This area should not be touchable unless the ringer drawer is open.
if (view == mRingerAndRowsContainer && !mIsRingerDrawerOpen) {
if (!isLandscape()) {
y += getRingerDrawerOpenExtraSize();
} else {
x += getRingerDrawerOpenExtraSize();
}
}
mTouchableRegion.op( mTouchableRegion.op(
locInWindow[0], (int) x,
locInWindow[1], (int) y,
locInWindow[0] + view.getWidth(), locInWindow[0] + view.getWidth(),
locInWindow[1] + view.getHeight(), locInWindow[1] + view.getHeight(),
Region.Op.UNION); Region.Op.UNION);
@@ -697,10 +711,10 @@ public class VolumeDialogImpl implements VolumeDialog,
mDialogView.getPaddingLeft(), mDialogView.getPaddingLeft(),
mDialogView.getPaddingTop(), mDialogView.getPaddingTop(),
mDialogView.getPaddingRight(), mDialogView.getPaddingRight(),
mDialogView.getPaddingBottom() + getRingerDrawerOpenExtraHeight()); mDialogView.getPaddingBottom() + getRingerDrawerOpenExtraSize());
} else { } else {
mDialogView.setPadding( mDialogView.setPadding(
mDialogView.getPaddingLeft() + getRingerDrawerOpenExtraHeight(), mDialogView.getPaddingLeft() + getRingerDrawerOpenExtraSize(),
mDialogView.getPaddingTop(), mDialogView.getPaddingTop(),
mDialogView.getPaddingRight(), mDialogView.getPaddingRight(),
mDialogView.getPaddingBottom()); mDialogView.getPaddingBottom());
@@ -1720,10 +1734,11 @@ public class VolumeDialogImpl implements VolumeDialog,
} }
/** /**
* Return the height of the 1-2 extra ringer options that are made visible when the ringer * Return the size of the 1-2 extra ringer options that are made visible when the ringer drawer
* drawer is opened. * is opened. The drawer options are square so this can be used for height calculations (when in
* portrait, and the drawer opens upward) or for width (when opening sideways in landscape).
*/ */
private int getRingerDrawerOpenExtraHeight() { private int getRingerDrawerOpenExtraSize() {
return (mRingerCount - 1) * mRingerDrawerItemSize; return (mRingerCount - 1) * mRingerDrawerItemSize;
} }
@@ -1737,7 +1752,7 @@ public class VolumeDialogImpl implements VolumeDialog,
} }
final Rect bounds = mRingerAndRowsContainerBackground.copyBounds(); final Rect bounds = mRingerAndRowsContainerBackground.copyBounds();
bounds.top = (int) (drawerClosedAmount * getRingerDrawerOpenExtraHeight()); bounds.top = (int) (drawerClosedAmount * getRingerDrawerOpenExtraSize());
mRingerAndRowsContainerBackground.setBounds(bounds); mRingerAndRowsContainerBackground.setBounds(bounds);
} }