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

Commit 31ed38e7 authored by amehfooz's avatar amehfooz Committed by Ahmed Mehfooz
Browse files

[DesktopStatusBar] Add a DesktopStatusBar composable

This CL creates a new composable which replaces the
existing StatusBar ui if desktop mode is enabled.

Bug: 433589833
Flag: com.android.systemui.status_bar_for_desktop
Test: manual
Change-Id: I669fb714e6d5529962845b448dd17e9c37b45ee5
parent 13b039d6
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -159,6 +159,15 @@ class FakeHomeStatusBarViewModel(
    override val areaDark: IsAreaDark by
        hydrator.hydratedStateOf(traceName = "areaDark", source = isAreaDarkSource)

    val desktopStatusBarEnabledSource = MutableStateFlow(false)

    override val isDesktopStatusBarEnabled: Boolean by
        hydrator.hydratedStateOf(
            traceName = "areaDark",
            source = desktopStatusBarEnabledSource,
            initialValue = false,
        )

    override suspend fun onActivated(): Nothing {
        hydrator.activate()
    }
+28 −0
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.statusbar.pipeline.shared.ui.composable

import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.android.systemui.statusbar.pipeline.shared.ui.viewmodel.HomeStatusBarViewModel

/** Top level composable responsible for all UI shown for the Status Bar for DesktopMode. */
@Composable
fun DesktopStatusBar(viewModel: HomeStatusBarViewModel, modifier: Modifier = Modifier) {
    Text("Desktop Status Bar", modifier = modifier)
}
+7 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ import com.android.systemui.statusbar.chips.ui.compose.OngoingActivityChips
import com.android.systemui.statusbar.core.NewStatusBarIcons
import com.android.systemui.statusbar.core.RudimentaryBattery
import com.android.systemui.statusbar.core.StatusBarConnectedDisplays
import com.android.systemui.statusbar.core.StatusBarForDesktop
import com.android.systemui.statusbar.events.domain.interactor.SystemStatusEventAnimationInteractor
import com.android.systemui.statusbar.featurepods.popups.StatusBarPopupChips
import com.android.systemui.statusbar.featurepods.popups.ui.compose.StatusBarPopupChipsContainer
@@ -185,6 +186,12 @@ fun StatusBarRoot(
            statusBarViewModel.appHandlesViewModelFactory.create(displayId)
        }

    // Let the DesktopStatusBar compose all the UI if [isDesktopStatusBarEnabled] is true.
    if (StatusBarForDesktop.isEnabled && statusBarViewModel.isDesktopStatusBarEnabled) {
        DesktopStatusBar(viewModel = statusBarViewModel)
        return
    }

    AndroidView(
        factory = { context ->
            val inflater = LayoutInflater.from(context)
+12 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import androidx.compose.runtime.getValue
import com.android.app.tracing.FlowTracing.traceEach
import com.android.app.tracing.TrackGroupUtils.trackGroup
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.desktop.domain.interactor.DesktopInteractor
import com.android.systemui.display.dagger.SystemUIDisplaySubcomponent.DisplayAware
import com.android.systemui.display.dagger.SystemUIDisplaySubcomponent.DisplayId
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
@@ -222,6 +223,9 @@ interface HomeStatusBarViewModel : Activatable {
    /** [IsAreaDark] applicable for this status bar's display and content area */
    val areaDark: IsAreaDark

    /** True if the desktop status bar is enabled. */
    val isDesktopStatusBarEnabled: Boolean

    /** Interface for the assisted factory, to allow for providing a fake in tests */
    interface HomeStatusBarViewModelFactory {
        fun create(): HomeStatusBarViewModel
@@ -242,6 +246,7 @@ constructor(
    homeStatusBarIconBlockListInteractor: HomeStatusBarIconBlockListInteractor,
    lightsOutInteractor: LightsOutInteractor,
    notificationsInteractor: ActiveNotificationsInteractor,
    desktopInteractor: DesktopInteractor,
    darkIconInteractor: DarkIconInteractor,
    headsUpNotificationInteractor: HeadsUpNotificationInteractor,
    keyguardTransitionInteractor: KeyguardTransitionInteractor,
@@ -426,6 +431,13 @@ constructor(
            )
        }

    override val isDesktopStatusBarEnabled: Boolean by
        hydrator.hydratedStateOf(
            traceName = "isDesktopStatusBarEnabled",
            initialValue = false,
            source = desktopInteractor.isDesktopFeatureSetEnabled,
        )

    /**
     * True if the current SysUI state can show the home status bar (aka this status bar), and false
     * if we shouldn't be showing any part of the home status bar.
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.pipeline.shared.ui.viewmodel

import android.content.testableContext
import com.android.systemui.desktop.domain.interactor.desktopInteractor
import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor
import com.android.systemui.kosmos.Kosmos
@@ -81,6 +82,7 @@ var Kosmos.homeStatusBarViewModelFactory: (Int) -> HomeStatusBarViewModel by
                homeStatusBarIconBlockListInteractor,
                lightsOutInteractor,
                activeNotificationsInteractor,
                desktopInteractor,
                darkIconInteractor,
                headsUpNotificationInteractor,
                keyguardTransitionInteractor,