diff options
| author | 2024-09-13 16:12:00 +0000 | |
|---|---|---|
| committer | 2024-09-13 16:12:00 +0000 | |
| commit | 61a577c01eca720a1f38cb07f1d5e65b3883beec (patch) | |
| tree | e8f5d122c48566675282c1fb5c8f8f699a1dc593 | |
| parent | e6f643bb22aaba0e55226c4323f87b76cd040ccd (diff) | |
| parent | c975409be97e613241fbc2b5e2520804233e67e4 (diff) | |
Merge "Remove onClick when Clear all button not visible" into main
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/notification/footer/ui/viewbinder/FooterViewBinder.kt | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/footer/ui/viewbinder/FooterViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/footer/ui/viewbinder/FooterViewBinder.kt index 637cadde6fc6..920541d101cf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/footer/ui/viewbinder/FooterViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/footer/ui/viewbinder/FooterViewBinder.kt @@ -44,7 +44,7 @@ object FooterViewBinder { viewModel, clearAllNotifications, launchNotificationSettings, - launchNotificationHistory + launchNotificationHistory, ) } } @@ -55,21 +55,15 @@ object FooterViewBinder { viewModel: FooterViewModel, clearAllNotifications: View.OnClickListener, launchNotificationSettings: View.OnClickListener, - launchNotificationHistory: View.OnClickListener + launchNotificationHistory: View.OnClickListener, ) = coroutineScope { - launch { - bindClearAllButton( - footer, - viewModel, - clearAllNotifications, - ) - } + launch { bindClearAllButton(footer, viewModel, clearAllNotifications) } launch { bindManageOrHistoryButton( footer, viewModel, launchNotificationSettings, - launchNotificationHistory + launchNotificationHistory, ) } launch { bindMessage(footer, viewModel) } @@ -80,8 +74,6 @@ object FooterViewBinder { viewModel: FooterViewModel, clearAllNotifications: View.OnClickListener, ) = coroutineScope { - footer.setClearAllButtonClickListener(clearAllNotifications) - launch { viewModel.clearAllButton.labelId.collect { textId -> footer.setClearAllButtonText(textId) @@ -96,18 +88,21 @@ object FooterViewBinder { launch { viewModel.clearAllButton.isVisible.collect { isVisible -> + if (isVisible.value) { + footer.setClearAllButtonClickListener(clearAllNotifications) + } else { + // When the button isn't visible, it also shouldn't react to clicks. This is + // necessary because when the clear all button is not visible, it's actually + // just the alpha that becomes 0 so it can still be tapped. + footer.setClearAllButtonClickListener(null) + } + if (isVisible.isAnimating) { - footer.setClearAllButtonVisible( - isVisible.value, - /* animate = */ true, - ) { _ -> + footer.setClearAllButtonVisible(isVisible.value, /* animate= */ true) { _ -> isVisible.stopAnimating() } } else { - footer.setClearAllButtonVisible( - isVisible.value, - /* animate = */ false, - ) + footer.setClearAllButtonVisible(isVisible.value, /* animate= */ false) } } } @@ -143,22 +138,24 @@ object FooterViewBinder { launch { viewModel.manageOrHistoryButton.isVisible.collect { isVisible -> - // NOTE: This visibility change is never animated. + // NOTE: This visibility change is never animated. We also don't need to do anything + // special about the onClickListener here, since we're changing the visibility to + // GONE so it won't be clickable anyway. footer.setManageOrHistoryButtonVisible(isVisible.value) } } } - private suspend fun bindMessage( - footer: FooterView, - viewModel: FooterViewModel, - ) = coroutineScope { - // Bind the resource IDs - footer.setMessageString(viewModel.message.messageId) - footer.setMessageIcon(viewModel.message.iconId) + private suspend fun bindMessage(footer: FooterView, viewModel: FooterViewModel) = + coroutineScope { + // Bind the resource IDs + footer.setMessageString(viewModel.message.messageId) + footer.setMessageIcon(viewModel.message.iconId) - launch { - viewModel.message.isVisible.collect { visible -> footer.setFooterLabelVisible(visible) } + launch { + viewModel.message.isVisible.collect { visible -> + footer.setFooterLabelVisible(visible) + } + } } - } } |