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

Commit a76f0b09 authored by Olivier St-Onge's avatar Olivier St-Onge
Browse files

Add repo and interactor for icon only tiles

List of tiles to be displayed as icon only is currently hardcoded.
Follow up cl will add the ViewModel that uses this.

Flag: none
Test: manually
Bug: 331598956
Change-Id: I87c3a0472535487b2d08dc243b5d79e8543f4244
parent 4309dcd0
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -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,
+27 −0
Original line number Diff line number Diff line
/*
 * 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
}
+53 −0
Original line number Diff line number Diff line
/*
 * 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")
            )
        )
}
+29 −0
Original line number Diff line number Diff line
/*
 * 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
}
+61 −0
Original line number Diff line number Diff line
/*
 * 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")
            )
    }
}