1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.communal.dagger 18 19 import android.content.Context 20 import com.android.systemui.communal.data.backup.CommunalBackupUtils 21 import com.android.systemui.communal.data.db.CommunalDatabaseModule 22 import com.android.systemui.communal.data.repository.CommunalMediaRepositoryModule 23 import com.android.systemui.communal.data.repository.CommunalPrefsRepositoryModule 24 import com.android.systemui.communal.data.repository.CommunalRepositoryModule 25 import com.android.systemui.communal.data.repository.CommunalSettingsRepositoryModule 26 import com.android.systemui.communal.data.repository.CommunalTutorialRepositoryModule 27 import com.android.systemui.communal.data.repository.CommunalWidgetRepositoryModule 28 import com.android.systemui.communal.shared.model.CommunalScenes 29 import com.android.systemui.communal.util.CommunalColors 30 import com.android.systemui.communal.util.CommunalColorsImpl 31 import com.android.systemui.communal.widgets.CommunalWidgetModule 32 import com.android.systemui.communal.widgets.EditWidgetsActivityStarter 33 import com.android.systemui.communal.widgets.EditWidgetsActivityStarterImpl 34 import com.android.systemui.dagger.SysUISingleton 35 import com.android.systemui.dagger.qualifiers.Application 36 import com.android.systemui.scene.shared.model.SceneContainerConfig 37 import com.android.systemui.scene.shared.model.SceneDataSource 38 import com.android.systemui.scene.shared.model.SceneDataSourceDelegator 39 import dagger.Binds 40 import dagger.Module 41 import dagger.Provides 42 import kotlinx.coroutines.CoroutineScope 43 44 @Module( 45 includes = 46 [ 47 CommunalRepositoryModule::class, 48 CommunalMediaRepositoryModule::class, 49 CommunalTutorialRepositoryModule::class, 50 CommunalWidgetRepositoryModule::class, 51 CommunalDatabaseModule::class, 52 CommunalWidgetModule::class, 53 CommunalPrefsRepositoryModule::class, 54 CommunalSettingsRepositoryModule::class, 55 ] 56 ) 57 interface CommunalModule { 58 @Binds bindEditWidgetsActivityStarternull59 fun bindEditWidgetsActivityStarter( 60 starter: EditWidgetsActivityStarterImpl 61 ): EditWidgetsActivityStarter 62 63 @Binds 64 @Communal 65 fun bindCommunalSceneDataSource(@Communal delegator: SceneDataSourceDelegator): SceneDataSource 66 67 @Binds fun bindCommunalColors(impl: CommunalColorsImpl): CommunalColors 68 69 companion object { 70 @Provides 71 @Communal 72 @SysUISingleton 73 fun providesCommunalSceneDataSourceDelegator( 74 @Application applicationScope: CoroutineScope 75 ): SceneDataSourceDelegator { 76 val config = 77 SceneContainerConfig( 78 sceneKeys = listOf(CommunalScenes.Blank, CommunalScenes.Communal), 79 initialSceneKey = CommunalScenes.Blank, 80 navigationDistances = 81 mapOf( 82 CommunalScenes.Blank to 0, 83 CommunalScenes.Communal to 1, 84 ), 85 ) 86 return SceneDataSourceDelegator(applicationScope, config) 87 } 88 89 @Provides 90 @SysUISingleton 91 fun providesCommunalBackupUtils( 92 @Application context: Context, 93 ): CommunalBackupUtils { 94 return CommunalBackupUtils(context) 95 } 96 } 97 } 98