From 337b53998665e6dbf0ad6ecc5d009f6c9c23be5d Mon Sep 17 00:00:00 2001 From: Arian Date: Tue, 29 Mar 2022 16:35:57 +0200 Subject: [PATCH] VolumeDialogImpl: Respect multiple visible rows in landscape If the user is in a call we are showing two volume rows, the default (music) stream and the active stream, in this case the voice call. Currently the second row is not touchable in landscape mode because the calculation of the touchable region does not handle the case of multiple visible rows. This patchset adds a check wether the ringer drawer extra size is bigger than the additionally visible rows and then substracts the size of the visible rows so that they stay touchable. Test: While receiving a call in landscape both, the music row and the ring row, are touchable. Touches at the left of the volume panel are still going through the app behind the volume panel. Change-Id: Icda80b7a98d5510747bc92ef12a3c7647131b18d --- .../systemui/volume/VolumeDialogImpl.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java index 58f74a0d2a02c..dccd392b72eaa 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java @@ -363,11 +363,13 @@ public class VolumeDialogImpl implements VolumeDialog, // 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. + // In landscape the ringer expands to the left and it has to be ensured that if there + // are multiple rows they are touchable. if (view == mTopContainer && !mIsRingerDrawerOpen) { if (!isLandscape()) { y += getRingerDrawerOpenExtraSize(); - } else { - x += getRingerDrawerOpenExtraSize(); + } else if (getRingerDrawerOpenExtraSize() > getVisibleRowsExtraSize()) { + x += (getRingerDrawerOpenExtraSize() - getVisibleRowsExtraSize()); } } @@ -1926,6 +1928,21 @@ public class VolumeDialogImpl implements VolumeDialog, return (mRingerCount - 1) * mRingerDrawerItemSize; } + /** + * Return the size of the additionally visible rows next to the default stream. + * An additional row is visible for example while receiving a voice call. + */ + private int getVisibleRowsExtraSize() { + VolumeRow activeRow = getActiveRow(); + int visibleRows = 0; + for (final VolumeRow row : mRows) { + if (shouldBeVisibleH(row, activeRow)) { + visibleRows++; + } + } + return (visibleRows - 1) * (mDialogWidth + mRingerRowsPadding); + } + private void updateBackgroundForDrawerClosedAmount() { if (mRingerAndDrawerContainerBackground == null) { return;