Inject WallpaperRepository directly (2/3)
Flag: EXEMPT refactor
Bug: 321021224
Test: set wallpaper
Change-Id: I601915b9b85d9f6ec73a434b95c68bbeace42416
diff --git a/src/com/android/customization/module/DefaultCustomizationPreferences.kt b/src/com/android/customization/module/DefaultCustomizationPreferences.kt
index 49fd1a9..0ef4a1d 100644
--- a/src/com/android/customization/module/DefaultCustomizationPreferences.kt
+++ b/src/com/android/customization/module/DefaultCustomizationPreferences.kt
@@ -17,8 +17,14 @@
import android.content.Context
import com.android.wallpaper.module.DefaultWallpaperPreferences
+import dagger.hilt.android.qualifiers.ApplicationContext
+import javax.inject.Inject
+import javax.inject.Singleton
-open class DefaultCustomizationPreferences(context: Context) :
+@Singleton
+open class DefaultCustomizationPreferences
+@Inject
+constructor(@ApplicationContext context: Context) :
DefaultWallpaperPreferences(context), CustomizationPreferences {
override fun getSerializedCustomThemes(): String? {
diff --git a/src/com/android/customization/module/ThemePickerInjector.kt b/src/com/android/customization/module/ThemePickerInjector.kt
index c08c4e5..e62235c 100644
--- a/src/com/android/customization/module/ThemePickerInjector.kt
+++ b/src/com/android/customization/module/ThemePickerInjector.kt
@@ -22,7 +22,6 @@
import android.content.Intent
import android.content.res.Resources
import android.net.Uri
-import android.text.TextUtils
import androidx.activity.ComponentActivity
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
@@ -217,12 +216,6 @@
wallpaperPreferences = getPreferences(context = appContext),
backgroundDispatcher = bgDispatcher,
),
- shouldHandleReload = {
- TextUtils.equals(
- getColorCustomizationManager(appContext).currentColorSource,
- COLOR_SOURCE_PRESET,
- )
- }
)
.also { wallpaperInteractor = it }
}
diff --git a/src_override/com/android/wallpaper/modules/ThemePickerAppModule.kt b/src_override/com/android/wallpaper/modules/ThemePickerAppModule.kt
index b700d2f..271f925 100644
--- a/src_override/com/android/wallpaper/modules/ThemePickerAppModule.kt
+++ b/src_override/com/android/wallpaper/modules/ThemePickerAppModule.kt
@@ -86,14 +86,13 @@
@Singleton
abstract fun bindColorPickerRepository(impl: ColorPickerRepositoryImpl): ColorPickerRepository
+ @Binds
+ @Singleton
+ abstract fun bindWallpaperPreferences(
+ impl: DefaultCustomizationPreferences
+ ): WallpaperPreferences
+
companion object {
- @Provides
- @Singleton
- fun provideWallpaperPreferences(
- @ApplicationContext context: Context
- ): WallpaperPreferences {
- return DefaultCustomizationPreferences(context)
- }
@Provides
@Singleton
diff --git a/src_override/com/android/wallpaper/picker/di/modules/InteractorModule.kt b/src_override/com/android/wallpaper/picker/di/modules/InteractorModule.kt
deleted file mode 100644
index 81edb2f..0000000
--- a/src_override/com/android/wallpaper/picker/di/modules/InteractorModule.kt
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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)
- }
- }
-}