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.wallpaper.module.DefaultPartnerProvider
20 import com.android.wallpaper.module.DefaultWallpaperPreferences
21 import com.android.wallpaper.module.Injector
22 import com.android.wallpaper.module.PartnerProvider
23 import com.android.wallpaper.module.WallpaperPicker2Injector
24 import com.android.wallpaper.module.WallpaperPreferences
25 import com.android.wallpaper.module.logging.NoOpUserEventLogger
26 import com.android.wallpaper.module.logging.UserEventLogger
27 import com.android.wallpaper.picker.customization.ui.binder.CustomizationOptionsBinder
28 import com.android.wallpaper.picker.customization.ui.binder.DefaultCustomizationOptionsBinder
29 import com.android.wallpaper.picker.preview.data.util.DefaultLiveWallpaperDownloader
30 import com.android.wallpaper.picker.preview.data.util.LiveWallpaperDownloader
31 import com.android.wallpaper.picker.preview.ui.util.DefaultImageEffectDialogUtil
32 import com.android.wallpaper.picker.preview.ui.util.ImageEffectDialogUtil
33 import com.android.wallpaper.util.converter.DefaultWallpaperModelFactory
34 import com.android.wallpaper.util.converter.WallpaperModelFactory
35 import dagger.Binds
36 import dagger.Module
37 import dagger.Provides
38 import dagger.hilt.InstallIn
39 import dagger.hilt.android.qualifiers.ApplicationContext
40 import dagger.hilt.components.SingletonComponent
41 import javax.inject.Singleton
42 
43 @Module
44 @InstallIn(SingletonComponent::class)
45 abstract class WallpaperPicker2AppModule {
bindInjectornull46     @Binds @Singleton abstract fun bindInjector(impl: WallpaperPicker2Injector): Injector
47 
48     @Binds
49     @Singleton
50     abstract fun bindWallpaperModelFactory(
51         impl: DefaultWallpaperModelFactory
52     ): WallpaperModelFactory
53 
54     @Binds
55     @Singleton
56     abstract fun bindLiveWallpaperDownloader(
57         impl: DefaultLiveWallpaperDownloader
58     ): LiveWallpaperDownloader
59 
60     @Binds
61     @Singleton
62     abstract fun bindPartnerProvider(impl: DefaultPartnerProvider): PartnerProvider
63 
64     @Binds
65     @Singleton
66     abstract fun bindEffectsWallpaperDialogUtil(
67         impl: DefaultImageEffectDialogUtil
68     ): ImageEffectDialogUtil
69 
70     @Binds
71     @Singleton
72     abstract fun bindCustomizationOptionsBinder(
73         impl: DefaultCustomizationOptionsBinder
74     ): CustomizationOptionsBinder
75 
76     companion object {
77         @Provides
78         @Singleton
79         fun provideWallpaperPreferences(
80             @ApplicationContext context: Context
81         ): WallpaperPreferences {
82             return DefaultWallpaperPreferences(context)
83         }
84 
85         @Provides
86         @Singleton
87         fun provideUserEventLogger(): UserEventLogger {
88             return NoOpUserEventLogger()
89         }
90     }
91 }
92