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

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

Merge "Notif redesign: Bind onClickListeners for new footer buttons" into main

parents 0b7fa745 64f669ee
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -309,7 +309,20 @@ public class FooterView extends StackScrollerDecorView {
        }
    }

    /** Set onClickListener for the manage/history button. */
    /** Set onClickListener for the notification settings button. */
    public void setSettingsButtonClickListener(OnClickListener listener) {
        mSettingsButton.setOnClickListener(listener);
    }

    /** Set onClickListener for the notification history button. */
    public void setHistoryButtonClickListener(OnClickListener listener) {
        mHistoryButton.setOnClickListener(listener);
    }

    /**
     * Set onClickListener for the manage/history button. This is replaced by two separate buttons
     * in the redesign.
     */
    public void setManageButtonClickListener(OnClickListener listener) {
        mManageOrHistoryButton.setOnClickListener(listener);
    }
+34 −1
Original line number Diff line number Diff line
@@ -18,9 +18,12 @@ package com.android.systemui.statusbar.notification.footer.ui.viewbinder

import android.view.View
import androidx.lifecycle.lifecycleScope
import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.internal.jank.InteractionJankMonitor
import com.android.systemui.Flags
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.statusbar.notification.NotificationActivityStarter
import com.android.systemui.statusbar.notification.NotificationActivityStarter.SettingsIntent
import com.android.systemui.statusbar.notification.emptyshade.shared.ModesEmptyShadeFix
import com.android.systemui.statusbar.notification.footer.ui.view.FooterView
import com.android.systemui.statusbar.notification.footer.ui.viewmodel.FooterViewModel
@@ -29,7 +32,6 @@ import com.android.systemui.util.ui.stopAnimating
import com.android.systemui.util.ui.value
import kotlinx.coroutines.DisposableHandle
import kotlinx.coroutines.coroutineScope
import com.android.app.tracing.coroutines.launchTraced as launch

/** Binds a [FooterView] to its [view model][FooterViewModel]. */
object FooterViewBinder {
@@ -74,6 +76,9 @@ object FooterViewBinder {
                    notificationActivityStarter,
                )
            }
        } else {
            bindSettingsButtonListener(footer, notificationActivityStarter)
            bindHistoryButtonListener(footer, notificationActivityStarter)
        }
        launch { bindMessage(footer, viewModel) }
    }
@@ -117,6 +122,34 @@ object FooterViewBinder {
        }
    }

    private fun bindSettingsButtonListener(
        footer: FooterView,
        notificationActivityStarter: NotificationActivityStarter,
    ) {
        val settingsIntent =
            SettingsIntent.forNotificationSettings(
                cujType = InteractionJankMonitor.CUJ_SHADE_APP_LAUNCH_FROM_HISTORY_BUTTON
            )
        val onClickListener = { view: View ->
            notificationActivityStarter.startSettingsIntent(view, settingsIntent)
        }
        footer.setSettingsButtonClickListener(onClickListener)
    }

    private fun bindHistoryButtonListener(
        footer: FooterView,
        notificationActivityStarter: NotificationActivityStarter,
    ) {
        val settingsIntent =
            SettingsIntent.forNotificationHistory(
                cujType = InteractionJankMonitor.CUJ_SHADE_APP_LAUNCH_FROM_HISTORY_BUTTON
            )
        val onClickListener = { view: View ->
            notificationActivityStarter.startSettingsIntent(view, settingsIntent)
        }
        footer.setHistoryButtonClickListener(onClickListener)
    }

    private suspend fun bindManageOrHistoryButton(
        footer: FooterView,
        viewModel: FooterViewModel,
+5 −2
Original line number Diff line number Diff line
@@ -98,7 +98,6 @@ class FooterViewModel(
    val manageButtonShouldLaunchHistory =
        notificationSettingsInteractor.isNotificationHistoryEnabled

    // TODO(b/366003631): When inlining the flag, consider adding this to FooterButtonViewModel.
    val manageOrHistoryButtonClick: Flow<SettingsIntent> by lazy {
        if (ModesEmptyShadeFix.isUnexpectedlyInLegacyMode()) {
            flowOf(SettingsIntent(Intent(Settings.ACTION_NOTIFICATION_SETTINGS)))
@@ -124,7 +123,11 @@ class FooterViewModel(
            else R.string.manage_notifications_text
        }

    /** The button for managing notification settings or opening notification history. */
    /**
     * The button for managing notification settings or opening notification history. This is
     * replaced by two separate buttons in the redesign. These are currently static, and therefore
     * not modeled here, but if that changes we can also add them as FooterButtonViewModels.
     */
    val manageOrHistoryButton: FooterButtonViewModel =
        FooterButtonViewModel(
            labelId = manageOrHistoryButtonText,