Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 61a577c0 authored by Ioana Alexandru's avatar Ioana Alexandru Committed by Android (Google) Code Review
Browse files

Merge "Remove onClick when Clear all button not visible" into main

parents e6f643bb c975409b
Loading
Loading
Loading
Loading
+28 −31
Original line number Diff line number Diff line
@@ -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 {
    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) }
                viewModel.message.isVisible.collect { visible ->
                    footer.setFooterLabelVisible(visible)
                }
            }
        }
}