Loading packages/SystemUI/compose/features/src/com/android/systemui/ambientcue/ui/compose/AmbientCueContainer.kt +9 −1 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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() } Loading @@ -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, Loading packages/SystemUI/compose/features/src/com/android/systemui/ambientcue/ui/compose/Chip.kt +7 −1 Original line number Diff line number Diff line Loading @@ -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), ) } Loading packages/SystemUI/compose/features/src/com/android/systemui/ambientcue/ui/compose/NavBarPill.kt +2 −0 Original line number Diff line number Diff line Loading @@ -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), ) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/ambientcue/data/repository/AmbientCueRepositoryTest.kt +8 −8 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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()) Loading @@ -86,7 +86,7 @@ class AmbientCueRepositoryTest : SysuiTestCase() { listOf(invalidTarget1, invalidTarget2) ) advanceUntilIdle() assertThat(isAttached).isFalse() assertThat(isVisible).isFalse() } @Test Loading packages/SystemUI/multivalentTests/src/com/android/systemui/ambientcue/domain/interactor/AmbientCueInteractorTest.kt +0 −16 Original line number Diff line number Diff line Loading @@ -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 Loading
packages/SystemUI/compose/features/src/com/android/systemui/ambientcue/ui/compose/AmbientCueContainer.kt +9 −1 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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() } Loading @@ -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, Loading
packages/SystemUI/compose/features/src/com/android/systemui/ambientcue/ui/compose/Chip.kt +7 −1 Original line number Diff line number Diff line Loading @@ -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), ) } Loading
packages/SystemUI/compose/features/src/com/android/systemui/ambientcue/ui/compose/NavBarPill.kt +2 −0 Original line number Diff line number Diff line Loading @@ -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), ) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/ambientcue/data/repository/AmbientCueRepositoryTest.kt +8 −8 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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()) Loading @@ -86,7 +86,7 @@ class AmbientCueRepositoryTest : SysuiTestCase() { listOf(invalidTarget1, invalidTarget2) ) advanceUntilIdle() assertThat(isAttached).isFalse() assertThat(isVisible).isFalse() } @Test Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/ambientcue/domain/interactor/AmbientCueInteractorTest.kt +0 −16 Original line number Diff line number Diff line Loading @@ -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