[automerger skipped] Import translations. DO NOT MERGE ANYWHERE am: 4e4c11ea2a -s ours
am skip reason: subject contains skip directive
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/ThemePicker/+/24177551
Change-Id: I519fa0d8a40f9567f62af907474bebdfd9df9e0b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..bff2d76
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.iml
diff --git a/Android.bp b/Android.bp
index f6c8558..9c9c222 100644
--- a/Android.bp
+++ b/Android.bp
@@ -82,6 +82,7 @@
"androidx.lifecycle_lifecycle-viewmodel-ktx",
"androidx.recyclerview_recyclerview",
"SystemUICustomizationLib",
+ "hilt_android",
],
jni_libs: [
diff --git a/res/layout/fragment_clock_settings.xml b/res/layout/fragment_clock_settings.xml
index bb4a0c2..5736265 100644
--- a/res/layout/fragment_clock_settings.xml
+++ b/res/layout/fragment_clock_settings.xml
@@ -19,7 +19,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:clipChildren="false">
+ android:clipChildren="false"
+ android:transitionGroup="true">
<FrameLayout
android:id="@+id/section_header_container"
diff --git a/res/layout/fragment_lock_screen_quick_affordances.xml b/res/layout/fragment_lock_screen_quick_affordances.xml
index 36d1697..ee259f1 100644
--- a/res/layout/fragment_lock_screen_quick_affordances.xml
+++ b/res/layout/fragment_lock_screen_quick_affordances.xml
@@ -19,7 +19,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:clipChildren="false">
+ android:clipChildren="false"
+ android:transitionGroup="true">
<FrameLayout
android:id="@+id/section_header_container"
diff --git a/res/values-h800dp/dimens.xml b/res/values-h800dp/dimens.xml
deleted file mode 100644
index 36d0d62..0000000
--- a/res/values-h800dp/dimens.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<resources>
- <!--
- Dimension for clock translationY when swiping clock carousel in picker,
- copied from sysui resources
- -->
- <dimen name="keyguard_large_clock_top_margin">-112dp</dimen>
-</resources>
\ No newline at end of file
diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml
index ce75c0d..8ffc7b4 100644
--- a/res/values-pt-rPT/strings.xml
+++ b/res/values-pt-rPT/strings.xml
@@ -86,8 +86,8 @@
<string name="delete_custom_theme_button" msgid="5102462988130208824">"Eliminar"</string>
<string name="cancel" msgid="4651030493668562067">"Cancelar"</string>
<string name="set_theme_wallpaper_dialog_message" msgid="2179661027350908003">"Defina a imagem de fundo do estilo"</string>
- <string name="use_style_instead_title" msgid="1578754995763917502">"Quer utilizar <xliff:g id="ID_1">%1$s</xliff:g>?"</string>
- <string name="use_style_instead_body" msgid="3051937045807471496">"Os componentes que escolheu correspondem ao estilo <xliff:g id="ID_1">%1$s</xliff:g>. Em vez disso, quer utilizar <xliff:g id="ID_2">%1$s</xliff:g>?"</string>
+ <string name="use_style_instead_title" msgid="1578754995763917502">"Pretende utilizar <xliff:g id="ID_1">%1$s</xliff:g>?"</string>
+ <string name="use_style_instead_body" msgid="3051937045807471496">"Os componentes que escolheu correspondem ao estilo <xliff:g id="ID_1">%1$s</xliff:g>. Em vez disso, pretende utilizar <xliff:g id="ID_2">%1$s</xliff:g>?"</string>
<string name="use_style_button" msgid="1754493078383627019">"Usar <xliff:g id="ID_1">%1$s</xliff:g>"</string>
<string name="no_thanks" msgid="7286616980115687627">"Não, obrigado"</string>
<string name="clock_preview_content_description" msgid="5460561185905717460">"Pré-visualização do relógio <xliff:g id="ID_1">%1$s</xliff:g>"</string>
diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml
index 553439f..e236474 100644
--- a/res/values-tr/strings.xml
+++ b/res/values-tr/strings.xml
@@ -35,7 +35,7 @@
<string name="clock_color_indigo" msgid="8910855386698452917">"Çivit mavisi"</string>
<string name="clock_color_violet" msgid="3454503847169375826">"Mor"</string>
<string name="clock_color_gray" msgid="9221530636948859231">"Gri"</string>
- <string name="clock_color_teal" msgid="7499223425741344251">"Deniz mavisi"</string>
+ <string name="clock_color_teal" msgid="7499223425741344251">"Turkuaz"</string>
<string name="clock_size" msgid="5028923902364418263">"Boyut"</string>
<string name="clock_size_dynamic" msgid="1023930312455061642">"Dinamik"</string>
<string name="clock_size_dynamic_description" msgid="2776620745774561662">"Saat boyutu, kilit ekranındaki içeriklere göre değişir"</string>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index a3e0d4a..47171e5 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -170,14 +170,4 @@
<dimen name="clock_color_size_button_corner_radius">16dp</dimen>
<dimen name="clock_color_size_button_icon_size">20dp</dimen>
<dimen name="clock_color_size_button_icon_margin_end">12dp</dimen>
-
- <!--
- Dimension for clock translationY when swiping clock carousel in picker,
- copied from sysui resources
- -->
- <dimen name="keyguard_large_clock_top_margin">-60dp</dimen>
- <!-- Dimension for the clock view, copied from sysui resources. -->
- <dimen name="small_clock_height">114dp</dimen>
- <dimen name="small_clock_padding_top">28dp</dimen>
- <dimen name="clock_padding_start">28dp</dimen>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index c70b596..b2c22b2 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -48,6 +48,7 @@
<item name="colorSurface">@color/design_default_color_surface</item>
<item name="colorOnSurface">@color/design_default_color_on_surface</item>
<item name="android:textAllCaps">false</item>
+ <item name="motionDurationLong1">500</item>
</style>
<!-- Snackbar margin -->
diff --git a/src/com/android/customization/model/grid/ui/fragment/GridFragment2.kt b/src/com/android/customization/model/grid/ui/fragment/GridFragment2.kt
index 6ab561f..b04c194 100644
--- a/src/com/android/customization/model/grid/ui/fragment/GridFragment2.kt
+++ b/src/com/android/customization/model/grid/ui/fragment/GridFragment2.kt
@@ -21,7 +21,10 @@
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.core.view.isVisible
import androidx.lifecycle.ViewModelProvider
+import androidx.transition.Transition
+import androidx.transition.doOnStart
import com.android.customization.model.grid.ui.binder.GridScreenBinder
import com.android.customization.model.grid.ui.viewmodel.GridScreenViewModel
import com.android.customization.module.ThemePickerInjector
@@ -85,6 +88,10 @@
}
)
+ (returnTransition as? Transition)?.doOnStart {
+ view.requireViewById<View>(R.id.preview).isVisible = false
+ }
+
return view
}
diff --git a/src/com/android/customization/module/CustomizationInjector.kt b/src/com/android/customization/module/CustomizationInjector.kt
index 5f8f9d3..8fd3768 100644
--- a/src/com/android/customization/module/CustomizationInjector.kt
+++ b/src/com/android/customization/module/CustomizationInjector.kt
@@ -16,6 +16,7 @@
package com.android.customization.module
import android.content.Context
+import android.content.res.Resources
import androidx.activity.ComponentActivity
import androidx.fragment.app.FragmentActivity
import com.android.customization.model.theme.OverlayManagerCompat
@@ -78,5 +79,5 @@
clockViewFactory: ClockViewFactory,
): ClockSettingsViewModel.Factory
- fun getClockDescriptionUtils(): ClockDescriptionUtils
+ fun getClockDescriptionUtils(resources: Resources): ClockDescriptionUtils
}
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 32e0599..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;
@@ -47,8 +46,6 @@
import com.android.customization.model.color.ColorOption;
import com.android.customization.model.grid.GridOption;
import com.android.customization.model.theme.ThemeBundle;
-import com.android.wallpaper.module.Injector;
-import com.android.wallpaper.module.InjectorProvider;
import com.android.wallpaper.module.NoOpUserEventLogger;
import com.android.wallpaper.module.WallpaperPreferences;
import com.android.wallpaper.module.WallpaperStatusChecker;
@@ -61,86 +58,59 @@
*/
public class StatsLogUserEventLogger extends NoOpUserEventLogger implements ThemesUserEventLogger {
- private static final String TAG = "StatsLogUserEventLogger";
- private final Context mContext;
private final WallpaperPreferences mPreferences;
private final WallpaperStatusChecker mWallpaperStatusChecker;
- public StatsLogUserEventLogger(Context appContext) {
- mContext = appContext;
- Injector injector = InjectorProvider.getInjector();
- mPreferences = injector.getPreferences(appContext);
- mWallpaperStatusChecker = injector.getWallpaperStatusChecker();
+ public StatsLogUserEventLogger(
+ WallpaperPreferences preferences,
+ WallpaperStatusChecker wallpaperStatusChecker) {
+ 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(mContext);
+ final boolean isLockWallpaperSet = mWallpaperStatusChecker.isLockWallpaperSet();
final String homeCollectionId = mPreferences.getHomeWallpaperCollectionId();
final String homeRemoteId = mPreferences.getHomeWallpaperRemoteId();
final String effects = mPreferences.getHomeWallpaperEffects();
@@ -151,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))
@@ -167,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))
@@ -178,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)
@@ -189,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();
@@ -204,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)))
@@ -216,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)))
@@ -228,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();
@@ -237,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 cceb896..a611d7a 100644
--- a/src/com/android/customization/module/ThemePickerInjector.kt
+++ b/src/com/android/customization/module/ThemePickerInjector.kt
@@ -19,6 +19,7 @@
import android.app.WallpaperManager
import android.content.Context
import android.content.Intent
+import android.content.res.Resources
import android.net.Uri
import android.os.Bundle
import android.text.TextUtils
@@ -68,6 +69,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.wallpaper.dispatchers.BackgroundDispatcher
+import com.android.wallpaper.dispatchers.MainDispatcher
import com.android.wallpaper.model.LiveWallpaperInfo
import com.android.wallpaper.model.WallpaperColorsViewModel
import com.android.wallpaper.model.WallpaperInfo
@@ -85,9 +88,19 @@
import com.android.wallpaper.picker.customization.domain.interactor.WallpaperInteractor
import com.android.wallpaper.picker.undo.domain.interactor.SnapshotRestorer
import com.android.wallpaper.util.ScreenSizeCalculator
-import kotlinx.coroutines.Dispatchers
+import javax.inject.Inject
+import javax.inject.Singleton
+import kotlinx.coroutines.CoroutineDispatcher
+import kotlinx.coroutines.CoroutineScope
-open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInjector {
+@Singleton
+open class ThemePickerInjector
+@Inject
+internal constructor(
+ @MainDispatcher private val mainScope: CoroutineScope,
+ @MainDispatcher private val mainDispatcher: CoroutineDispatcher,
+ @BackgroundDispatcher private val bgDispatcher: CoroutineDispatcher,
+) : WallpaperPicker2Injector(mainScope, bgDispatcher), CustomizationInjector {
private var customizationSections: CustomizationSections? = null
private var userEventLogger: UserEventLogger? = null
private var prefs: WallpaperPreferences? = null
@@ -183,8 +196,12 @@
@Synchronized
override fun getUserEventLogger(context: Context): ThemesUserEventLogger {
- return if (userEventLogger != null) userEventLogger as ThemesUserEventLogger
- else StatsLogUserEventLogger(context.applicationContext).also { userEventLogger = it }
+ return userEventLogger as? ThemesUserEventLogger
+ ?: StatsLogUserEventLogger(
+ getPreferences(context.applicationContext),
+ getWallpaperStatusChecker(context.applicationContext),
+ )
+ .also { userEventLogger = it }
}
@Synchronized
@@ -244,7 +261,7 @@
wallpaperManager = WallpaperManager.getInstance(appContext)
),
wallpaperPreferences = getPreferences(context = appContext),
- backgroundDispatcher = Dispatchers.IO,
+ backgroundDispatcher = bgDispatcher,
),
shouldHandleReload = {
TextUtils.equals(
@@ -284,7 +301,7 @@
val client = getKeyguardQuickAffordancePickerProviderClient(context)
val appContext = context.applicationContext
return KeyguardQuickAffordancePickerInteractor(
- KeyguardQuickAffordancePickerRepository(client, Dispatchers.IO),
+ KeyguardQuickAffordancePickerRepository(client, bgDispatcher),
client
) {
getKeyguardQuickAffordanceSnapshotRestorer(appContext)
@@ -295,7 +312,7 @@
context: Context
): CustomizationProviderClient {
return customizationProviderClient
- ?: CustomizationProviderClientImpl(context.applicationContext, Dispatchers.IO).also {
+ ?: CustomizationProviderClientImpl(context.applicationContext, bgDispatcher).also {
customizationProviderClient = it
}
}
@@ -330,7 +347,7 @@
repository =
NotificationsRepository(
scope = getApplicationCoroutineScope(),
- backgroundDispatcher = Dispatchers.IO,
+ backgroundDispatcher = bgDispatcher,
secureSettingsRepository = getSecureSettingsRepository(context),
),
snapshotRestorer = { getNotificationsSnapshotRestorer(appContext) },
@@ -354,8 +371,8 @@
?: ClockRegistryProvider(
context = context.applicationContext,
coroutineScope = getApplicationCoroutineScope(),
- mainDispatcher = Dispatchers.Main,
- backgroundDispatcher = Dispatchers.IO,
+ mainDispatcher = mainDispatcher,
+ backgroundDispatcher = bgDispatcher,
)
.also { clockRegistryProvider = it })
.get()
@@ -372,7 +389,7 @@
secureSettingsRepository = getSecureSettingsRepository(appContext),
registry = getClockRegistry(appContext),
scope = getApplicationCoroutineScope(),
- mainDispatcher = Dispatchers.Main,
+ mainDispatcher = mainDispatcher,
),
snapshotRestorer = { getClockPickerSnapshotRestorer(appContext) },
)
@@ -394,7 +411,7 @@
interactor: ClockPickerInteractor,
): ClockCarouselViewModel.Factory {
return clockCarouselViewModelFactory
- ?: ClockCarouselViewModel.Factory(interactor, Dispatchers.IO).also {
+ ?: ClockCarouselViewModel.Factory(interactor, bgDispatcher).also {
clockCarouselViewModelFactory = it
}
}
@@ -489,7 +506,7 @@
?: DarkModeSnapshotRestorer(
context = appContext,
manager = appContext.getSystemService(Context.UI_MODE_SERVICE) as UiModeManager,
- backgroundDispatcher = Dispatchers.IO,
+ backgroundDispatcher = bgDispatcher,
)
.also { darkModeSnapshotRestorer = it }
}
@@ -537,7 +554,7 @@
.also { clockSettingsViewModelFactory = it }
}
- override fun getClockDescriptionUtils(): ClockDescriptionUtils {
+ override fun getClockDescriptionUtils(resources: Resources): ClockDescriptionUtils {
return clockDescriptionUtils
?: ThemePickerClockDescriptionUtils().also { clockDescriptionUtils = it }
}
@@ -564,7 +581,7 @@
GridRepositoryImpl(
applicationScope = getApplicationCoroutineScope(),
manager = GridOptionsManager.getInstance(context),
- backgroundDispatcher = Dispatchers.IO,
+ backgroundDispatcher = bgDispatcher,
),
snapshotRestorer = { getGridSnapshotRestorer(appContext) },
)
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 be6c6cb..aeed45e 100644
--- a/src/com/android/customization/picker/clock/data/repository/ClockPickerRepositoryImpl.kt
+++ b/src/com/android/customization/picker/clock/data/repository/ClockPickerRepositoryImpl.kt
@@ -33,6 +33,7 @@
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.callbackFlow
+import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapLatest
@@ -56,7 +57,7 @@
registry
.getClocks()
.filter { "NOT_IN_USE" !in it.clockId }
- .map { it.toModel() }
+ .map { it.toModel(isSelected = it.clockId == registry.currentClockId) }
trySend(allClocks)
}
@@ -90,6 +91,7 @@
.getClocks()
.find { clockMetadata -> clockMetadata.clockId == currentClockId }
?.toModel(
+ isSelected = true,
selectedColorId = metadata?.getSelectedColorId(),
colorTone = metadata?.getColorTone()
?: ClockMetadataModel.DEFAULT_COLOR_TONE_PROGRESS,
@@ -146,9 +148,10 @@
)
.map { setting -> setting == 1 }
.map { isDynamic -> if (isDynamic) ClockSize.DYNAMIC else ClockSize.SMALL }
+ .distinctUntilChanged()
.shareIn(
scope = scope,
- started = SharingStarted.WhileSubscribed(),
+ started = SharingStarted.Eagerly,
replay = 1,
)
@@ -176,6 +179,7 @@
/** By default, [ClockMetadataModel] has no color information unless specified. */
private fun ClockMetadata.toModel(
+ isSelected: Boolean,
selectedColorId: String? = null,
@IntRange(from = 0, to = 100) colorTone: Int = 0,
@ColorInt seedColor: Int? = null,
@@ -183,6 +187,7 @@
return ClockMetadataModel(
clockId = clockId,
name = name,
+ isSelected = isSelected,
selectedColorId = selectedColorId,
colorToneProgress = colorTone,
seedColor = seedColor,
diff --git a/src/com/android/customization/picker/clock/data/repository/ClockRegistryProvider.kt b/src/com/android/customization/picker/clock/data/repository/ClockRegistryProvider.kt
index 652ffdd..b197edf 100644
--- a/src/com/android/customization/picker/clock/data/repository/ClockRegistryProvider.kt
+++ b/src/com/android/customization/picker/clock/data/repository/ClockRegistryProvider.kt
@@ -29,6 +29,7 @@
import com.android.systemui.shared.plugins.PluginManagerImpl
import com.android.systemui.shared.plugins.PluginPrefs
import com.android.systemui.shared.system.UncaughtExceptionPreHandlerManager_Factory
+import com.android.wallpaper.module.InjectorProvider
import java.util.concurrent.Executors
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
@@ -55,6 +56,8 @@
DefaultClockProvider(context, LayoutInflater.from(context), context.resources),
keepAllLoaded = true,
subTag = "Picker",
+ isTransitClockEnabled =
+ InjectorProvider.getInjector().getFlags().isTransitClockEnabled(context)
)
}
diff --git a/src/com/android/customization/picker/clock/shared/model/ClockMetadataModel.kt b/src/com/android/customization/picker/clock/shared/model/ClockMetadataModel.kt
index bd87ba6..2522507 100644
--- a/src/com/android/customization/picker/clock/shared/model/ClockMetadataModel.kt
+++ b/src/com/android/customization/picker/clock/shared/model/ClockMetadataModel.kt
@@ -24,6 +24,7 @@
data class ClockMetadataModel(
val clockId: String,
val name: String,
+ val isSelected: Boolean,
val selectedColorId: String?,
@IntRange(from = 0, to = 100) val colorToneProgress: Int,
@ColorInt val seedColor: Int?,
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 4f4bd1b..6e745d5 100644
--- a/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt
+++ b/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt
@@ -33,6 +33,7 @@
import androidx.recyclerview.widget.RecyclerView
import com.android.customization.picker.clock.shared.ClockSize
import com.android.customization.picker.clock.ui.adapter.ClockSettingsTabAdapter
+import com.android.customization.picker.clock.ui.view.ClockCarouselView
import com.android.customization.picker.clock.ui.view.ClockHostView
import com.android.customization.picker.clock.ui.view.ClockSizeRadioButtonGroup
import com.android.customization.picker.clock.ui.view.ClockViewFactory
@@ -199,7 +200,7 @@
sizeOptions.radioButtonDynamic.isChecked = false
sizeOptions.radioButtonSmall.isChecked = true
clockHostView.doOnPreDraw {
- it.pivotX = 0F
+ it.pivotX = ClockCarouselView.getCenteredHostViewPivotX(it)
it.pivotY = 0F
}
}
diff --git a/src/com/android/customization/picker/clock/ui/fragment/ClockCustomDemoFragment.kt b/src/com/android/customization/picker/clock/ui/fragment/ClockCustomDemoFragment.kt
deleted file mode 100644
index f138d6a..0000000
--- a/src/com/android/customization/picker/clock/ui/fragment/ClockCustomDemoFragment.kt
+++ /dev/null
@@ -1,93 +0,0 @@
-package com.android.customization.picker.clock.ui.fragment
-
-import android.content.Context
-import android.os.Bundle
-import android.util.TypedValue
-import android.view.ContextThemeWrapper
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import android.view.ViewGroup.LayoutParams.MATCH_PARENT
-import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
-import android.widget.FrameLayout
-import android.widget.TextView
-import android.widget.Toast
-import androidx.core.view.setPadding
-import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.recyclerview.widget.RecyclerView
-import com.android.customization.module.ThemePickerInjector
-import com.android.internal.annotations.VisibleForTesting
-import com.android.systemui.plugins.ClockMetadata
-import com.android.systemui.shared.clocks.ClockRegistry
-import com.android.wallpaper.R
-import com.android.wallpaper.module.InjectorProvider
-import com.android.wallpaper.picker.AppbarFragment
-
-class ClockCustomDemoFragment : AppbarFragment() {
- @VisibleForTesting lateinit var recyclerView: RecyclerView
- @VisibleForTesting lateinit var clockRegistry: ClockRegistry
-
- override fun onCreateView(
- inflater: LayoutInflater,
- container: ViewGroup?,
- savedInstanceState: Bundle?
- ): View {
- val view = inflater.inflate(R.layout.fragment_clock_custom_picker_demo, container, false)
- setUpToolbar(view)
- clockRegistry =
- (InjectorProvider.getInjector() as ThemePickerInjector).getClockRegistry(
- requireContext(),
- )
- val listInUse = clockRegistry.getClocks().filter { "NOT_IN_USE" !in it.clockId }
-
- recyclerView = view.requireViewById(R.id.clock_preview_card_list_demo)
- recyclerView.layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false)
- recyclerView.adapter =
- ClockRecyclerAdapter(listInUse, requireContext()) {
- clockRegistry.currentClockId = it.clockId
- Toast.makeText(context, "${it.name} selected", Toast.LENGTH_SHORT).show()
- }
- return view
- }
-
- override fun getDefaultTitle(): CharSequence {
- return getString(R.string.clock_title)
- }
-
- internal class ClockRecyclerAdapter(
- val list: List<ClockMetadata>,
- val context: Context,
- val onClockSelected: (ClockMetadata) -> Unit
- ) : RecyclerView.Adapter<ClockRecyclerAdapter.ViewHolder>() {
- class ViewHolder(val view: View, val textView: TextView, val onItemClicked: (Int) -> Unit) :
- RecyclerView.ViewHolder(view) {
- init {
- itemView.setOnClickListener { onItemClicked(absoluteAdapterPosition) }
- }
- }
-
- override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder {
- val rootView = FrameLayout(viewGroup.context)
- val textView =
- TextView(ContextThemeWrapper(viewGroup.context, R.style.SectionTitleTextStyle))
- textView.setPadding(ITEM_PADDING)
- rootView.addView(textView)
- val outValue = TypedValue()
- context.theme.resolveAttribute(android.R.attr.selectableItemBackground, outValue, true)
- rootView.setBackgroundResource(outValue.resourceId)
- val lp = RecyclerView.LayoutParams(MATCH_PARENT, WRAP_CONTENT)
- rootView.layoutParams = lp
- return ViewHolder(rootView, textView) { onClockSelected(list[it]) }
- }
-
- override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
- viewHolder.textView.text = list[position].name
- }
-
- override fun getItemCount() = list.size
-
- companion object {
- val ITEM_PADDING = 40
- }
- }
-}
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 f4684d8..0b02ed9 100644
--- a/src/com/android/customization/picker/clock/ui/fragment/ClockSettingsFragment.kt
+++ b/src/com/android/customization/picker/clock/ui/fragment/ClockSettingsFragment.kt
@@ -20,8 +20,11 @@
import android.view.View
import android.view.ViewGroup
import androidx.cardview.widget.CardView
+import androidx.core.view.isVisible
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.get
+import androidx.transition.Transition
+import androidx.transition.doOnStart
import com.android.customization.module.ThemePickerInjector
import com.android.customization.picker.clock.ui.binder.ClockSettingsBinder
import com.android.systemui.shared.clocks.shared.model.ClockPreviewConstants
@@ -130,6 +133,8 @@
viewLifecycleOwner,
)
+ (returnTransition as? Transition)?.doOnStart { lockScreenView.isVisible = false }
+
return view
}
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 8764e54..aa6cc91 100644
--- a/src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt
+++ b/src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt
@@ -71,17 +71,31 @@
clockViewFactory = factory
}
+ // This function is for the custom accessibility action to trigger a transition to the next
+ // carousel item. If the current item is the last item in the carousel, the next item
+ // will be the first item.
fun transitionToNext() {
- val index = (carousel.currentIndex + 1) % carousel.count
- if (index < carousel.count && index > 0) {
- carousel.transitionToIndex(index, 0)
+ if (carousel.count != 0) {
+ val index = (carousel.currentIndex + 1) % carousel.count
+ carousel.jumpToIndex(index)
+ // Explicitly called this since using transitionToIndex(index) leads to
+ // race-condition between announcement of content description of the correct clock-face
+ // and the selection of clock face itself
+ adapter.onNewItem(index)
}
}
+ // This function is for the custom accessibility action to trigger a transition to
+ // the previous carousel item. If the current item is the first item in the carousel,
+ // the previous item will be the last item.
fun transitionToPrevious() {
- val index = (carousel.currentIndex - 1) % carousel.count
- if (index < carousel.count && index > 0) {
- carousel.transitionToIndex(index, 0)
+ if (carousel.count != 0) {
+ val index = (carousel.currentIndex + carousel.count - 1) % carousel.count
+ carousel.jumpToIndex(index)
+ // Explicitly called this since using transitionToIndex(index) leads to
+ // race-condition between announcement of content description of the correct clock-face
+ // and the selection of clock face itself
+ adapter.onNewItem(index)
}
}
@@ -101,7 +115,13 @@
adapter = ClockCarouselAdapter(clockSize, clocks, clockViewFactory, onClockSelected)
carousel.setAdapter(adapter)
- carousel.refresh()
+ val indexOfSelectedClock =
+ clocks
+ .indexOfFirst { it.isSelected }
+ // If not found, default to the first clock as selected:
+ .takeIf { it != -1 }
+ ?: 0
+ carousel.jumpToIndex(indexOfSelectedClock)
motionLayout.setTransitionListener(
object : MotionLayout.TransitionListener {
@@ -211,11 +231,13 @@
}
?: return
offCenterClockHostView.doOnPreDraw {
- it.pivotX = progress * it.width / 2
+ it.pivotX =
+ progress * it.width / 2 + (1 - progress) * getCenteredHostViewPivotX(it)
it.pivotY = progress * it.height / 2
}
toCenterClockHostView.doOnPreDraw {
- it.pivotX = (1 - progress) * it.width / 2
+ it.pivotX =
+ (1 - progress) * it.width / 2 + progress * getCenteredHostViewPivotX(it)
it.pivotY = (1 - progress) * it.height / 2
}
offCenterClockFrame.translationX =
@@ -265,9 +287,11 @@
fun setSelectedClockIndex(
index: Int,
) {
- // jumpToIndex to the same position can cause the views unnecessarily populate again.
- // Only call jumpToIndex when the jump-to index is different from the current carousel.
- if (index != carousel.currentIndex) {
+ // 1. setUpClockCarouselView() can possibly not be called before setSelectedClockIndex().
+ // We need to check if index out of bound.
+ // 2. jumpToIndex() to the same position can cause the views unnecessarily populate again.
+ // We only call jumpToIndex when the index is different from the current carousel.
+ if (index < carousel.count && index != carousel.currentIndex) {
carousel.jumpToIndex(index)
}
}
@@ -417,7 +441,7 @@
) {
clockHostView.doOnPreDraw {
if (isMiddleView) {
- it.pivotX = 0F
+ it.pivotX = getCenteredHostViewPivotX(it)
it.pivotY = 0F
clockView.translationX = 0F
clockView.translationY = 0F
@@ -507,6 +531,10 @@
return rootViewId == R.id.item_view_2
}
+ fun getCenteredHostViewPivotX(hostView: View): Float {
+ return if (hostView.isLayoutRtl) hostView.width.toFloat() else 0F
+ }
+
private fun getTranslationDistance(
hostLength: Int,
frameLength: Int,
diff --git a/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselItemViewModel.kt b/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselItemViewModel.kt
index 708fa2f..9811426 100644
--- a/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselItemViewModel.kt
+++ b/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselItemViewModel.kt
@@ -20,15 +20,14 @@
import com.android.wallpaper.R
import com.android.wallpaper.module.InjectorProvider
-class ClockCarouselItemViewModel(val clockId: String) {
+class ClockCarouselItemViewModel(val clockId: String, val isSelected: Boolean) {
/** Description for accessibility purposes when a clock is selected. */
fun getContentDescription(resources: Resources): String {
val clockContent =
(InjectorProvider.getInjector() as? CustomizationInjector)
- ?.getClockDescriptionUtils()
- ?.getDescriptionResId(clockId)
- ?.let { resources.getString(it) }
+ ?.getClockDescriptionUtils(resources)
+ ?.getDescription(clockId)
?: ""
return resources.getString(R.string.select_clock_action_description, clockContent)
}
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 a4f9cc4..7922054 100644
--- a/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModel.kt
+++ b/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModel.kt
@@ -50,7 +50,7 @@
.mapLatest { allClocks ->
// Delay to avoid the case that the full list of clocks is not initiated.
delay(CLOCKS_EVENT_UPDATE_DELAY_MILLIS)
- allClocks.map { ClockCarouselItemViewModel(it.clockId) }
+ allClocks.map { ClockCarouselItemViewModel(it.clockId, it.isSelected) }
}
.stateIn(viewModelScope, SharingStarted.Eagerly, emptyList())
diff --git a/src/com/android/customization/picker/clock/utils/ClockDescriptionUtils.kt b/src/com/android/customization/picker/clock/utils/ClockDescriptionUtils.kt
index 9a0b66f..28ea4a3 100644
--- a/src/com/android/customization/picker/clock/utils/ClockDescriptionUtils.kt
+++ b/src/com/android/customization/picker/clock/utils/ClockDescriptionUtils.kt
@@ -15,14 +15,12 @@
*/
package com.android.customization.picker.clock.utils
-import androidx.annotation.StringRes
-
/** Provides clock description for accessibility purposes. */
interface ClockDescriptionUtils {
/**
- * TODO (b/287507746) : Migrate description res ID to system UI or a shared library, instead of
- * preserving the clock description at the Wallpaper Picker side.
+ * TODO (b/287507746) : Migrate the clock description to system UI or a shared library, instead
+ * of preserving at the Wallpaper Picker side.
*/
- @StringRes fun getDescriptionResId(clockId: String): Int
+ fun getDescription(clockId: String): String
}
diff --git a/src/com/android/customization/picker/clock/utils/ThemePickerClockDescriptionUtils.kt b/src/com/android/customization/picker/clock/utils/ThemePickerClockDescriptionUtils.kt
index 43f19b3..a04ebff 100644
--- a/src/com/android/customization/picker/clock/utils/ThemePickerClockDescriptionUtils.kt
+++ b/src/com/android/customization/picker/clock/utils/ThemePickerClockDescriptionUtils.kt
@@ -15,12 +15,8 @@
*/
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 R.string.clock_title
+ override fun getDescription(clockId: String): String {
+ return ""
}
}
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 78bfa43..a70b509 100644
--- a/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt
+++ b/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt
@@ -22,9 +22,12 @@
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.cardview.widget.CardView
+import androidx.core.view.isVisible
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.get
import androidx.lifecycle.lifecycleScope
+import androidx.transition.Transition
+import androidx.transition.doOnStart
import com.android.customization.model.mode.DarkModeSectionController
import com.android.customization.module.ThemePickerInjector
import com.android.customization.picker.color.ui.binder.ColorPickerBinder
@@ -197,6 +200,12 @@
.createView(requireContext())
darkModeSectionView.background = null
darkModeToggleContainerView.addView(darkModeSectionView)
+
+ (returnTransition as? Transition)?.doOnStart {
+ lockScreenView.isVisible = false
+ homeScreenView.isVisible = false
+ }
+
return view
}
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(
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 68367c8..091f484 100644
--- a/src/com/android/customization/picker/quickaffordance/ui/binder/KeyguardQuickAffordancePickerBinder.kt
+++ b/src/com/android/customization/picker/quickaffordance/ui/binder/KeyguardQuickAffordancePickerBinder.kt
@@ -37,6 +37,7 @@
import com.android.wallpaper.picker.common.icon.ui.viewmodel.Icon
import com.android.wallpaper.picker.option.ui.adapter.OptionItemAdapter
import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.collectIndexed
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flatMapLatest
@@ -99,13 +100,18 @@
selectedFlags.indexOfFirst { it }
}
}
- .collect { selectedPosition ->
+ .collectIndexed { index, selectedPosition ->
// Scroll the view to show the first selected affordance.
if (selectedPosition != -1) {
// We use "post" because we need to give the adapter item a pass to
// update the view.
affordancesView.post {
- affordancesView.smoothScrollToPosition(selectedPosition)
+ if (index == 0) {
+ // don't animate on initial collection
+ affordancesView.scrollToPosition(selectedPosition)
+ } else {
+ affordancesView.smoothScrollToPosition(selectedPosition)
+ }
}
}
}
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 28ad51a..7e1f4d3 100644
--- a/src/com/android/customization/picker/quickaffordance/ui/binder/KeyguardQuickAffordanceSectionViewBinder.kt
+++ b/src/com/android/customization/picker/quickaffordance/ui/binder/KeyguardQuickAffordanceSectionViewBinder.kt
@@ -48,7 +48,7 @@
lifecycleOwner.lifecycleScope.launch {
viewModel.summary
- .flowWithLifecycle(lifecycleOwner.lifecycle, Lifecycle.State.RESUMED)
+ .flowWithLifecycle(lifecycleOwner.lifecycle, Lifecycle.State.STARTED)
.collectLatest { summary ->
TextViewBinder.bind(
view = descriptionView,
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 d5f0d33..400f266 100644
--- a/src/com/android/customization/picker/quickaffordance/ui/fragment/KeyguardQuickAffordancePickerFragment.kt
+++ b/src/com/android/customization/picker/quickaffordance/ui/fragment/KeyguardQuickAffordancePickerFragment.kt
@@ -21,8 +21,11 @@
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.core.view.isVisible
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.get
+import androidx.transition.Transition
+import androidx.transition.doOnStart
import com.android.customization.module.ThemePickerInjector
import com.android.customization.picker.quickaffordance.ui.binder.KeyguardQuickAffordancePickerBinder
import com.android.customization.picker.quickaffordance.ui.binder.KeyguardQuickAffordancePreviewBinder
@@ -30,9 +33,7 @@
import com.android.wallpaper.R
import com.android.wallpaper.module.InjectorProvider
import com.android.wallpaper.picker.AppbarFragment
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-@OptIn(ExperimentalCoroutinesApi::class)
class KeyguardQuickAffordancePickerFragment : AppbarFragment() {
companion object {
const val DESTINATION_ID = "quick_affordances"
@@ -77,6 +78,12 @@
viewModel = viewModel,
lifecycleOwner = this,
)
+ postponeEnterTransition()
+ view.post { startPostponedEnterTransition() }
+ (returnTransition as? Transition)?.doOnStart {
+ // Hide preview during exit transition animation
+ view?.findViewById<View>(R.id.preview)?.isVisible = false
+ }
return view
}
diff --git a/src/com/android/customization/picker/CustomizationPickerApplication.java b/src_override/com/android/customization/picker/CustomizationPickerApplication.java
similarity index 72%
rename from src/com/android/customization/picker/CustomizationPickerApplication.java
rename to src_override/com/android/customization/picker/CustomizationPickerApplication.java
index 178cfbf..08303d9 100644
--- a/src/com/android/customization/picker/CustomizationPickerApplication.java
+++ b/src_override/com/android/customization/picker/CustomizationPickerApplication.java
@@ -20,12 +20,23 @@
import com.android.customization.module.ThemePickerInjector;
import com.android.wallpaper.module.InjectorProvider;
-public class CustomizationPickerApplication extends Application {
+import dagger.hilt.android.HiltAndroidApp;
+
+import javax.inject.Inject;
+
+/**
+ * Application subclass that initializes the injector.
+ */
+@HiltAndroidApp(Application.class)
+public class CustomizationPickerApplication extends Hilt_CustomizationPickerApplication {
+
+ @Inject ThemePickerInjector mInjector;
+
@Override
public void onCreate() {
super.onCreate();
// Initialize the injector.
- InjectorProvider.setInjector(new ThemePickerInjector());
+ InjectorProvider.setInjector(mInjector);
}
}
diff --git a/tests/common/Android.bp b/tests/common/Android.bp
new file mode 100644
index 0000000..2904fad
--- /dev/null
+++ b/tests/common/Android.bp
@@ -0,0 +1,39 @@
+// 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.
+//
+
+//
+// Build rule for WallpaperPicker2 tests
+//
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+android_library {
+ name: "ThemePickerTestLib",
+
+ defaults: ["ThemePicker_defaults"],
+ srcs: [
+ "src/com/android/customization/testing/**/*.java",
+ "src/com/android/customization/testing/**/*.kt",
+ ],
+ static_libs: [
+ "WallpaperPicker2TestLib",
+ "androidx.annotation_annotation",
+ "kotlinx_coroutines_test",
+ "truth-prebuilt",
+ ],
+
+ platform_apis: true,
+}
diff --git a/tests/common/AndroidManifest.xml b/tests/common/AndroidManifest.xml
new file mode 100644
index 0000000..81a2f03
--- /dev/null
+++ b/tests/common/AndroidManifest.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.wallpaper">
+
+ <application>
+ </application>
+</manifest>
diff --git a/tests/src/com/android/customization/testing/TestDefaultCustomizationPreferences.java b/tests/common/src/com/android/customization/testing/TestDefaultCustomizationPreferences.java
similarity index 61%
rename from tests/src/com/android/customization/testing/TestDefaultCustomizationPreferences.java
rename to tests/common/src/com/android/customization/testing/TestDefaultCustomizationPreferences.java
index bcf5a5f..81890f0 100644
--- a/tests/src/com/android/customization/testing/TestDefaultCustomizationPreferences.java
+++ b/tests/common/src/com/android/customization/testing/TestDefaultCustomizationPreferences.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2019 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.testing;
import android.content.Context;
diff --git a/tests/common/src/com/android/customization/testing/TestDrawableLayerResolver.java b/tests/common/src/com/android/customization/testing/TestDrawableLayerResolver.java
new file mode 100644
index 0000000..8b16299
--- /dev/null
+++ b/tests/common/src/com/android/customization/testing/TestDrawableLayerResolver.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2019 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.testing;
+
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.LayerDrawable;
+
+import com.android.wallpaper.module.DrawableLayerResolver;
+
+/**
+ * Test implementation of {@link DrawableLayerResolver}.
+ */
+public class TestDrawableLayerResolver implements DrawableLayerResolver {
+ @Override
+ public Drawable resolveLayer(LayerDrawable layerDrawable) {
+ return layerDrawable.getDrawable(0);
+ }
+}
diff --git a/tests/common/src/com/android/customization/testing/TestPackageStatusNotifier.java b/tests/common/src/com/android/customization/testing/TestPackageStatusNotifier.java
new file mode 100644
index 0000000..2aadae8
--- /dev/null
+++ b/tests/common/src/com/android/customization/testing/TestPackageStatusNotifier.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2019 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.testing;
+
+import com.android.wallpaper.module.PackageStatusNotifier;
+
+/**
+ * Test implementation of {@link PackageStatusNotifier}.
+ */
+public class TestPackageStatusNotifier implements PackageStatusNotifier {
+ @Override
+ public void addListener(Listener listener, String action) {
+ // Do nothing
+ }
+
+ @Override
+ public void removeListener(Listener listener) {
+ // Do nothing
+ }
+}
diff --git a/tests/src/com/android/customization/testing/TestPluginManager.kt b/tests/common/src/com/android/customization/testing/TestPluginManager.kt
similarity index 100%
rename from tests/src/com/android/customization/testing/TestPluginManager.kt
rename to tests/common/src/com/android/customization/testing/TestPluginManager.kt
diff --git a/tests/src/com/android/customization/testing/TestThemeManager.java b/tests/common/src/com/android/customization/testing/TestThemeManager.java
similarity index 60%
rename from tests/src/com/android/customization/testing/TestThemeManager.java
rename to tests/common/src/com/android/customization/testing/TestThemeManager.java
index c4d25fb..5175b24 100644
--- a/tests/src/com/android/customization/testing/TestThemeManager.java
+++ b/tests/common/src/com/android/customization/testing/TestThemeManager.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2019 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.testing;
import androidx.fragment.app.FragmentActivity;
diff --git a/tests/src/com/android/customization/testing/TestThemesUserEventLogger.java b/tests/common/src/com/android/customization/testing/TestThemesUserEventLogger.java
similarity index 63%
rename from tests/src/com/android/customization/testing/TestThemesUserEventLogger.java
rename to tests/common/src/com/android/customization/testing/TestThemesUserEventLogger.java
index 2bb2082..22a5b94 100644
--- a/tests/src/com/android/customization/testing/TestThemesUserEventLogger.java
+++ b/tests/common/src/com/android/customization/testing/TestThemesUserEventLogger.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2019 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.testing;
import com.android.customization.model.color.ColorOption;
diff --git a/tests/robotests/Android.bp b/tests/robotests/Android.bp
index 4416e1c..ed684f4 100644
--- a/tests/robotests/Android.bp
+++ b/tests/robotests/Android.bp
@@ -2,13 +2,23 @@
package {
default_applicable_licenses: ["Android-Apache-2.0"],
}
+
android_robolectric_test {
name: "ThemePickerRoboTests",
srcs: [
"src/**/*.java",
"src/**/*.kt",
],
+ // TODO(b/291104503) Enable this test
+ exclude_srcs: ["src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt"],
java_resource_dirs: ["config"],
+ static_libs: [
+ "WallpaperPicker2TestLib",
+ "androidx.test.rules",
+ "junit",
+ "kotlinx_coroutines_test",
+ "truth-prebuilt",
+ ],
libs: [
"androidx.test.core",
"androidx.test.runner",
diff --git a/tests/robotests/src/com/android/customization/model/color/ColorSectionControllerTest.java b/tests/robotests/src/com/android/customization/model/color/ColorSectionControllerTest.java
index 820e641..4e1a36a 100644
--- a/tests/robotests/src/com/android/customization/model/color/ColorSectionControllerTest.java
+++ b/tests/robotests/src/com/android/customization/model/color/ColorSectionControllerTest.java
@@ -22,6 +22,7 @@
import com.android.wallpaper.model.WallpaperColorsViewModel;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
@@ -32,6 +33,7 @@
/**
* Tests of {@link ColorSectionController}.
*/
+@Ignore("b/290798811")
@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
public final class ColorSectionControllerTest {
diff --git a/tests/src/com/android/customization/model/grid/data/repository/FakeGridRepository.kt b/tests/robotests/src/com/android/customization/model/grid/data/repository/FakeGridRepository.kt
similarity index 100%
rename from tests/src/com/android/customization/model/grid/data/repository/FakeGridRepository.kt
rename to tests/robotests/src/com/android/customization/model/grid/data/repository/FakeGridRepository.kt
diff --git a/tests/src/com/android/customization/model/grid/domain/interactor/GridInteractorTest.kt b/tests/robotests/src/com/android/customization/model/grid/domain/interactor/GridInteractorTest.kt
similarity index 100%
rename from tests/src/com/android/customization/model/grid/domain/interactor/GridInteractorTest.kt
rename to tests/robotests/src/com/android/customization/model/grid/domain/interactor/GridInteractorTest.kt
diff --git a/tests/src/com/android/customization/model/grid/domain/interactor/GridSnapshotRestorerTest.kt b/tests/robotests/src/com/android/customization/model/grid/domain/interactor/GridSnapshotRestorerTest.kt
similarity index 100%
rename from tests/src/com/android/customization/model/grid/domain/interactor/GridSnapshotRestorerTest.kt
rename to tests/robotests/src/com/android/customization/model/grid/domain/interactor/GridSnapshotRestorerTest.kt
diff --git a/tests/src/com/android/customization/model/grid/ui/viewmodel/GridScreenViewModelTest.kt b/tests/robotests/src/com/android/customization/model/grid/ui/viewmodel/GridScreenViewModelTest.kt
similarity index 100%
rename from tests/src/com/android/customization/model/grid/ui/viewmodel/GridScreenViewModelTest.kt
rename to tests/robotests/src/com/android/customization/model/grid/ui/viewmodel/GridScreenViewModelTest.kt
diff --git a/tests/src/com/android/customization/model/mode/DarkModeSnapshotRestorerTest.kt b/tests/robotests/src/com/android/customization/model/mode/DarkModeSnapshotRestorerTest.kt
similarity index 100%
rename from tests/src/com/android/customization/model/mode/DarkModeSnapshotRestorerTest.kt
rename to tests/robotests/src/com/android/customization/model/mode/DarkModeSnapshotRestorerTest.kt
diff --git a/tests/src/com/android/customization/model/picker/color/domain/interactor/ColorPickerInteractorTest.kt b/tests/robotests/src/com/android/customization/model/picker/color/domain/interactor/ColorPickerInteractorTest.kt
similarity index 98%
rename from tests/src/com/android/customization/model/picker/color/domain/interactor/ColorPickerInteractorTest.kt
rename to tests/robotests/src/com/android/customization/model/picker/color/domain/interactor/ColorPickerInteractorTest.kt
index cbf1365..d4f24ee 100644
--- a/tests/src/com/android/customization/model/picker/color/domain/interactor/ColorPickerInteractorTest.kt
+++ b/tests/robotests/src/com/android/customization/model/picker/color/domain/interactor/ColorPickerInteractorTest.kt
@@ -32,11 +32,11 @@
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
+import org.robolectric.RobolectricTestRunner
@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
-@RunWith(JUnit4::class)
+@RunWith(RobolectricTestRunner::class)
class ColorPickerInteractorTest {
private lateinit var underTest: ColorPickerInteractor
private lateinit var repository: FakeColorPickerRepository
diff --git a/tests/src/com/android/customization/model/picker/color/domain/interactor/ColorPickerSnapshotRestorerTest.kt b/tests/robotests/src/com/android/customization/model/picker/color/domain/interactor/ColorPickerSnapshotRestorerTest.kt
similarity index 98%
rename from tests/src/com/android/customization/model/picker/color/domain/interactor/ColorPickerSnapshotRestorerTest.kt
rename to tests/robotests/src/com/android/customization/model/picker/color/domain/interactor/ColorPickerSnapshotRestorerTest.kt
index 71a8f23..5f3e39e 100644
--- a/tests/src/com/android/customization/model/picker/color/domain/interactor/ColorPickerSnapshotRestorerTest.kt
+++ b/tests/robotests/src/com/android/customization/model/picker/color/domain/interactor/ColorPickerSnapshotRestorerTest.kt
@@ -34,11 +34,11 @@
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
+import org.robolectric.RobolectricTestRunner
@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
-@RunWith(JUnit4::class)
+@RunWith(RobolectricTestRunner::class)
class ColorPickerSnapshotRestorerTest {
private lateinit var underTest: ColorPickerSnapshotRestorer
diff --git a/tests/src/com/android/customization/model/picker/color/ui/viewmodel/ColorPickerViewModelTest.kt b/tests/robotests/src/com/android/customization/model/picker/color/ui/viewmodel/ColorPickerViewModelTest.kt
similarity index 98%
rename from tests/src/com/android/customization/model/picker/color/ui/viewmodel/ColorPickerViewModelTest.kt
rename to tests/robotests/src/com/android/customization/model/picker/color/ui/viewmodel/ColorPickerViewModelTest.kt
index a29d559..9968c5f 100644
--- a/tests/src/com/android/customization/model/picker/color/ui/viewmodel/ColorPickerViewModelTest.kt
+++ b/tests/robotests/src/com/android/customization/model/picker/color/ui/viewmodel/ColorPickerViewModelTest.kt
@@ -43,11 +43,11 @@
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
+import org.robolectric.RobolectricTestRunner
@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
-@RunWith(JUnit4::class)
+@RunWith(RobolectricTestRunner::class)
class ColorPickerViewModelTest {
private lateinit var underTest: ColorPickerViewModel
private lateinit var repository: FakeColorPickerRepository
diff --git a/tests/src/com/android/customization/model/picker/quickaffordance/data/repository/KeyguardQuickAffordancePickerRepositoryTest.kt b/tests/robotests/src/com/android/customization/model/picker/quickaffordance/data/repository/KeyguardQuickAffordancePickerRepositoryTest.kt
similarity index 97%
rename from tests/src/com/android/customization/model/picker/quickaffordance/data/repository/KeyguardQuickAffordancePickerRepositoryTest.kt
rename to tests/robotests/src/com/android/customization/model/picker/quickaffordance/data/repository/KeyguardQuickAffordancePickerRepositoryTest.kt
index 3f22ced..35dbadd 100644
--- a/tests/src/com/android/customization/model/picker/quickaffordance/data/repository/KeyguardQuickAffordancePickerRepositoryTest.kt
+++ b/tests/robotests/src/com/android/customization/model/picker/quickaffordance/data/repository/KeyguardQuickAffordancePickerRepositoryTest.kt
@@ -35,11 +35,11 @@
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
+import org.robolectric.RobolectricTestRunner
@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
-@RunWith(JUnit4::class)
+@RunWith(RobolectricTestRunner::class)
class KeyguardQuickAffordancePickerRepositoryTest {
private lateinit var underTest: KeyguardQuickAffordancePickerRepository
diff --git a/tests/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
similarity index 98%
rename from tests/src/com/android/customization/model/picker/quickaffordance/domain/interactor/KeyguardQuickAffordancePickerInteractorTest.kt
rename to tests/robotests/src/com/android/customization/model/picker/quickaffordance/domain/interactor/KeyguardQuickAffordancePickerInteractorTest.kt
index fea94dc..efe9f64 100644
--- a/tests/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
@@ -39,11 +39,11 @@
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
+import org.robolectric.RobolectricTestRunner
@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
-@RunWith(JUnit4::class)
+@RunWith(RobolectricTestRunner::class)
class KeyguardQuickAffordancePickerInteractorTest {
private lateinit var underTest: KeyguardQuickAffordancePickerInteractor
diff --git a/tests/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
similarity index 100%
rename from tests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt
rename to tests/robotests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt
diff --git a/tests/src/com/android/customization/model/themedicon/domain/interactor/ThemedIconInteractorTest.kt b/tests/robotests/src/com/android/customization/model/themedicon/domain/interactor/ThemedIconInteractorTest.kt
similarity index 100%
rename from tests/src/com/android/customization/model/themedicon/domain/interactor/ThemedIconInteractorTest.kt
rename to tests/robotests/src/com/android/customization/model/themedicon/domain/interactor/ThemedIconInteractorTest.kt
diff --git a/tests/src/com/android/customization/model/themedicon/domain/interactor/ThemedIconSnapshotRestorerTest.kt b/tests/robotests/src/com/android/customization/model/themedicon/domain/interactor/ThemedIconSnapshotRestorerTest.kt
similarity index 100%
rename from tests/src/com/android/customization/model/themedicon/domain/interactor/ThemedIconSnapshotRestorerTest.kt
rename to tests/robotests/src/com/android/customization/model/themedicon/domain/interactor/ThemedIconSnapshotRestorerTest.kt
diff --git a/tests/src/com/android/customization/picker/clock/data/repository/FakeClockPickerRepository.kt b/tests/robotests/src/com/android/customization/picker/clock/data/repository/FakeClockPickerRepository.kt
similarity index 84%
rename from tests/src/com/android/customization/picker/clock/data/repository/FakeClockPickerRepository.kt
rename to tests/robotests/src/com/android/customization/picker/clock/data/repository/FakeClockPickerRepository.kt
index bf2766d..95d7e35 100644
--- a/tests/src/com/android/customization/picker/clock/data/repository/FakeClockPickerRepository.kt
+++ b/tests/robotests/src/com/android/customization/picker/clock/data/repository/FakeClockPickerRepository.kt
@@ -45,11 +45,12 @@
val selectedClock = fakeClocks.find { clock -> clock.clockId == selectedClockId }
checkNotNull(selectedClock)
ClockMetadataModel(
- selectedClock.clockId,
- selectedClock.name,
- selectedColor,
- colorTone,
- seedColor,
+ clockId = selectedClock.clockId,
+ name = selectedClock.name,
+ isSelected = true,
+ selectedColorId = selectedColor,
+ colorToneProgress = colorTone,
+ seedColor = seedColor,
)
}
@@ -81,10 +82,10 @@
const val CLOCK_ID_3 = "clock3"
val fakeClocks =
listOf(
- ClockMetadataModel(CLOCK_ID_0, "clock0", null, 50, null),
- ClockMetadataModel(CLOCK_ID_1, "clock1", null, 50, null),
- ClockMetadataModel(CLOCK_ID_2, "clock2", null, 50, null),
- ClockMetadataModel(CLOCK_ID_3, "clock3", null, 50, null),
+ ClockMetadataModel(CLOCK_ID_0, "clock0", true, null, 50, null),
+ ClockMetadataModel(CLOCK_ID_1, "clock1", false, null, 50, null),
+ ClockMetadataModel(CLOCK_ID_2, "clock2", false, null, 50, null),
+ ClockMetadataModel(CLOCK_ID_3, "clock3", false, null, 50, null),
)
const val CLOCK_COLOR_ID = "RED"
const val CLOCK_COLOR_TONE_PROGRESS = 87
diff --git a/tests/src/com/android/customization/picker/clock/domain/interactor/ClockPickerInteractorTest.kt b/tests/robotests/src/com/android/customization/picker/clock/domain/interactor/ClockPickerInteractorTest.kt
similarity index 97%
rename from tests/src/com/android/customization/picker/clock/domain/interactor/ClockPickerInteractorTest.kt
rename to tests/robotests/src/com/android/customization/picker/clock/domain/interactor/ClockPickerInteractorTest.kt
index 1a7ebb5..c8e39be 100644
--- a/tests/src/com/android/customization/picker/clock/domain/interactor/ClockPickerInteractorTest.kt
+++ b/tests/robotests/src/com/android/customization/picker/clock/domain/interactor/ClockPickerInteractorTest.kt
@@ -17,11 +17,11 @@
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
+import org.robolectric.RobolectricTestRunner
@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
-@RunWith(JUnit4::class)
+@RunWith(RobolectricTestRunner::class)
class ClockPickerInteractorTest {
private lateinit var underTest: ClockPickerInteractor
diff --git a/tests/robotests/src/com/android/customization/picker/clock/ui/fragment/ClockCustomDemoFragmentTest.kt b/tests/robotests/src/com/android/customization/picker/clock/ui/fragment/ClockCustomDemoFragmentTest.kt
deleted file mode 100644
index 0a54312..0000000
--- a/tests/robotests/src/com/android/customization/picker/clock/ui/fragment/ClockCustomDemoFragmentTest.kt
+++ /dev/null
@@ -1,75 +0,0 @@
-package com.android.customization.picker.clock.ui.fragment
-
-import android.view.View
-import androidx.appcompat.app.AppCompatActivity
-import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.recyclerview.widget.RecyclerView
-import com.android.systemui.plugins.ClockMetadata
-import com.android.systemui.plugins.ClockSettings
-import com.android.systemui.plugins.PluginManager
-import com.android.systemui.shared.clocks.ClockRegistry
-import org.junit.Assert
-import org.junit.Before
-import org.junit.Ignore
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.mockito.Mock
-import org.mockito.Mockito.verify
-import org.mockito.Mockito.`when` as whenever
-import org.mockito.MockitoAnnotations
-import org.robolectric.Robolectric
-import org.robolectric.RobolectricTestRunner
-import org.robolectric.annotation.Config
-
-/** Tests of [ClockCustomDemoFragment]. */
-@RunWith(RobolectricTestRunner::class)
-@Config(manifest = Config.NONE)
-@Ignore("b/270606895")
-class ClockCustomDemoFragmentTest {
- private lateinit var mActivity: AppCompatActivity
- private var mClockCustomDemoFragment: ClockCustomDemoFragment? = null
- @Mock private lateinit var registry: ClockRegistry
- @Mock private lateinit var mockPluginManager: PluginManager
-
- private var settingValue: ClockSettings? = null
-
- @Before
- fun setUp() {
- MockitoAnnotations.initMocks(this)
- mActivity = Robolectric.buildActivity(AppCompatActivity::class.java).get()
- mClockCustomDemoFragment = ClockCustomDemoFragment()
- whenever(registry.getClocks())
- .thenReturn(
- listOf(
- ClockMetadata("CLOCK_1", "Clock 1"),
- ClockMetadata("CLOCK_2", "Clock 2"),
- ClockMetadata("CLOCK_NOT_IN_USE", "Clock not in use")
- )
- )
-
- mClockCustomDemoFragment!!.clockRegistry = registry
- mClockCustomDemoFragment!!.recyclerView = RecyclerView(mActivity)
- mClockCustomDemoFragment!!.recyclerView.layoutManager =
- LinearLayoutManager(mActivity, RecyclerView.VERTICAL, false)
- }
-
- @Test
- fun testItemCount_getCorrectClockCount() {
- Assert.assertEquals(3, mClockCustomDemoFragment!!.recyclerView.adapter!!.itemCount)
- }
-
- @Test
- fun testClick_setCorrectClockId() {
- mClockCustomDemoFragment!!
- .recyclerView
- .measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
- mClockCustomDemoFragment!!.recyclerView.layout(0, 0, 100, 10000)
- val testPosition = 1
- mClockCustomDemoFragment!!
- .recyclerView
- .findViewHolderForAdapterPosition(testPosition)
- ?.itemView
- ?.performClick()
- verify(registry).currentClockId = "CLOCK_1"
- }
-}
diff --git a/tests/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModelTest.kt b/tests/robotests/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModelTest.kt
similarity index 92%
rename from tests/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModelTest.kt
rename to tests/robotests/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModelTest.kt
index c5eb796..1b1eb9a 100644
--- a/tests/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModelTest.kt
+++ b/tests/robotests/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModelTest.kt
@@ -37,22 +37,23 @@
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
+import org.robolectric.RobolectricTestRunner
@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
-@RunWith(JUnit4::class)
+@RunWith(RobolectricTestRunner::class)
class ClockCarouselViewModelTest {
private val repositoryWithMultipleClocks by lazy { FakeClockPickerRepository() }
private val repositoryWithSingleClock by lazy {
FakeClockPickerRepository(
listOf(
ClockMetadataModel(
- "clock0",
- "clock0",
- null,
- ClockMetadataModel.DEFAULT_COLOR_TONE_PROGRESS,
- null,
+ clockId = "clock0",
+ name = "clock0",
+ isSelected = true,
+ selectedColorId = null,
+ colorToneProgress = ClockMetadataModel.DEFAULT_COLOR_TONE_PROGRESS,
+ seedColor = null,
),
)
)
diff --git a/tests/src/com/android/customization/picker/clock/ui/viewmodel/ClockSectionViewModelTest.kt b/tests/robotests/src/com/android/customization/picker/clock/ui/viewmodel/ClockSectionViewModelTest.kt
similarity index 97%
rename from tests/src/com/android/customization/picker/clock/ui/viewmodel/ClockSectionViewModelTest.kt
rename to tests/robotests/src/com/android/customization/picker/clock/ui/viewmodel/ClockSectionViewModelTest.kt
index 293e393..19a704c 100644
--- a/tests/src/com/android/customization/picker/clock/ui/viewmodel/ClockSectionViewModelTest.kt
+++ b/tests/robotests/src/com/android/customization/picker/clock/ui/viewmodel/ClockSectionViewModelTest.kt
@@ -36,11 +36,11 @@
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
+import org.robolectric.RobolectricTestRunner
@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
-@RunWith(JUnit4::class)
+@RunWith(RobolectricTestRunner::class)
class ClockSectionViewModelTest {
private lateinit var clockColorMap: Map<String, ClockColorViewModel>
diff --git a/tests/src/com/android/customization/picker/clock/ui/viewmodel/ClockSettingsViewModelTest.kt b/tests/robotests/src/com/android/customization/picker/clock/ui/viewmodel/ClockSettingsViewModelTest.kt
similarity index 98%
rename from tests/src/com/android/customization/picker/clock/ui/viewmodel/ClockSettingsViewModelTest.kt
rename to tests/robotests/src/com/android/customization/picker/clock/ui/viewmodel/ClockSettingsViewModelTest.kt
index f58baf8..f09e977 100644
--- a/tests/src/com/android/customization/picker/clock/ui/viewmodel/ClockSettingsViewModelTest.kt
+++ b/tests/robotests/src/com/android/customization/picker/clock/ui/viewmodel/ClockSettingsViewModelTest.kt
@@ -28,11 +28,11 @@
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
+import org.robolectric.RobolectricTestRunner
@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
-@RunWith(JUnit4::class)
+@RunWith(RobolectricTestRunner::class)
class ClockSettingsViewModelTest {
private lateinit var context: Context
diff --git a/tests/src/com/android/customization/picker/notifications/data/repository/NotificationsRepositoryTest.kt b/tests/robotests/src/com/android/customization/picker/notifications/data/repository/NotificationsRepositoryTest.kt
similarity index 100%
rename from tests/src/com/android/customization/picker/notifications/data/repository/NotificationsRepositoryTest.kt
rename to tests/robotests/src/com/android/customization/picker/notifications/data/repository/NotificationsRepositoryTest.kt
diff --git a/tests/src/com/android/customization/picker/notifications/ui/viewmodel/NotificationSectionViewModelTest.kt b/tests/robotests/src/com/android/customization/picker/notifications/ui/viewmodel/NotificationSectionViewModelTest.kt
similarity index 97%
rename from tests/src/com/android/customization/picker/notifications/ui/viewmodel/NotificationSectionViewModelTest.kt
rename to tests/robotests/src/com/android/customization/picker/notifications/ui/viewmodel/NotificationSectionViewModelTest.kt
index 63334f2..5c3544a 100644
--- a/tests/src/com/android/customization/picker/notifications/ui/viewmodel/NotificationSectionViewModelTest.kt
+++ b/tests/robotests/src/com/android/customization/picker/notifications/ui/viewmodel/NotificationSectionViewModelTest.kt
@@ -37,11 +37,11 @@
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
+import org.robolectric.RobolectricTestRunner
@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
-@RunWith(JUnit4::class)
+@RunWith(RobolectricTestRunner::class)
class NotificationSectionViewModelTest {
private lateinit var underTest: NotificationSectionViewModel
diff --git a/tests/src/com/android/customization/testing/TestDrawableLayerResolver.java b/tests/src/com/android/customization/testing/TestDrawableLayerResolver.java
deleted file mode 100644
index e507221..0000000
--- a/tests/src/com/android/customization/testing/TestDrawableLayerResolver.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.android.customization.testing;
-
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.LayerDrawable;
-
-import com.android.wallpaper.module.DrawableLayerResolver;
-
-/**
- * Test implementation of {@link DrawableLayerResolver}.
- */
-public class TestDrawableLayerResolver implements DrawableLayerResolver {
- @Override
- public Drawable resolveLayer(LayerDrawable layerDrawable) {
- return layerDrawable.getDrawable(0);
- }
-}
diff --git a/tests/src/com/android/customization/testing/TestPackageStatusNotifier.java b/tests/src/com/android/customization/testing/TestPackageStatusNotifier.java
deleted file mode 100644
index 1e6a1a2..0000000
--- a/tests/src/com/android/customization/testing/TestPackageStatusNotifier.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.android.customization.testing;
-
-import com.android.wallpaper.module.PackageStatusNotifier;
-
-/**
- * Test implementation of {@link PackageStatusNotifier}.
- */
-public class TestPackageStatusNotifier implements PackageStatusNotifier {
- @Override
- public void addListener(Listener listener, String action) {
- // Do nothing
- }
-
- @Override
- public void removeListener(Listener listener) {
- // Do nothing
- }
-}