Merge "Inject WallpaperInteractor and repository (2/3)" into main
diff --git a/src/com/android/customization/model/themedicon/ThemedIconSectionController.java b/src/com/android/customization/model/themedicon/ThemedIconSectionController.java
index 6c738c7..be7da04 100644
--- a/src/com/android/customization/model/themedicon/ThemedIconSectionController.java
+++ b/src/com/android/customization/model/themedicon/ThemedIconSectionController.java
@@ -29,6 +29,7 @@
import com.android.wallpaper.R;
import com.android.wallpaper.model.CustomizationSectionController;
+// TODO (b/311712452): Refactor CustomizationSectionController to use recommended arch UI components
/** The {@link CustomizationSectionController} for themed icon section. */
public class ThemedIconSectionController implements
CustomizationSectionController<ThemedIconSectionView> {
diff --git a/src/com/android/customization/module/logging/SysUiStatsLogger.kt b/src/com/android/customization/module/logging/SysUiStatsLogger.kt
index 6c55df8..111c2c2 100644
--- a/src/com/android/customization/module/logging/SysUiStatsLogger.kt
+++ b/src/com/android/customization/module/logging/SysUiStatsLogger.kt
@@ -15,15 +15,15 @@
*/
package com.android.customization.module.logging
+import android.stats.style.StyleEnums.CLOCK_SIZE_UNSPECIFIED
+import android.stats.style.StyleEnums.COLOR_SOURCE_UNSPECIFIED
+import android.stats.style.StyleEnums.DATE_PREFERENCE_UNSPECIFIED
+import android.stats.style.StyleEnums.EFFECT_PREFERENCE_UNSPECIFIED
+import android.stats.style.StyleEnums.LAUNCHED_PREFERENCE_UNSPECIFIED
+import android.stats.style.StyleEnums.LOCATION_PREFERENCE_UNSPECIFIED
+import android.stats.style.StyleEnums.SET_WALLPAPER_ENTRY_POINT_UNSPECIFIED
+import android.stats.style.StyleEnums.WALLPAPER_DESTINATION_UNSPECIFIED
import com.android.systemui.shared.system.SysUiStatsLog
-import com.android.systemui.shared.system.SysUiStatsLog.STYLE_UICHANGED__CLOCK_SIZE__CLOCK_SIZE_UNSPECIFIED
-import com.android.systemui.shared.system.SysUiStatsLog.STYLE_UICHANGED__COLOR_SOURCE__COLOR_SOURCE_UNSPECIFIED
-import com.android.systemui.shared.system.SysUiStatsLog.STYLE_UICHANGED__DATE_PREFERENCE__DATE_PREFERENCE_UNSPECIFIED
-import com.android.systemui.shared.system.SysUiStatsLog.STYLE_UICHANGED__EFFECT_PREFERENCE__EFFECT_PREFERENCE_UNSPECIFIED
-import com.android.systemui.shared.system.SysUiStatsLog.STYLE_UICHANGED__LAUNCHED_PREFERENCE__LAUNCHED_PREFERENCE_UNSPECIFIED
-import com.android.systemui.shared.system.SysUiStatsLog.STYLE_UICHANGED__LOCATION_PREFERENCE__LOCATION_PREFERENCE_UNSPECIFIED
-import com.android.systemui.shared.system.SysUiStatsLog.STYLE_UICHANGED__SET_WALLPAPER_ENTRY_POINT__SET_WALLPAPER_ENTRY_POINT_UNSPECIFIED
-import com.android.systemui.shared.system.SysUiStatsLog.STYLE_UICHANGED__WALLPAPER_DESTINATION__WALLPAPER_DESTINATION_UNSPECIFIED
import com.android.systemui.shared.system.SysUiStatsLog.STYLE_UI_CHANGED
import com.android.wallpaper.module.logging.UserEventLogger.SetWallpaperEntryPoint
@@ -38,12 +38,10 @@
private var wallpaperCategoryHash = 0
private var wallpaperIdHash = 0
private var colorPreference = 0
- private var locationPreference =
- STYLE_UICHANGED__LOCATION_PREFERENCE__LOCATION_PREFERENCE_UNSPECIFIED
- private var datePreference = STYLE_UICHANGED__DATE_PREFERENCE__DATE_PREFERENCE_UNSPECIFIED
- private var launchedPreference =
- STYLE_UICHANGED__LAUNCHED_PREFERENCE__LAUNCHED_PREFERENCE_UNSPECIFIED
- private var effectPreference = STYLE_UICHANGED__EFFECT_PREFERENCE__EFFECT_PREFERENCE_UNSPECIFIED
+ private var locationPreference = LOCATION_PREFERENCE_UNSPECIFIED
+ private var datePreference = DATE_PREFERENCE_UNSPECIFIED
+ private var launchedPreference = LAUNCHED_PREFERENCE_UNSPECIFIED
+ private var effectPreference = EFFECT_PREFERENCE_UNSPECIFIED
private var effectIdHash = 0
private var lockWallpaperCategoryHash = 0
private var lockWallpaperIdHash = 0
@@ -54,13 +52,11 @@
private var timeElapsedMillis = 0L
private var effectResultCode = -1
private var appSessionId = 0
- private var setWallpaperEntryPoint =
- STYLE_UICHANGED__SET_WALLPAPER_ENTRY_POINT__SET_WALLPAPER_ENTRY_POINT_UNSPECIFIED
- private var wallpaperDestination =
- STYLE_UICHANGED__WALLPAPER_DESTINATION__WALLPAPER_DESTINATION_UNSPECIFIED
- private var colorSource = STYLE_UICHANGED__COLOR_SOURCE__COLOR_SOURCE_UNSPECIFIED
+ private var setWallpaperEntryPoint = SET_WALLPAPER_ENTRY_POINT_UNSPECIFIED
+ private var wallpaperDestination = WALLPAPER_DESTINATION_UNSPECIFIED
+ private var colorSource = COLOR_SOURCE_UNSPECIFIED
private var seedColor = 0
- private var clockSize = STYLE_UICHANGED__CLOCK_SIZE__CLOCK_SIZE_UNSPECIFIED
+ private var clockSize = CLOCK_SIZE_UNSPECIFIED
private var toggleOn = false
private var shortcut = ""
private var shortcutSlotId = ""
diff --git a/src/com/android/customization/module/logging/ThemesUserEventLoggerImpl.kt b/src/com/android/customization/module/logging/ThemesUserEventLoggerImpl.kt
index 1441c71..3f4a6dc 100644
--- a/src/com/android/customization/module/logging/ThemesUserEventLoggerImpl.kt
+++ b/src/com/android/customization/module/logging/ThemesUserEventLoggerImpl.kt
@@ -25,6 +25,7 @@
import android.stats.style.StyleEnums.GRID_APPLIED
import android.stats.style.StyleEnums.LAUNCHED_CROP_AND_SET_ACTION
import android.stats.style.StyleEnums.LAUNCHED_DEEP_LINK
+import android.stats.style.StyleEnums.LAUNCHED_KEYGUARD
import android.stats.style.StyleEnums.LAUNCHED_LAUNCHER
import android.stats.style.StyleEnums.LAUNCHED_LAUNCH_ICON
import android.stats.style.StyleEnums.LAUNCHED_PREFERENCE_UNSPECIFIED
@@ -55,6 +56,7 @@
import com.android.wallpaper.module.logging.UserEventLogger.EffectStatus
import com.android.wallpaper.module.logging.UserEventLogger.SetWallpaperEntryPoint
import com.android.wallpaper.module.logging.UserEventLogger.WallpaperDestination
+import com.android.wallpaper.util.ActivityUtils
import com.android.wallpaper.util.LaunchSourceUtils
import javax.inject.Inject
import javax.inject.Singleton
@@ -246,9 +248,10 @@
LaunchSourceUtils.LAUNCH_SOURCE_SUW -> LAUNCHED_SUW
LaunchSourceUtils.LAUNCH_SOURCE_TIPS -> LAUNCHED_TIPS
LaunchSourceUtils.LAUNCH_SOURCE_DEEP_LINK -> LAUNCHED_DEEP_LINK
+ LaunchSourceUtils.LAUNCH_SOURCE_KEYGUARD -> LAUNCHED_KEYGUARD
else -> LAUNCHED_PREFERENCE_UNSPECIFIED
}
- } else if (hasExtra(LaunchSourceUtils.LAUNCH_SETTINGS_SEARCH)) {
+ } else if (ActivityUtils.isLaunchedFromSettingsSearch(this)) {
LAUNCHED_SETTINGS_SEARCH
} else if (action != null && action == WallpaperManager.ACTION_CROP_AND_SET_WALLPAPER) {
LAUNCHED_CROP_AND_SET_ACTION
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 0f39c54..d17cdf8 100644
--- a/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt
+++ b/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt
@@ -141,6 +141,7 @@
launch {
viewModel.colorOptions.collect { colorOptions ->
+ colorOptionContainerListView.removeAllViews()
colorOptions.forEachIndexed { index, colorOption ->
colorOption.payload?.let { payload ->
val item =
diff --git a/src/com/android/customization/picker/quickaffordance/domain/interactor/KeyguardQuickAffordancePickerInteractor.kt b/src/com/android/customization/picker/quickaffordance/domain/interactor/KeyguardQuickAffordancePickerInteractor.kt
index 6080194..3eca624 100644
--- a/src/com/android/customization/picker/quickaffordance/domain/interactor/KeyguardQuickAffordancePickerInteractor.kt
+++ b/src/com/android/customization/picker/quickaffordance/domain/interactor/KeyguardQuickAffordancePickerInteractor.kt
@@ -64,7 +64,7 @@
}
/** Unselects all affordances from the slot with the given ID. */
- suspend fun unselectAll(slotId: String) {
+ suspend fun unselectAllFromSlot(slotId: String) {
client.deleteAllSelections(
slotId = slotId,
)
@@ -72,6 +72,11 @@
snapshotRestorer.get().storeSnapshot()
}
+ /** Unselects all affordances from all slots. */
+ suspend fun unselectAll() {
+ client.querySlots().forEach { client.deleteAllSelections(it.id) }
+ }
+
/** Returns a [Drawable] for the given resource ID, from the system UI package. */
suspend fun getAffordanceIcon(
@DrawableRes iconResourceId: Int,
diff --git a/src/com/android/customization/picker/quickaffordance/domain/interactor/KeyguardQuickAffordanceSnapshotRestorer.kt b/src/com/android/customization/picker/quickaffordance/domain/interactor/KeyguardQuickAffordanceSnapshotRestorer.kt
index 3c7928c..fee0cb5 100644
--- a/src/com/android/customization/picker/quickaffordance/domain/interactor/KeyguardQuickAffordanceSnapshotRestorer.kt
+++ b/src/com/android/customization/picker/quickaffordance/domain/interactor/KeyguardQuickAffordanceSnapshotRestorer.kt
@@ -42,9 +42,14 @@
}
override suspend fun restoreToSnapshot(snapshot: RestorableSnapshot) {
+ // reset all current selections
+ interactor.unselectAll()
+
+ val allSelections = checkNotNull(snapshot.args[KEY_SELECTIONS])
+ if (allSelections.isEmpty()) return
+
val selections: List<Pair<String, String>> =
- checkNotNull(snapshot.args[KEY_SELECTIONS]).split(SELECTION_SEPARATOR).map { selection
- ->
+ allSelections.split(SELECTION_SEPARATOR).map { selection ->
val (slotId, affordanceId) = selection.split(SLOT_AFFORDANCE_SEPARATOR)
slotId to affordanceId
}
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 42aced9..260c0d3 100644
--- a/src/com/android/customization/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModel.kt
+++ b/src/com/android/customization/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModel.kt
@@ -217,7 +217,9 @@
if (!isSelected) {
{
viewModelScope.launch {
- quickAffordanceInteractor.unselectAll(selectedSlotId)
+ quickAffordanceInteractor.unselectAllFromSlot(
+ selectedSlotId
+ )
logger.logShortcutApplied(
shortcut = "none",
shortcutSlotId = selectedSlotId,
diff --git a/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java b/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java
index 3e03a41..f83da8c 100644
--- a/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java
+++ b/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java
@@ -40,18 +40,16 @@
protected void onFinishInflate() {
super.onFinishInflate();
mSwitchView = findViewById(R.id.themed_icon_toggle);
- setOnClickListener(v -> mSwitchView.toggle());
- mSwitchView.setOnCheckedChangeListener((buttonView, isChecked) -> viewActivated(isChecked));
+ setOnClickListener(v -> {
+ mSwitchView.toggle();
+ if (mSectionViewListener != null) {
+ mSectionViewListener.onViewActivated(getContext(), mSwitchView.isChecked());
+ }
+ });
}
/** Gets the switch view. */
public Switch getSwitch() {
return mSwitchView;
}
-
- private void viewActivated(boolean isChecked) {
- if (mSectionViewListener != null) {
- mSectionViewListener.onViewActivated(getContext(), isChecked);
- }
- }
}
diff --git a/tests/robotests/src/com/android/customization/model/picker/quickaffordance/domain/interactor/KeyguardQuickAffordancePickerInteractorTest.kt b/tests/robotests/src/com/android/customization/model/picker/quickaffordance/domain/interactor/KeyguardQuickAffordancePickerInteractorTest.kt
index bf53f61..4b4790a 100644
--- a/tests/robotests/src/com/android/customization/model/picker/quickaffordance/domain/interactor/KeyguardQuickAffordancePickerInteractorTest.kt
+++ b/tests/robotests/src/com/android/customization/model/picker/quickaffordance/domain/interactor/KeyguardQuickAffordancePickerInteractorTest.kt
@@ -132,7 +132,7 @@
affordanceId = FakeCustomizationProviderClient.AFFORDANCE_3,
)
- underTest.unselectAll(
+ underTest.unselectAllFromSlot(
slotId = KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_END,
)