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

Commit bf86ce66 authored by Lucas Dupin's avatar Lucas Dupin Committed by Android (Google) Code Review
Browse files

Merge "Consolidate visibility and window LayoutParams" into main

parents dac16060 8bd5f9fb
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@@ -30,6 +31,7 @@ import com.android.systemui.lifecycle.rememberViewModel
fun AmbientCueContainer(
    modifier: Modifier = Modifier,
    ambientCueViewModelFactory: AmbientCueViewModel.Factory,
    onShouldInterceptTouches: (Boolean) -> Unit,
) {
    val viewModel = rememberViewModel("AmbientCueContainer") { ambientCueViewModelFactory.create() }

@@ -40,7 +42,13 @@ fun AmbientCueContainer(
    // TODO: b/414507396 - Replace with the height of the navbar
    val chipsBottomPadding = 46.dp

    Box(modifier.clickable(expanded) { viewModel.collapse() }) {
    LaunchedEffect(expanded) { onShouldInterceptTouches(expanded) }

    Box(
        modifier.clickable(enabled = expanded, indication = null, interactionSource = null) {
            viewModel.collapse()
        }
    ) {
        BackgroundGlow(visible, Modifier.align(Alignment.BottomCenter))
        NavBarPill(
            actions = actions,
+7 −1
Original line number Diff line number Diff line
@@ -60,12 +60,18 @@ fun Chip(action: ActionViewModel, modifier: Modifier = Modifier) {
            modifier = Modifier.size(24.dp).clip(CircleShape),
        )

        Text(action.label, style = MaterialTheme.typography.labelLarge, color = outlineColor)
        Text(
            action.label,
            style = MaterialTheme.typography.labelLarge,
            color = outlineColor,
            maxLines = 1,
        )
        if (action.attribution != null) {
            Text(
                action.attribution,
                style = MaterialTheme.typography.labelLarge,
                color = outlineColor,
                maxLines = 1,
                modifier = Modifier.padding(start = 4.dp).alpha(0.4f),
            )
        }
+2 −0
Original line number Diff line number Diff line
@@ -137,12 +137,14 @@ fun NavBarPill(
                        Text(
                            text = action.label,
                            style = MaterialTheme.typography.labelSmall,
                            maxLines = 1,
                            color = outlineColor,
                        )
                        if (action.attribution != null) {
                            Text(
                                text = action.attribution,
                                style = MaterialTheme.typography.labelSmall,
                                maxLines = 1,
                                color = outlineColor,
                                modifier = Modifier.padding(start = 4.dp).alpha(0.4f),
                            )
+8 −8
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.ambientcue.data.repository.AmbientCueRepositoryImpl.Companion.AMBIENT_ACTION_FEATURE
import com.android.systemui.ambientcue.data.repository.AmbientCueRepositoryImpl.Companion.AMBIENT_CUE_SURFACE
import com.android.systemui.broadcast.broadcastDispatcher
import com.android.systemui.concurrency.fakeExecutor
import com.android.systemui.kosmos.advanceUntilIdle
import com.android.systemui.kosmos.backgroundScope
@@ -57,28 +56,29 @@ class AmbientCueRepositoryTest : SysuiTestCase() {
    private val underTest =
        AmbientCueRepositoryImpl(
            backgroundScope = kosmos.backgroundScope,
            broadcastDispatcher = kosmos.broadcastDispatcher,
            smartSpaceManager = smartSpaceManager,
            executor = kosmos.fakeExecutor,
            applicationContext = kosmos.testableContext,
        )

    @Test
    fun isAttached_whenHasActions_true() =
    fun isVisible_whenHasActions_true() =
        kosmos.runTest {
            val isAttached by collectLastValue(underTest.isAttached)
            val actions by collectLastValue(underTest.actions)
            val isVisible by collectLastValue(underTest.isVisible)
            runCurrent()
            verify(smartSpaceSession)
                .addOnTargetsAvailableListener(any(), onTargetsAvailableListenerCaptor.capture())
            onTargetsAvailableListenerCaptor.firstValue.onTargetsAvailable(allTargets)
            advanceUntilIdle()
            assertThat(isAttached).isTrue()
            assertThat(isVisible).isTrue()
        }

    @Test
    fun isAttached_whenNoActions_false() =
    fun isVisible_whenNoActions_false() =
        kosmos.runTest {
            val isAttached by collectLastValue(underTest.isAttached)
            val actions by collectLastValue(underTest.actions)
            val isVisible by collectLastValue(underTest.isVisible)
            runCurrent()
            verify(smartSpaceSession)
                .addOnTargetsAvailableListener(any(), onTargetsAvailableListenerCaptor.capture())
@@ -86,7 +86,7 @@ class AmbientCueRepositoryTest : SysuiTestCase() {
                listOf(invalidTarget1, invalidTarget2)
            )
            advanceUntilIdle()
            assertThat(isAttached).isFalse()
            assertThat(isVisible).isFalse()
        }

    @Test
+0 −16
Original line number Diff line number Diff line
@@ -37,22 +37,6 @@ import org.junit.runner.RunWith
class AmbientCueInteractorTest : SysuiTestCase() {
    private val kosmos = testKosmos()

    @Test
    fun isAttached_whenCreated_true() =
        kosmos.runTest {
            val isAttached by collectLastValue(ambientCueInteractor.isAttached)
            ambientCueRepository.fake.setIsAttached(true)
            assertThat(isAttached).isTrue()
        }

    @Test
    fun isAttached_whenDestroyed_false() =
        kosmos.runTest {
            val isAttached by collectLastValue(ambientCueInteractor.isAttached)
            ambientCueRepository.fake.setIsAttached(false)
            assertThat(isAttached).isFalse()
        }

    @Test
    fun isVisible_setTrue_true() =
        kosmos.runTest {
Loading