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

Commit 11a36f4a authored by Kai Li's avatar Kai Li Committed by Android (Google) Code Review
Browse files

Merge "Move DelegatedSurfaceView into a provider class." into main

parents 7731683d fc3ef3be
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.underlay.ui.compose

import androidx.compose.foundation.layout.Box
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import javax.inject.Inject

interface UnderlayComposableProvider {
  @Composable fun Content(modifier: Modifier)
}

class UnderlayComposableProviderImpl @Inject constructor() : UnderlayComposableProvider {

  @Composable
  override fun Content(modifier: Modifier) { }
}
 No newline at end of file
+31 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.underlay

import com.android.systemui.underlay.ui.compose.UnderlayComposableProvider
import com.android.systemui.underlay.ui.compose.UnderlayComposableProviderImpl
import dagger.Binds
import dagger.Module

@Module
interface UnderlayComposableProviderModule {

    @Binds
    fun bindUnderlayComposableProvider(
        provider: UnderlayComposableProviderImpl
    ): UnderlayComposableProvider
}
+5 −13
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.underlay.ui.compose

import android.util.Log
import android.view.SurfaceView
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
@@ -25,16 +24,18 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import com.android.compose.PlatformIconButton
import com.android.systemui.res.R

@Composable
fun UnderlayContainer(modifier: Modifier = Modifier) {
fun UnderlayContainer(
    modifier: Modifier = Modifier,
    content: UnderlayComposableProvider,
) {
    Box(modifier = modifier) {
        // TODO: b/407634988 - Add rounded horns

        DelegatedSurfaceView()
        content.Content(modifier = Modifier)

        // Close Button.
        PlatformIconButton(
@@ -50,13 +51,4 @@ fun UnderlayContainer(modifier: Modifier = Modifier) {
    }
}

/**
 * The SurfaceView content, which is currently blank, will be populated by another app using the
 * DelegatedUI framework.
 */
@Composable
private fun DelegatedSurfaceView(modifier: Modifier = Modifier) {
    AndroidView(factory = { context -> SurfaceView(context) }, modifier = modifier)
}

private const val TAG = "UnderlayContainer"
+12 −3
Original line number Diff line number Diff line
@@ -24,12 +24,17 @@ import androidx.compose.ui.platform.ComposeView
import com.android.compose.theme.PlatformTheme
import com.android.systemui.compose.ComposeInitializer
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.underlay.ui.compose.UnderlayComposableProvider
import com.android.systemui.underlay.ui.compose.UnderlayContainer
import javax.inject.Inject

/** A root view of the Underlay SysUI window. */
class UnderlayWindowRootView @Inject constructor(@Application applicationContext: Context) :
    FrameLayout(applicationContext) {
class UnderlayWindowRootView
@Inject
constructor(
    @Application applicationContext: Context,
    content: UnderlayComposableProvider,
) : FrameLayout(applicationContext) {

    init {
        layoutParams =
@@ -49,7 +54,11 @@ class UnderlayWindowRootView @Inject constructor(@Application applicationContext
                        defaultFocusHighlightEnabled = false
                        fitsSystemWindows = false
                    }
                setContent { PlatformTheme { UnderlayContainer() } }
                setContent {
                    PlatformTheme {
                        UnderlayContainer(content = content)
                    }
                }
            }

        addView(composeView)