Loading src/com/android/customization/module/ThemePickerInjector.kt +5 −3 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModelProvider import com.android.customization.model.color.ColorCustomizationManager import com.android.customization.model.color.ColorOptionsProvider import com.android.customization.model.color.ColorOptionsProvider.COLOR_SOURCE_PRESET import com.android.customization.model.grid.GridOptionsManager import com.android.customization.model.mode.DarkModeSnapshotRestorer Loading Loading @@ -197,6 +196,10 @@ internal constructor( } override fun getWallpaperInteractor(context: Context): WallpaperInteractor { if (getFlags().isMultiCropEnabled() && getFlags().isMultiCropPreviewUiEnabled()) { return injectedWallpaperInteractor } val appContext = context.applicationContext return wallpaperInteractor ?: WallpaperInteractor( Loading @@ -206,7 +209,6 @@ internal constructor( client = WallpaperClientImpl( context = appContext, infoFactory = getCurrentWallpaperInfoFactory(appContext), wallpaperManager = WallpaperManager.getInstance(appContext), wallpaperPreferences = getPreferences(appContext) ), Loading @@ -216,7 +218,7 @@ internal constructor( shouldHandleReload = { TextUtils.equals( getColorCustomizationManager(appContext).currentColorSource, ColorOptionsProvider.COLOR_SOURCE_PRESET COLOR_SOURCE_PRESET, ) } ) Loading src_override/com/android/wallpaper/picker/di/modules/InteractorModule.kt 0 → 100644 +44 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wallpaper.picker.di.modules import android.text.TextUtils import com.android.customization.model.color.ColorCustomizationManager import com.android.customization.model.color.ColorOptionsProvider.COLOR_SOURCE_PRESET import com.android.wallpaper.picker.customization.data.repository.WallpaperRepository import com.android.wallpaper.picker.customization.domain.interactor.WallpaperInteractor import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import javax.inject.Singleton /** This class provides the singleton scoped interactors for theme picker. */ @InstallIn(SingletonComponent::class) @Module internal object InteractorModule { @Provides @Singleton fun provideWallpaperInteractor( wallpaperRepository: WallpaperRepository, colorCustomizationManager: ColorCustomizationManager, ): WallpaperInteractor { return WallpaperInteractor(wallpaperRepository) { TextUtils.equals(colorCustomizationManager.currentColorSource, COLOR_SOURCE_PRESET) } } } tests/module/src/com/android/customization/TestModule.kt +12 −0 Original line number Diff line number Diff line package com.android.customization import androidx.test.core.app.ApplicationProvider import com.android.customization.model.color.ColorCustomizationManager import com.android.customization.model.theme.OverlayManagerCompat import com.android.customization.module.CustomizationInjector import com.android.customization.module.CustomizationPreferences import com.android.customization.module.logging.TestThemesUserEventLogger Loading Loading @@ -66,5 +69,14 @@ abstract class TestModule { fun provideDefaultWallpaperModelFactory(): DefaultWallpaperModelFactory { return DefaultWallpaperModelFactory() } @Provides @Singleton fun provideColorCustomizationManager(): ColorCustomizationManager { return ColorCustomizationManager.getInstance( ApplicationProvider.getApplicationContext(), OverlayManagerCompat(ApplicationProvider.getApplicationContext()) ) } } } Loading
src/com/android/customization/module/ThemePickerInjector.kt +5 −3 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModelProvider import com.android.customization.model.color.ColorCustomizationManager import com.android.customization.model.color.ColorOptionsProvider import com.android.customization.model.color.ColorOptionsProvider.COLOR_SOURCE_PRESET import com.android.customization.model.grid.GridOptionsManager import com.android.customization.model.mode.DarkModeSnapshotRestorer Loading Loading @@ -197,6 +196,10 @@ internal constructor( } override fun getWallpaperInteractor(context: Context): WallpaperInteractor { if (getFlags().isMultiCropEnabled() && getFlags().isMultiCropPreviewUiEnabled()) { return injectedWallpaperInteractor } val appContext = context.applicationContext return wallpaperInteractor ?: WallpaperInteractor( Loading @@ -206,7 +209,6 @@ internal constructor( client = WallpaperClientImpl( context = appContext, infoFactory = getCurrentWallpaperInfoFactory(appContext), wallpaperManager = WallpaperManager.getInstance(appContext), wallpaperPreferences = getPreferences(appContext) ), Loading @@ -216,7 +218,7 @@ internal constructor( shouldHandleReload = { TextUtils.equals( getColorCustomizationManager(appContext).currentColorSource, ColorOptionsProvider.COLOR_SOURCE_PRESET COLOR_SOURCE_PRESET, ) } ) Loading
src_override/com/android/wallpaper/picker/di/modules/InteractorModule.kt 0 → 100644 +44 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wallpaper.picker.di.modules import android.text.TextUtils import com.android.customization.model.color.ColorCustomizationManager import com.android.customization.model.color.ColorOptionsProvider.COLOR_SOURCE_PRESET import com.android.wallpaper.picker.customization.data.repository.WallpaperRepository import com.android.wallpaper.picker.customization.domain.interactor.WallpaperInteractor import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import javax.inject.Singleton /** This class provides the singleton scoped interactors for theme picker. */ @InstallIn(SingletonComponent::class) @Module internal object InteractorModule { @Provides @Singleton fun provideWallpaperInteractor( wallpaperRepository: WallpaperRepository, colorCustomizationManager: ColorCustomizationManager, ): WallpaperInteractor { return WallpaperInteractor(wallpaperRepository) { TextUtils.equals(colorCustomizationManager.currentColorSource, COLOR_SOURCE_PRESET) } } }
tests/module/src/com/android/customization/TestModule.kt +12 −0 Original line number Diff line number Diff line package com.android.customization import androidx.test.core.app.ApplicationProvider import com.android.customization.model.color.ColorCustomizationManager import com.android.customization.model.theme.OverlayManagerCompat import com.android.customization.module.CustomizationInjector import com.android.customization.module.CustomizationPreferences import com.android.customization.module.logging.TestThemesUserEventLogger Loading Loading @@ -66,5 +69,14 @@ abstract class TestModule { fun provideDefaultWallpaperModelFactory(): DefaultWallpaperModelFactory { return DefaultWallpaperModelFactory() } @Provides @Singleton fun provideColorCustomizationManager(): ColorCustomizationManager { return ColorCustomizationManager.getInstance( ApplicationProvider.getApplicationContext(), OverlayManagerCompat(ApplicationProvider.getApplicationContext()) ) } } }