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

Commit 7d12addd authored by Lucas Silva's avatar Lucas Silva Committed by Android (Google) Code Review
Browse files

Merge "Add ambient status bar to hub" into main

parents c3a221ef 6c236589
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ object Communal {
        val Grid = ElementKey("CommunalContent")
        val LockIcon = ElementKey("CommunalLockIcon")
        val IndicationArea = ElementKey("CommunalIndicationArea")
        val StatusBar = ElementKey("StatusBar")
    }
}

@@ -92,6 +93,7 @@ val sceneTransitions = transitions {
            fade(Communal.Elements.Grid)
            fade(Communal.Elements.IndicationArea)
            fade(Communal.Elements.LockIcon)
            fade(Communal.Elements.StatusBar)
        }
        timestampRange(startMillis = 167, endMillis = 334) { fade(Communal.Elements.Scrim) }
    }
+15 −7
Original line number Diff line number Diff line
@@ -16,13 +16,16 @@

package com.android.systemui.communal.ui.compose

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.unit.IntRect
import com.android.compose.animation.scene.SceneScope
import com.android.compose.theme.LocalAndroidColorScheme
import com.android.systemui.communal.ui.compose.section.AmbientStatusBarSection
import com.android.systemui.communal.ui.viewmodel.CommunalViewModel
import com.android.systemui.communal.widgets.WidgetInteractionHandler
import com.android.systemui.keyguard.ui.composable.blueprint.BlueprintAlignmentLines
@@ -38,19 +41,24 @@ constructor(
    private val interactionHandler: WidgetInteractionHandler,
    private val dialogFactory: SystemUIDialogFactory,
    private val lockSection: LockSection,
    private val ambientStatusBarSection: AmbientStatusBarSection,
) {

    @Composable
    fun SceneScope.Content(modifier: Modifier = Modifier) {
        Layout(
            modifier = modifier.fillMaxSize(),
            content = {
                Box(modifier = Modifier.fillMaxSize()) {
                    with(ambientStatusBarSection) {
                        AmbientStatusBar(modifier = Modifier.fillMaxWidth())
                    }
                    CommunalHub(
                        viewModel = viewModel,
                        interactionHandler = interactionHandler,
                        dialogFactory = dialogFactory,
                        modifier = Modifier.element(Communal.Elements.Grid)
                    )
                }
                with(lockSection) {
                    LockIcon(
                        overrideColor = LocalAndroidColorScheme.current.onPrimaryContainer,
+55 −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.communal.ui.compose.section

import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView
import com.android.compose.animation.scene.SceneScope
import com.android.systemui.ambient.statusbar.dagger.AmbientStatusBarComponent
import com.android.systemui.ambient.statusbar.ui.AmbientStatusBarView
import com.android.systemui.communal.ui.compose.Communal
import com.android.systemui.res.R
import javax.inject.Inject

class AmbientStatusBarSection
@Inject
constructor(
    private val factory: AmbientStatusBarComponent.Factory,
) {
    @Composable
    fun SceneScope.AmbientStatusBar(modifier: Modifier = Modifier) {
        AndroidView(
            factory = { context ->
                (LayoutInflater.from(context)
                        .inflate(
                            /* resource = */ R.layout.ambient_status_bar_view,
                            /* root = */ FrameLayout(context),
                            /* attachToRoot = */ false,
                        ) as AmbientStatusBarView)
                    .apply {
                        visibility = View.VISIBLE
                        factory.create(this).getController().apply { init() }
                    }
            },
            modifier = modifier.element(Communal.Elements.StatusBar)
        )
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -146,6 +146,7 @@ public class AmbientStatusBarViewControllerTest extends SysuiTestCase {
                mDreamOverlayStateController,
                mUserTracker,
                mKosmos.getWifiInteractor(),
                mKosmos.getCommunalSceneInteractor(),
                mLogBuffer);
    }

@@ -272,6 +273,7 @@ public class AmbientStatusBarViewControllerTest extends SysuiTestCase {
                mDreamOverlayStateController,
                mUserTracker,
                mKosmos.getWifiInteractor(),
                mKosmos.getCommunalSceneInteractor(),
                mLogBuffer);
        controller.onViewAttached();
        verify(mView, never()).showIcon(
+19 −2
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.view.View;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;

import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dreams.DreamLogger;
import com.android.systemui.dreams.DreamOverlayNotificationCountProvider;
@@ -82,9 +83,11 @@ public class AmbientStatusBarViewController extends ViewController<AmbientStatus
    private final Executor mMainExecutor;
    private final List<DreamOverlayStatusBarItemsProvider.StatusBarItem> mExtraStatusBarItems =
            new ArrayList<>();
    private final CommunalSceneInteractor mCommunalSceneInteractor;
    private final DreamLogger mLogger;

    private boolean mIsAttached;
    private boolean mCommunalVisible;

    // Whether dream entry animations are finished.
    private boolean mEntryAnimationsFinished = false;
@@ -140,6 +143,7 @@ public class AmbientStatusBarViewController extends ViewController<AmbientStatus
            DreamOverlayStateController dreamOverlayStateController,
            UserTracker userTracker,
            WifiInteractor wifiInteractor,
            CommunalSceneInteractor communalSceneInteractor,
            @DreamLog LogBuffer logBuffer) {
        super(view);
        mResources = resources;
@@ -155,6 +159,7 @@ public class AmbientStatusBarViewController extends ViewController<AmbientStatus
        mDreamOverlayStateController = dreamOverlayStateController;
        mUserTracker = userTracker;
        mWifiInteractor = wifiInteractor;
        mCommunalSceneInteractor = communalSceneInteractor;
        mLogger = new DreamLogger(logBuffer, TAG);

        // Register to receive show/hide updates for the system status bar. Our custom status bar
@@ -172,6 +177,12 @@ public class AmbientStatusBarViewController extends ViewController<AmbientStatus
                network -> updateWifiUnavailableStatusIcon(
                        network instanceof WifiNetworkModel.Active));

        collectFlow(
                mView,
                mCommunalSceneInteractor.isCommunalVisible(),
                this::onCommunalVisibleChanged
        );

        mNextAlarmController.addCallback(mNextAlarmCallback);
        updateAlarmStatusIcon();

@@ -230,9 +241,15 @@ public class AmbientStatusBarViewController extends ViewController<AmbientStatus
        mView.setTranslationY(translationY);
    }

    private void onCommunalVisibleChanged(boolean visible) {
        mCommunalVisible = visible;
        updateVisibility();
    }

    private boolean shouldShowStatusBar() {
        return !mDreamOverlayStateController.isLowLightActive()
                && !mStatusBarWindowStateController.windowIsShowing();
        return (!mDreamOverlayStateController.isLowLightActive()
                && !mStatusBarWindowStateController.windowIsShowing())
                || mCommunalVisible;
    }

    @VisibleForTesting
Loading