summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Lin <giolin@google.com>2023-12-07 19:18:23 +0000
committerGeorge Lin <giolin@google.com>2023-12-08 19:14:43 +0000
commita149d581d4e8cfc346af5a1d161f4f7c68c4cf8a (patch)
tree374d240db1ae47aae1c13a8db88fc94e951c647b
parent3149f90aa1786426e741de14683b23a885e19084 (diff)
downloadThemePicker-a149d581d4e8cfc346af5a1d161f4f7c68c4cf8a.tar.gz
Refactor WallpaperModelFactory (3/3)
This CL makes the following changes: This CL makes the following changes: 1. Created an interface WallpaperDataFactory, which is implemented by DefaultWallpaperModelFactory and GooogleWallpaperModelFactory, respectively, depending which project we include. This also avoids complex inheritence pattern, where developers need to go back and forth to know what's going on when converting. 2. Made DefaultWallpaperModelFactory and GooogleWallpaperModelFactory injectable classes. 3. Moved functions in DataFactory classes to companion extension functions. Developers do not need to look into many classes. 4. Since DownloadableLiveWallpaperInfo represents a wallpaper that's not yet downloaded, we should treat it as a static wallpaper that shows the static image. Test: Manually tested that the downloadable wallpaper shows Bug: 291761856 Flag: ACONFIG com.android.wallpaper.multi_crop_preview_ui_flag DEVELOPMENT Change-Id: Iefc7202bcd9e963cfb3cc1c5933925f87a40d663
-rw-r--r--src_override/com/android/wallpaper/module/AppModule.kt13
-rw-r--r--tests/module/src/com/android/customization/TestModule.kt13
2 files changed, 14 insertions, 12 deletions
diff --git a/src_override/com/android/wallpaper/module/AppModule.kt b/src_override/com/android/wallpaper/module/AppModule.kt
index 16e5a885..0d80e228 100644
--- a/src_override/com/android/wallpaper/module/AppModule.kt
+++ b/src_override/com/android/wallpaper/module/AppModule.kt
@@ -25,6 +25,7 @@ import com.android.customization.module.logging.ThemesUserEventLogger
import com.android.customization.module.logging.ThemesUserEventLoggerImpl
import com.android.wallpaper.module.logging.UserEventLogger
import com.android.wallpaper.util.converter.DefaultWallpaperModelFactory
+import com.android.wallpaper.util.converter.WallpaperModelFactory
import dagger.Binds
import dagger.Module
import dagger.Provides
@@ -46,6 +47,12 @@ abstract class AppModule {
@Singleton
abstract fun bindThemesUserEventLogger(impl: ThemesUserEventLoggerImpl): ThemesUserEventLogger
+ @Binds
+ @Singleton
+ abstract fun bindWallpaperModelFactory(
+ impl: DefaultWallpaperModelFactory
+ ): WallpaperModelFactory
+
companion object {
@Provides
@Singleton
@@ -57,12 +64,6 @@ abstract class AppModule {
@Provides
@Singleton
- fun provideDefaultWallpaperModelFactory(): DefaultWallpaperModelFactory {
- return DefaultWallpaperModelFactory()
- }
-
- @Provides
- @Singleton
fun provideColorCustomizationManager(
@ApplicationContext context: Context
): ColorCustomizationManager {
diff --git a/tests/module/src/com/android/customization/TestModule.kt b/tests/module/src/com/android/customization/TestModule.kt
index 84b870f7..1ad63a91 100644
--- a/tests/module/src/com/android/customization/TestModule.kt
+++ b/tests/module/src/com/android/customization/TestModule.kt
@@ -17,6 +17,7 @@ import com.android.wallpaper.module.logging.UserEventLogger
import com.android.wallpaper.testing.TestInjector
import com.android.wallpaper.testing.TestWallpaperPreferences
import com.android.wallpaper.util.converter.DefaultWallpaperModelFactory
+import com.android.wallpaper.util.converter.WallpaperModelFactory
import dagger.Binds
import dagger.Module
import dagger.Provides
@@ -63,13 +64,13 @@ abstract class TestModule {
impl: TestDefaultCustomizationPreferences
): CustomizationPreferences
- companion object {
- @Provides
- @Singleton
- fun provideDefaultWallpaperModelFactory(): DefaultWallpaperModelFactory {
- return DefaultWallpaperModelFactory()
- }
+ @Binds
+ @Singleton
+ abstract fun bindWallpaperModelFactory(
+ impl: DefaultWallpaperModelFactory
+ ): WallpaperModelFactory
+ companion object {
@Provides
@Singleton
fun provideColorCustomizationManager(): ColorCustomizationManager {