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.picker.di.modules 17 18 import android.content.Context 19 import com.android.wallpaper.R 20 import com.android.wallpaper.util.PreviewUtils 21 import dagger.Module 22 import dagger.Provides 23 import dagger.hilt.InstallIn 24 import dagger.hilt.android.components.ActivityRetainedComponent 25 import dagger.hilt.android.qualifiers.ApplicationContext 26 import dagger.hilt.android.scopes.ActivityRetainedScoped 27 import javax.inject.Qualifier 28 29 /* 30 * This class provides the preview utils instances required for a specific screen type 31 */ 32 @InstallIn(ActivityRetainedComponent::class) 33 @Module 34 object PreviewUtilsModule { 35 36 @Qualifier @Retention(AnnotationRetention.BINARY) annotation class LockScreenPreviewUtils 37 38 @Qualifier @Retention(AnnotationRetention.BINARY) annotation class HomeScreenPreviewUtils 39 40 @LockScreenPreviewUtils 41 @ActivityRetainedScoped 42 @Provides provideLockScreenPreviewUtilsnull43 fun provideLockScreenPreviewUtils( 44 @ApplicationContext appContext: Context, 45 ): PreviewUtils { 46 return PreviewUtils( 47 context = appContext, 48 authority = 49 appContext.getString( 50 R.string.lock_screen_preview_provider_authority, 51 ), 52 ) 53 } 54 55 @HomeScreenPreviewUtils 56 @ActivityRetainedScoped 57 @Provides provideHomeScreenPreviewUtilsnull58 fun provideHomeScreenPreviewUtils( 59 @ApplicationContext appContext: Context, 60 ): PreviewUtils { 61 return PreviewUtils( 62 context = appContext, 63 authorityMetadataKey = 64 appContext.getString( 65 R.string.grid_control_metadata_name, 66 ), 67 ) 68 } 69 } 70