Merge "Add dispatcher module for Hilt injection (2/3)" into udc-qpr-dev
diff --git a/src/com/android/customization/module/DefaultCustomizationSections.java b/src/com/android/customization/module/DefaultCustomizationSections.java
index b408a89..04d331e 100644
--- a/src/com/android/customization/module/DefaultCustomizationSections.java
+++ b/src/com/android/customization/module/DefaultCustomizationSections.java
@@ -122,7 +122,8 @@
wallpaperInteractor,
mThemedIconInteractor,
wallpaperManager,
- isTwoPaneAndSmallWidth)
+ isTwoPaneAndSmallWidth,
+ savedInstanceState)
: new PreviewWithThemeSectionController(
activity,
lifecycleOwner,
@@ -134,7 +135,8 @@
wallpaperInteractor,
mThemedIconInteractor,
wallpaperManager,
- isTwoPaneAndSmallWidth));
+ isTwoPaneAndSmallWidth,
+ savedInstanceState));
sectionControllers.add(
new ConnectedSectionController(
diff --git a/src/com/android/customization/module/StatsLogUserEventLogger.java b/src/com/android/customization/module/StatsLogUserEventLogger.java
index e16f3ee..057234b 100644
--- a/src/com/android/customization/module/StatsLogUserEventLogger.java
+++ b/src/com/android/customization/module/StatsLogUserEventLogger.java
@@ -37,7 +37,6 @@
import static com.android.wallpaper.util.LaunchSourceUtils.WALLPAPER_LAUNCH_SOURCE;
import android.app.WallpaperManager;
-import android.content.Context;
import android.content.Intent;
import android.stats.style.StyleEnums;
import android.text.TextUtils;
@@ -59,85 +58,57 @@
*/
public class StatsLogUserEventLogger extends NoOpUserEventLogger implements ThemesUserEventLogger {
- private final Context mContext;
private final WallpaperPreferences mPreferences;
private final WallpaperStatusChecker mWallpaperStatusChecker;
public StatsLogUserEventLogger(
- Context appContext,
WallpaperPreferences preferences,
WallpaperStatusChecker wallpaperStatusChecker) {
- mContext = appContext;
mPreferences = preferences;
mWallpaperStatusChecker = wallpaperStatusChecker;
}
@Override
public void logAppLaunched(Intent launchSource) {
- new SysUiStatsLogger()
- .setAction(STYLE_UICHANGED__ACTION__APP_LAUNCHED)
+ new SysUiStatsLogger(STYLE_UICHANGED__ACTION__APP_LAUNCHED)
.setLaunchedPreference(getAppLaunchSource(launchSource))
.log();
}
@Override
public void logResumed(boolean provisioned, boolean wallpaper) {
- new SysUiStatsLogger()
- .setAction(StyleEnums.ONRESUME)
+ new SysUiStatsLogger(StyleEnums.ONRESUME)
.log();
}
@Override
public void logStopped() {
- new SysUiStatsLogger()
- .setAction(StyleEnums.ONSTOP)
+ new SysUiStatsLogger(StyleEnums.ONSTOP)
.log();
}
@Override
public void logActionClicked(String collectionId, int actionLabelResId) {
- new SysUiStatsLogger()
- .setAction(StyleEnums.WALLPAPER_EXPLORE)
+ new SysUiStatsLogger(StyleEnums.WALLPAPER_EXPLORE)
.setWallpaperCategoryHash(getIdHashCode(collectionId))
.log();
}
@Override
public void logIndividualWallpaperSelected(String collectionId) {
- new SysUiStatsLogger()
- .setAction(StyleEnums.WALLPAPER_SELECT)
+ new SysUiStatsLogger(StyleEnums.WALLPAPER_SELECT)
.setWallpaperCategoryHash(getIdHashCode(collectionId))
.log();
}
@Override
public void logCategorySelected(String collectionId) {
- new SysUiStatsLogger()
- .setAction(StyleEnums.WALLPAPER_OPEN_CATEGORY)
+ new SysUiStatsLogger(StyleEnums.WALLPAPER_OPEN_CATEGORY)
.setWallpaperCategoryHash(getIdHashCode(collectionId))
.log();
}
@Override
- public void logLiveWallpaperInfoSelected(String collectionId, @Nullable String wallpaperId) {
- new SysUiStatsLogger()
- .setAction(StyleEnums.LIVE_WALLPAPER_INFO_SELECT)
- .setWallpaperCategoryHash(getIdHashCode(collectionId))
- .setWallpaperIdHash(getIdHashCode(wallpaperId))
- .log();
- }
-
- @Override
- public void logLiveWallpaperCustomizeSelected(String collectionId,
- @Nullable String wallpaperId) {
- new SysUiStatsLogger().setAction(StyleEnums.LIVE_WALLPAPER_CUSTOMIZE_SELECT)
- .setWallpaperCategoryHash(getIdHashCode(collectionId))
- .setWallpaperIdHash(getIdHashCode(wallpaperId))
- .log();
-
- }
-
- @Override
public void logSnapshot() {
final boolean isLockWallpaperSet = mWallpaperStatusChecker.isLockWallpaperSet();
final String homeCollectionId = mPreferences.getHomeWallpaperCollectionId();
@@ -150,7 +121,7 @@
String lockWallpaperId = isLockWallpaperSet ? mPreferences.getLockWallpaperRemoteId()
: homeWallpaperId;
- new SysUiStatsLogger().setAction(StyleEnums.SNAPSHOT)
+ new SysUiStatsLogger(StyleEnums.SNAPSHOT)
.setWallpaperCategoryHash(getIdHashCode(homeCollectionId))
.setWallpaperIdHash(getIdHashCode(homeWallpaperId))
.setLockWallpaperCategoryHash(getIdHashCode(lockCollectionId))
@@ -166,8 +137,7 @@
@Override
public void logWallpaperSet(String collectionId, @Nullable String wallpaperId,
@Nullable String effects) {
- new SysUiStatsLogger()
- .setAction(StyleEnums.WALLPAPER_APPLIED)
+ new SysUiStatsLogger(StyleEnums.WALLPAPER_APPLIED)
.setWallpaperCategoryHash(getIdHashCode(collectionId))
.setWallpaperIdHash(getIdHashCode(wallpaperId))
.setEffectIdHash(getIdHashCode(effects))
@@ -177,8 +147,7 @@
@Override
public void logEffectApply(String effect, @EffectStatus int status, long timeElapsedMillis,
int resultCode) {
- new SysUiStatsLogger()
- .setAction(StyleEnums.WALLPAPER_EFFECT_APPLIED)
+ new SysUiStatsLogger(StyleEnums.WALLPAPER_EFFECT_APPLIED)
.setEffectPreference(status)
.setEffectIdHash(getIdHashCode(effect))
.setTimeElapsed(timeElapsedMillis)
@@ -188,8 +157,7 @@
@Override
public void logEffectProbe(String effect, @EffectStatus int status) {
- new SysUiStatsLogger()
- .setAction(StyleEnums.WALLPAPER_EFFECT_PROBE)
+ new SysUiStatsLogger(StyleEnums.WALLPAPER_EFFECT_PROBE)
.setEffectPreference(status)
.setEffectIdHash(getIdHashCode(effect))
.log();
@@ -203,8 +171,7 @@
@Override
public void logThemeSelected(ThemeBundle theme, boolean isCustomTheme) {
- new SysUiStatsLogger()
- .setAction(StyleEnums.PICKER_SELECT)
+ new SysUiStatsLogger(StyleEnums.PICKER_SELECT)
.setColorPackageHash(
Objects.hashCode(getThemePackage(theme, OVERLAY_CATEGORY_COLOR)))
.setFontPackageHash(Objects.hashCode(getThemePackage(theme, OVERLAY_CATEGORY_FONT)))
@@ -215,8 +182,7 @@
@Override
public void logThemeApplied(ThemeBundle theme, boolean isCustomTheme) {
- new SysUiStatsLogger()
- .setAction(StyleEnums.PICKER_APPLIED)
+ new SysUiStatsLogger(StyleEnums.PICKER_APPLIED)
.setColorPackageHash(
Objects.hashCode(getThemePackage(theme, OVERLAY_CATEGORY_COLOR)))
.setFontPackageHash(Objects.hashCode(getThemePackage(theme, OVERLAY_CATEGORY_FONT)))
@@ -227,8 +193,7 @@
@Override
public void logColorApplied(int action, ColorOption colorOption) {
- new SysUiStatsLogger()
- .setAction(action)
+ new SysUiStatsLogger(action)
.setColorPreference(colorOption.getIndex())
.setColorVariant(colorOption.getStyle().ordinal() + 1)
.log();
@@ -236,16 +201,14 @@
@Override
public void logGridSelected(GridOption grid) {
- new SysUiStatsLogger()
- .setAction(StyleEnums.PICKER_SELECT)
+ new SysUiStatsLogger(StyleEnums.PICKER_SELECT)
.setLauncherGrid(grid.cols)
.log();
}
@Override
public void logGridApplied(GridOption grid) {
- new SysUiStatsLogger()
- .setAction(StyleEnums.PICKER_APPLIED)
+ new SysUiStatsLogger(StyleEnums.PICKER_APPLIED)
.setLauncherGrid(grid.cols)
.log();
}
diff --git a/src/com/android/customization/module/SysUiStatsLogger.kt b/src/com/android/customization/module/SysUiStatsLogger.kt
index 318bf1f..8e97b0b 100644
--- a/src/com/android/customization/module/SysUiStatsLogger.kt
+++ b/src/com/android/customization/module/SysUiStatsLogger.kt
@@ -20,10 +20,8 @@
import com.android.systemui.shared.system.SysUiStatsLog.STYLE_UI_CHANGED
/** The builder for [SysUiStatsLog]. */
-class SysUiStatsLogger {
+class SysUiStatsLogger(val action: Int) {
- private var atom = STYLE_UI_CHANGED
- private var action = StyleEnums.DEFAULT_ACTION
private var colorPackageHash = 0
private var fontPackageHash = 0
private var shapePackageHash = 0
@@ -46,85 +44,83 @@
private var timeElapsedMillis = 0L
private var effectResultCode = -1
- fun setAction(action: Int) = apply { this.action = action }
-
- fun setColorPackageHash(color_package_hash: Int) = apply {
- this.colorPackageHash = color_package_hash
+ fun setColorPackageHash(colorPackageHash: Int) = apply {
+ this.colorPackageHash = colorPackageHash
}
- fun setFontPackageHash(font_package_hash: Int) = apply {
- this.fontPackageHash = font_package_hash
+ fun setFontPackageHash(fontPackageHash: Int) = apply {
+ this.fontPackageHash = fontPackageHash
}
- fun setShapePackageHash(shape_package_hash: Int) = apply {
- this.shapePackageHash = shape_package_hash
+ fun setShapePackageHash(shapePackageHash: Int) = apply {
+ this.shapePackageHash = shapePackageHash
}
- fun setClockPackageHash(clock_package_hash: Int) = apply {
- this.clockPackageHash = clock_package_hash
+ fun setClockPackageHash(clockPackageHash: Int) = apply {
+ this.clockPackageHash = clockPackageHash
}
- fun setLauncherGrid(launcher_grid: Int) = apply { this.launcherGrid = launcher_grid }
+ fun setLauncherGrid(launcherGrid: Int) = apply { this.launcherGrid = launcherGrid }
- fun setWallpaperCategoryHash(wallpaper_category_hash: Int) = apply {
- this.wallpaperCategoryHash = wallpaper_category_hash
+ fun setWallpaperCategoryHash(wallpaperCategoryHash: Int) = apply {
+ this.wallpaperCategoryHash = wallpaperCategoryHash
}
- fun setWallpaperIdHash(wallpaper_id_hash: Int) = apply {
- this.wallpaperIdHash = wallpaper_id_hash
+ fun setWallpaperIdHash(wallpaperIdHash: Int) = apply {
+ this.wallpaperIdHash = wallpaperIdHash
}
- fun setColorPreference(color_preference: Int) = apply {
- this.colorPreference = color_preference
+ fun setColorPreference(colorPreference: Int) = apply {
+ this.colorPreference = colorPreference
}
- fun setLocationPreference(location_preference: Int) = apply {
- this.locationPreference = location_preference
+ fun setLocationPreference(locationPreference: Int) = apply {
+ this.locationPreference = locationPreference
}
- fun setDatePreference(date_preference: Int) = apply { this.datePreference = date_preference }
+ fun setDatePreference(datePreference: Int) = apply { this.datePreference = datePreference }
- fun setLaunchedPreference(launched_preference: Int) = apply {
- this.launchedPreference = launched_preference
+ fun setLaunchedPreference(launchedPreference: Int) = apply {
+ this.launchedPreference = launchedPreference
}
- fun setEffectPreference(effect_preference: Int) = apply {
- this.effectPreference = effect_preference
+ fun setEffectPreference(effectPreference: Int) = apply {
+ this.effectPreference = effectPreference
}
- fun setEffectIdHash(effect_id_hash: Int) = apply { this.effectIdHash = effect_id_hash }
+ fun setEffectIdHash(effectIdHash: Int) = apply { this.effectIdHash = effectIdHash }
- fun setLockWallpaperCategoryHash(lock_wallpaper_category_hash: Int) = apply {
- this.lockWallpaperCategoryHash = lock_wallpaper_category_hash
+ fun setLockWallpaperCategoryHash(lockWallpaperCategoryHash: Int) = apply {
+ this.lockWallpaperCategoryHash = lockWallpaperCategoryHash
}
- fun setLockWallpaperIdHash(lock_wallpaper_id_hash: Int) = apply {
- this.lockWallpaperIdHash = lock_wallpaper_id_hash
+ fun setLockWallpaperIdHash(lockWallpaperIdHash: Int) = apply {
+ this.lockWallpaperIdHash = lockWallpaperIdHash
}
- fun setFirstLaunchDateSinceSetup(first_launch_date_since_setup: Int) = apply {
- this.firstLaunchDateSinceSetup = first_launch_date_since_setup
+ fun setFirstLaunchDateSinceSetup(firstLaunchDateSinceSetup: Int) = apply {
+ this.firstLaunchDateSinceSetup = firstLaunchDateSinceSetup
}
- fun setFirstWallpaperApplyDateSinceSetup(first_wallpaper_apply_date_since_setup: Int) = apply {
- this.firstWallpaperApplyDateSinceSetup = first_wallpaper_apply_date_since_setup
+ fun setFirstWallpaperApplyDateSinceSetup(firstWallpaperApplyDateSinceSetup: Int) = apply {
+ this.firstWallpaperApplyDateSinceSetup = firstWallpaperApplyDateSinceSetup
}
- fun setAppLaunchCount(app_launch_count: Int) = apply { this.appLaunchCount = app_launch_count }
+ fun setAppLaunchCount(appLaunchCount: Int) = apply { this.appLaunchCount = appLaunchCount }
- fun setColorVariant(color_variant: Int) = apply { this.colorVariant = color_variant }
+ fun setColorVariant(colorVariant: Int) = apply { this.colorVariant = colorVariant }
- fun setTimeElapsed(time_elapsed_millis: Long) = apply {
- this.timeElapsedMillis = time_elapsed_millis
+ fun setTimeElapsed(timeElapsedMillis: Long) = apply {
+ this.timeElapsedMillis = timeElapsedMillis
}
- fun setEffectResultCode(effect_result_code: Int) = apply {
- this.effectResultCode = effect_result_code
+ fun setEffectResultCode(effectResultCode: Int) = apply {
+ this.effectResultCode = effectResultCode
}
fun log() {
SysUiStatsLog.write(
- atom,
+ STYLE_UI_CHANGED,
action,
colorPackageHash,
fontPackageHash,
diff --git a/src/com/android/customization/module/ThemePickerInjector.kt b/src/com/android/customization/module/ThemePickerInjector.kt
index 25a69b5..902ef6e 100644
--- a/src/com/android/customization/module/ThemePickerInjector.kt
+++ b/src/com/android/customization/module/ThemePickerInjector.kt
@@ -195,12 +195,10 @@
@Synchronized
override fun getUserEventLogger(context: Context): ThemesUserEventLogger {
- val appContext = context.applicationContext
return userEventLogger as? ThemesUserEventLogger
?: StatsLogUserEventLogger(
- appContext,
- getPreferences(appContext),
- getWallpaperStatusChecker(appContext),
+ getPreferences(context.applicationContext),
+ getWallpaperStatusChecker(context.applicationContext),
)
.also { userEventLogger = it }
}
diff --git a/src/com/android/customization/picker/clock/utils/ThemePickerClockDescriptionUtils.kt b/src/com/android/customization/picker/clock/utils/ThemePickerClockDescriptionUtils.kt
index 6b3b405..43f19b3 100644
--- a/src/com/android/customization/picker/clock/utils/ThemePickerClockDescriptionUtils.kt
+++ b/src/com/android/customization/picker/clock/utils/ThemePickerClockDescriptionUtils.kt
@@ -16,10 +16,11 @@
package com.android.customization.picker.clock.utils
import androidx.annotation.StringRes
+import com.android.wallpaper.R
class ThemePickerClockDescriptionUtils : ClockDescriptionUtils {
@StringRes
override fun getDescriptionResId(clockId: String): Int {
- return -1
+ return R.string.clock_title
}
}
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 8e91798..7cf3550 100644
--- a/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
+++ b/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
@@ -20,6 +20,7 @@
import android.app.WallpaperManager
import android.content.Context
import android.graphics.Rect
+import android.os.Bundle
import android.view.TouchDelegate
import android.view.View
import android.view.View.OnAttachStateChangeListener
@@ -72,6 +73,7 @@
themedIconInteractor: ThemedIconInteractor,
wallpaperManager: WallpaperManager,
private val isTwoPaneAndSmallWidth: Boolean,
+ savedInstanceState: Bundle?,
) :
PreviewWithThemeSectionController(
activity,
@@ -85,6 +87,7 @@
themedIconInteractor,
wallpaperManager,
isTwoPaneAndSmallWidth,
+ savedInstanceState,
) {
private val viewModel =
diff --git a/src/com/android/customization/picker/preview/ui/section/PreviewWithThemeSectionController.kt b/src/com/android/customization/picker/preview/ui/section/PreviewWithThemeSectionController.kt
index 56c6c30..ba48b53 100644
--- a/src/com/android/customization/picker/preview/ui/section/PreviewWithThemeSectionController.kt
+++ b/src/com/android/customization/picker/preview/ui/section/PreviewWithThemeSectionController.kt
@@ -20,6 +20,7 @@
import android.app.Activity
import android.app.WallpaperManager
import android.content.Context
+import android.os.Bundle
import androidx.lifecycle.LifecycleOwner
import com.android.customization.model.themedicon.domain.interactor.ThemedIconInteractor
import com.android.customization.picker.preview.ui.viewmodel.PreviewWithThemeViewModel
@@ -51,6 +52,7 @@
private val themedIconInteractor: ThemedIconInteractor,
wallpaperManager: WallpaperManager,
isTwoPaneAndSmallWidth: Boolean,
+ savedInstanceState: Bundle?,
) :
ScreenPreviewSectionController(
activity,
@@ -62,7 +64,8 @@
wallpaperPreviewNavigator,
wallpaperInteractor,
wallpaperManager,
- isTwoPaneAndSmallWidth
+ isTwoPaneAndSmallWidth,
+ savedInstanceState,
) {
override fun createScreenPreviewViewModel(context: Context): ScreenPreviewViewModel {
return PreviewWithThemeViewModel(