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

Commit 1b8bfe2e authored by Danny Burakov's avatar Danny Burakov Committed by Android (Google) Code Review
Browse files

Merge "[bc25] Remove NotificationsShadeScene and associated code." into main

parents e028e7cc 04e15565
Loading
Loading
Loading
Loading
+0 −29
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.scene

import com.android.systemui.notifications.ui.composable.NotificationsShadeScene
import com.android.systemui.scene.ui.composable.Scene
import dagger.Binds
import dagger.Module
import dagger.multibindings.IntoSet

@Module
interface NotificationsShadeSceneModule {

    @Binds @IntoSet fun notificationsShade(scene: NotificationsShadeScene): Scene
}
+0 −116
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.notifications.ui.composable

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.android.compose.animation.scene.SceneScope
import com.android.compose.animation.scene.UserAction
import com.android.compose.animation.scene.UserActionResult
import com.android.systemui.battery.BatteryMeterViewController
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.lifecycle.rememberViewModel
import com.android.systemui.notifications.ui.viewmodel.NotificationsShadeUserActionsViewModel
import com.android.systemui.scene.session.ui.composable.SaveableSession
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.ui.composable.Scene
import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.shade.ui.composable.ExpandedShadeHeader
import com.android.systemui.shade.ui.composable.OverlayShade
import com.android.systemui.shade.ui.viewmodel.ShadeHeaderViewModel
import com.android.systemui.statusbar.notification.stack.ui.view.NotificationScrollView
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel
import com.android.systemui.statusbar.phone.ui.StatusBarIconController
import com.android.systemui.statusbar.phone.ui.TintedIconManager
import dagger.Lazy
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow

@SysUISingleton
class NotificationsShadeScene
@Inject
constructor(
    private val actionsViewModelFactory: NotificationsShadeUserActionsViewModel.Factory,
    private val shadeHeaderViewModelFactory: ShadeHeaderViewModel.Factory,
    private val notificationsPlaceholderViewModelFactory: NotificationsPlaceholderViewModel.Factory,
    private val tintedIconManagerFactory: TintedIconManager.Factory,
    private val batteryMeterViewControllerFactory: BatteryMeterViewController.Factory,
    private val statusBarIconController: StatusBarIconController,
    private val shadeSession: SaveableSession,
    private val stackScrollView: Lazy<NotificationScrollView>,
) : ExclusiveActivatable(), Scene {

    override val key = Scenes.NotificationsShade

    private val actionsViewModel: NotificationsShadeUserActionsViewModel by lazy {
        actionsViewModelFactory.create()
    }

    override val userActions: Flow<Map<UserAction, UserActionResult>> = actionsViewModel.actions

    override suspend fun onActivated(): Nothing {
        actionsViewModel.activate()
    }

    @Composable
    override fun SceneScope.Content(
        modifier: Modifier,
    ) {
        val notificationsPlaceholderViewModel =
            rememberViewModel("NotificationsShadeScene") {
                notificationsPlaceholderViewModelFactory.create()
            }

        OverlayShade(
            modifier = modifier,
            onScrimClicked = {},
        ) {
            Column {
                ExpandedShadeHeader(
                    viewModelFactory = shadeHeaderViewModelFactory,
                    createTintedIconManager = tintedIconManagerFactory::create,
                    createBatteryMeterViewController = batteryMeterViewControllerFactory::create,
                    statusBarIconController = statusBarIconController,
                    modifier = Modifier.padding(horizontal = 16.dp),
                )

                NotificationScrollingStack(
                    shadeSession = shadeSession,
                    stackScrollView = stackScrollView.get(),
                    viewModel = notificationsPlaceholderViewModel,
                    maxScrimTop = { 0f },
                    shouldPunchHoleBehindScrim = false,
                    shouldFillMaxSize = false,
                    shouldReserveSpaceForNavBar = false,
                    shadeMode = ShadeMode.Dual,
                    modifier = Modifier.fillMaxWidth(),
                )

                // Communicates the bottom position of the drawable area within the shade to NSSL.
                NotificationStackCutoffGuideline(
                    stackScrollView = stackScrollView.get(),
                    viewModel = notificationsPlaceholderViewModel,
                )
            }
        }
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ import dagger.multibindings.IntoMap
            EmptySceneModule::class,
            GoneSceneModule::class,
            NotificationsShadeOverlayModule::class,
            NotificationsShadeSceneModule::class,
            NotificationsShadeSessionModule::class,
            QuickSettingsShadeOverlayModule::class,
            QuickSettingsSceneModule::class,
+0 −1
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@ import dagger.multibindings.IntoMap
            ShadeSceneModule::class,
            QuickSettingsShadeOverlayModule::class,
            NotificationsShadeOverlayModule::class,
            NotificationsShadeSceneModule::class,
            NotificationsShadeSessionModule::class,
            SceneDomainModule::class,

+0 −16
Original line number Diff line number Diff line
@@ -42,22 +42,6 @@ object Scenes {
    /** The lockscreen is the scene that shows when the device is locked. */
    @JvmField val Lockscreen = SceneKey("lockscreen")

    /**
     * The notifications shade scene primarily shows a scrollable list of notifications as an
     * overlay UI.
     *
     * It's used only in the dual shade configuration, where there are two separate shades: one for
     * notifications (this scene) and another for [QuickSettingsShade].
     *
     * It's not used in the single/accordion configuration (swipe down once to reveal the shade,
     * swipe down again the to expand quick settings) or in the "split" shade configuration (on
     * large screens or unfolded foldables, where notifications and quick settings are shown
     * side-by-side in their own columns).
     */
    @Deprecated("The notifications shade scene has been replaced by an overlay")
    @JvmField
    val NotificationsShade = SceneKey("notifications_shade")

    /**
     * The quick settings scene shows the quick setting tiles.
     *