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.wallpaper.picker.di.modules 18 19 import android.app.WallpaperManager 20 import android.content.Context 21 import android.content.pm.PackageManager 22 import com.android.wallpaper.module.DefaultNetworkStatusNotifier 23 import com.android.wallpaper.module.LargeScreenMultiPanesChecker 24 import com.android.wallpaper.module.MultiPanesChecker 25 import com.android.wallpaper.module.NetworkStatusNotifier 26 import com.android.wallpaper.network.Requester 27 import com.android.wallpaper.network.WallpaperRequester 28 import com.android.wallpaper.picker.category.domain.interactor.CategoryInteractor 29 import com.android.wallpaper.picker.category.domain.interactor.CreativeCategoryInteractor 30 import com.android.wallpaper.picker.category.domain.interactor.MyPhotosInteractor 31 import com.android.wallpaper.picker.category.domain.interactor.implementations.CategoryInteractorImpl 32 import com.android.wallpaper.picker.category.domain.interactor.implementations.CreativeCategoryInteractorImpl 33 import com.android.wallpaper.picker.category.domain.interactor.implementations.MyPhotosInteractorImpl 34 import com.android.wallpaper.picker.customization.data.content.WallpaperClient 35 import com.android.wallpaper.picker.customization.data.content.WallpaperClientImpl 36 import com.android.wallpaper.system.UiModeManagerImpl 37 import com.android.wallpaper.system.UiModeManagerWrapper 38 import com.android.wallpaper.util.WallpaperParser 39 import com.android.wallpaper.util.WallpaperParserImpl 40 import com.android.wallpaper.util.converter.category.CategoryFactory 41 import com.android.wallpaper.util.converter.category.DefaultCategoryFactory 42 import dagger.Binds 43 import dagger.Module 44 import dagger.Provides 45 import dagger.hilt.InstallIn 46 import dagger.hilt.android.qualifiers.ApplicationContext 47 import dagger.hilt.components.SingletonComponent 48 import javax.inject.Singleton 49 50 @Module 51 @InstallIn(SingletonComponent::class) 52 abstract class SharedAppModule { bindUiModeManagernull53 @Binds @Singleton abstract fun bindUiModeManager(impl: UiModeManagerImpl): UiModeManagerWrapper 54 55 @Binds 56 @Singleton 57 abstract fun bindNetworkStatusNotifier( 58 impl: DefaultNetworkStatusNotifier 59 ): NetworkStatusNotifier 60 61 @Binds @Singleton abstract fun bindWallpaperRequester(impl: WallpaperRequester): Requester 62 63 @Binds 64 @Singleton 65 abstract fun bindWallpaperXMLParser(impl: WallpaperParserImpl): WallpaperParser 66 67 @Binds 68 @Singleton 69 abstract fun bindCategoryFactory(impl: DefaultCategoryFactory): CategoryFactory 70 71 @Binds @Singleton abstract fun bindWallpaperClient(impl: WallpaperClientImpl): WallpaperClient 72 73 @Binds 74 @Singleton 75 abstract fun bindCategoryInteractor(impl: CategoryInteractorImpl): CategoryInteractor 76 77 @Binds 78 @Singleton 79 abstract fun bindCreativeCategoryInteractor( 80 impl: CreativeCategoryInteractorImpl 81 ): CreativeCategoryInteractor 82 83 @Binds 84 @Singleton 85 abstract fun bindMyPhotosInteractor(impl: MyPhotosInteractorImpl): MyPhotosInteractor 86 87 companion object { 88 @Provides 89 @Singleton 90 fun provideWallpaperManager(@ApplicationContext appContext: Context): WallpaperManager { 91 return WallpaperManager.getInstance(appContext) 92 } 93 94 @Provides 95 @Singleton 96 fun providePackageManager(@ApplicationContext appContext: Context): PackageManager { 97 return appContext.packageManager 98 } 99 100 @Provides 101 @Singleton 102 fun provideMultiPanesChecker(): MultiPanesChecker { 103 return LargeScreenMultiPanesChecker() 104 } 105 } 106 } 107