diff options
| -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) +                } +            }          } -    }  }  |