diff options
13 files changed, 81 insertions, 59 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/view/accessibility/domain/interactor/CaptioningInteractor.kt b/packages/SettingsLib/src/com/android/settingslib/view/accessibility/domain/interactor/CaptioningInteractor.kt deleted file mode 100644 index 858c8b369a14..000000000000 --- a/packages/SettingsLib/src/com/android/settingslib/view/accessibility/domain/interactor/CaptioningInteractor.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.settingslib.view.accessibility.domain.interactor - -import com.android.settingslib.view.accessibility.data.repository.CaptioningRepository -import kotlinx.coroutines.flow.StateFlow - -class CaptioningInteractor(private val repository: CaptioningRepository) { - - val isSystemAudioCaptioningEnabled: StateFlow<Boolean> - get() = repository.isSystemAudioCaptioningEnabled - - val isSystemAudioCaptioningUiEnabled: StateFlow<Boolean> - get() = repository.isSystemAudioCaptioningUiEnabled - - suspend fun setIsSystemAudioCaptioningEnabled(enabled: Boolean) = - repository.setIsSystemAudioCaptioningEnabled(enabled) -} diff --git a/packages/SettingsLib/tests/integ/src/com/android/settingslib/view/accessibility/data/repository/CaptioningRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/data/repository/CaptioningRepositoryTest.kt index a5233e7d51d6..dd85d9bd2d7c 100644 --- a/packages/SettingsLib/tests/integ/src/com/android/settingslib/view/accessibility/data/repository/CaptioningRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/data/repository/CaptioningRepositoryTest.kt @@ -14,11 +14,12 @@ * limitations under the License. */ -package com.android.settingslib.view.accessibility.data.repository +package com.android.systemui.accessibility.data.repository import android.view.accessibility.CaptioningManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.systemui.SysuiTestCase import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.launchIn @@ -40,7 +41,7 @@ import org.mockito.MockitoAnnotations @SmallTest @Suppress("UnspecifiedRegisterReceiverFlag") @RunWith(AndroidJUnit4::class) -class CaptioningRepositoryTest { +class CaptioningRepositoryTest : SysuiTestCase() { @Captor private lateinit var listenerCaptor: ArgumentCaptor<CaptioningManager.CaptioningChangeListener> diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/captioning/ui/viewmodel/CaptioningViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/captioning/ui/viewmodel/CaptioningViewModelTest.kt index 4cf924ad1609..cb6dc193394e 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/captioning/ui/viewmodel/CaptioningViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/captioning/ui/viewmodel/CaptioningViewModelTest.kt @@ -20,11 +20,12 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.internal.logging.uiEventLogger import com.android.systemui.SysuiTestCase +import com.android.systemui.accessibility.data.repository.captioningRepository +import com.android.systemui.accessibility.domain.interactor.captioningInteractor import com.android.systemui.coroutines.collectLastValue +import com.android.systemui.kosmos.applicationCoroutineScope import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos -import com.android.systemui.view.accessibility.data.repository.captioningInteractor -import com.android.systemui.view.accessibility.data.repository.captioningRepository import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runCurrent @@ -49,7 +50,7 @@ class CaptioningViewModelTest : SysuiTestCase() { CaptioningViewModel( context, captioningInteractor, - testScope.backgroundScope, + applicationCoroutineScope, uiEventLogger, ) } diff --git a/packages/SettingsLib/src/com/android/settingslib/view/accessibility/data/repository/CaptioningRepository.kt b/packages/SystemUI/src/com/android/systemui/accessibility/data/repository/CaptioningRepository.kt index 0b71d257d562..bf749d4cfc35 100644 --- a/packages/SettingsLib/src/com/android/settingslib/view/accessibility/data/repository/CaptioningRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/accessibility/data/repository/CaptioningRepository.kt @@ -1,20 +1,20 @@ /* * 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 + * 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 + * 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. + * 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.settingslib.view.accessibility.data.repository +package com.android.systemui.accessibility.data.repository import android.view.accessibility.CaptioningManager import kotlin.coroutines.CoroutineContext diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/domain/interactor/CaptioningInteractor.kt b/packages/SystemUI/src/com/android/systemui/accessibility/domain/interactor/CaptioningInteractor.kt new file mode 100644 index 000000000000..1d493c697652 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/accessibility/domain/interactor/CaptioningInteractor.kt @@ -0,0 +1,32 @@ +/* + * 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.accessibility.domain.interactor + +import com.android.systemui.accessibility.data.repository.CaptioningRepository +import kotlinx.coroutines.flow.StateFlow + +class CaptioningInteractor(private val repository: CaptioningRepository) { + + val isSystemAudioCaptioningEnabled: StateFlow<Boolean> + get() = repository.isSystemAudioCaptioningEnabled + + val isSystemAudioCaptioningUiEnabled: StateFlow<Boolean> + get() = repository.isSystemAudioCaptioningUiEnabled + + suspend fun setIsSystemAudioCaptioningEnabled(enabled: Boolean) = + repository.setIsSystemAudioCaptioningEnabled(enabled) +} diff --git a/packages/SystemUI/src/com/android/systemui/volume/dagger/CaptioningModule.kt b/packages/SystemUI/src/com/android/systemui/volume/dagger/CaptioningModule.kt index 73f52373f893..9715772f089f 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/dagger/CaptioningModule.kt +++ b/packages/SystemUI/src/com/android/systemui/volume/dagger/CaptioningModule.kt @@ -17,9 +17,9 @@ package com.android.systemui.volume.dagger import android.view.accessibility.CaptioningManager -import com.android.settingslib.view.accessibility.data.repository.CaptioningRepository -import com.android.settingslib.view.accessibility.data.repository.CaptioningRepositoryImpl -import com.android.settingslib.view.accessibility.domain.interactor.CaptioningInteractor +import com.android.systemui.accessibility.data.repository.CaptioningRepository +import com.android.systemui.accessibility.data.repository.CaptioningRepositoryImpl +import com.android.systemui.accessibility.domain.interactor.CaptioningInteractor import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background diff --git a/packages/SystemUI/src/com/android/systemui/volume/panel/component/captioning/domain/CaptioningAvailabilityCriteria.kt b/packages/SystemUI/src/com/android/systemui/volume/panel/component/captioning/domain/CaptioningAvailabilityCriteria.kt index 85da1d0efe3a..52f2ce63ba21 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/panel/component/captioning/domain/CaptioningAvailabilityCriteria.kt +++ b/packages/SystemUI/src/com/android/systemui/volume/panel/component/captioning/domain/CaptioningAvailabilityCriteria.kt @@ -17,7 +17,7 @@ package com.android.systemui.volume.panel.component.captioning.domain import com.android.internal.logging.UiEventLogger -import com.android.settingslib.view.accessibility.domain.interactor.CaptioningInteractor +import com.android.systemui.accessibility.domain.interactor.CaptioningInteractor import com.android.systemui.volume.panel.dagger.scope.VolumePanelScope import com.android.systemui.volume.panel.domain.ComponentAvailabilityCriteria import com.android.systemui.volume.panel.ui.VolumePanelUiEvent diff --git a/packages/SystemUI/src/com/android/systemui/volume/panel/component/captioning/ui/viewmodel/CaptioningViewModel.kt b/packages/SystemUI/src/com/android/systemui/volume/panel/component/captioning/ui/viewmodel/CaptioningViewModel.kt index ca5aef8eee2e..9e708433dfbf 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/panel/component/captioning/ui/viewmodel/CaptioningViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/volume/panel/component/captioning/ui/viewmodel/CaptioningViewModel.kt @@ -18,7 +18,7 @@ package com.android.systemui.volume.panel.component.captioning.ui.viewmodel import android.content.Context import com.android.internal.logging.UiEventLogger -import com.android.settingslib.view.accessibility.domain.interactor.CaptioningInteractor +import com.android.systemui.accessibility.domain.interactor.CaptioningInteractor import com.android.systemui.common.shared.model.Icon import com.android.systemui.res.R import com.android.systemui.volume.panel.component.button.ui.viewmodel.ButtonViewModel diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/accessibility/data/repository/CaptioningRepositoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/accessibility/data/repository/CaptioningRepositoryKosmos.kt new file mode 100644 index 000000000000..5c39e324bd95 --- /dev/null +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/accessibility/data/repository/CaptioningRepositoryKosmos.kt @@ -0,0 +1,22 @@ +/* + * 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.accessibility.data.repository + +import com.android.systemui.kosmos.Kosmos + +var Kosmos.fakeCaptioningRepository by Kosmos.Fixture { FakeCaptioningRepository() } +val Kosmos.captioningRepository by Kosmos.Fixture { fakeCaptioningRepository } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/view/accessibility/data/repository/FakeCaptioningRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/accessibility/data/repository/FakeCaptioningRepository.kt index 663aaf282f98..2a0e764279d6 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/view/accessibility/data/repository/FakeCaptioningRepository.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/accessibility/data/repository/FakeCaptioningRepository.kt @@ -14,9 +14,8 @@ * limitations under the License. */ -package com.android.systemui.view.accessibility.data.repository +package com.android.systemui.accessibility.data.repository -import com.android.settingslib.view.accessibility.data.repository.CaptioningRepository import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/view/accessibility/data/repository/CaptioningKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/accessibility/domain/interactor/CaptioningInteractorKosmos.kt index 0e978f2fe5c4..2125e956e602 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/view/accessibility/data/repository/CaptioningKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/accessibility/domain/interactor/CaptioningInteractorKosmos.kt @@ -14,10 +14,9 @@ * limitations under the License. */ -package com.android.systemui.view.accessibility.data.repository +package com.android.systemui.accessibility.domain.interactor -import com.android.settingslib.view.accessibility.domain.interactor.CaptioningInteractor +import com.android.systemui.accessibility.data.repository.captioningRepository import com.android.systemui.kosmos.Kosmos -val Kosmos.captioningRepository by Kosmos.Fixture { FakeCaptioningRepository() } val Kosmos.captioningInteractor by Kosmos.Fixture { CaptioningInteractor(captioningRepository) } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/captioning/CaptioningModuleKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/captioning/CaptioningModuleKosmos.kt index e7162d27a031..6d30c68c57ba 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/captioning/CaptioningModuleKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/captioning/CaptioningModuleKosmos.kt @@ -17,9 +17,9 @@ package com.android.systemui.volume.panel.component.captioning import com.android.internal.logging.uiEventLogger +import com.android.systemui.accessibility.domain.interactor.captioningInteractor import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope -import com.android.systemui.view.accessibility.data.repository.captioningInteractor import com.android.systemui.volume.panel.component.button.ui.composable.ToggleButtonComponent import com.android.systemui.volume.panel.component.captioning.domain.CaptioningAvailabilityCriteria import com.android.systemui.volume.panel.component.captioning.ui.viewmodel.captioningViewModel diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/captioning/ui/viewmodel/CaptioningViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/captioning/ui/viewmodel/CaptioningViewModelKosmos.kt index 0edd9e026912..e23a21a792e4 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/captioning/ui/viewmodel/CaptioningViewModelKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/captioning/ui/viewmodel/CaptioningViewModelKosmos.kt @@ -18,9 +18,9 @@ package com.android.systemui.volume.panel.component.captioning.ui.viewmodel import android.content.applicationContext import com.android.internal.logging.uiEventLogger +import com.android.systemui.accessibility.domain.interactor.captioningInteractor import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope -import com.android.systemui.view.accessibility.data.repository.captioningInteractor val Kosmos.captioningViewModel by Kosmos.Fixture { |