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

Commit c975409b authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

Remove onClick when Clear all button not visible

It was technically possible to still tap the button even if it wasn't
visible.

Fix: 365878735
Test: manually verified that sensitive notifications can't be cleared by
tapping on the empty space
Flag: EXEMPT trivial bugfix

Change-Id: I023ab53fc5e5020694acdd96c77b1fe625636a05
parent 004d702c
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)
                }
            }
        }
}