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

Commit cc373044 authored by Jiaming Cheng's avatar Jiaming Cheng Committed by Android (Google) Code Review
Browse files

Merge "[QSDetailedView] Move Composable Rendering out from TileDetailsViewModel" into main

parents 4945b52c dc5c295e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -62,8 +62,8 @@ class DetailsViewModelTest : SysuiTestCase() {
            val tiles = currentTilesInteractor.currentTiles.value

            assertThat(currentTilesInteractor.currentTilesSpecs.size).isEqualTo(2)
            assertThat(tiles!![1].spec).isEqualTo(specNoDetails)
            (tiles!![1].tile as FakeQSTile).hasDetailsViewModel = false
            assertThat(tiles[1].spec).isEqualTo(specNoDetails)
            (tiles[1].tile as FakeQSTile).hasDetailsViewModel = false

            assertThat(underTest.activeTileDetails).isNull()

+0 −7
Original line number Diff line number Diff line
@@ -16,17 +16,10 @@

package com.android.systemui.plugins.qs

import androidx.compose.runtime.Composable

/**
 * The base view model class for rendering the Tile's TileDetailsView.
 */
abstract class TileDetailsViewModel {

    // The view content of this tile details view.
    @Composable
    abstract fun GetContentView()

    // The callback when the settings button is clicked. Currently this is the same as the on tile
    // long press callback
    abstract fun clickOnSettingsButton()
+36 −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.bluetooth.qsdialog

import android.view.LayoutInflater
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView
import com.android.systemui.res.R

@Composable
fun BluetoothDetailsContent() {
    AndroidView(
        modifier = Modifier.fillMaxSize(),
        factory = { context ->
            // Inflate with the existing dialog xml layout
            LayoutInflater.from(context).inflate(R.layout.bluetooth_tile_dialog, null)
            // TODO: b/378513956 - Implement the bluetooth details view
        },
    )
}
+0 −19
Original line number Diff line number Diff line
@@ -16,30 +16,11 @@

package com.android.systemui.bluetooth.qsdialog

import android.view.LayoutInflater
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView
import com.android.systemui.plugins.qs.TileDetailsViewModel
import com.android.systemui.res.R

class BluetoothDetailsViewModel(onLongClick: () -> Unit) : TileDetailsViewModel() {
    private val _onLongClick = onLongClick

    @Composable
    override fun GetContentView() {
        AndroidView(
            modifier = Modifier.fillMaxWidth().fillMaxHeight(),
            factory = { context ->
                // Inflate with the existing dialog xml layout
                LayoutInflater.from(context).inflate(R.layout.bluetooth_tile_dialog, null)
                // TODO: b/378513956 - Implement the bluetooth details view
            },
        )
    }

    override fun clickOnSettingsButton() {
        _onLongClick()
    }
+20 −1
Original line number Diff line number Diff line
@@ -38,8 +38,17 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.android.systemui.bluetooth.qsdialog.BluetoothDetailsContent
import com.android.systemui.bluetooth.qsdialog.BluetoothDetailsViewModel
import com.android.systemui.plugins.qs.TileDetailsViewModel
import com.android.systemui.qs.flags.QsDetailedView
import com.android.systemui.qs.panels.ui.viewmodel.DetailsViewModel
import com.android.systemui.qs.tiles.dialog.InternetDetailsContent
import com.android.systemui.qs.tiles.dialog.InternetDetailsViewModel
import com.android.systemui.qs.tiles.dialog.ModesDetailsContent
import com.android.systemui.qs.tiles.dialog.ModesDetailsViewModel
import com.android.systemui.qs.tiles.dialog.ScreenRecordDetailsContent
import com.android.systemui.qs.tiles.dialog.ScreenRecordDetailsViewModel

@Composable
fun TileDetails(modifier: Modifier = Modifier, detailsViewModel: DetailsViewModel) {
@@ -107,7 +116,17 @@ fun TileDetails(modifier: Modifier = Modifier, detailsViewModel: DetailsViewMode
                style = MaterialTheme.typography.titleSmall,
            )
        }
        tileDetailedViewModel.GetContentView()
        MapTileDetailsContent(tileDetailedViewModel)
    }
}

@Composable
private fun MapTileDetailsContent(tileDetailsViewModel: TileDetailsViewModel) {
    when (tileDetailsViewModel) {
        is InternetDetailsViewModel -> InternetDetailsContent(tileDetailsViewModel)
        is ScreenRecordDetailsViewModel -> ScreenRecordDetailsContent(tileDetailsViewModel)
        is BluetoothDetailsViewModel -> BluetoothDetailsContent()
        is ModesDetailsViewModel -> ModesDetailsContent(tileDetailsViewModel)
    }
}

Loading