[automerger skipped] Merge Android 24Q1 Release (ab/11220357) am: 4625595c6a -s ours
am skip reason: Merged-In If7c143c2d2c887cd941aedbfdf874aeac7277638 with SHA-1 e6571e6d71 is already in history
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/ThemePicker/+/25973325
Change-Id: I1e7c4498ade26b243c58af85a549b494d76611ce
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/Android.bp b/Android.bp
index d3a7c51..4b78713 100644
--- a/Android.bp
+++ b/Android.bp
@@ -19,22 +19,6 @@
default_applicable_licenses: ["Android-Apache-2.0"],
}
-filegroup {
- name: "ThemePicker_srcs",
- srcs: [
- "src/**/*.java",
- "src/**/*.kt",
- ],
-}
-
-filegroup {
- name: "ThemePicker_src_overrides",
- srcs: [
- "src_override/**/*.java",
- "src_override/**/*.kt",
- ],
-}
-
// Production-only files that should be excluded in tests.
filegroup {
name: "ThemePicker_src_prod",
@@ -42,6 +26,30 @@
srcs: ["src_override/com/android/customization/picker/CustomizationPickerApplication.java"],
}
+java_library {
+ name: "ThemePickerOverridesLib",
+ srcs: [
+ "src_override/**/*.java",
+ "src_override/**/*.kt",
+ ],
+ exclude_srcs: [":ThemePicker_src_prod"],
+ libs: [
+ "hilt_android",
+ "ThemePickerLib",
+ ],
+}
+
+java_library {
+ name: "ThemePickerApplicationLib",
+ srcs: [":ThemePicker_src_prod"],
+ libs: [
+ "hilt_android",
+ "ThemePickerLib",
+ "ThemePickerOverridesLib",
+ ],
+}
+
+
filegroup {
name: "ThemePicker_Manifest",
srcs: [
@@ -49,39 +57,14 @@
],
}
-genrule {
- name: "ThemePicker_res",
- tools: ["soong_zip"],
- srcs: [
- "res/**/*",
- ],
- out: ["ThemePicker_res.zip"],
- cmd: "INPUTS=($(in)) && "
- + "RES_DIR=$$(dirname $$(dirname $${INPUTS[0]})) && "
- + "$(location soong_zip) -o $(out) -C $$RES_DIR -D $$RES_DIR"
-}
-
-genrule {
- name: "ThemePicker_res_overrides",
- tools: ["soong_zip"],
- srcs: [
- "res_override/**/*",
- ],
- out: ["ThemePicker_res_overrides.zip"],
- cmd: "INPUTS=($(in)) && "
- + "RES_DIR=$$(dirname $$(dirname $${INPUTS[0]})) && "
- + "$(location soong_zip) -o $(out) -C $$RES_DIR -D $$RES_DIR"
-}
-
-// Common defaults that doesn't have ThemePicker specifics.
-java_defaults {
- name: "ThemePicker_common_defaults",
+android_library {
+ name: "ThemePickerLib",
static_libs: [
"guava",
"monet",
- "renderscript_toolkit",
- "wallpaper-common-deps",
+ "renderscript_toolkit",
+ "WallpaperPicker2Lib",
"SettingsLibSettingsTheme",
"SystemUI-statsd",
"styleprotoslite",
@@ -93,21 +76,35 @@
"hilt_android",
],
- jni_libs: [
- "librenderscript-toolkit",
+ srcs: [
+ "src/**/*.java",
+ "src/**/*.kt",
],
- srcs: [
- ":WallpaperPicker2_srcs",
- ":ThemePicker_srcs",
+ resource_dirs: [
+ "res",
+ "res_override",
+ ],
+
+ manifest: "AndroidManifest-empty.xml",
+}
+
+java_defaults {
+ name: "ThemePicker_defaults",
+ static_libs: [
+ "ThemePickerLib",
+ "ThemePickerOverridesLib",
+ "hilt_android",
+ ],
+
+ jni_libs: [
+ "librenderscript-toolkit",
],
required: ["android.software.theme_picker.xml"],
use_embedded_native_libs: true,
- resource_zips: [":WallpaperPicker2_res", ":ThemePicker_res", ":ThemePicker_res_overrides"],
-
optimize: {
enabled: false,
},
@@ -118,12 +115,6 @@
system_ext_specific: true,
}
-java_defaults {
- name: "ThemePicker_defaults",
- defaults: ["ThemePicker_common_defaults"],
- srcs: [":ThemePicker_src_overrides"],
-}
-
prebuilt_etc {
name: "android.software.theme_picker.xml",
system_ext_specific: true,
@@ -142,4 +133,5 @@
manifest: "AndroidManifest.xml",
additional_manifests: [":WallpaperPicker2_Manifest"],
overrides: ["WallpaperPicker", "WallpaperPicker2"],
+ static_libs: ["ThemePickerApplicationLib"],
}
diff --git a/AndroidManifest-empty.xml b/AndroidManifest-empty.xml
new file mode 100644
index 0000000..e2b3605
--- /dev/null
+++ b/AndroidManifest-empty.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ package="com.android.themepicker">
+</manifest>
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b8126e5..de4737c 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -15,6 +15,7 @@
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_WALLPAPER_INTERNAL"/>
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
+ <uses-permission android:name="android.permission.SET_WALLPAPER_DIM_AMOUNT" />
<queries>
<package android:name="android"/>
diff --git a/android.software.theme_picker.xml b/android.software.theme_picker.xml
index 95d49f4..7e0de8a 100644
--- a/android.software.theme_picker.xml
+++ b/android.software.theme_picker.xml
@@ -24,5 +24,6 @@
<permission name="android.permission.SET_WALLPAPER"/>
<permission name="android.permission.SET_WALLPAPER_COMPONENT"/>
<permission name="android.permission.WRITE_SECURE_SETTINGS"/>
+ <permission name="android.permission.SET_WALLPAPER_DIM_AMOUNT"/>
</privapp-permissions>
</permissions>
diff --git a/res/layout/fragment_grid.xml b/res/layout/fragment_grid.xml
index f022268..e77da57 100644
--- a/res/layout/fragment_grid.xml
+++ b/res/layout/fragment_grid.xml
@@ -33,9 +33,11 @@
<com.android.wallpaper.picker.DisplayAspectRatioFrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
+ android:layout_marginHorizontal="24dp"
android:layout_weight="1"
+ android:paddingBottom="40dp"
android:paddingTop="20dp"
- android:paddingBottom="40dp">
+ android:clipChildren="false">
<include
android:id="@+id/preview"
diff --git a/src/com/android/customization/model/ResourceConstants.java b/src/com/android/customization/model/ResourceConstants.java
index aaee935..c1cff13 100644
--- a/src/com/android/customization/model/ResourceConstants.java
+++ b/src/com/android/customization/model/ResourceConstants.java
@@ -19,7 +19,7 @@
import android.content.res.Resources;
import android.provider.Settings.Secure;
-import com.android.wallpaper.R;
+import com.android.themepicker.R;
import java.util.ArrayList;
import java.util.Arrays;
diff --git a/src/com/android/customization/model/color/ColorCustomizationManager.java b/src/com/android/customization/model/color/ColorCustomizationManager.java
index a09efd2..5bd302b 100644
--- a/src/com/android/customization/model/color/ColorCustomizationManager.java
+++ b/src/com/android/customization/model/color/ColorCustomizationManager.java
@@ -48,7 +48,7 @@
import com.android.customization.model.color.ColorOptionsProvider.ColorSource;
import com.android.customization.model.theme.OverlayManagerCompat;
import com.android.customization.module.logging.ThemesUserEventLogger;
-import com.android.wallpaper.R;
+import com.android.themepicker.R;
import org.json.JSONArray;
import org.json.JSONException;
diff --git a/src/com/android/customization/model/color/ColorOption.java b/src/com/android/customization/model/color/ColorOption.java
index f57aa86..ae695dd 100644
--- a/src/com/android/customization/model/color/ColorOption.java
+++ b/src/com/android/customization/model/color/ColorOption.java
@@ -30,7 +30,7 @@
import com.android.customization.model.color.ColorOptionsProvider.ColorSource;
import com.android.customization.module.logging.ThemesUserEventLogger;
import com.android.systemui.monet.Style;
-import com.android.wallpaper.R;
+import com.android.themepicker.R;
import org.json.JSONException;
import org.json.JSONObject;
diff --git a/src/com/android/customization/model/color/ColorOptionImpl.kt b/src/com/android/customization/model/color/ColorOptionImpl.kt
index f090528..ecef2a7 100644
--- a/src/com/android/customization/model/color/ColorOptionImpl.kt
+++ b/src/com/android/customization/model/color/ColorOptionImpl.kt
@@ -23,7 +23,7 @@
import com.android.customization.model.color.ColorOptionsProvider.ColorSource
import com.android.customization.picker.color.shared.model.ColorType
import com.android.systemui.monet.Style
-import com.android.wallpaper.R
+import com.android.themepicker.R
/**
* Represents a color option in the revamped UI, it can be used for both wallpaper and preset colors
diff --git a/src/com/android/customization/model/color/ColorProvider.kt b/src/com/android/customization/model/color/ColorProvider.kt
index 6fdfd2c..79925d8 100644
--- a/src/com/android/customization/model/color/ColorProvider.kt
+++ b/src/com/android/customization/model/color/ColorProvider.kt
@@ -38,7 +38,7 @@
import com.android.customization.picker.color.shared.model.ColorType
import com.android.systemui.monet.ColorScheme
import com.android.systemui.monet.Style
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.module.InjectorProvider
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
diff --git a/src/com/android/customization/model/color/ThemedWallpaperColorResources.kt b/src/com/android/customization/model/color/ThemedWallpaperColorResources.kt
index 906d902..7c89953 100644
--- a/src/com/android/customization/model/color/ThemedWallpaperColorResources.kt
+++ b/src/com/android/customization/model/color/ThemedWallpaperColorResources.kt
@@ -24,32 +24,40 @@
import com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_THEME_STYLE
import com.android.systemui.monet.ColorScheme
import com.android.systemui.monet.Style
+import com.android.systemui.shared.settings.data.repository.SecureSettingsRepository
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
import org.json.JSONException
import org.json.JSONObject
-class ThemedWallpaperColorResources(wallpaperColors: WallpaperColors, context: Context) :
- WallpaperColorResources(wallpaperColors) {
+class ThemedWallpaperColorResources(
+ private val wallpaperColors: WallpaperColors,
+ private val secureSettingsRepository: SecureSettingsRepository,
+) : WallpaperColorResources() {
- init {
- val wallpaperColorScheme =
- ColorScheme(
- wallpaperColors = wallpaperColors,
- darkTheme = false,
- style = fetchThemeStyleFromSetting(context)
- )
- addOverlayColor(wallpaperColorScheme.neutral1, R.color.system_neutral1_10)
- addOverlayColor(wallpaperColorScheme.neutral2, R.color.system_neutral2_10)
- addOverlayColor(wallpaperColorScheme.accent1, R.color.system_accent1_10)
- addOverlayColor(wallpaperColorScheme.accent2, R.color.system_accent2_10)
- addOverlayColor(wallpaperColorScheme.accent3, R.color.system_accent3_10)
+ override suspend fun apply(context: Context, callback: () -> Unit) {
+ withContext(Dispatchers.IO) {
+ val wallpaperColorScheme =
+ ColorScheme(
+ wallpaperColors = wallpaperColors,
+ darkTheme = false,
+ style = fetchThemeStyleFromSetting(),
+ )
+ with(wallpaperColorScheme) {
+ addOverlayColor(neutral1, R.color.system_neutral1_10)
+ addOverlayColor(neutral2, R.color.system_neutral2_10)
+ addOverlayColor(accent1, R.color.system_accent1_10)
+ addOverlayColor(accent2, R.color.system_accent2_10)
+ addOverlayColor(accent3, R.color.system_accent3_10)
+ }
+ applyToContext(context)
+ callback.invoke()
+ }
}
- private fun fetchThemeStyleFromSetting(context: Context): Style {
+ private suspend fun fetchThemeStyleFromSetting(): Style {
val overlayPackageJson =
- Settings.Secure.getString(
- context.contentResolver,
- Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES,
- )
+ secureSettingsRepository.getString(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES)
return if (!overlayPackageJson.isNullOrEmpty()) {
try {
val jsonObject = JSONObject(overlayPackageJson)
diff --git a/src/com/android/customization/model/grid/GridOption.java b/src/com/android/customization/model/grid/GridOption.java
index 347929c..b350351 100644
--- a/src/com/android/customization/model/grid/GridOption.java
+++ b/src/com/android/customization/model/grid/GridOption.java
@@ -26,7 +26,7 @@
import com.android.customization.model.CustomizationManager;
import com.android.customization.model.CustomizationOption;
import com.android.customization.widget.GridTileDrawable;
-import com.android.wallpaper.R;
+import com.android.themepicker.R;
/**
* Represents a grid layout option available in the current launcher.
diff --git a/src/com/android/customization/model/grid/GridOptionsManager.java b/src/com/android/customization/model/grid/GridOptionsManager.java
index bd24cf5..09c6c65 100644
--- a/src/com/android/customization/model/grid/GridOptionsManager.java
+++ b/src/com/android/customization/model/grid/GridOptionsManager.java
@@ -56,8 +56,8 @@
if (sGridOptionsManager == null) {
Context appContext = context.getApplicationContext();
CustomizationInjector injector = (CustomizationInjector) InjectorProvider.getInjector();
- ThemesUserEventLogger eventLogger = (ThemesUserEventLogger) injector.getUserEventLogger(
- appContext);
+ ThemesUserEventLogger eventLogger =
+ (ThemesUserEventLogger) injector.getUserEventLogger();
sGridOptionsManager = new GridOptionsManager(
new LauncherGridOptionsProvider(appContext,
appContext.getString(R.string.grid_control_metadata_name)),
diff --git a/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java b/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java
index e71cca9..33ad81d 100644
--- a/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java
+++ b/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java
@@ -32,7 +32,7 @@
import androidx.lifecycle.MutableLiveData;
import com.android.customization.model.ResourceConstants;
-import com.android.wallpaper.R;
+import com.android.themepicker.R;
import com.android.wallpaper.config.BaseFlags;
import com.android.wallpaper.util.PreviewUtils;
diff --git a/src/com/android/customization/model/mode/DarkModeSectionController.java b/src/com/android/customization/model/mode/DarkModeSectionController.java
index 7139829..3da7ae9 100644
--- a/src/com/android/customization/model/mode/DarkModeSectionController.java
+++ b/src/com/android/customization/model/mode/DarkModeSectionController.java
@@ -41,7 +41,7 @@
import com.android.customization.module.logging.ThemesUserEventLogger;
import com.android.customization.picker.mode.DarkModeSectionView;
-import com.android.wallpaper.R;
+import com.android.themepicker.R;
import com.android.wallpaper.model.CustomizationSectionController;
import java.util.concurrent.ExecutorService;
diff --git a/src/com/android/customization/model/themedicon/ThemedIconSectionController.java b/src/com/android/customization/model/themedicon/ThemedIconSectionController.java
index 1cc6d0a..4b3f2f5 100644
--- a/src/com/android/customization/model/themedicon/ThemedIconSectionController.java
+++ b/src/com/android/customization/model/themedicon/ThemedIconSectionController.java
@@ -26,7 +26,7 @@
import com.android.customization.model.themedicon.domain.interactor.ThemedIconSnapshotRestorer;
import com.android.customization.module.logging.ThemesUserEventLogger;
import com.android.customization.picker.themedicon.ThemedIconSectionView;
-import com.android.wallpaper.R;
+import com.android.themepicker.R;
import com.android.wallpaper.model.CustomizationSectionController;
// TODO (b/311712452): Refactor CustomizationSectionController to use recommended arch UI components
diff --git a/src/com/android/customization/model/themedicon/ThemedIconSwitchProvider.java b/src/com/android/customization/model/themedicon/ThemedIconSwitchProvider.java
index 5e2a60a..6b8deaa 100644
--- a/src/com/android/customization/model/themedicon/ThemedIconSwitchProvider.java
+++ b/src/com/android/customization/model/themedicon/ThemedIconSwitchProvider.java
@@ -25,7 +25,7 @@
import androidx.annotation.Nullable;
import com.android.customization.module.CustomizationPreferences;
-import com.android.wallpaper.R;
+import com.android.themepicker.R;
import com.android.wallpaper.module.InjectorProvider;
import java.util.concurrent.ExecutorService;
diff --git a/src/com/android/customization/module/CustomizationInjector.kt b/src/com/android/customization/module/CustomizationInjector.kt
index 82203d9..d761598 100644
--- a/src/com/android/customization/module/CustomizationInjector.kt
+++ b/src/com/android/customization/module/CustomizationInjector.kt
@@ -18,7 +18,6 @@
import android.content.Context
import android.content.res.Resources
import androidx.activity.ComponentActivity
-import com.android.customization.module.logging.ThemesUserEventLogger
import com.android.customization.picker.clock.domain.interactor.ClockPickerInteractor
import com.android.customization.picker.clock.ui.view.ClockViewFactory
import com.android.customization.picker.clock.ui.viewmodel.ClockCarouselViewModel
@@ -55,7 +54,6 @@
interactor: ClockPickerInteractor,
clockViewFactory: ClockViewFactory,
resources: Resources,
- logger: ThemesUserEventLogger,
): ClockCarouselViewModel.Factory
fun getClockViewFactory(activity: ComponentActivity): ClockViewFactory
diff --git a/src/com/android/customization/module/ThemePickerInjector.kt b/src/com/android/customization/module/ThemePickerInjector.kt
index f22e562..8fd13d3 100644
--- a/src/com/android/customization/module/ThemePickerInjector.kt
+++ b/src/com/android/customization/module/ThemePickerInjector.kt
@@ -56,8 +56,6 @@
import com.android.customization.picker.grid.domain.interactor.GridInteractor
import com.android.customization.picker.grid.domain.interactor.GridSnapshotRestorer
import com.android.customization.picker.grid.ui.viewmodel.GridScreenViewModel
-import com.android.customization.picker.notifications.data.repository.NotificationsRepository
-import com.android.customization.picker.notifications.domain.interactor.NotificationsInteractor
import com.android.customization.picker.notifications.domain.interactor.NotificationsSnapshotRestorer
import com.android.customization.picker.notifications.ui.viewmodel.NotificationSectionViewModel
import com.android.customization.picker.quickaffordance.data.repository.KeyguardQuickAffordancePickerRepository
@@ -67,6 +65,8 @@
import com.android.systemui.shared.clocks.ClockRegistry
import com.android.systemui.shared.customization.data.content.CustomizationProviderClient
import com.android.systemui.shared.customization.data.content.CustomizationProviderClientImpl
+import com.android.systemui.shared.notifications.data.repository.NotificationSettingsRepository
+import com.android.systemui.shared.notifications.domain.interactor.NotificationSettingsInteractor
import com.android.wallpaper.config.BaseFlags
import com.android.wallpaper.module.CustomizationSections
import com.android.wallpaper.module.FragmentFactory
@@ -80,6 +80,7 @@
import com.android.wallpaper.picker.di.modules.MainDispatcher
import com.android.wallpaper.picker.undo.domain.interactor.SnapshotRestorer
import com.android.wallpaper.util.ScreenSizeCalculator
+import dagger.Lazy
import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.CoroutineDispatcher
@@ -88,12 +89,12 @@
@Singleton
open class ThemePickerInjector
@Inject
-internal constructor(
+constructor(
@MainDispatcher private val mainScope: CoroutineScope,
@MainDispatcher private val mainDispatcher: CoroutineDispatcher,
+ @BackgroundDispatcher private val bgScope: CoroutineScope,
@BackgroundDispatcher private val bgDispatcher: CoroutineDispatcher,
- private val userEventLogger: ThemesUserEventLogger,
-) : WallpaperPicker2Injector(mainScope, bgDispatcher, userEventLogger), CustomizationInjector {
+) : WallpaperPicker2Injector(mainScope, bgDispatcher), CustomizationInjector {
private var customizationSections: CustomizationSections? = null
private var wallpaperInteractor: WallpaperInteractor? = null
private var keyguardQuickAffordancePickerInteractor: KeyguardQuickAffordancePickerInteractor? =
@@ -110,7 +111,7 @@
private var clockCarouselViewModelFactory: ClockCarouselViewModel.Factory? = null
private var clockViewFactory: ClockViewFactory? = null
private var clockPickerSnapshotRestorer: ClockPickerSnapshotRestorer? = null
- private var notificationsInteractor: NotificationsInteractor? = null
+ private var notificationSettingsInteractor: NotificationSettingsInteractor? = null
private var notificationSectionViewModelFactory: NotificationSectionViewModel.Factory? = null
private var colorPickerInteractor: ColorPickerInteractor? = null
private var colorPickerViewModelFactory: ColorPickerViewModel.Factory? = null
@@ -124,6 +125,7 @@
private var gridSnapshotRestorer: GridSnapshotRestorer? = null
private var gridScreenViewModelFactory: GridScreenViewModel.Factory? = null
private var clockRegistryProvider: ClockRegistryProvider? = null
+ @Inject lateinit var themesUserEventLogger: Lazy<ThemesUserEventLogger>
override fun getCustomizationSections(activity: ComponentActivity): CustomizationSections {
val appContext = activity.applicationContext
@@ -142,13 +144,12 @@
interactor = getClockPickerInteractor(appContext),
clockViewFactory = clockViewFactory,
resources = resources,
- logger = userEventLogger,
),
clockViewFactory,
getThemedIconSnapshotRestorer(appContext),
getThemedIconInteractor(),
getColorPickerInteractor(appContext, getWallpaperColorsRepository()),
- getUserEventLogger(appContext),
+ getUserEventLogger(),
)
.also { customizationSections = it }
}
@@ -166,8 +167,8 @@
}
@Synchronized
- override fun getUserEventLogger(context: Context): ThemesUserEventLogger {
- return userEventLogger
+ override fun getUserEventLogger(): ThemesUserEventLogger {
+ return themesUserEventLogger.get()
}
override fun getFragmentFactory(): FragmentFactory? {
@@ -200,7 +201,7 @@
override fun getWallpaperInteractor(context: Context): WallpaperInteractor {
if (getFlags().isMultiCropEnabled() && getFlags().isMultiCropPreviewUiEnabled()) {
- return injectedWallpaperInteractor
+ return injectedWallpaperInteractor.get()
}
val appContext = context.applicationContext
@@ -246,7 +247,7 @@
getKeyguardQuickAffordancePickerInteractor(context),
getWallpaperInteractor(context),
getCurrentWallpaperInfoFactory(context),
- getUserEventLogger(context),
+ getUserEventLogger(),
)
.also { keyguardQuickAffordancePickerViewModelFactory = it }
}
@@ -290,26 +291,24 @@
return notificationSectionViewModelFactory
?: NotificationSectionViewModel.Factory(
interactor = getNotificationsInteractor(context),
- logger = getUserEventLogger(context),
+ logger = getUserEventLogger(),
)
.also { notificationSectionViewModelFactory = it }
}
private fun getNotificationsInteractor(
context: Context,
- ): NotificationsInteractor {
- val appContext = context.applicationContext
- return notificationsInteractor
- ?: NotificationsInteractor(
+ ): NotificationSettingsInteractor {
+ return notificationSettingsInteractor
+ ?: NotificationSettingsInteractor(
repository =
- NotificationsRepository(
+ NotificationSettingsRepository(
scope = getApplicationCoroutineScope(),
backgroundDispatcher = bgDispatcher,
secureSettingsRepository = getSecureSettingsRepository(context),
),
- snapshotRestorer = { getNotificationsSnapshotRestorer(appContext) },
)
- .also { notificationsInteractor = it }
+ .also { notificationSettingsInteractor = it }
}
private fun getNotificationsSnapshotRestorer(context: Context): NotificationsSnapshotRestorer {
@@ -319,6 +318,7 @@
getNotificationsInteractor(
context = context,
),
+ backgroundScope = bgScope,
)
.also { notificationsSnapshotRestorer = it }
}
@@ -357,7 +357,6 @@
interactor: ClockPickerInteractor,
clockViewFactory: ClockViewFactory,
resources: Resources,
- logger: ThemesUserEventLogger,
): ClockCarouselViewModel.Factory {
return clockCarouselViewModelFactory
?: ClockCarouselViewModel.Factory(
@@ -365,7 +364,7 @@
bgDispatcher,
clockViewFactory,
resources,
- logger,
+ getUserEventLogger(),
)
.also { clockCarouselViewModelFactory = it }
}
@@ -406,7 +405,7 @@
wallpaperColors: WallpaperColors,
context: Context
): WallpaperColorResources {
- return ThemedWallpaperColorResources(wallpaperColors, context)
+ return ThemedWallpaperColorResources(wallpaperColors, getSecureSettingsRepository(context))
}
override fun getColorPickerInteractor(
@@ -436,7 +435,7 @@
?: ColorPickerViewModel.Factory(
context.applicationContext,
getColorPickerInteractor(context, wallpaperColorsRepository),
- userEventLogger,
+ getUserEventLogger(),
)
.also { colorPickerViewModelFactory = it }
}
@@ -508,7 +507,7 @@
context,
wallpaperColorsRepository,
),
- userEventLogger,
+ getUserEventLogger(),
) { clockId ->
clockId?.let { clockViewFactory.getController(clockId).config.isReactiveToTone }
?: false
diff --git a/src/com/android/customization/module/logging/AppSessionId.kt b/src/com/android/customization/module/logging/AppSessionId.kt
index c831f22..7553fe9 100644
--- a/src/com/android/customization/module/logging/AppSessionId.kt
+++ b/src/com/android/customization/module/logging/AppSessionId.kt
@@ -15,6 +15,7 @@
*/
package com.android.customization.module.logging
+import android.util.Log
import com.android.internal.logging.InstanceId
import com.android.internal.logging.InstanceIdSequence
import javax.inject.Inject
@@ -23,7 +24,9 @@
@Singleton
class AppSessionId @Inject constructor() {
- private var sessionId: InstanceId = newInstanceId()
+ private var idSequence: InstanceIdSequence? = null
+
+ private var sessionId: InstanceId? = null
fun createNewId(): AppSessionId {
sessionId = newInstanceId()
@@ -31,12 +34,23 @@
}
fun getId(): Int {
- return sessionId.hashCode()
+ val id =
+ sessionId
+ ?: newInstanceId().also {
+ Log.w(
+ TAG,
+ "Session ID should not be null. We should always call createNewId() before calling getId()."
+ )
+ sessionId = it
+ }
+ return id.hashCode()
}
- private fun newInstanceId(): InstanceId = InstanceIdSequence(INSTANCE_ID_MAX).newInstanceId()
+ private fun newInstanceId(): InstanceId =
+ (idSequence ?: InstanceIdSequence(INSTANCE_ID_MAX).also { idSequence = it }).newInstanceId()
companion object {
+ private const val TAG = "AppSessionId"
// At most 20 bits: ~1m possibilities, ~0.5% probability of collision in 100 values
private const val INSTANCE_ID_MAX = 1 shl 20
}
diff --git a/src/com/android/customization/module/logging/SysUiStatsLogger.kt b/src/com/android/customization/module/logging/SysUiStatsLogger.kt
index 111c2c2..71363fb 100644
--- a/src/com/android/customization/module/logging/SysUiStatsLogger.kt
+++ b/src/com/android/customization/module/logging/SysUiStatsLogger.kt
@@ -60,6 +60,7 @@
private var toggleOn = false
private var shortcut = ""
private var shortcutSlotId = ""
+ private var lockEffectIdHash = 0
fun setColorPackageHash(colorPackageHash: Int) = apply {
this.colorPackageHash = colorPackageHash
@@ -151,6 +152,10 @@
fun setShortcutSlotId(shortcutSlotId: String) = apply { this.shortcutSlotId = shortcutSlotId }
+ fun setLockEffectIdHash(lockEffectIdHash: Int) = apply {
+ this.lockEffectIdHash = lockEffectIdHash
+ }
+
fun log() {
SysUiStatsLog.write(
STYLE_UI_CHANGED,
@@ -185,6 +190,7 @@
toggleOn,
shortcut,
shortcutSlotId,
+ lockEffectIdHash,
)
}
}
diff --git a/src/com/android/customization/module/logging/ThemesUserEventLoggerImpl.kt b/src/com/android/customization/module/logging/ThemesUserEventLoggerImpl.kt
index 3f4a6dc..b28086b 100644
--- a/src/com/android/customization/module/logging/ThemesUserEventLoggerImpl.kt
+++ b/src/com/android/customization/module/logging/ThemesUserEventLoggerImpl.kt
@@ -75,9 +75,10 @@
SysUiStatsLogger(SNAPSHOT)
.setWallpaperCategoryHash(preferences.getHomeCategoryHash())
.setWallpaperIdHash(preferences.getHomeWallpaperIdHash())
+ .setEffectIdHash(preferences.getHomeWallpaperEffectsIdHash())
.setLockWallpaperCategoryHash(preferences.getLockCategoryHash())
.setLockWallpaperIdHash(preferences.getLockWallpaperIdHash())
- .setEffectIdHash(preferences.getHomeWallpaperEffectsIdHash())
+ .setLockEffectIdHash(preferences.getLockWallpaperEffectsIdHash())
.setColorSource(colorManager.currentColorSourceForLogging)
.setColorVariant(colorManager.currentStyleForLogging)
.setSeedColor(colorManager.currentSeedColorForLogging)
@@ -110,9 +111,10 @@
.setAppSessionId(appSessionId.getId())
.setWallpaperCategoryHash(if (isHomeWallpaperSet) categoryHash else 0)
.setWallpaperIdHash(if (isHomeWallpaperSet) wallpaperIdHash else 0)
+ .setEffectIdHash(if (isHomeWallpaperSet) getIdHashCode(effects) else 0)
.setLockWallpaperCategoryHash(if (isLockWallpaperSet) categoryHash else 0)
.setLockWallpaperIdHash(if (isLockWallpaperSet) wallpaperIdHash else 0)
- .setEffectIdHash(getIdHashCode(effects))
+ .setLockEffectIdHash(if (isLockWallpaperSet) getIdHashCode(effects) else 0)
.setSetWallpaperEntryPoint(setWallpaperEntryPoint)
.setWallpaperDestination(destination)
.log()
@@ -293,6 +295,11 @@
return getIdHashCode(getHomeWallpaperEffects())
}
+ /** If not set, the output hash is 0. */
+ private fun WallpaperPreferences.getLockWallpaperEffectsIdHash(): Int {
+ return getIdHashCode(getLockWallpaperEffects())
+ }
+
private fun getIdHashCode(id: String?): Int {
return id?.hashCode() ?: 0
}
diff --git a/src/com/android/customization/picker/WallpaperPreviewer.java b/src/com/android/customization/picker/WallpaperPreviewer.java
deleted file mode 100644
index 18bc89c..0000000
--- a/src/com/android/customization/picker/WallpaperPreviewer.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * Copyright (C) 2020 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.customization.picker;
-
-import android.app.Activity;
-import android.app.WallpaperColors;
-import android.content.Intent;
-import android.graphics.Rect;
-import android.graphics.RenderEffect;
-import android.graphics.Shader.TileMode;
-import android.service.wallpaper.WallpaperService;
-import android.view.Surface;
-import android.view.SurfaceView;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-
-import androidx.annotation.MainThread;
-import androidx.annotation.Nullable;
-import androidx.cardview.widget.CardView;
-import androidx.lifecycle.Lifecycle;
-import androidx.lifecycle.LifecycleObserver;
-import androidx.lifecycle.OnLifecycleEvent;
-
-import com.android.wallpaper.model.LiveWallpaperInfo;
-import com.android.wallpaper.model.WallpaperInfo;
-import com.android.wallpaper.util.ResourceUtils;
-import com.android.wallpaper.util.ScreenSizeCalculator;
-import com.android.wallpaper.util.SizeCalculator;
-import com.android.wallpaper.util.VideoWallpaperUtils;
-import com.android.wallpaper.util.WallpaperConnection;
-import com.android.wallpaper.util.WallpaperConnection.WallpaperConnectionListener;
-import com.android.wallpaper.util.WallpaperSurfaceCallback;
-import com.android.wallpaper.widget.WallpaperColorsLoader;
-
-/** A class to load the wallpaper to the view. */
-public class WallpaperPreviewer implements LifecycleObserver {
-
- private final Rect mPreviewLocalRect = new Rect();
- private final Rect mPreviewGlobalRect = new Rect();
- private final int[] mLivePreviewLocation = new int[2];
-
- private final Activity mActivity;
- private final ImageView mHomePreview;
- private final SurfaceView mWallpaperSurface;
- @Nullable private final ImageView mFadeInScrim;
-
- private WallpaperSurfaceCallback mWallpaperSurfaceCallback;
- private WallpaperInfo mWallpaper;
- private WallpaperConnection mWallpaperConnection;
- @Nullable private WallpaperColorsListener mWallpaperColorsListener;
-
- /** Interface for getting {@link WallpaperColors} from wallpaper. */
- public interface WallpaperColorsListener {
- /** Gets called when wallpaper color is available or updated. */
- void onWallpaperColorsChanged(WallpaperColors colors);
- }
-
- public WallpaperPreviewer(Lifecycle lifecycle, Activity activity, ImageView homePreview,
- SurfaceView wallpaperSurface) {
- this(lifecycle, activity, homePreview, wallpaperSurface, null);
- }
-
- public WallpaperPreviewer(Lifecycle lifecycle, Activity activity, ImageView homePreview,
- SurfaceView wallpaperSurface, @Nullable ImageView fadeInScrim) {
- lifecycle.addObserver(this);
-
- mActivity = activity;
- mHomePreview = homePreview;
- mWallpaperSurface = wallpaperSurface;
- mFadeInScrim = fadeInScrim;
- mWallpaperSurfaceCallback = new WallpaperSurfaceCallback(activity, mHomePreview,
- mWallpaperSurface, this::setUpWallpaperPreview);
- mWallpaperSurface.setZOrderMediaOverlay(true);
- mWallpaperSurface.getHolder().addCallback(mWallpaperSurfaceCallback);
-
- View rootView = homePreview.getRootView();
- rootView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
- @Override
- public void onLayoutChange(View v, int left, int top, int right, int bottom,
- int oldLeft, int oldTop, int oldRight, int oldBottom) {
- updatePreviewCardRadius();
- rootView.removeOnLayoutChangeListener(this);
- }
- });
- }
-
- @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
- @MainThread
- public void onResume() {
- if (mWallpaperConnection != null) {
- mWallpaperConnection.setVisibility(true);
- }
- }
-
- @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
- @MainThread
- public void onPause() {
- if (mWallpaperConnection != null) {
- mWallpaperConnection.setVisibility(false);
- }
- }
-
- @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
- @MainThread
- public void onStop() {
- if (mWallpaperConnection != null) {
- mWallpaperConnection.disconnect();
- mWallpaperConnection = null;
- }
- }
-
- @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
- @MainThread
- public void onDestroy() {
- if (mWallpaperConnection != null) {
- mWallpaperConnection.disconnect();
- mWallpaperConnection = null;
- }
-
- mWallpaperSurfaceCallback.cleanUp();
- mWallpaperSurface.getHolder().removeCallback(mWallpaperSurfaceCallback);
- Surface surface = mWallpaperSurface.getHolder().getSurface();
- if (surface != null) {
- surface.release();
- }
- }
-
- /**
- * Sets a wallpaper to be shown on preview screen.
- *
- * @param wallpaperInfo the wallpaper to preview
- * @param listener the listener for getting the wallpaper color of {@param wallpaperInfo}
- */
- public void setWallpaper(WallpaperInfo wallpaperInfo,
- @Nullable WallpaperColorsListener listener) {
- mWallpaper = wallpaperInfo;
- mWallpaperColorsListener = listener;
- if (mFadeInScrim != null && VideoWallpaperUtils.needsFadeIn(wallpaperInfo)) {
- mFadeInScrim.animate().cancel();
- mFadeInScrim.setAlpha(1f);
- mFadeInScrim.setVisibility(View.VISIBLE);
- }
- setUpWallpaperPreview();
- }
-
- private void setUpWallpaperPreview() {
- ImageView homeImageWallpaper = mWallpaperSurfaceCallback.getHomeImageWallpaper();
- if (mWallpaper != null && homeImageWallpaper != null) {
- homeImageWallpaper.post(() -> {
- if (mActivity == null || mActivity.isDestroyed()) {
- return;
- }
- boolean renderInImageWallpaperSurface = !(mWallpaper instanceof LiveWallpaperInfo);
- mWallpaper.getThumbAsset(mActivity.getApplicationContext())
- .loadPreviewImage(mActivity,
- renderInImageWallpaperSurface ? homeImageWallpaper : mHomePreview,
- ResourceUtils.getColorAttr(
- mActivity, android.R.attr.colorSecondary),
- /* offsetToStart= */ true);
- if (mWallpaper instanceof LiveWallpaperInfo) {
- ImageView preview = homeImageWallpaper;
- if (VideoWallpaperUtils.needsFadeIn(mWallpaper) && mFadeInScrim != null) {
- preview = mFadeInScrim;
- preview.setRenderEffect(
- RenderEffect.createBlurEffect(150f, 150f, TileMode.CLAMP));
- }
- mWallpaper.getThumbAsset(mActivity.getApplicationContext())
- .loadPreviewImage(
- mActivity,
- preview,
- ResourceUtils.getColorAttr(
- mActivity, android.R.attr.colorSecondary),
- /* offsetToStart= */ true);
- setUpLiveWallpaperPreview(mWallpaper);
- } else {
- // Ensure live wallpaper connection is disconnected.
- if (mWallpaperConnection != null) {
- mWallpaperConnection.disconnect();
- mWallpaperConnection = null;
- }
-
- // Load wallpaper color for static wallpaper.
- if (mWallpaperColorsListener != null) {
- WallpaperColorsLoader.getWallpaperColors(
- mActivity,
- mWallpaper.getThumbAsset(mActivity),
- mWallpaperColorsListener::onWallpaperColorsChanged);
- }
- }
- });
- }
- }
-
- private void setUpLiveWallpaperPreview(WallpaperInfo homeWallpaper) {
- if (mActivity == null || mActivity.isFinishing()) {
- return;
- }
-
- if (mWallpaperConnection != null) {
- mWallpaperConnection.disconnect();
- }
- if (WallpaperConnection.isPreviewAvailable()) {
- mHomePreview.getLocationOnScreen(mLivePreviewLocation);
- mPreviewGlobalRect.set(0, 0, mHomePreview.getMeasuredWidth(),
- mHomePreview.getMeasuredHeight());
- mPreviewLocalRect.set(mPreviewGlobalRect);
- mPreviewGlobalRect.offset(mLivePreviewLocation[0], mLivePreviewLocation[1]);
-
- mWallpaperConnection = new WallpaperConnection(
- getWallpaperIntent(homeWallpaper.getWallpaperComponent()), mActivity,
- new WallpaperConnectionListener() {
- @Override
- public void onWallpaperColorsChanged(WallpaperColors colors,
- int displayId) {
- if (mWallpaperColorsListener != null) {
- mWallpaperColorsListener.onWallpaperColorsChanged(colors);
- }
- }
-
- @Override
- public void onEngineShown() {
- if (mFadeInScrim != null && VideoWallpaperUtils.needsFadeIn(
- homeWallpaper)) {
- mFadeInScrim.animate().alpha(0.0f)
- .setDuration(VideoWallpaperUtils.TRANSITION_MILLIS)
- .withEndAction(
- () -> mFadeInScrim.setVisibility(View.INVISIBLE));
- }
- }
- }, mWallpaperSurface, WallpaperConnection.WhichPreview.PREVIEW_CURRENT);
-
- mWallpaperConnection.setVisibility(true);
- mHomePreview.post(() -> {
- if (mWallpaperConnection != null && !mWallpaperConnection.connect()) {
- mWallpaperConnection = null;
- }
- });
- } else {
- // Load wallpaper color from the thumbnail.
- if (mWallpaperColorsListener != null) {
- WallpaperColorsLoader.getWallpaperColors(
- mActivity,
- mWallpaper.getThumbAsset(mActivity),
- mWallpaperColorsListener::onWallpaperColorsChanged);
- }
- }
- }
-
- /** Updates the preview card view corner radius to match the device corner radius. */
- private void updatePreviewCardRadius() {
- final float screenAspectRatio =
- ScreenSizeCalculator.getInstance().getScreenAspectRatio(mActivity);
- CardView cardView = (CardView) mHomePreview.getParent();
- final int cardWidth = (int) (cardView.getMeasuredHeight() / screenAspectRatio);
- ViewGroup.LayoutParams layoutParams = cardView.getLayoutParams();
- layoutParams.width = cardWidth;
- cardView.setLayoutParams(layoutParams);
- cardView.setRadius(SizeCalculator.getPreviewCornerRadius(mActivity, cardWidth));
- }
-
- private static Intent getWallpaperIntent(android.app.WallpaperInfo info) {
- return new Intent(WallpaperService.SERVICE_INTERFACE)
- .setClassName(info.getPackageName(), info.getServiceName());
- }
-}
diff --git a/src/com/android/customization/picker/clock/data/repository/ClockPickerRepositoryImpl.kt b/src/com/android/customization/picker/clock/data/repository/ClockPickerRepositoryImpl.kt
index cc4079a..4a4aae1 100644
--- a/src/com/android/customization/picker/clock/data/repository/ClockPickerRepositoryImpl.kt
+++ b/src/com/android/customization/picker/clock/data/repository/ClockPickerRepositoryImpl.kt
@@ -23,7 +23,7 @@
import com.android.customization.picker.clock.shared.model.ClockMetadataModel
import com.android.systemui.plugins.clocks.ClockMetadata
import com.android.systemui.shared.clocks.ClockRegistry
-import com.android.wallpaper.settings.data.repository.SecureSettingsRepository
+import com.android.systemui.shared.settings.data.repository.SecureSettingsRepository
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -157,7 +157,7 @@
)
override suspend fun setClockSize(size: ClockSize) {
- secureSettingsRepository.set(
+ secureSettingsRepository.setInt(
name = Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK,
value = if (size == ClockSize.DYNAMIC) 1 else 0,
)
diff --git a/src/com/android/customization/picker/clock/ui/adapter/ClockSettingsTabAdapter.kt b/src/com/android/customization/picker/clock/ui/adapter/ClockSettingsTabAdapter.kt
index 981a8e8..1dccb21 100644
--- a/src/com/android/customization/picker/clock/ui/adapter/ClockSettingsTabAdapter.kt
+++ b/src/com/android/customization/picker/clock/ui/adapter/ClockSettingsTabAdapter.kt
@@ -22,7 +22,7 @@
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.android.customization.picker.clock.ui.viewmodel.ClockSettingsTabViewModel
-import com.android.wallpaper.R
+import com.android.themepicker.R
/** Adapter for the tab recycler view on the clock settings screen. */
class ClockSettingsTabAdapter : RecyclerView.Adapter<ClockSettingsTabAdapter.ViewHolder>() {
diff --git a/src/com/android/customization/picker/clock/ui/binder/CarouselAccessibilityDelegate.kt b/src/com/android/customization/picker/clock/ui/binder/CarouselAccessibilityDelegate.kt
index eb11171..1026f19 100644
--- a/src/com/android/customization/picker/clock/ui/binder/CarouselAccessibilityDelegate.kt
+++ b/src/com/android/customization/picker/clock/ui/binder/CarouselAccessibilityDelegate.kt
@@ -21,7 +21,7 @@
import android.os.Bundle
import android.view.View
import android.view.accessibility.AccessibilityNodeInfo
-import com.android.wallpaper.R
+import com.android.themepicker.R
class CarouselAccessibilityDelegate(
private val context: Context,
diff --git a/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt b/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt
index d17cdf8..b1bd0ef 100644
--- a/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt
+++ b/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt
@@ -46,7 +46,7 @@
import com.android.customization.picker.clock.ui.viewmodel.ClockSettingsViewModel
import com.android.customization.picker.color.ui.binder.ColorOptionIconBinder
import com.android.customization.picker.common.ui.view.ItemSpacing
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.picker.option.ui.binder.OptionItemBinder
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.mapNotNull
diff --git a/src/com/android/customization/picker/clock/ui/fragment/ClockSettingsFragment.kt b/src/com/android/customization/picker/clock/ui/fragment/ClockSettingsFragment.kt
index dc70633..b8bd2f3 100644
--- a/src/com/android/customization/picker/clock/ui/fragment/ClockSettingsFragment.kt
+++ b/src/com/android/customization/picker/clock/ui/fragment/ClockSettingsFragment.kt
@@ -29,7 +29,7 @@
import com.android.customization.module.ThemePickerInjector
import com.android.customization.picker.clock.ui.binder.ClockSettingsBinder
import com.android.systemui.shared.clocks.shared.model.ClockPreviewConstants
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.module.CustomizationSections
import com.android.wallpaper.module.InjectorProvider
import com.android.wallpaper.picker.AppbarFragment
@@ -80,7 +80,8 @@
context = context,
authority =
resources.getString(
- R.string.lock_screen_preview_provider_authority,
+ com.android.wallpaper.R.string
+ .lock_screen_preview_provider_authority,
),
),
wallpaperInfoProvider = { forceReload ->
@@ -148,6 +149,9 @@
}
override fun getToolbarTextColor(): Int {
- return ContextCompat.getColor(requireContext(), R.color.system_on_surface)
+ return ContextCompat.getColor(
+ requireContext(),
+ com.android.wallpaper.R.color.system_on_surface
+ )
}
}
diff --git a/src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt b/src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt
index cae4e06..d0a30a4 100644
--- a/src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt
+++ b/src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt
@@ -32,7 +32,7 @@
import com.android.customization.picker.clock.shared.ClockSize
import com.android.customization.picker.clock.ui.viewmodel.ClockCarouselItemViewModel
import com.android.systemui.plugins.clocks.ClockController
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.picker.FixedWidthDisplayRatioFrameLayout
import java.lang.Float.max
@@ -334,7 +334,7 @@
private fun overrideScreenPreviewWidth() {
val overrideWidth =
context.resources.getDimensionPixelSize(
- R.dimen.screen_preview_width_for_2_pane_small_width
+ com.android.wallpaper.R.dimen.screen_preview_width_for_2_pane_small_width
)
itemViewIds.forEach { id ->
val itemView = motionLayout.requireViewById<FrameLayout>(id)
@@ -361,13 +361,17 @@
val layout = constraint.layout
if (
constraint.layout.mWidth ==
- context.resources.getDimensionPixelSize(R.dimen.screen_preview_width)
+ context.resources.getDimensionPixelSize(
+ com.android.wallpaper.R.dimen.screen_preview_width
+ )
) {
layout.mWidth = overrideWidth
}
if (
constraint.layout.widthMax ==
- context.resources.getDimensionPixelSize(R.dimen.screen_preview_width)
+ context.resources.getDimensionPixelSize(
+ com.android.wallpaper.R.dimen.screen_preview_width
+ )
) {
layout.widthMax = overrideWidth
}
diff --git a/src/com/android/customization/picker/clock/ui/view/ClockViewFactoryImpl.kt b/src/com/android/customization/picker/clock/ui/view/ClockViewFactoryImpl.kt
index 5caea58..cf9e247 100644
--- a/src/com/android/customization/picker/clock/ui/view/ClockViewFactoryImpl.kt
+++ b/src/com/android/customization/picker/clock/ui/view/ClockViewFactoryImpl.kt
@@ -29,7 +29,7 @@
import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.plugins.clocks.WeatherData
import com.android.systemui.shared.clocks.ClockRegistry
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.util.TimeUtils.TimeTicker
import java.util.concurrent.ConcurrentHashMap
@@ -86,7 +86,9 @@
val layoutParams =
FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
- resources.getDimensionPixelSize(R.dimen.small_clock_height)
+ resources.getDimensionPixelSize(
+ com.android.systemui.customization.R.dimen.small_clock_height
+ )
)
layoutParams.topMargin = getSmallClockTopMargin()
layoutParams.marginStart = getSmallClockStartPadding()
@@ -97,10 +99,14 @@
private fun getSmallClockTopMargin() =
getStatusBarHeight(appContext.resources) +
- appContext.resources.getDimensionPixelSize(R.dimen.small_clock_padding_top)
+ appContext.resources.getDimensionPixelSize(
+ com.android.systemui.customization.R.dimen.small_clock_padding_top
+ )
private fun getSmallClockStartPadding() =
- appContext.resources.getDimensionPixelSize(R.dimen.clock_padding_start)
+ appContext.resources.getDimensionPixelSize(
+ com.android.systemui.customization.R.dimen.clock_padding_start
+ )
override fun updateColorForAllClocks(@ColorInt seedColor: Int?) {
clockControllers.values.forEach { it.events.onSeedColorChanged(seedColor = seedColor) }
@@ -169,14 +175,22 @@
// Initialize large clock
controller.largeClock.events.onRegionDarknessChanged(isWallpaperDark)
controller.largeClock.events.onFontSettingChanged(
- resources.getDimensionPixelSize(R.dimen.large_clock_text_size).toFloat()
+ resources
+ .getDimensionPixelSize(
+ com.android.systemui.customization.R.dimen.large_clock_text_size
+ )
+ .toFloat()
)
controller.largeClock.events.onTargetRegionChanged(getLargeClockRegion())
// Initialize small clock
controller.smallClock.events.onRegionDarknessChanged(isWallpaperDark)
controller.smallClock.events.onFontSettingChanged(
- resources.getDimensionPixelSize(R.dimen.small_clock_text_size).toFloat()
+ resources
+ .getDimensionPixelSize(
+ com.android.systemui.customization.R.dimen.small_clock_text_size
+ )
+ .toFloat()
)
controller.smallClock.events.onTargetRegionChanged(getSmallClockRegion())
@@ -204,8 +218,13 @@
*/
private fun getLargeClockRegion(): Rect {
val largeClockTopMargin =
- resources.getDimensionPixelSize(R.dimen.keyguard_large_clock_top_margin)
- val targetHeight = resources.getDimensionPixelSize(R.dimen.large_clock_text_size) * 2
+ resources.getDimensionPixelSize(
+ com.android.systemui.customization.R.dimen.keyguard_large_clock_top_margin
+ )
+ val targetHeight =
+ resources.getDimensionPixelSize(
+ com.android.systemui.customization.R.dimen.large_clock_text_size
+ ) * 2
val top = (screenSize.y / 2 - targetHeight / 2 + largeClockTopMargin / 2)
return Rect(0, top, screenSize.x, (top + targetHeight))
}
@@ -217,7 +236,10 @@
*/
private fun getSmallClockRegion(): Rect {
val topMargin = getSmallClockTopMargin()
- val targetHeight = resources.getDimensionPixelSize(R.dimen.small_clock_height)
+ val targetHeight =
+ resources.getDimensionPixelSize(
+ com.android.systemui.customization.R.dimen.small_clock_height
+ )
return Rect(getSmallClockStartPadding(), topMargin, screenSize.x, topMargin + targetHeight)
}
diff --git a/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModel.kt b/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModel.kt
index 3f6394b..28f58c4 100644
--- a/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModel.kt
+++ b/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModel.kt
@@ -24,7 +24,7 @@
import com.android.customization.picker.clock.domain.interactor.ClockPickerInteractor
import com.android.customization.picker.clock.shared.ClockSize
import com.android.customization.picker.clock.ui.view.ClockViewFactory
-import com.android.wallpaper.R
+import com.android.themepicker.R
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job
@@ -33,6 +33,7 @@
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.flatMapLatest
+import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.flow.mapNotNull
@@ -65,6 +66,10 @@
ClockCarouselItemViewModel(it.clockId, it.isSelected, contentDescription)
}
}
+ // makes sure that the operations above this statement are executed on I/O dispatcher
+ // while parallelism limits the number of threads this can run on which makes sure that
+ // the flows run sequentially
+ .flowOn(backgroundDispatcher.limitedParallelism(1))
.stateIn(viewModelScope, SharingStarted.Eagerly, emptyList())
val selectedClockSize: Flow<ClockSize> = interactor.selectedClockSize
@@ -78,24 +83,24 @@
if (seedColor == null) {
if (isDarkThemeEnabled) {
// In dark mode, use darkest surface container color
- R.color.system_surface_container_high
+ com.android.wallpaper.R.color.system_surface_container_high
} else {
// In light mode, use lightest surface container color
- R.color.system_surface_bright
+ com.android.wallpaper.R.color.system_surface_bright
}
} else {
val luminance = Color.luminance(seedColor)
if (isDarkThemeEnabled) {
if (luminance <= CARD_COLOR_CHANGE_LUMINANCE_THRESHOLD_DARK_THEME) {
- R.color.system_surface_bright
+ com.android.wallpaper.R.color.system_surface_bright
} else {
- R.color.system_surface_container_high
+ com.android.wallpaper.R.color.system_surface_container_high
}
} else {
if (luminance <= CARD_COLOR_CHANGE_LUMINANCE_THRESHOLD_LIGHT_THEME) {
- R.color.system_surface_bright
+ com.android.wallpaper.R.color.system_surface_bright
} else {
- R.color.system_surface_container_highest
+ com.android.wallpaper.R.color.system_surface_container_highest
}
}
}
diff --git a/src/com/android/customization/picker/clock/ui/viewmodel/ClockColorViewModel.kt b/src/com/android/customization/picker/clock/ui/viewmodel/ClockColorViewModel.kt
index 9d622da..6e6944d 100644
--- a/src/com/android/customization/picker/clock/ui/viewmodel/ClockColorViewModel.kt
+++ b/src/com/android/customization/picker/clock/ui/viewmodel/ClockColorViewModel.kt
@@ -19,7 +19,7 @@
import android.annotation.ColorInt
import android.content.res.Resources
import android.graphics.Color
-import com.android.wallpaper.R
+import com.android.themepicker.R
/** The view model that defines custom clock colors. */
data class ClockColorViewModel(
diff --git a/src/com/android/customization/picker/clock/ui/viewmodel/ClockSettingsViewModel.kt b/src/com/android/customization/picker/clock/ui/viewmodel/ClockSettingsViewModel.kt
index d0e4f8f..2a93f27 100644
--- a/src/com/android/customization/picker/clock/ui/viewmodel/ClockSettingsViewModel.kt
+++ b/src/com/android/customization/picker/clock/ui/viewmodel/ClockSettingsViewModel.kt
@@ -31,7 +31,7 @@
import com.android.customization.picker.color.shared.model.ColorOptionModel
import com.android.customization.picker.color.shared.model.ColorType
import com.android.customization.picker.color.ui.viewmodel.ColorOptionIconViewModel
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.picker.common.text.ui.viewmodel.Text
import com.android.wallpaper.picker.option.ui.viewmodel.OptionItemViewModel
import kotlinx.coroutines.ExperimentalCoroutinesApi
diff --git a/src/com/android/customization/picker/color/ui/adapter/ColorTypeTabAdapter.kt b/src/com/android/customization/picker/color/ui/adapter/ColorTypeTabAdapter.kt
index 553f586..62cf62a 100644
--- a/src/com/android/customization/picker/color/ui/adapter/ColorTypeTabAdapter.kt
+++ b/src/com/android/customization/picker/color/ui/adapter/ColorTypeTabAdapter.kt
@@ -23,7 +23,7 @@
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.android.customization.picker.color.ui.viewmodel.ColorTypeTabViewModel
-import com.android.wallpaper.R
+import com.android.themepicker.R
/** Adapts between color type items and views. */
class ColorTypeTabAdapter : RecyclerView.Adapter<ColorTypeTabAdapter.ViewHolder>() {
diff --git a/src/com/android/customization/picker/color/ui/binder/ColorPickerBinder.kt b/src/com/android/customization/picker/color/ui/binder/ColorPickerBinder.kt
index 9838c31..7b5b598 100644
--- a/src/com/android/customization/picker/color/ui/binder/ColorPickerBinder.kt
+++ b/src/com/android/customization/picker/color/ui/binder/ColorPickerBinder.kt
@@ -33,7 +33,7 @@
import com.android.customization.picker.color.ui.viewmodel.ColorOptionIconViewModel
import com.android.customization.picker.color.ui.viewmodel.ColorPickerViewModel
import com.android.customization.picker.common.ui.view.ItemSpacing
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.picker.option.ui.adapter.OptionItemAdapter
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
diff --git a/src/com/android/customization/picker/color/ui/binder/ColorSectionViewBinder.kt b/src/com/android/customization/picker/color/ui/binder/ColorSectionViewBinder.kt
index ad81614..c2dc381 100644
--- a/src/com/android/customization/picker/color/ui/binder/ColorSectionViewBinder.kt
+++ b/src/com/android/customization/picker/color/ui/binder/ColorSectionViewBinder.kt
@@ -29,7 +29,7 @@
import androidx.lifecycle.repeatOnLifecycle
import com.android.customization.picker.color.ui.viewmodel.ColorOptionIconViewModel
import com.android.customization.picker.color.ui.viewmodel.ColorPickerViewModel
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.picker.common.icon.ui.viewbinder.ContentDescriptionViewBinder
import com.android.wallpaper.picker.option.ui.viewmodel.OptionItemViewModel
import kotlinx.coroutines.launch
@@ -99,11 +99,7 @@
LayoutInflater.from(view.context)
.inflate(R.layout.color_option_no_background, view, false)
item.payload?.let {
- ColorOptionIconBinder.bind(
- itemView.requireViewById(R.id.option_tile),
- item.payload,
- night
- )
+ ColorOptionIconBinder.bind(itemView.requireViewById(R.id.option_tile), it, night)
ContentDescriptionViewBinder.bind(
view = itemView.requireViewById(R.id.option_tile),
viewModel = item.text,
diff --git a/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt b/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt
index 2c00609..d6c728e 100644
--- a/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt
+++ b/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt
@@ -32,7 +32,7 @@
import com.android.customization.model.mode.DarkModeSectionController
import com.android.customization.module.ThemePickerInjector
import com.android.customization.picker.color.ui.binder.ColorPickerBinder
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.module.CustomizationSections
import com.android.wallpaper.module.InjectorProvider
import com.android.wallpaper.picker.AppbarFragment
@@ -108,7 +108,8 @@
authority =
requireContext()
.getString(
- R.string.lock_screen_preview_provider_authority,
+ com.android.wallpaper.R.string
+ .lock_screen_preview_provider_authority,
),
),
wallpaperInfoProvider = { forceReload ->
@@ -159,7 +160,7 @@
authorityMetadataKey =
requireContext()
.getString(
- R.string.grid_control_metadata_name,
+ com.android.wallpaper.R.string.grid_control_metadata_name,
),
),
wallpaperInfoProvider = { forceReload ->
@@ -203,7 +204,7 @@
context,
lifecycle,
injector.getDarkModeSnapshotRestorer(requireContext()),
- injector.getUserEventLogger(requireContext()),
+ injector.getUserEventLogger(),
)
.createView(requireContext())
darkModeSectionView.background = null
@@ -255,6 +256,9 @@
}
override fun getToolbarTextColor(): Int {
- return ContextCompat.getColor(requireContext(), R.color.system_on_surface)
+ return ContextCompat.getColor(
+ requireContext(),
+ com.android.wallpaper.R.color.system_on_surface
+ )
}
}
diff --git a/src/com/android/customization/picker/color/ui/section/ColorSectionController.kt b/src/com/android/customization/picker/color/ui/section/ColorSectionController.kt
index a36fd80..646d8ac 100644
--- a/src/com/android/customization/picker/color/ui/section/ColorSectionController.kt
+++ b/src/com/android/customization/picker/color/ui/section/ColorSectionController.kt
@@ -24,7 +24,7 @@
import com.android.customization.picker.color.ui.fragment.ColorPickerFragment
import com.android.customization.picker.color.ui.view.ColorSectionView
import com.android.customization.picker.color.ui.viewmodel.ColorPickerViewModel
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.model.CustomizationSectionController
import com.android.wallpaper.model.CustomizationSectionController.CustomizationSectionNavigationController as NavigationController
diff --git a/src/com/android/customization/picker/color/ui/viewmodel/ColorPickerViewModel.kt b/src/com/android/customization/picker/color/ui/viewmodel/ColorPickerViewModel.kt
index ed83136..32e9362 100644
--- a/src/com/android/customization/picker/color/ui/viewmodel/ColorPickerViewModel.kt
+++ b/src/com/android/customization/picker/color/ui/viewmodel/ColorPickerViewModel.kt
@@ -24,7 +24,7 @@
import com.android.customization.module.logging.ThemesUserEventLogger
import com.android.customization.picker.color.domain.interactor.ColorPickerInteractor
import com.android.customization.picker.color.shared.model.ColorType
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.picker.common.text.ui.viewmodel.Text
import com.android.wallpaper.picker.option.ui.viewmodel.OptionItemViewModel
import kotlin.math.max
diff --git a/src/com/android/customization/picker/grid/ui/binder/GridScreenBinder.kt b/src/com/android/customization/picker/grid/ui/binder/GridScreenBinder.kt
index bcb3737..9948dee 100644
--- a/src/com/android/customization/picker/grid/ui/binder/GridScreenBinder.kt
+++ b/src/com/android/customization/picker/grid/ui/binder/GridScreenBinder.kt
@@ -29,7 +29,7 @@
import com.android.customization.picker.common.ui.view.ItemSpacing
import com.android.customization.picker.grid.ui.viewmodel.GridIconViewModel
import com.android.customization.picker.grid.ui.viewmodel.GridScreenViewModel
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.picker.option.ui.adapter.OptionItemAdapter
import com.android.wallpaper.picker.option.ui.binder.OptionItemBinder
import kotlinx.coroutines.CoroutineDispatcher
@@ -45,7 +45,7 @@
isGridApplyButtonEnabled: Boolean,
onOptionApplied: () -> Unit,
) {
- val optionView: RecyclerView = view.requireViewById(R.id.options)
+ val optionView: RecyclerView = view.requireViewById(com.android.wallpaper.R.id.options)
optionView.layoutManager =
LinearLayoutManager(
view.context,
@@ -60,8 +60,10 @@
backgroundDispatcher = backgroundDispatcher,
foregroundTintSpec =
OptionItemBinder.TintSpec(
- selectedColor = view.context.getColor(R.color.system_on_surface),
- unselectedColor = view.context.getColor(R.color.system_on_surface),
+ selectedColor =
+ view.context.getColor(com.android.wallpaper.R.color.system_on_surface),
+ unselectedColor =
+ view.context.getColor(com.android.wallpaper.R.color.system_on_surface),
),
bindIcon = { foregroundView: View, gridIcon: GridIconViewModel ->
val imageView = foregroundView as? ImageView
diff --git a/src/com/android/customization/picker/grid/ui/fragment/GridFragment.kt b/src/com/android/customization/picker/grid/ui/fragment/GridFragment.kt
index 2a301b4..74b88db 100644
--- a/src/com/android/customization/picker/grid/ui/fragment/GridFragment.kt
+++ b/src/com/android/customization/picker/grid/ui/fragment/GridFragment.kt
@@ -34,7 +34,7 @@
import com.android.customization.picker.grid.domain.interactor.GridInteractor
import com.android.customization.picker.grid.ui.binder.GridScreenBinder
import com.android.customization.picker.grid.ui.viewmodel.GridScreenViewModel
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.config.BaseFlags
import com.android.wallpaper.module.CurrentWallpaperInfoFactory
import com.android.wallpaper.module.CustomizationSections
@@ -154,7 +154,10 @@
}
override fun getToolbarTextColor(): Int {
- return ContextCompat.getColor(requireContext(), R.color.system_on_surface)
+ return ContextCompat.getColor(
+ requireContext(),
+ com.android.wallpaper.R.color.system_on_surface
+ )
}
private fun bindScreenPreview(
@@ -174,7 +177,7 @@
authorityMetadataKey =
requireContext()
.getString(
- R.string.grid_control_metadata_name,
+ com.android.wallpaper.R.string.grid_control_metadata_name,
),
),
initialExtrasProvider = {
diff --git a/src/com/android/customization/picker/grid/ui/section/GridSectionController.java b/src/com/android/customization/picker/grid/ui/section/GridSectionController.java
index 6ae9acd..0e15609 100644
--- a/src/com/android/customization/picker/grid/ui/section/GridSectionController.java
+++ b/src/com/android/customization/picker/grid/ui/section/GridSectionController.java
@@ -31,7 +31,7 @@
import com.android.customization.model.grid.GridOptionsManager;
import com.android.customization.picker.grid.ui.fragment.GridFragment;
import com.android.customization.picker.grid.ui.view.GridSectionView;
-import com.android.wallpaper.R;
+import com.android.themepicker.R;
import com.android.wallpaper.model.CustomizationSectionController;
import java.util.List;
diff --git a/src/com/android/customization/picker/mode/DarkModeSectionView.java b/src/com/android/customization/picker/mode/DarkModeSectionView.java
index 6fc0a57..803fb0e 100644
--- a/src/com/android/customization/picker/mode/DarkModeSectionView.java
+++ b/src/com/android/customization/picker/mode/DarkModeSectionView.java
@@ -22,7 +22,7 @@
import androidx.annotation.Nullable;
-import com.android.wallpaper.R;
+import com.android.themepicker.R;
import com.android.wallpaper.picker.SectionView;
/** The view of section in the customization picker fragment. */
diff --git a/src/com/android/customization/picker/notifications/data/repository/NotificationsRepository.kt b/src/com/android/customization/picker/notifications/data/repository/NotificationsRepository.kt
deleted file mode 100644
index c75ddce..0000000
--- a/src/com/android/customization/picker/notifications/data/repository/NotificationsRepository.kt
+++ /dev/null
@@ -1,74 +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.customization.picker.notifications.data.repository
-
-import android.provider.Settings
-import com.android.customization.picker.notifications.shared.model.NotificationSettingsModel
-import com.android.wallpaper.settings.data.repository.SecureSettingsRepository
-import kotlinx.coroutines.CoroutineDispatcher
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.flow.SharedFlow
-import kotlinx.coroutines.flow.SharingStarted
-import kotlinx.coroutines.flow.map
-import kotlinx.coroutines.flow.shareIn
-import kotlinx.coroutines.withContext
-
-/** Provides access to state related to notifications. */
-class NotificationsRepository(
- scope: CoroutineScope,
- private val backgroundDispatcher: CoroutineDispatcher,
- private val secureSettingsRepository: SecureSettingsRepository,
-) {
- /** The current state of the notification setting. */
- val settings: SharedFlow<NotificationSettingsModel> =
- secureSettingsRepository
- .intSetting(
- name = Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
- )
- .map { lockScreenShowNotificationsInt ->
- NotificationSettingsModel(
- isShowNotificationsOnLockScreenEnabled = lockScreenShowNotificationsInt == 1,
- )
- }
- .shareIn(
- scope = scope,
- started = SharingStarted.WhileSubscribed(),
- replay = 1,
- )
-
- suspend fun getSettings(): NotificationSettingsModel {
- return withContext(backgroundDispatcher) {
- NotificationSettingsModel(
- isShowNotificationsOnLockScreenEnabled =
- secureSettingsRepository.get(
- name = Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
- defaultValue = 0,
- ) == 1
- )
- }
- }
-
- suspend fun setSettings(model: NotificationSettingsModel) {
- withContext(backgroundDispatcher) {
- secureSettingsRepository.set(
- name = Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
- value = if (model.isShowNotificationsOnLockScreenEnabled) 1 else 0,
- )
- }
- }
-}
diff --git a/src/com/android/customization/picker/notifications/domain/interactor/NotificationsInteractor.kt b/src/com/android/customization/picker/notifications/domain/interactor/NotificationsInteractor.kt
deleted file mode 100644
index 1f892f0..0000000
--- a/src/com/android/customization/picker/notifications/domain/interactor/NotificationsInteractor.kt
+++ /dev/null
@@ -1,52 +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.customization.picker.notifications.domain.interactor
-
-import com.android.customization.picker.notifications.data.repository.NotificationsRepository
-import com.android.customization.picker.notifications.shared.model.NotificationSettingsModel
-import javax.inject.Provider
-import kotlinx.coroutines.flow.Flow
-
-/** Encapsulates business logic for interacting with notifications. */
-class NotificationsInteractor(
- private val repository: NotificationsRepository,
- private val snapshotRestorer: Provider<NotificationsSnapshotRestorer>,
-) {
- /** The current state of the notification setting. */
- val settings: Flow<NotificationSettingsModel> = repository.settings
-
- /** Toggles the setting to show or hide notifications on the lock screen. */
- suspend fun toggleShowNotificationsOnLockScreenEnabled() {
- val currentModel = repository.getSettings()
- setSettings(
- currentModel.copy(
- isShowNotificationsOnLockScreenEnabled =
- !currentModel.isShowNotificationsOnLockScreenEnabled,
- )
- )
- }
-
- suspend fun setSettings(model: NotificationSettingsModel) {
- repository.setSettings(model)
- snapshotRestorer.get().storeSnapshot(model)
- }
-
- suspend fun getSettings(): NotificationSettingsModel {
- return repository.getSettings()
- }
-}
diff --git a/src/com/android/customization/picker/notifications/domain/interactor/NotificationsSnapshotRestorer.kt b/src/com/android/customization/picker/notifications/domain/interactor/NotificationsSnapshotRestorer.kt
index c782b74..09d2d29 100644
--- a/src/com/android/customization/picker/notifications/domain/interactor/NotificationsSnapshotRestorer.kt
+++ b/src/com/android/customization/picker/notifications/domain/interactor/NotificationsSnapshotRestorer.kt
@@ -12,24 +12,27 @@
* 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.customization.picker.notifications.domain.interactor
-import com.android.customization.picker.notifications.shared.model.NotificationSettingsModel
+import com.android.systemui.shared.notifications.domain.interactor.NotificationSettingsInteractor
+import com.android.wallpaper.picker.di.modules.BackgroundDispatcher
import com.android.wallpaper.picker.undo.domain.interactor.SnapshotRestorer
import com.android.wallpaper.picker.undo.domain.interactor.SnapshotStore
import com.android.wallpaper.picker.undo.shared.model.RestorableSnapshot
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.launch
/** Handles state restoration for notification settings. */
class NotificationsSnapshotRestorer(
- private val interactor: NotificationsInteractor,
+ private val interactor: NotificationSettingsInteractor,
+ @BackgroundDispatcher private val backgroundScope: CoroutineScope,
) : SnapshotRestorer {
private var snapshotStore: SnapshotStore = SnapshotStore.NOOP
- fun storeSnapshot(model: NotificationSettingsModel) {
+ private fun storeSnapshot(model: NotificationSnapshotModel) {
snapshotStore.store(snapshot(model))
}
@@ -37,20 +40,25 @@
store: SnapshotStore,
): RestorableSnapshot {
snapshotStore = store
- return snapshot(interactor.getSettings())
+ backgroundScope.launch {
+ interactor.isShowNotificationsOnLockScreenEnabled.collect {
+ storeSnapshot(
+ NotificationSnapshotModel(isShowNotificationsOnLockScreenEnabled = it)
+ )
+ }
+ }
+ return snapshot(
+ NotificationSnapshotModel(interactor.isShowNotificationsOnLockScreenEnabled.value)
+ )
}
override suspend fun restoreToSnapshot(snapshot: RestorableSnapshot) {
val isShowNotificationsOnLockScreenEnabled =
snapshot.args[KEY_IS_SHOW_NOTIFICATIONS_ON_LOCK_SCREEN_ENABLED]?.toBoolean() ?: false
- interactor.setSettings(
- NotificationSettingsModel(
- isShowNotificationsOnLockScreenEnabled = isShowNotificationsOnLockScreenEnabled,
- )
- )
+ interactor.setShowNotificationsOnLockscreenEnabled(isShowNotificationsOnLockScreenEnabled)
}
- private fun snapshot(model: NotificationSettingsModel): RestorableSnapshot {
+ private fun snapshot(model: NotificationSnapshotModel): RestorableSnapshot {
return RestorableSnapshot(
mapOf(
KEY_IS_SHOW_NOTIFICATIONS_ON_LOCK_SCREEN_ENABLED to
@@ -64,3 +72,9 @@
"is_show_notifications_on_lock_screen_enabled"
}
}
+
+/** Snapshot of notification settings relevant to the theme picker. */
+private data class NotificationSnapshotModel(
+ /** Whether notifications are shown on the lock screen. */
+ val isShowNotificationsOnLockScreenEnabled: Boolean = false,
+)
diff --git a/src/com/android/customization/picker/notifications/shared/model/NotificationSettingsModel.kt b/src/com/android/customization/picker/notifications/shared/model/NotificationSettingsModel.kt
deleted file mode 100644
index 7ce388b..0000000
--- a/src/com/android/customization/picker/notifications/shared/model/NotificationSettingsModel.kt
+++ /dev/null
@@ -1,24 +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.customization.picker.notifications.shared.model
-
-/** Models notification settings. */
-data class NotificationSettingsModel(
- /** Whether notifications are shown on the lock screen. */
- val isShowNotificationsOnLockScreenEnabled: Boolean = false,
-)
diff --git a/src/com/android/customization/picker/notifications/ui/binder/NotificationSectionBinder.kt b/src/com/android/customization/picker/notifications/ui/binder/NotificationSectionBinder.kt
index 1868a4e..8f2727c 100644
--- a/src/com/android/customization/picker/notifications/ui/binder/NotificationSectionBinder.kt
+++ b/src/com/android/customization/picker/notifications/ui/binder/NotificationSectionBinder.kt
@@ -25,7 +25,7 @@
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.android.customization.picker.notifications.ui.viewmodel.NotificationSectionViewModel
-import com.android.wallpaper.R
+import com.android.themepicker.R
import kotlinx.coroutines.launch
/**
diff --git a/src/com/android/customization/picker/notifications/ui/section/NotificationSectionController.kt b/src/com/android/customization/picker/notifications/ui/section/NotificationSectionController.kt
index d35c382..15deb00 100644
--- a/src/com/android/customization/picker/notifications/ui/section/NotificationSectionController.kt
+++ b/src/com/android/customization/picker/notifications/ui/section/NotificationSectionController.kt
@@ -24,7 +24,7 @@
import com.android.customization.picker.notifications.ui.binder.NotificationSectionBinder
import com.android.customization.picker.notifications.ui.view.NotificationSectionView
import com.android.customization.picker.notifications.ui.viewmodel.NotificationSectionViewModel
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.model.CustomizationSectionController
/** Controls a section with UI that lets the user toggle notification settings. */
diff --git a/src/com/android/customization/picker/notifications/ui/viewmodel/NotificationSectionViewModel.kt b/src/com/android/customization/picker/notifications/ui/viewmodel/NotificationSectionViewModel.kt
index 1a5254f..5db7626 100644
--- a/src/com/android/customization/picker/notifications/ui/viewmodel/NotificationSectionViewModel.kt
+++ b/src/com/android/customization/picker/notifications/ui/viewmodel/NotificationSectionViewModel.kt
@@ -22,35 +22,33 @@
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import com.android.customization.module.logging.ThemesUserEventLogger
-import com.android.customization.picker.notifications.domain.interactor.NotificationsInteractor
+import com.android.systemui.shared.notifications.domain.interactor.NotificationSettingsInteractor
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
/** Models UI state for a section that lets the user control the notification settings. */
class NotificationSectionViewModel
@VisibleForTesting
constructor(
- private val interactor: NotificationsInteractor,
+ private val interactor: NotificationSettingsInteractor,
private val logger: ThemesUserEventLogger,
) : ViewModel() {
/** Whether the switch should be on. */
- val isSwitchOn: Flow<Boolean> =
- interactor.settings.map { model -> model.isShowNotificationsOnLockScreenEnabled }
+ val isSwitchOn: Flow<Boolean> = interactor.isShowNotificationsOnLockScreenEnabled
/** Notifies that the section has been clicked. */
fun onClicked() {
viewModelScope.launch {
- interactor.toggleShowNotificationsOnLockScreenEnabled()
+ interactor.toggleShowNotificationsOnLockscreenEnabled()
logger.logLockScreenNotificationApplied(
- interactor.getSettings().isShowNotificationsOnLockScreenEnabled
+ interactor.isShowNotificationsOnLockScreenEnabled.value
)
}
}
class Factory(
- private val interactor: NotificationsInteractor,
+ private val interactor: NotificationSettingsInteractor,
private val logger: ThemesUserEventLogger,
) : ViewModelProvider.Factory {
@Suppress("UNCHECKED_CAST")
diff --git a/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt b/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
index eb25af7..c434ce3 100644
--- a/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
+++ b/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
@@ -39,7 +39,7 @@
import com.android.customization.picker.clock.ui.view.ClockViewFactory
import com.android.customization.picker.clock.ui.viewmodel.ClockCarouselViewModel
import com.android.customization.picker.color.domain.interactor.ColorPickerInteractor
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.model.CustomizationSectionController
import com.android.wallpaper.model.CustomizationSectionController.CustomizationSectionNavigationController
import com.android.wallpaper.model.WallpaperPreviewNavigator
@@ -111,9 +111,9 @@
val view = super.createView(context, params)
if (screen == CustomizationSections.Screen.LOCK_SCREEN) {
val screenPreviewClickView: ScreenPreviewClickView =
- view.requireViewById(R.id.screen_preview_click_view)
+ view.requireViewById(com.android.wallpaper.R.id.screen_preview_click_view)
val clockColorAndSizeButtonStub: ViewStub =
- view.requireViewById(R.id.clock_color_and_size_button)
+ view.requireViewById(com.android.wallpaper.R.id.clock_color_and_size_button)
clockColorAndSizeButtonStub.layoutResource = R.layout.clock_color_and_size_button
clockColorAndSizeButton = clockColorAndSizeButtonStub.inflate() as View
clockColorAndSizeButton?.setOnClickListener {
@@ -127,14 +127,17 @@
val padding =
context
.getResources()
- .getDimensionPixelSize(R.dimen.screen_preview_section_vertical_space)
+ .getDimensionPixelSize(
+ com.android.wallpaper.R.dimen.screen_preview_section_vertical_space
+ )
rect.top -= padding
rect.bottom += padding
val touchDelegate = TouchDelegate(rect, clockColorAndSizeButton)
view.setTouchDelegate(touchDelegate)
}
- val carouselViewStub: ViewStub = view.requireViewById(R.id.clock_carousel_view_stub)
+ val carouselViewStub: ViewStub =
+ view.requireViewById(com.android.wallpaper.R.id.clock_carousel_view_stub)
carouselViewStub.layoutResource = R.layout.clock_carousel_view
val carouselView = carouselViewStub.inflate() as ClockCarouselView
diff --git a/src/com/android/customization/picker/quickaffordance/ui/adapter/SlotTabAdapter.kt b/src/com/android/customization/picker/quickaffordance/ui/adapter/SlotTabAdapter.kt
index 0e3b716..fb2462f 100644
--- a/src/com/android/customization/picker/quickaffordance/ui/adapter/SlotTabAdapter.kt
+++ b/src/com/android/customization/picker/quickaffordance/ui/adapter/SlotTabAdapter.kt
@@ -23,7 +23,7 @@
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.android.customization.picker.quickaffordance.ui.viewmodel.KeyguardQuickAffordanceSlotViewModel
-import com.android.wallpaper.R
+import com.android.themepicker.R
/** Adapts between lock screen quick affordance slot items and views. */
class SlotTabAdapter : RecyclerView.Adapter<SlotTabAdapter.ViewHolder>() {
diff --git a/src/com/android/customization/picker/quickaffordance/ui/binder/KeyguardQuickAffordancePickerBinder.kt b/src/com/android/customization/picker/quickaffordance/ui/binder/KeyguardQuickAffordancePickerBinder.kt
index 3ac52ad..3b583f3 100644
--- a/src/com/android/customization/picker/quickaffordance/ui/binder/KeyguardQuickAffordancePickerBinder.kt
+++ b/src/com/android/customization/picker/quickaffordance/ui/binder/KeyguardQuickAffordancePickerBinder.kt
@@ -34,7 +34,7 @@
import com.android.customization.picker.common.ui.view.ItemSpacing
import com.android.customization.picker.quickaffordance.ui.adapter.SlotTabAdapter
import com.android.customization.picker.quickaffordance.ui.viewmodel.KeyguardQuickAffordancePickerViewModel
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.picker.common.dialog.ui.viewbinder.DialogViewBinder
import com.android.wallpaper.picker.common.dialog.ui.viewmodel.DialogViewModel
import com.android.wallpaper.picker.common.icon.ui.viewbinder.IconViewBinder
diff --git a/src/com/android/customization/picker/quickaffordance/ui/binder/KeyguardQuickAffordanceSectionViewBinder.kt b/src/com/android/customization/picker/quickaffordance/ui/binder/KeyguardQuickAffordanceSectionViewBinder.kt
index 7e1f4d3..b771fb7 100644
--- a/src/com/android/customization/picker/quickaffordance/ui/binder/KeyguardQuickAffordanceSectionViewBinder.kt
+++ b/src/com/android/customization/picker/quickaffordance/ui/binder/KeyguardQuickAffordanceSectionViewBinder.kt
@@ -26,7 +26,7 @@
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import com.android.customization.picker.quickaffordance.ui.viewmodel.KeyguardQuickAffordancePickerViewModel
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.picker.common.icon.ui.viewbinder.IconViewBinder
import com.android.wallpaper.picker.common.text.ui.viewbinder.TextViewBinder
import kotlinx.coroutines.flow.collectLatest
diff --git a/src/com/android/customization/picker/quickaffordance/ui/fragment/KeyguardQuickAffordancePickerFragment.kt b/src/com/android/customization/picker/quickaffordance/ui/fragment/KeyguardQuickAffordancePickerFragment.kt
index 467e5a0..fd79ca5 100644
--- a/src/com/android/customization/picker/quickaffordance/ui/fragment/KeyguardQuickAffordancePickerFragment.kt
+++ b/src/com/android/customization/picker/quickaffordance/ui/fragment/KeyguardQuickAffordancePickerFragment.kt
@@ -31,7 +31,7 @@
import com.android.customization.picker.quickaffordance.ui.binder.KeyguardQuickAffordancePickerBinder
import com.android.customization.picker.quickaffordance.ui.binder.KeyguardQuickAffordancePreviewBinder
import com.android.customization.picker.quickaffordance.ui.viewmodel.KeyguardQuickAffordancePickerViewModel
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.module.InjectorProvider
import com.android.wallpaper.picker.AppbarFragment
@@ -97,6 +97,9 @@
}
override fun getToolbarTextColor(): Int {
- return ContextCompat.getColor(requireContext(), R.color.system_on_surface)
+ return ContextCompat.getColor(
+ requireContext(),
+ com.android.wallpaper.R.color.system_on_surface
+ )
}
}
diff --git a/src/com/android/customization/picker/quickaffordance/ui/section/KeyguardQuickAffordanceSectionController.kt b/src/com/android/customization/picker/quickaffordance/ui/section/KeyguardQuickAffordanceSectionController.kt
index 0c7b250..52bbb0c 100644
--- a/src/com/android/customization/picker/quickaffordance/ui/section/KeyguardQuickAffordanceSectionController.kt
+++ b/src/com/android/customization/picker/quickaffordance/ui/section/KeyguardQuickAffordanceSectionController.kt
@@ -24,7 +24,7 @@
import com.android.customization.picker.quickaffordance.ui.fragment.KeyguardQuickAffordancePickerFragment
import com.android.customization.picker.quickaffordance.ui.view.KeyguardQuickAffordanceSectionView
import com.android.customization.picker.quickaffordance.ui.viewmodel.KeyguardQuickAffordancePickerViewModel
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.config.BaseFlags
import com.android.wallpaper.model.CustomizationSectionController
import com.android.wallpaper.model.CustomizationSectionController.CustomizationSectionNavigationController as NavigationController
diff --git a/src/com/android/customization/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModel.kt b/src/com/android/customization/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModel.kt
index 260c0d3..97afb7a 100644
--- a/src/com/android/customization/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModel.kt
+++ b/src/com/android/customization/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModel.kt
@@ -30,7 +30,7 @@
import com.android.customization.picker.quickaffordance.domain.interactor.KeyguardQuickAffordancePickerInteractor
import com.android.systemui.shared.keyguard.shared.model.KeyguardQuickAffordanceSlots
import com.android.systemui.shared.quickaffordance.shared.model.KeyguardPreviewConstants
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.module.CurrentWallpaperInfoFactory
import com.android.wallpaper.module.CustomizationSections
import com.android.wallpaper.picker.common.button.ui.viewmodel.ButtonStyle
@@ -76,7 +76,7 @@
context = applicationContext,
authority =
applicationContext.getString(
- R.string.lock_screen_preview_provider_authority,
+ com.android.wallpaper.R.string.lock_screen_preview_provider_authority,
),
),
initialExtrasProvider = {
diff --git a/src/com/android/customization/picker/settings/ui/section/MoreSettingsSectionController.kt b/src/com/android/customization/picker/settings/ui/section/MoreSettingsSectionController.kt
index 5e890cd..7302b0f 100644
--- a/src/com/android/customization/picker/settings/ui/section/MoreSettingsSectionController.kt
+++ b/src/com/android/customization/picker/settings/ui/section/MoreSettingsSectionController.kt
@@ -23,7 +23,7 @@
import android.provider.Settings
import android.view.LayoutInflater
import com.android.customization.picker.settings.ui.view.MoreSettingsSectionView
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.model.CustomizationSectionController
class MoreSettingsSectionController : CustomizationSectionController<MoreSettingsSectionView> {
diff --git a/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java b/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java
index f83da8c..2bbe74e 100644
--- a/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java
+++ b/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java
@@ -21,7 +21,7 @@
import androidx.annotation.Nullable;
-import com.android.wallpaper.R;
+import com.android.themepicker.R;
import com.android.wallpaper.picker.SectionView;
/**
diff --git a/src_override/com/android/wallpaper/module/AppModule.kt b/src_override/com/android/wallpaper/module/AppModule.kt
index 0d80e22..8de80d6 100644
--- a/src_override/com/android/wallpaper/module/AppModule.kt
+++ b/src_override/com/android/wallpaper/module/AppModule.kt
@@ -24,6 +24,8 @@
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.picker.preview.data.util.DefaultLiveWallpaperDownloader
+import com.android.wallpaper.picker.preview.data.util.LiveWallpaperDownloader
import com.android.wallpaper.util.converter.DefaultWallpaperModelFactory
import com.android.wallpaper.util.converter.WallpaperModelFactory
import dagger.Binds
@@ -53,6 +55,12 @@
impl: DefaultWallpaperModelFactory
): WallpaperModelFactory
+ @Binds
+ @Singleton
+ abstract fun bindLiveWallpaperDownloader(
+ impl: DefaultLiveWallpaperDownloader
+ ): LiveWallpaperDownloader
+
companion object {
@Provides
@Singleton
diff --git a/tests/Android.bp b/tests/Android.bp
index 74dc6a1..33f1c3f 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -47,6 +47,7 @@
"WallpaperPicker2TestLib",
"WallpaperPicker2TestRunner",
"ThemePickerTestLib",
+ "SystemUICustomizationTestUtils",
"androidx.test.espresso.core",
"androidx.test.espresso.contrib",
"androidx.test.espresso.intents",
diff --git a/tests/common/Android.bp b/tests/common/Android.bp
index 9215ba6..06c3834 100644
--- a/tests/common/Android.bp
+++ b/tests/common/Android.bp
@@ -23,12 +23,12 @@
android_library {
name: "ThemePickerTestLib",
- defaults: ["ThemePicker_common_defaults"],
srcs: [
"src/**/*.java",
"src/**/*.kt",
],
static_libs: [
+ "ThemePickerLib",
"WallpaperPicker2TestLib",
"androidx.annotation_annotation",
"kotlinx_coroutines_test",
diff --git a/tests/common/src/com/android/customization/testing/TestCustomizationInjector.kt b/tests/common/src/com/android/customization/testing/TestCustomizationInjector.kt
index b0ffcb6..caa5029 100644
--- a/tests/common/src/com/android/customization/testing/TestCustomizationInjector.kt
+++ b/tests/common/src/com/android/customization/testing/TestCustomizationInjector.kt
@@ -4,7 +4,6 @@
import android.content.Context
import android.content.res.Resources
import androidx.activity.ComponentActivity
-import com.android.customization.model.color.ThemedWallpaperColorResources
import com.android.customization.model.color.WallpaperColorResources
import com.android.customization.module.CustomizationInjector
import com.android.customization.module.CustomizationPreferences
@@ -56,7 +55,7 @@
wallpaperColors: WallpaperColors,
context: Context
): WallpaperColorResources {
- return ThemedWallpaperColorResources(wallpaperColors, context)
+ throw UnsupportedOperationException("not implemented")
}
override fun getColorPickerInteractor(
@@ -77,7 +76,6 @@
interactor: ClockPickerInteractor,
clockViewFactory: ClockViewFactory,
resources: Resources,
- logger: ThemesUserEventLogger,
): ClockCarouselViewModel.Factory {
throw UnsupportedOperationException("not implemented")
}
@@ -98,7 +96,7 @@
// TestInjector overrides
/////////////////
- override fun getUserEventLogger(context: Context): UserEventLogger {
+ override fun getUserEventLogger(): UserEventLogger {
return themesUserEventLogger
}
}
diff --git a/tests/module/src/com/android/customization/TestModule.kt b/tests/module/src/com/android/customization/TestModule.kt
index 1ad63a9..4600434 100644
--- a/tests/module/src/com/android/customization/TestModule.kt
+++ b/tests/module/src/com/android/customization/TestModule.kt
@@ -14,6 +14,8 @@
import com.android.wallpaper.module.WallpaperPreferences
import com.android.wallpaper.module.logging.TestUserEventLogger
import com.android.wallpaper.module.logging.UserEventLogger
+import com.android.wallpaper.picker.preview.data.util.DefaultLiveWallpaperDownloader
+import com.android.wallpaper.picker.preview.data.util.LiveWallpaperDownloader
import com.android.wallpaper.testing.TestInjector
import com.android.wallpaper.testing.TestWallpaperPreferences
import com.android.wallpaper.util.converter.DefaultWallpaperModelFactory
@@ -70,6 +72,12 @@
impl: DefaultWallpaperModelFactory
): WallpaperModelFactory
+ @Binds
+ @Singleton
+ abstract fun bindLiveWallpaperDownloader(
+ impl: DefaultLiveWallpaperDownloader
+ ): LiveWallpaperDownloader
+
companion object {
@Provides
@Singleton
diff --git a/tests/robotests/Android.bp b/tests/robotests/Android.bp
index d4dde59..0a0a57f 100644
--- a/tests/robotests/Android.bp
+++ b/tests/robotests/Android.bp
@@ -24,6 +24,8 @@
"junit",
"kotlinx_coroutines_test",
"truth",
+ "SystemUICustomizationTestUtils",
+ "ThemePickerApplicationLib",
],
libs: [
diff --git a/tests/robotests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt b/tests/robotests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt
index b572401..53ade86 100644
--- a/tests/robotests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt
+++ b/tests/robotests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt
@@ -31,7 +31,7 @@
import com.android.systemui.shared.customization.data.content.CustomizationProviderClient
import com.android.systemui.shared.customization.data.content.FakeCustomizationProviderClient
import com.android.systemui.shared.keyguard.shared.model.KeyguardQuickAffordanceSlots
-import com.android.wallpaper.R
+import com.android.themepicker.R
import com.android.wallpaper.module.InjectorProvider
import com.android.wallpaper.picker.common.icon.ui.viewmodel.Icon
import com.android.wallpaper.picker.common.text.ui.viewmodel.Text
diff --git a/tests/robotests/src/com/android/customization/picker/notifications/data/repository/NotificationsRepositoryTest.kt b/tests/robotests/src/com/android/customization/picker/notifications/data/repository/NotificationsRepositoryTest.kt
deleted file mode 100644
index be799db..0000000
--- a/tests/robotests/src/com/android/customization/picker/notifications/data/repository/NotificationsRepositoryTest.kt
+++ /dev/null
@@ -1,94 +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.customization.picker.notifications.data.repository
-
-import android.provider.Settings
-import androidx.test.filters.SmallTest
-import com.android.customization.picker.notifications.shared.model.NotificationSettingsModel
-import com.android.wallpaper.testing.FakeSecureSettingsRepository
-import com.android.wallpaper.testing.collectLastValue
-import com.google.common.truth.Truth.assertThat
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.test.StandardTestDispatcher
-import kotlinx.coroutines.test.TestScope
-import kotlinx.coroutines.test.runTest
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
-
-@OptIn(ExperimentalCoroutinesApi::class)
-@SmallTest
-@RunWith(JUnit4::class)
-class NotificationsRepositoryTest {
-
- private lateinit var underTest: NotificationsRepository
-
- private lateinit var testScope: TestScope
- private lateinit var secureSettingsRepository: FakeSecureSettingsRepository
-
- @Before
- fun setUp() {
- val testDispatcher = StandardTestDispatcher()
- testScope = TestScope(testDispatcher)
- secureSettingsRepository = FakeSecureSettingsRepository()
-
- underTest =
- NotificationsRepository(
- scope = testScope.backgroundScope,
- backgroundDispatcher = testDispatcher,
- secureSettingsRepository = secureSettingsRepository,
- )
- }
-
- @Test
- fun settings() =
- testScope.runTest {
- val settings = collectLastValue(underTest.settings)
-
- secureSettingsRepository.set(
- name = Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
- value = 1,
- )
- assertThat(settings())
- .isEqualTo(NotificationSettingsModel(isShowNotificationsOnLockScreenEnabled = true))
-
- secureSettingsRepository.set(
- name = Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
- value = 0,
- )
- assertThat(settings())
- .isEqualTo(
- NotificationSettingsModel(isShowNotificationsOnLockScreenEnabled = false)
- )
- }
-
- @Test
- fun setSettings() =
- testScope.runTest {
- val settings = collectLastValue(underTest.settings)
-
- val model1 = NotificationSettingsModel(isShowNotificationsOnLockScreenEnabled = true)
- underTest.setSettings(model1)
- assertThat(settings()).isEqualTo(model1)
-
- val model2 = NotificationSettingsModel(isShowNotificationsOnLockScreenEnabled = false)
- underTest.setSettings(model2)
- assertThat(settings()).isEqualTo(model2)
- }
-}
diff --git a/tests/robotests/src/com/android/customization/picker/notifications/ui/viewmodel/NotificationSectionViewModelTest.kt b/tests/robotests/src/com/android/customization/picker/notifications/ui/viewmodel/NotificationSectionViewModelTest.kt
index 1ff1fc8..8966de5 100644
--- a/tests/robotests/src/com/android/customization/picker/notifications/ui/viewmodel/NotificationSectionViewModelTest.kt
+++ b/tests/robotests/src/com/android/customization/picker/notifications/ui/viewmodel/NotificationSectionViewModelTest.kt
@@ -20,16 +20,13 @@
import androidx.test.filters.SmallTest
import com.android.customization.module.logging.TestThemesUserEventLogger
import com.android.customization.module.logging.ThemesUserEventLogger
-import com.android.customization.picker.notifications.data.repository.NotificationsRepository
-import com.android.customization.picker.notifications.domain.interactor.NotificationsInteractor
-import com.android.customization.picker.notifications.domain.interactor.NotificationsSnapshotRestorer
-import com.android.wallpaper.testing.FakeSecureSettingsRepository
-import com.android.wallpaper.testing.FakeSnapshotStore
+import com.android.systemui.shared.notifications.data.repository.NotificationSettingsRepository
+import com.android.systemui.shared.notifications.domain.interactor.NotificationSettingsInteractor
+import com.android.systemui.shared.settings.data.repository.FakeSecureSettingsRepository
import com.android.wallpaper.testing.collectLastValue
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.resetMain
@@ -51,7 +48,7 @@
private lateinit var underTest: NotificationSectionViewModel
private lateinit var testScope: TestScope
- private lateinit var interactor: NotificationsInteractor
+ private lateinit var interactor: NotificationSettingsInteractor
@Before
fun setUp() {
@@ -59,19 +56,13 @@
Dispatchers.setMain(testDispatcher)
testScope = TestScope(testDispatcher)
interactor =
- NotificationsInteractor(
+ NotificationSettingsInteractor(
repository =
- NotificationsRepository(
+ NotificationSettingsRepository(
scope = testScope.backgroundScope,
backgroundDispatcher = testDispatcher,
secureSettingsRepository = FakeSecureSettingsRepository(),
),
- snapshotRestorer = {
- NotificationsSnapshotRestorer(
- interactor = interactor,
- )
- .apply { runBlocking { setUpSnapshotRestorer(FakeSnapshotStore()) } }
- },
)
underTest =