Merge "[SB Refactor] Add content descriptions for the mobile triangle." into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
87db26d80b
@@ -29,6 +29,7 @@ import androidx.lifecycle.Lifecycle
|
|||||||
import androidx.lifecycle.repeatOnLifecycle
|
import androidx.lifecycle.repeatOnLifecycle
|
||||||
import com.android.settingslib.graph.SignalDrawable
|
import com.android.settingslib.graph.SignalDrawable
|
||||||
import com.android.systemui.R
|
import com.android.systemui.R
|
||||||
|
import com.android.systemui.common.ui.binder.ContentDescriptionViewBinder
|
||||||
import com.android.systemui.common.ui.binder.IconViewBinder
|
import com.android.systemui.common.ui.binder.IconViewBinder
|
||||||
import com.android.systemui.lifecycle.repeatWhenAttached
|
import com.android.systemui.lifecycle.repeatWhenAttached
|
||||||
import com.android.systemui.statusbar.StatusBarIconView
|
import com.android.systemui.statusbar.StatusBarIconView
|
||||||
@@ -97,6 +98,12 @@ object MobileIconBinder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
launch {
|
||||||
|
viewModel.contentDescription.distinctUntilChanged().collect {
|
||||||
|
ContentDescriptionViewBinder.bind(it, view)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set the network type icon
|
// Set the network type icon
|
||||||
launch {
|
launch {
|
||||||
viewModel.networkTypeIcon.distinctUntilChanged().collect { dataTypeId ->
|
viewModel.networkTypeIcon.distinctUntilChanged().collect { dataTypeId ->
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel
|
package com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel
|
||||||
|
|
||||||
|
import com.android.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH
|
||||||
|
import com.android.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH_NONE
|
||||||
import com.android.settingslib.graph.SignalDrawable
|
import com.android.settingslib.graph.SignalDrawable
|
||||||
import com.android.systemui.common.shared.model.ContentDescription
|
import com.android.systemui.common.shared.model.ContentDescription
|
||||||
import com.android.systemui.common.shared.model.Icon
|
import com.android.systemui.common.shared.model.Icon
|
||||||
@@ -43,6 +45,7 @@ interface MobileIconViewModelCommon {
|
|||||||
val subscriptionId: Int
|
val subscriptionId: Int
|
||||||
/** An int consumable by [SignalDrawable] for display */
|
/** An int consumable by [SignalDrawable] for display */
|
||||||
val iconId: Flow<Int>
|
val iconId: Flow<Int>
|
||||||
|
val contentDescription: Flow<ContentDescription>
|
||||||
val roaming: Flow<Boolean>
|
val roaming: Flow<Boolean>
|
||||||
/** The RAT icon (LTE, 3G, 5G, etc) to be displayed. Null if we shouldn't show anything */
|
/** The RAT icon (LTE, 3G, 5G, etc) to be displayed. Null if we shouldn't show anything */
|
||||||
val networkTypeIcon: Flow<Icon?>
|
val networkTypeIcon: Flow<Icon?>
|
||||||
@@ -102,6 +105,23 @@ constructor(
|
|||||||
.stateIn(scope, SharingStarted.WhileSubscribed(), initial)
|
.stateIn(scope, SharingStarted.WhileSubscribed(), initial)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val contentDescription: Flow<ContentDescription> = run {
|
||||||
|
val initial = ContentDescription.Resource(PHONE_SIGNAL_STRENGTH_NONE)
|
||||||
|
combine(
|
||||||
|
iconInteractor.level,
|
||||||
|
iconInteractor.isInService,
|
||||||
|
) { level, isInService ->
|
||||||
|
val resId =
|
||||||
|
when {
|
||||||
|
isInService -> PHONE_SIGNAL_STRENGTH[level]
|
||||||
|
else -> PHONE_SIGNAL_STRENGTH_NONE
|
||||||
|
}
|
||||||
|
ContentDescription.Resource(resId)
|
||||||
|
}
|
||||||
|
.distinctUntilChanged()
|
||||||
|
.stateIn(scope, SharingStarted.WhileSubscribed(), initial)
|
||||||
|
}
|
||||||
|
|
||||||
private val showNetworkTypeIcon: Flow<Boolean> =
|
private val showNetworkTypeIcon: Flow<Boolean> =
|
||||||
combine(
|
combine(
|
||||||
iconInteractor.isDataConnected,
|
iconInteractor.isDataConnected,
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
package com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel
|
package com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest
|
import androidx.test.filters.SmallTest
|
||||||
|
import com.android.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH
|
||||||
|
import com.android.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH_NONE
|
||||||
import com.android.settingslib.graph.SignalDrawable
|
import com.android.settingslib.graph.SignalDrawable
|
||||||
import com.android.settingslib.mobile.TelephonyIcons.THREE_G
|
import com.android.settingslib.mobile.TelephonyIcons.THREE_G
|
||||||
import com.android.systemui.SysuiTestCase
|
import com.android.systemui.SysuiTestCase
|
||||||
@@ -121,6 +123,39 @@ class MobileIconViewModelTest : SysuiTestCase() {
|
|||||||
job.cancel()
|
job.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun contentDescription_notInService_usesNoPhone() =
|
||||||
|
testScope.runTest {
|
||||||
|
var latest: ContentDescription? = null
|
||||||
|
val job = underTest.contentDescription.onEach { latest = it }.launchIn(this)
|
||||||
|
|
||||||
|
interactor.isInService.value = false
|
||||||
|
|
||||||
|
assertThat((latest as ContentDescription.Resource).res)
|
||||||
|
.isEqualTo(PHONE_SIGNAL_STRENGTH_NONE)
|
||||||
|
|
||||||
|
job.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun contentDescription_inService_usesLevel() =
|
||||||
|
testScope.runTest {
|
||||||
|
var latest: ContentDescription? = null
|
||||||
|
val job = underTest.contentDescription.onEach { latest = it }.launchIn(this)
|
||||||
|
|
||||||
|
interactor.isInService.value = true
|
||||||
|
|
||||||
|
interactor.level.value = 2
|
||||||
|
assertThat((latest as ContentDescription.Resource).res)
|
||||||
|
.isEqualTo(PHONE_SIGNAL_STRENGTH[2])
|
||||||
|
|
||||||
|
interactor.level.value = 0
|
||||||
|
assertThat((latest as ContentDescription.Resource).res)
|
||||||
|
.isEqualTo(PHONE_SIGNAL_STRENGTH[0])
|
||||||
|
|
||||||
|
job.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun networkType_dataEnabled_groupIsRepresented() =
|
fun networkType_dataEnabled_groupIsRepresented() =
|
||||||
testScope.runTest {
|
testScope.runTest {
|
||||||
|
|||||||
Reference in New Issue
Block a user