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

Commit 47c05043 authored by Ale Nijamkin's avatar Ale Nijamkin Committed by Android (Google) Code Review
Browse files

Merge "[Flexiglass] Fix back handling in QS Edit mode" into main

parents 49af9037 bdc60a19
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.qs.ui.composable

import android.view.ViewGroup
import androidx.activity.compose.BackHandler
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.tween
import androidx.compose.animation.expandVertically
@@ -122,6 +123,13 @@ private fun SceneScope.QuickSettingsScene(
    // TODO(b/280887232): implement the real UI.
    Box(modifier = modifier.fillMaxSize()) {
        val isCustomizing by viewModel.qsSceneAdapter.isCustomizing.collectAsState()

        BackHandler(
            enabled = isCustomizing,
        ) {
            viewModel.qsSceneAdapter.requestCloseCustomizer()
        }

        val collapsedHeaderHeight =
            with(LocalDensity.current) { ShadeHeader.Dimensions.CollapsedHeight.roundToPx() }
        val lifecycleOwner = LocalLifecycleOwner.current
+12 −0
Original line number Diff line number Diff line
@@ -496,4 +496,16 @@ class QSSceneAdapterImplTest : SysuiTestCase() {
            runCurrent()
            verify(qsImpl!!).setInSplitShade(true)
        }

    @Test
    fun requestCloseCustomizer() =
        testScope.runTest {
            val qsImpl by collectLastValue(underTest.qsImpl)

            underTest.inflate(context)
            runCurrent()

            underTest.requestCloseCustomizer()
            verify(qsImpl!!).closeCustomizer()
        }
}
+4 −14
Original line number Diff line number Diff line
@@ -133,18 +133,13 @@ class QuickSettingsSceneViewModelTest : SysuiTestCase() {
        }

    @Test
    fun destinationsCustomizing() =
    fun destinationsCustomizing_noDestinations() =
        testScope.runTest {
            overrideResource(R.bool.config_use_split_notification_shade, false)
            val destinations by collectLastValue(underTest.destinationScenes)
            qsFlexiglassAdapter.setCustomizing(true)

            assertThat(destinations)
                .isEqualTo(
                    mapOf(
                        Back to UserActionResult(Scenes.QuickSettings),
                    )
                )
            assertThat(destinations).isEmpty()
        }

    @Test
@@ -164,18 +159,13 @@ class QuickSettingsSceneViewModelTest : SysuiTestCase() {
        }

    @Test
    fun destinations_whenCustomizing_inSplitShade() =
    fun destinations_whenCustomizing_inSplitShade_noDestinations() =
        testScope.runTest {
            overrideResource(R.bool.config_use_split_notification_shade, true)
            val destinations by collectLastValue(underTest.destinationScenes)
            qsFlexiglassAdapter.setCustomizing(true)

            assertThat(destinations)
                .isEqualTo(
                    mapOf(
                        Back to UserActionResult(Scenes.QuickSettings),
                    )
                )
            assertThat(destinations).isEmpty()
        }

    @Test
+7 −0
Original line number Diff line number Diff line
@@ -93,6 +93,9 @@ interface QSSceneAdapter {
    val isQsFullyCollapsed: Boolean
        get() = true

    /** Request that the customizer be closed. Possibly animating it. */
    fun requestCloseCustomizer()

    sealed interface State {

        val isVisible: Boolean
@@ -277,6 +280,10 @@ constructor(
        bottomNavBarSize.emit(padding)
    }

    override fun requestCloseCustomizer() {
        qsImpl.value?.closeCustomizer()
    }

    private fun QSImpl.applyState(state: QSSceneAdapter.State) {
        setQsVisible(state.isVisible)
        setExpanded(state.isVisible && state.expansion > 0f)
+3 −2
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import androidx.lifecycle.LifecycleOwner
import com.android.compose.animation.scene.Back
import com.android.compose.animation.scene.Swipe
import com.android.compose.animation.scene.SwipeDirection
import com.android.compose.animation.scene.UserAction
import com.android.compose.animation.scene.UserActionResult
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.qs.FooterActionsController
@@ -47,7 +46,9 @@ constructor(
    val destinationScenes =
        qsSceneAdapter.isCustomizing.map { customizing ->
            if (customizing) {
                mapOf<UserAction, UserActionResult>(Back to UserActionResult(Scenes.QuickSettings))
                // TODO(b/332749288) Empty map so there are no back handlers and back can close
                // customizer
                emptyMap()
                // TODO(b/330200163) Add an Up from Bottom to be able to collapse the shade
                // while customizing
            } else {
Loading