diff options
5 files changed, 176 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/dagger/QSModule.java b/packages/SystemUI/src/com/android/systemui/qs/dagger/QSModule.java index 1aef9206d99f..8d3500a4f9f0 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/dagger/QSModule.java +++ b/packages/SystemUI/src/com/android/systemui/qs/dagger/QSModule.java @@ -29,6 +29,7 @@ import com.android.systemui.qs.AutoAddTracker; import com.android.systemui.qs.QSHost; import com.android.systemui.qs.ReduceBrightColorsController; import com.android.systemui.qs.external.QSExternalModule; +import com.android.systemui.qs.panels.dagger.PanelsModule; import com.android.systemui.qs.pipeline.dagger.QSPipelineModule; import com.android.systemui.qs.tileimpl.QSTileImpl; import com.android.systemui.qs.tiles.di.QSTilesModule; @@ -44,21 +45,22 @@ import com.android.systemui.statusbar.policy.SafetyController; import com.android.systemui.statusbar.policy.WalletController; import com.android.systemui.util.settings.SecureSettings; -import java.util.Map; - -import javax.inject.Named; - import dagger.Binds; import dagger.Module; import dagger.Provides; import dagger.multibindings.Multibinds; +import java.util.Map; + +import javax.inject.Named; + /** * Module for QS dependencies */ @Module(subcomponents = {QSFragmentComponent.class, QSSceneComponent.class}, includes = { MediaModule.class, + PanelsModule.class, QSExternalModule.class, QSFlagsModule.class, QSHostModule.class, diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/dagger/PanelsModule.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/dagger/PanelsModule.kt new file mode 100644 index 000000000000..1307296dd2b7 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/qs/panels/dagger/PanelsModule.kt @@ -0,0 +1,27 @@ +/* + * 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.qs.panels.dagger + +import com.android.systemui.qs.panels.data.repository.IconTilesRepository +import com.android.systemui.qs.panels.data.repository.IconTilesRepositoryImpl +import dagger.Binds +import dagger.Module + +@Module +interface PanelsModule { + @Binds fun bindIconTilesRepository(impl: IconTilesRepositoryImpl): IconTilesRepository +} diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/IconTilesRepository.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/IconTilesRepository.kt new file mode 100644 index 000000000000..92f87e78f090 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/IconTilesRepository.kt @@ -0,0 +1,53 @@ +/* + * 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.qs.panels.data.repository + +import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.qs.pipeline.shared.TileSpec +import javax.inject.Inject +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOf + +/** Repository for retrieving the list of [TileSpec] to be displayed as icons. */ +interface IconTilesRepository { + val iconTilesSpecs: Flow<Set<TileSpec>> +} + +@SysUISingleton +class IconTilesRepositoryImpl @Inject constructor() : IconTilesRepository { + + /** Set of toggleable tiles that are suitable for being shown as an icon. */ + override val iconTilesSpecs: Flow<Set<TileSpec>> = + flowOf( + setOf( + TileSpec.create("airplane"), + TileSpec.create("battery"), + TileSpec.create("cameratoggle"), + TileSpec.create("cast"), + TileSpec.create("color_correction"), + TileSpec.create("inversion"), + TileSpec.create("saver"), + TileSpec.create("dnd"), + TileSpec.create("flashlight"), + TileSpec.create("location"), + TileSpec.create("mictoggle"), + TileSpec.create("nfc"), + TileSpec.create("night"), + TileSpec.create("rotation") + ) + ) +} diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/IconTilesInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/IconTilesInteractor.kt new file mode 100644 index 000000000000..367c67093605 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/IconTilesInteractor.kt @@ -0,0 +1,29 @@ +/* + * 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.qs.panels.domain.interactor + +import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.qs.panels.data.repository.IconTilesRepository +import com.android.systemui.qs.pipeline.shared.TileSpec +import javax.inject.Inject +import kotlinx.coroutines.flow.Flow + +/** Interactor for retrieving the list of [TileSpec] to be displayed as icons. */ +@SysUISingleton +class IconTilesInteractor @Inject constructor(private val repo: IconTilesRepository) { + val iconTilesSpecs: Flow<Set<TileSpec>> = repo.iconTilesSpecs +} diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/panels/domain/repository/IconTilesRepositoryImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/panels/domain/repository/IconTilesRepositoryImplTest.kt new file mode 100644 index 000000000000..8cc3a85ef6c8 --- /dev/null +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/panels/domain/repository/IconTilesRepositoryImplTest.kt @@ -0,0 +1,61 @@ +/* + * 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.qs.panels.domain.repository + +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.SmallTest +import com.android.systemui.SysuiTestCase +import com.android.systemui.coroutines.collectLastValue +import com.android.systemui.qs.panels.data.repository.IconTilesRepositoryImpl +import com.android.systemui.qs.pipeline.shared.TileSpec +import com.google.common.truth.Truth.assertThat +import kotlinx.coroutines.test.runTest +import org.junit.Test +import org.junit.runner.RunWith + +@SmallTest +@RunWith(AndroidJUnit4::class) +class IconTilesRepositoryImplTest : SysuiTestCase() { + + private val underTest = IconTilesRepositoryImpl() + + @Test + fun iconTilesSpecsIsValid() = runTest { + val tilesSpecs by collectLastValue(underTest.iconTilesSpecs) + assertThat(tilesSpecs).isEqualTo(ICON_ONLY_TILES_SPECS) + } + + companion object { + private val ICON_ONLY_TILES_SPECS = + setOf( + TileSpec.create("airplane"), + TileSpec.create("battery"), + TileSpec.create("cameratoggle"), + TileSpec.create("cast"), + TileSpec.create("color_correction"), + TileSpec.create("inversion"), + TileSpec.create("saver"), + TileSpec.create("dnd"), + TileSpec.create("flashlight"), + TileSpec.create("location"), + TileSpec.create("mictoggle"), + TileSpec.create("nfc"), + TileSpec.create("night"), + TileSpec.create("rotation") + ) + } +} |