Merge "Revert "BC25 Preview current wallpapers (2/2)"" into main
diff --git a/src/com/android/customization/module/ThemePickerInjector.kt b/src/com/android/customization/module/ThemePickerInjector.kt
index 08bb800..c08c4e5 100644
--- a/src/com/android/customization/module/ThemePickerInjector.kt
+++ b/src/com/android/customization/module/ThemePickerInjector.kt
@@ -22,6 +22,7 @@
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
@@ -67,7 +68,9 @@
import com.android.wallpaper.module.FragmentFactory
import com.android.wallpaper.module.WallpaperPicker2Injector
import com.android.wallpaper.picker.CustomizationPickerActivity
+import com.android.wallpaper.picker.customization.data.content.WallpaperClientImpl
import com.android.wallpaper.picker.customization.data.repository.WallpaperColorsRepository
+import com.android.wallpaper.picker.customization.data.repository.WallpaperRepository
import com.android.wallpaper.picker.customization.domain.interactor.WallpaperInteractor
import com.android.wallpaper.picker.di.modules.BackgroundDispatcher
import com.android.wallpaper.picker.di.modules.MainDispatcher
@@ -89,6 +92,7 @@
@BackgroundDispatcher private val bgDispatcher: CoroutineDispatcher,
) : WallpaperPicker2Injector(mainScope, bgDispatcher), CustomizationInjector {
private var customizationSections: CustomizationSections? = null
+ private var wallpaperInteractor: WallpaperInteractor? = null
private var keyguardQuickAffordancePickerViewModelFactory:
KeyguardQuickAffordancePickerViewModel.Factory? =
null
@@ -194,7 +198,33 @@
}
override fun getWallpaperInteractor(context: Context): WallpaperInteractor {
- return injectedWallpaperInteractor.get()
+ if (getFlags().isMultiCropEnabled()) {
+ return injectedWallpaperInteractor.get()
+ }
+
+ val appContext = context.applicationContext
+ return wallpaperInteractor
+ ?: WallpaperInteractor(
+ repository =
+ WallpaperRepository(
+ scope = getApplicationCoroutineScope(),
+ client =
+ WallpaperClientImpl(
+ context = appContext,
+ wallpaperManager = WallpaperManager.getInstance(appContext),
+ wallpaperPreferences = getPreferences(appContext),
+ ),
+ wallpaperPreferences = getPreferences(context = appContext),
+ backgroundDispatcher = bgDispatcher,
+ ),
+ shouldHandleReload = {
+ TextUtils.equals(
+ getColorCustomizationManager(appContext).currentColorSource,
+ COLOR_SOURCE_PRESET,
+ )
+ }
+ )
+ .also { wallpaperInteractor = it }
}
override fun getKeyguardQuickAffordancePickerInteractor(