• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 package com.android.wallpaper.modules
17 
18 import android.content.Context
19 import com.android.customization.model.color.ColorCustomizationManager
20 import com.android.customization.model.theme.OverlayManagerCompat
21 import com.android.customization.module.CustomizationInjector
22 import com.android.customization.module.DefaultCustomizationPreferences
23 import com.android.customization.module.ThemePickerInjector
24 import com.android.customization.module.logging.ThemesUserEventLogger
25 import com.android.customization.module.logging.ThemesUserEventLoggerImpl
26 import com.android.customization.picker.clock.data.repository.ClockPickerRepository
27 import com.android.customization.picker.clock.data.repository.ClockPickerRepositoryImpl
28 import com.android.customization.picker.clock.data.repository.ClockRegistryProvider
29 import com.android.customization.picker.color.data.repository.ColorPickerRepository
30 import com.android.customization.picker.color.data.repository.ColorPickerRepository2
31 import com.android.customization.picker.color.data.repository.ColorPickerRepositoryImpl
32 import com.android.customization.picker.color.data.repository.ColorPickerRepositoryImpl2
33 import com.android.customization.picker.themedicon.data.repository.ThemedIconRepository
34 import com.android.customization.picker.themedicon.data.repository.ThemedIconRepositoryImpl
35 import com.android.systemui.shared.clocks.ClockRegistry
36 import com.android.systemui.shared.customization.data.content.CustomizationProviderClient
37 import com.android.systemui.shared.customization.data.content.CustomizationProviderClientImpl
38 import com.android.systemui.shared.settings.data.repository.SecureSettingsRepository
39 import com.android.systemui.shared.settings.data.repository.SecureSettingsRepositoryImpl
40 import com.android.systemui.shared.settings.data.repository.SystemSettingsRepository
41 import com.android.systemui.shared.settings.data.repository.SystemSettingsRepositoryImpl
42 import com.android.wallpaper.customization.ui.binder.ThemePickerCustomizationOptionsBinder
43 import com.android.wallpaper.customization.ui.binder.ThemePickerToolbarBinder
44 import com.android.wallpaper.effects.DefaultEffectsController
45 import com.android.wallpaper.effects.EffectsController
46 import com.android.wallpaper.module.DefaultPartnerProvider
47 import com.android.wallpaper.module.DefaultRecentWallpaperManager
48 import com.android.wallpaper.module.PartnerProvider
49 import com.android.wallpaper.module.RecentWallpaperManager
50 import com.android.wallpaper.module.WallpaperPreferences
51 import com.android.wallpaper.module.logging.UserEventLogger
52 import com.android.wallpaper.picker.category.domain.interactor.CategoriesLoadingStatusInteractor
53 import com.android.wallpaper.picker.category.domain.interactor.CategoryInteractor
54 import com.android.wallpaper.picker.category.domain.interactor.CreativeCategoryInteractor
55 import com.android.wallpaper.picker.category.domain.interactor.CuratedPhotosInteractor
56 import com.android.wallpaper.picker.category.domain.interactor.OnDeviceWallpapersInteractor
57 import com.android.wallpaper.picker.category.domain.interactor.ThirdPartyCategoryInteractor
58 import com.android.wallpaper.picker.category.domain.interactor.implementations.CategoryInteractorImpl
59 import com.android.wallpaper.picker.category.domain.interactor.implementations.CreativeCategoryInteractorImpl
60 import com.android.wallpaper.picker.category.domain.interactor.implementations.DefaultCategoriesLoadingStatusInteractor
61 import com.android.wallpaper.picker.category.domain.interactor.implementations.DefaultCuratedPhotosInteractorImpl
62 import com.android.wallpaper.picker.category.domain.interactor.implementations.DefaultOnDeviceWallpapersInteractor
63 import com.android.wallpaper.picker.category.domain.interactor.implementations.ThirdPartyCategoryInteractorImpl
64 import com.android.wallpaper.picker.category.ui.binder.BannerProvider
65 import com.android.wallpaper.picker.category.ui.binder.DefaultBannerProvider
66 import com.android.wallpaper.picker.category.ui.view.providers.IndividualPickerFactory
67 import com.android.wallpaper.picker.category.ui.view.providers.implementation.DefaultIndividualPickerFactory
68 import com.android.wallpaper.picker.category.wrapper.DefaultWallpaperCategoryWrapper
69 import com.android.wallpaper.picker.category.wrapper.WallpaperCategoryWrapper
70 import com.android.wallpaper.picker.common.preview.ui.binder.ThemePickerWorkspaceCallbackBinder
71 import com.android.wallpaper.picker.common.preview.ui.binder.WorkspaceCallbackBinder
72 import com.android.wallpaper.picker.customization.ui.binder.CustomizationOptionsBinder
73 import com.android.wallpaper.picker.customization.ui.binder.ToolbarBinder
74 import com.android.wallpaper.picker.di.modules.BackgroundDispatcher
75 import com.android.wallpaper.picker.di.modules.MainDispatcher
76 import com.android.wallpaper.picker.preview.ui.util.DefaultImageEffectDialogUtil
77 import com.android.wallpaper.picker.preview.ui.util.ImageEffectDialogUtil
78 import com.android.wallpaper.util.converter.DefaultWallpaperModelFactory
79 import com.android.wallpaper.util.converter.WallpaperModelFactory
80 import dagger.Binds
81 import dagger.Module
82 import dagger.Provides
83 import dagger.hilt.InstallIn
84 import dagger.hilt.android.qualifiers.ApplicationContext
85 import dagger.hilt.components.SingletonComponent
86 import javax.inject.Singleton
87 import kotlinx.coroutines.CoroutineDispatcher
88 import kotlinx.coroutines.CoroutineScope
89 
90 @Module
91 @InstallIn(SingletonComponent::class)
92 abstract class ThemePickerAppModule {
93 
bindBannerProvidernull94     @Binds @Singleton abstract fun bindBannerProvider(impl: DefaultBannerProvider): BannerProvider
95 
96     @Binds
97     @Singleton
98     abstract fun bindClockPickerRepository(impl: ClockPickerRepositoryImpl): ClockPickerRepository
99 
100     @Binds
101     @Singleton
102     abstract fun bindColorPickerRepository(impl: ColorPickerRepositoryImpl): ColorPickerRepository
103 
104     @Binds
105     @Singleton
106     abstract fun bindColorPickerRepository2(
107         impl: ColorPickerRepositoryImpl2
108     ): ColorPickerRepository2
109 
110     @Binds
111     @Singleton
112     abstract fun bindThemedIconRepository(impl: ThemedIconRepositoryImpl): ThemedIconRepository
113 
114     @Binds
115     @Singleton
116     abstract fun bindCreativeCategoryInteractor(
117         impl: CreativeCategoryInteractorImpl
118     ): CreativeCategoryInteractor
119 
120     @Binds
121     @Singleton
122     abstract fun bindWallpaperCategoryWrapper(
123         impl: DefaultWallpaperCategoryWrapper
124     ): WallpaperCategoryWrapper
125 
126     @Binds
127     @Singleton
128     abstract fun bindCuratedPhotosInteractor(
129         impl: DefaultCuratedPhotosInteractorImpl
130     ): CuratedPhotosInteractor
131 
132     @Binds
133     @Singleton
134     abstract fun bindCustomizationInjector(impl: ThemePickerInjector): CustomizationInjector
135 
136     @Binds
137     @Singleton
138     abstract fun bindCustomizationOptionsBinder(
139         impl: ThemePickerCustomizationOptionsBinder
140     ): CustomizationOptionsBinder
141 
142     @Binds
143     @Singleton
144     abstract fun bindEffectsController(impl: DefaultEffectsController): EffectsController
145 
146     @Binds
147     @Singleton
148     abstract fun bindGoogleCategoryInteractor(impl: CategoryInteractorImpl): CategoryInteractor
149 
150     @Binds
151     @Singleton
152     abstract fun bindOnDeviceWallpapersInteractor(
153         impl: DefaultOnDeviceWallpapersInteractor
154     ): OnDeviceWallpapersInteractor
155 
156     @Binds
157     @Singleton
158     abstract fun bindImageEffectDialogUtil(
159         impl: DefaultImageEffectDialogUtil
160     ): ImageEffectDialogUtil
161 
162     @Binds
163     @Singleton
164     abstract fun bindIndividualPickerFactoryFragment(
165         impl: DefaultIndividualPickerFactory
166     ): IndividualPickerFactory
167 
168     @Binds
169     @Singleton
170     abstract fun bindLoadingStatusInteractor(
171         impl: DefaultCategoriesLoadingStatusInteractor
172     ): CategoriesLoadingStatusInteractor
173 
174     @Binds
175     @Singleton
176     abstract fun bindPartnerProvider(impl: DefaultPartnerProvider): PartnerProvider
177 
178     @Binds
179     @Singleton
180     abstract fun bindThemesUserEventLogger(impl: ThemesUserEventLoggerImpl): ThemesUserEventLogger
181 
182     @Binds
183     @Singleton
184     abstract fun bindThirdPartyCategoryInteractor(
185         impl: ThirdPartyCategoryInteractorImpl
186     ): ThirdPartyCategoryInteractor
187 
188     @Binds @Singleton abstract fun bindToolbarBinder(impl: ThemePickerToolbarBinder): ToolbarBinder
189 
190     @Binds
191     @Singleton
192     abstract fun bindUserEventLogger(impl: ThemesUserEventLoggerImpl): UserEventLogger
193 
194     @Binds
195     @Singleton
196     abstract fun bindWallpaperModelFactory(
197         impl: DefaultWallpaperModelFactory
198     ): WallpaperModelFactory
199 
200     @Binds
201     @Singleton
202     abstract fun bindWallpaperPreferences(
203         impl: DefaultCustomizationPreferences
204     ): WallpaperPreferences
205 
206     @Binds
207     @Singleton
208     abstract fun bindWorkspaceCallbackBinder(
209         impl: ThemePickerWorkspaceCallbackBinder
210     ): WorkspaceCallbackBinder
211 
212     @Binds
213     @Singleton
214     abstract fun bindRecentWallpaperManager(
215         impl: DefaultRecentWallpaperManager
216     ): RecentWallpaperManager
217 
218     companion object {
219 
220         @Provides
221         @Singleton
222         fun provideClockRegistry(
223             @ApplicationContext context: Context,
224             @MainDispatcher mainScope: CoroutineScope,
225             @MainDispatcher mainDispatcher: CoroutineDispatcher,
226             @BackgroundDispatcher bgDispatcher: CoroutineDispatcher,
227         ): ClockRegistry {
228             return ClockRegistryProvider(
229                     context = context,
230                     coroutineScope = mainScope,
231                     mainDispatcher = mainDispatcher,
232                     backgroundDispatcher = bgDispatcher,
233                 )
234                 .get()
235         }
236 
237         @Provides
238         @Singleton
239         fun provideColorCustomizationManager(
240             @ApplicationContext context: Context
241         ): ColorCustomizationManager {
242             return ColorCustomizationManager.getInstance(context, OverlayManagerCompat(context))
243         }
244 
245         @Provides
246         @Singleton
247         fun provideCustomizationProviderClient(
248             @ApplicationContext context: Context,
249             @BackgroundDispatcher bgDispatcher: CoroutineDispatcher,
250         ): CustomizationProviderClient {
251             return CustomizationProviderClientImpl(context, bgDispatcher)
252         }
253 
254         @Provides
255         @Singleton
256         fun provideSecureSettingsRepository(
257             @ApplicationContext context: Context,
258             @BackgroundDispatcher bgDispatcher: CoroutineDispatcher,
259         ): SecureSettingsRepository {
260             return SecureSettingsRepositoryImpl(context.contentResolver, bgDispatcher)
261         }
262 
263         @Provides
264         @Singleton
265         fun provideSystemSettingsRepository(
266             @ApplicationContext context: Context,
267             @BackgroundDispatcher bgDispatcher: CoroutineDispatcher,
268         ): SystemSettingsRepository {
269             return SystemSettingsRepositoryImpl(context.contentResolver, bgDispatcher)
270         }
271     }
272 }
273