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

Commit 8858a75d authored by Chandru S's avatar Chandru S
Browse files

Create a separate composable for integrating the bouncer in legacy keyguard.

This allows us to minor UI tweaks that are necessary for integrating the compose bouncer in legacy keyguard

Bug: 310005730
Flag: com.android.systemui.compose_bouncer
Test: everything builds, compose bouncer shows up when flag is on.
Change-Id: I4c7fb84250f187d1b31e8f3108b132caa2730240
parent 3b2c905b
Loading
Loading
Loading
Loading
+2 −13
Original line number Diff line number Diff line
@@ -8,14 +8,12 @@ import androidx.compose.ui.platform.ComposeView
import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.compose.theme.PlatformTheme
import com.android.keyguard.ViewMediatorCallback
import com.android.systemui.authentication.domain.interactor.AuthenticationInteractor
import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor
import com.android.systemui.bouncer.ui.BouncerDialogFactory
import com.android.systemui.bouncer.ui.composable.BouncerContent
import com.android.systemui.bouncer.ui.composable.BouncerContainer
import com.android.systemui.bouncer.ui.viewmodel.BouncerSceneContentViewModel
import com.android.systemui.lifecycle.rememberViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import kotlinx.coroutines.flow.collectLatest
@@ -49,16 +47,7 @@ object ComposeBouncerViewBinder {
                                    this@repeatWhenAttached.lifecycle
                            }
                        )
                        setContent {
                            PlatformTheme {
                                BouncerContent(
                                    rememberViewModel("ComposeBouncerViewBinder") {
                                        viewModelFactory.create()
                                    },
                                    dialogFactory,
                                )
                            }
                        }
                        setContent { BouncerContainer(viewModelFactory, dialogFactory) }
                    }
                }
            }
+54 −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.bouncer.ui.composable

import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.android.compose.theme.PlatformTheme
import com.android.systemui.bouncer.ui.BouncerDialogFactory
import com.android.systemui.bouncer.ui.viewmodel.BouncerSceneContentViewModel
import com.android.systemui.compose.modifiers.sysuiResTag
import com.android.systemui.lifecycle.rememberViewModel

/** Container that includes the compose bouncer and is meant to be included in legacy keyguard. */
@Composable
fun BouncerContainer(
    viewModelFactory: BouncerSceneContentViewModel.Factory,
    dialogFactory: BouncerDialogFactory,
) {
    PlatformTheme {
        val backgroundColor = MaterialTheme.colorScheme.surface

        val bouncerViewModel = rememberViewModel("BouncerContainer") { viewModelFactory.create() }
        Box {
            Canvas(Modifier.fillMaxSize()) { drawRect(color = backgroundColor) }

            // Separate the bouncer content into a reusable composable that
            // doesn't have any SceneScope
            // dependencies
            BouncerContent(
                bouncerViewModel,
                dialogFactory,
                Modifier.sysuiResTag(Bouncer.TestTags.Root).fillMaxSize()
            )
        }
    }
}