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

Commit 6d15a570 authored by Fabián Kozynski's avatar Fabián Kozynski
Browse files

Use InfiniteGrid in dual shade

Instead of paginated grid.

Test: manual, open QS shade
Test: atest com.android.systemui.qs.panels
Flag: com.android.systemui.dual_shade
Fixes: 381279551
Change-Id: I34510f35d59c018eb733cacedd146a580ac02c18
parent 9789ec82
Loading
Loading
Loading
Loading
+17 −13
Original line number Diff line number Diff line
@@ -26,8 +26,10 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredHeightIn
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
@@ -50,6 +52,7 @@ import com.android.systemui.qs.flags.QsDetailedView
import com.android.systemui.qs.panels.ui.compose.EditMode
import com.android.systemui.qs.panels.ui.compose.TileDetails
import com.android.systemui.qs.panels.ui.compose.TileGrid
import com.android.systemui.qs.ui.composable.QuickSettingsShade.Dimensions.GridMaxHeight
import com.android.systemui.qs.ui.viewmodel.QuickSettingsContainerViewModel
import com.android.systemui.qs.ui.viewmodel.QuickSettingsShadeOverlayActionsViewModel
import com.android.systemui.qs.ui.viewmodel.QuickSettingsShadeOverlayContentViewModel
@@ -122,7 +125,9 @@ constructor(
// A sealed interface to represent the possible states of the `ShadeBody`
sealed interface ShadeBodyState {
    data object Editing : ShadeBodyState

    data object TileDetails : ShadeBodyState

    data object Default : ShadeBodyState
}

@@ -149,9 +154,8 @@ fun SceneScope.ShadeBody(viewModel: QuickSettingsContainerViewModel) {
            ShadeBodyState.Editing -> {
                EditMode(
                    viewModel = viewModel.editModeViewModel,
                    modifier = Modifier
                        .fillMaxWidth()
                        .padding(QuickSettingsShade.Dimensions.Padding),
                    modifier =
                        Modifier.fillMaxWidth().padding(QuickSettingsShade.Dimensions.Padding),
                )
            }
            ShadeBodyState.TileDetails -> {
@@ -182,7 +186,7 @@ fun SceneScope.QuickSettingsLayout(
                .padding(
                    start = QuickSettingsShade.Dimensions.Padding,
                    end = QuickSettingsShade.Dimensions.Padding,
                    top = QuickSettingsShade.Dimensions.Padding,
                    bottom = QuickSettingsShade.Dimensions.Padding / 2,
                ),
    ) {
        BrightnessSliderContainer(
@@ -190,14 +194,14 @@ fun SceneScope.QuickSettingsLayout(
            modifier =
                Modifier.fillMaxWidth().height(QuickSettingsShade.Dimensions.BrightnessSliderHeight),
        )
        Box {
            GridAnchor()
            TileGrid(
                viewModel = viewModel.tileGridViewModel,
        Box(
            modifier =
                    Modifier.fillMaxWidth()
                        .heightIn(max = QuickSettingsShade.Dimensions.GridMaxHeight),
            )
                Modifier.requiredHeightIn(max = GridMaxHeight)
                    .verticalNestedScrollToScene()
                    .verticalScroll(rememberScrollState())
        ) {
            GridAnchor()
            TileGrid(viewModel = viewModel.tileGridViewModel, modifier = Modifier.fillMaxWidth())
        }
    }
}
@@ -207,6 +211,6 @@ object QuickSettingsShade {
    object Dimensions {
        val Padding = 16.dp
        val BrightnessSliderHeight = 64.dp
        val GridMaxHeight = 800.dp
        val GridMaxHeight = 420.dp
    }
}
+53 −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.qs.panels.data.repository

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.kosmos.collectLastValue
import com.android.systemui.kosmos.runTest
import com.android.systemui.qs.panels.shared.model.InfiniteGridLayoutType
import com.android.systemui.qs.panels.shared.model.PaginatedGridLayoutType
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlin.test.Test
import org.junit.runner.RunWith

@SmallTest
@RunWith(AndroidJUnit4::class)
class GridLayoutTypeRepositoryTest : SysuiTestCase() {
    val kosmos = testKosmos()

    val underTest = kosmos.gridLayoutTypeRepository

    @Test
    fun defaultType_paginated() =
        kosmos.runTest {
            val type by collectLastValue(underTest.defaultLayoutType)

            assertThat(type).isEqualTo(PaginatedGridLayoutType)
        }

    @Test
    fun dualShadeType_infinite() =
        kosmos.runTest {
            val type by collectLastValue(underTest.dualShadeLayoutType)

            assertThat(type).isEqualTo(InfiniteGridLayoutType)
        }
}
+68 −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.qs.panels.domain.interactor

import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.collectLastValue
import com.android.systemui.kosmos.runTest
import com.android.systemui.qs.panels.shared.model.InfiniteGridLayoutType
import com.android.systemui.qs.panels.shared.model.PaginatedGridLayoutType
import com.android.systemui.shade.data.repository.fakeShadeRepository
import com.android.systemui.shade.shared.flag.DualShade
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlin.test.Test
import org.junit.runner.RunWith

@SmallTest
@RunWith(AndroidJUnit4::class)
class GridLayoutTypeInteractorTest : SysuiTestCase() {
    val kosmos = testKosmos()

    val Kosmos.underTest by Kosmos.Fixture { kosmos.gridLayoutTypeInteractor }

    @DisableFlags(DualShade.FLAG_NAME)
    @Test
    fun noDualShade_gridAlwaysPaginated() =
        kosmos.runTest {
            val type by collectLastValue(underTest.layout)

            fakeShadeRepository.setShadeLayoutWide(false)
            assertThat(type).isEqualTo(PaginatedGridLayoutType)

            fakeShadeRepository.setShadeLayoutWide(true)
            assertThat(type).isEqualTo(PaginatedGridLayoutType)
        }

    @EnableFlags(DualShade.FLAG_NAME)
    @Test
    fun dualShade_gridAlwaysInfinite() =
        kosmos.runTest {
            val type by collectLastValue(underTest.layout)

            fakeShadeRepository.setShadeLayoutWide(false)
            assertThat(type).isEqualTo(InfiniteGridLayoutType)

            fakeShadeRepository.setShadeLayoutWide(true)
            assertThat(type).isEqualTo(InfiniteGridLayoutType)
        }
}
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.kosmos.testScope
import com.android.systemui.qs.panels.data.repository.DefaultLargeTilesRepository
import com.android.systemui.qs.panels.data.repository.defaultLargeTilesRepository
import com.android.systemui.qs.panels.domain.interactor.infiniteGridLayout
import com.android.systemui.qs.panels.ui.compose.infinitegrid.infiniteGridLayout
import com.android.systemui.qs.panels.ui.viewmodel.MockTileViewModel
import com.android.systemui.qs.pipeline.shared.TileSpec
import com.android.systemui.testKosmos
+1 −7
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.verticalScroll
@@ -709,12 +708,7 @@ constructor(
                                    GridAnchor()
                                    TileGrid(
                                        viewModel = containerViewModel.tileGridViewModel,
                                        modifier =
                                            Modifier.fillMaxWidth()
                                                .heightIn(
                                                    max =
                                                        QuickSettingsShade.Dimensions.GridMaxHeight
                                                ),
                                        modifier = Modifier.fillMaxWidth(),
                                    )
                                }
                            }
Loading