summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Wang <wangaustin@google.com>2023-11-21 20:35:51 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2023-11-21 20:35:51 +0000
commit3bba5507c6901e6387506cb460094f330f3c2372 (patch)
tree0bf77e08ebdadb9c85b00ad1251022171103e016
parent30ad6968433eed5b7cd8de95af0a5f732ce3ab61 (diff)
parent20268af06d0c9024aa278d055e21e120b7cca1c0 (diff)
downloadThemePicker-3bba5507c6901e6387506cb460094f330f3c2372.tar.gz
Merge "Inject WallpaperInteractor and repository (2/3)" into main
-rw-r--r--src/com/android/customization/module/ThemePickerInjector.kt8
-rw-r--r--src_override/com/android/wallpaper/picker/di/modules/InteractorModule.kt44
-rw-r--r--tests/module/src/com/android/customization/TestModule.kt12
3 files changed, 61 insertions, 3 deletions
diff --git a/src/com/android/customization/module/ThemePickerInjector.kt b/src/com/android/customization/module/ThemePickerInjector.kt
index 819f906f..e01fa44e 100644
--- a/src/com/android/customization/module/ThemePickerInjector.kt
+++ b/src/com/android/customization/module/ThemePickerInjector.kt
@@ -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
@@ -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(
@@ -206,7 +209,6 @@ internal constructor(
client =
WallpaperClientImpl(
context = appContext,
- infoFactory = getCurrentWallpaperInfoFactory(appContext),
wallpaperManager = WallpaperManager.getInstance(appContext),
wallpaperPreferences = getPreferences(appContext)
),
@@ -216,7 +218,7 @@ internal constructor(
shouldHandleReload = {
TextUtils.equals(
getColorCustomizationManager(appContext).currentColorSource,
- ColorOptionsProvider.COLOR_SOURCE_PRESET
+ COLOR_SOURCE_PRESET,
)
}
)
diff --git a/src_override/com/android/wallpaper/picker/di/modules/InteractorModule.kt b/src_override/com/android/wallpaper/picker/di/modules/InteractorModule.kt
new file mode 100644
index 00000000..81edb2fa
--- /dev/null
+++ b/src_override/com/android/wallpaper/picker/di/modules/InteractorModule.kt
@@ -0,0 +1,44 @@
+/*
+ * 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)
+ }
+ }
+}
diff --git a/tests/module/src/com/android/customization/TestModule.kt b/tests/module/src/com/android/customization/TestModule.kt
index 19c42f8b..84b870f7 100644
--- a/tests/module/src/com/android/customization/TestModule.kt
+++ b/tests/module/src/com/android/customization/TestModule.kt
@@ -1,5 +1,8 @@
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
@@ -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())
+ )
+ }
}
}