Merge "Fixes crashes in WallpaperPicker2 app on AOSP" into udc-qpr-dev
diff --git a/res/layout/clock_size_radio_button_group.xml b/res/layout/clock_size_radio_button_group.xml
index 2aa78d2..56d0ab7 100644
--- a/res/layout/clock_size_radio_button_group.xml
+++ b/res/layout/clock_size_radio_button_group.xml
@@ -68,11 +68,21 @@
android:layout_marginEnd="8dp"
android:clickable="false" />
- <TextView
- style="@style/SectionTitleTextStyle"
- android:layout_width="wrap_content"
+ <LinearLayout
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:text="@string/clock_size_small" />
+ android:orientation="vertical">
+ <TextView
+ style="@style/SectionTitleTextStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/clock_size_small" />
+
+ <TextView
+ style="@style/SectionSubtitleTextStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/clock_size_small_description" />
+ </LinearLayout>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/single_clock_view.xml b/res/layout/single_clock_view.xml
deleted file mode 100644
index ffc6039..0000000
--- a/res/layout/single_clock_view.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?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.
--->
-<com.android.wallpaper.picker.FixedWidthDisplayRatioFrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="@dimen/screen_preview_width"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:clipChildren="false">
- <com.android.customization.picker.clock.ui.view.ClockHostView
- android:id="@+id/single_clock_host_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center" />
-</com.android.wallpaper.picker.FixedWidthDisplayRatioFrameLayout>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 680947d..eb68dce 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -90,6 +90,9 @@
<!-- Title of a radio button to apply clock size small. [CHAR LIMIT=15] -->
<string name="clock_size_small">Small</string>
+ <!-- Description of a radio button to apply clock size small. [CHAR LIMIT=NONE] -->
+ <string name="clock_size_small_description">A small clock shows in the corner of your screen</string>
+
<!-- Title of a section of the customization picker where the user can select a Grid size for
the home screen. [CHAR LIMIT=15] -->
<string name="grid_title">App grid</string>
diff --git a/src/com/android/customization/model/CustomizationManager.java b/src/com/android/customization/model/CustomizationManager.java
index 104cc83..e6d3872 100644
--- a/src/com/android/customization/model/CustomizationManager.java
+++ b/src/com/android/customization/model/CustomizationManager.java
@@ -72,6 +72,9 @@
*/
void apply(T option, Callback callback);
+ /** Preview the given option without committing the change. */
+ default void preview(T option) {}
+
/**
* Loads the available options for the type of Customization managed by this class, calling the
* given callback when done.
diff --git a/src/com/android/customization/model/color/ColorProvider.kt b/src/com/android/customization/model/color/ColorProvider.kt
index e545271..74a4051 100644
--- a/src/com/android/customization/model/color/ColorProvider.kt
+++ b/src/com/android/customization/model/color/ColorProvider.kt
@@ -432,7 +432,8 @@
val extractor = ColorBundlePreviewExtractor(mContext)
val bundles: MutableList<ColorOption> = ArrayList()
- val bundleNames = getItemsFromStub(COLOR_BUNDLES_ARRAY_NAME)
+ val bundleNames =
+ if (isAvailable) getItemsFromStub(COLOR_BUNDLES_ARRAY_NAME) else emptyArray()
// Color option index value starts from 1.
var index = 1
val maxPresetColors = if (themeStyleEnabled) bundleNames.size else MAX_PRESET_COLORS
diff --git a/src/com/android/customization/model/grid/GridOption.java b/src/com/android/customization/model/grid/GridOption.java
index 19c5d4f..17ba115 100644
--- a/src/com/android/customization/model/grid/GridOption.java
+++ b/src/com/android/customization/model/grid/GridOption.java
@@ -49,7 +49,6 @@
};
private final String mTitle;
- private final boolean mIsCurrent;
private final String mIconShapePath;
private final GridTileDrawable mTileDrawable;
public final String name;
@@ -57,6 +56,7 @@
public final int cols;
public final Uri previewImageUri;
public final int previewPagesCount;
+ private boolean mIsCurrent;
public GridOption(String title, String name, boolean isCurrent, int rows, int cols,
Uri previewImageUri, int previewPagesCount, String iconShapePath) {
@@ -71,6 +71,10 @@
this.previewPagesCount = previewPagesCount;
}
+ public void setIsCurrent(boolean isCurrent) {
+ mIsCurrent = isCurrent;
+ }
+
protected GridOption(Parcel in) {
mTitle = in.readString();
mIsCurrent = in.readByte() != 0;
diff --git a/src/com/android/customization/model/grid/GridOptionsManager.java b/src/com/android/customization/model/grid/GridOptionsManager.java
index b7ee37f..78dbb5b 100644
--- a/src/com/android/customization/model/grid/GridOptionsManager.java
+++ b/src/com/android/customization/model/grid/GridOptionsManager.java
@@ -99,6 +99,11 @@
}
@Override
+ public void preview(GridOption option) {
+ mProvider.updateView();
+ }
+
+ @Override
public void fetchOptions(OptionsFetchedListener<GridOption> callback, boolean reload) {
sExecutorService.submit(() -> {
List<GridOption> gridOptions = mProvider.fetch(reload);
diff --git a/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java b/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java
index 4e775c6..8f1860e 100644
--- a/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java
+++ b/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java
@@ -117,6 +117,10 @@
mPreviewUtils.renderPreview(bundle, callback);
}
+ void updateView() {
+ mLiveData.postValue(new Object());
+ }
+
int applyGrid(String name) {
ContentValues values = new ContentValues();
values.put("name", name);
diff --git a/src/com/android/customization/model/grid/data/repository/GridRepository.kt b/src/com/android/customization/model/grid/data/repository/GridRepository.kt
index 9a3be0c..e65c18e 100644
--- a/src/com/android/customization/model/grid/data/repository/GridRepository.kt
+++ b/src/com/android/customization/model/grid/data/repository/GridRepository.kt
@@ -38,12 +38,14 @@
suspend fun isAvailable(): Boolean
fun getOptionChanges(): Flow<Unit>
suspend fun getOptions(): GridOptionItemsModel
+ fun getSelectedOption(): GridOption?
}
class GridRepositoryImpl(
private val applicationScope: CoroutineScope,
private val manager: GridOptionsManager,
private val backgroundDispatcher: CoroutineDispatcher,
+ private val isGridApplyButtonEnabled: Boolean,
) : GridRepository {
override suspend fun isAvailable(): Boolean {
@@ -55,6 +57,8 @@
private val selectedOption = MutableStateFlow<GridOption?>(null)
+ override fun getSelectedOption() = selectedOption.value
+
override suspend fun getOptions(): GridOptionItemsModel {
return withContext(backgroundDispatcher) {
suspendCancellableCoroutine { continuation ->
@@ -62,7 +66,11 @@
object : CustomizationManager.OptionsFetchedListener<GridOption> {
override fun onOptionsLoaded(options: MutableList<GridOption>?) {
val optionsOrEmpty = options ?: emptyList()
- selectedOption.value = optionsOrEmpty.find { it.isActive(manager) }
+ // After Apply Button is added, we will rely on onSelected() method
+ // to update selectedOption.
+ if (!isGridApplyButtonEnabled || selectedOption.value == null) {
+ selectedOption.value = optionsOrEmpty.find { it.isActive(manager) }
+ }
continuation.resume(
GridOptionItemsModel.Loaded(
optionsOrEmpty.map { option -> toModel(option) }
@@ -105,18 +113,26 @@
private suspend fun onSelected(option: GridOption) {
withContext(backgroundDispatcher) {
suspendCancellableCoroutine { continuation ->
- manager.apply(
- option,
- object : CustomizationManager.Callback {
- override fun onSuccess() {
- continuation.resume(true)
- }
+ if (isGridApplyButtonEnabled) {
+ selectedOption.value?.setIsCurrent(false)
+ selectedOption.value = option
+ selectedOption.value?.setIsCurrent(true)
+ manager.preview(option)
+ continuation.resume(true)
+ } else {
+ manager.apply(
+ option,
+ object : CustomizationManager.Callback {
+ override fun onSuccess() {
+ continuation.resume(true)
+ }
- override fun onError(throwable: Throwable?) {
- continuation.resume(false)
- }
- },
- )
+ override fun onError(throwable: Throwable?) {
+ continuation.resume(false)
+ }
+ },
+ )
+ }
}
}
}
diff --git a/src/com/android/customization/model/grid/domain/interactor/GridInteractor.kt b/src/com/android/customization/model/grid/domain/interactor/GridInteractor.kt
index cdb679d..6cb00ff 100644
--- a/src/com/android/customization/model/grid/domain/interactor/GridInteractor.kt
+++ b/src/com/android/customization/model/grid/domain/interactor/GridInteractor.kt
@@ -95,4 +95,6 @@
model
}
}
+
+ fun getSelectedOptionName(): String? = repository.getSelectedOption()?.name
}
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 5ca0fe0..14d1344 100644
--- a/src/com/android/customization/model/grid/ui/fragment/GridFragment2.kt
+++ b/src/com/android/customization/model/grid/ui/fragment/GridFragment2.kt
@@ -26,6 +26,7 @@
import androidx.lifecycle.ViewModelProvider
import androidx.transition.Transition
import androidx.transition.doOnStart
+import com.android.customization.model.grid.domain.interactor.GridInteractor
import com.android.customization.model.grid.ui.binder.GridScreenBinder
import com.android.customization.model.grid.ui.viewmodel.GridScreenViewModel
import com.android.customization.module.ThemePickerInjector
@@ -65,7 +66,8 @@
bindScreenPreview(
view,
wallpaperInfoFactory,
- injector.getWallpaperInteractor(requireContext())
+ injector.getWallpaperInteractor(requireContext()),
+ injector.getGridInteractor(requireContext())
)
val viewModelFactory = injector.getGridScreenViewModelFactory(requireContext())
@@ -84,7 +86,8 @@
bindScreenPreview(
view,
wallpaperInfoFactory,
- injector.getWallpaperInteractor(requireContext())
+ injector.getWallpaperInteractor(requireContext()),
+ injector.getGridInteractor(requireContext())
)
}
)
@@ -112,6 +115,7 @@
view: View,
wallpaperInfoFactory: CurrentWallpaperInfoFactory,
wallpaperInteractor: WallpaperInteractor,
+ gridInteractor: GridInteractor
): ScreenPreviewBinder.Binding {
return ScreenPreviewBinder.bind(
activity = requireActivity(),
@@ -127,6 +131,11 @@
R.string.grid_control_metadata_name,
),
),
+ initialExtrasProvider = {
+ val bundle = Bundle()
+ bundle.putString("name", gridInteractor.getSelectedOptionName())
+ bundle
+ },
wallpaperInfoProvider = {
suspendCancellableCoroutine { continuation ->
wallpaperInfoFactory.createCurrentWallpaperInfos(
diff --git a/src/com/android/customization/module/StatsLogUserEventLogger.java b/src/com/android/customization/module/StatsLogUserEventLogger.java
index 057234b..647cdc9 100644
--- a/src/com/android/customization/module/StatsLogUserEventLogger.java
+++ b/src/com/android/customization/module/StatsLogUserEventLogger.java
@@ -163,6 +163,16 @@
.log();
}
+ @Override
+ public void logEffectForegroundDownload(String effect, @EffectStatus int status,
+ long timeElapsedMillis) {
+ new SysUiStatsLogger(StyleEnums.WALLPAPER_EFFECT_FG_DOWNLOAD)
+ .setEffectPreference(status)
+ .setEffectIdHash(getIdHashCode(effect))
+ .setTimeElapsed(timeElapsedMillis)
+ .log();
+ }
+
@Nullable
private String getThemePackage(ThemeBundle theme, String category) {
Map<String, String> packages = theme.getPackagesByCategory();
diff --git a/src/com/android/customization/module/ThemePickerInjector.kt b/src/com/android/customization/module/ThemePickerInjector.kt
index 653c403..3197bf6 100644
--- a/src/com/android/customization/module/ThemePickerInjector.kt
+++ b/src/com/android/customization/module/ThemePickerInjector.kt
@@ -69,6 +69,7 @@
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.config.BaseFlags
import com.android.wallpaper.dispatchers.BackgroundDispatcher
import com.android.wallpaper.dispatchers.MainDispatcher
import com.android.wallpaper.model.LiveWallpaperInfo
@@ -571,7 +572,7 @@
.also { gridScreenViewModelFactory = it }
}
- private fun getGridInteractor(
+ fun getGridInteractor(
context: Context,
): GridInteractor {
val appContext = context.applicationContext
@@ -583,6 +584,8 @@
applicationScope = getApplicationCoroutineScope(),
manager = GridOptionsManager.getInstance(context),
backgroundDispatcher = bgDispatcher,
+ isGridApplyButtonEnabled =
+ BaseFlags.get().isGridApplyButtonEnabled(appContext),
),
snapshotRestorer = { getGridSnapshotRestorer(appContext) },
)
diff --git a/src/com/android/customization/picker/clock/ui/binder/ClockCarouselViewBinder.kt b/src/com/android/customization/picker/clock/ui/binder/ClockCarouselViewBinder.kt
index 89fac89..7880d82 100644
--- a/src/com/android/customization/picker/clock/ui/binder/ClockCarouselViewBinder.kt
+++ b/src/com/android/customization/picker/clock/ui/binder/ClockCarouselViewBinder.kt
@@ -16,8 +16,6 @@
package com.android.customization.picker.clock.ui.binder
import android.content.Context
-import android.view.ViewGroup
-import android.widget.FrameLayout
import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
@@ -27,7 +25,6 @@
import com.android.customization.picker.clock.ui.view.ClockCarouselView
import com.android.customization.picker.clock.ui.view.ClockViewFactory
import com.android.customization.picker.clock.ui.viewmodel.ClockCarouselViewModel
-import com.android.wallpaper.R
import com.android.wallpaper.picker.customization.ui.section.ScreenPreviewClickView
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.launch
@@ -38,7 +35,6 @@
fun bind(
context: Context,
carouselView: ClockCarouselView,
- singleClockView: ViewGroup,
screenPreviewClickView: ScreenPreviewClickView,
viewModel: ClockCarouselViewModel,
clockViewFactory: ClockViewFactory,
@@ -46,6 +42,7 @@
isTwoPaneAndSmallWidth: Boolean,
) {
carouselView.setClockViewFactory(clockViewFactory)
+ carouselView.isVisible = true
clockViewFactory.updateRegionDarkness()
val carouselAccessibilityDelegate =
CarouselAccessibilityDelegate(
@@ -61,12 +58,8 @@
)
screenPreviewClickView.accessibilityDelegate = carouselAccessibilityDelegate
- val singleClockHostView =
- singleClockView.requireViewById<FrameLayout>(R.id.single_clock_host_view)
lifecycleOwner.lifecycleScope.launch {
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
- launch { viewModel.isCarouselVisible.collect { carouselView.isVisible = it } }
-
launch {
combine(viewModel.selectedClockSize, viewModel.allClocks, ::Pair).collect {
(size, allClocks) ->
@@ -98,21 +91,6 @@
launch {
viewModel.seedColor.collect { clockViewFactory.updateColorForAllClocks(it) }
}
-
- launch {
- viewModel.isSingleClockViewVisible.collect { singleClockView.isVisible = it }
- }
-
- launch {
- viewModel.clockId.collect { clockId ->
- singleClockHostView.removeAllViews()
- val clockView = clockViewFactory.getLargeView(clockId)
- // The clock view might still be attached to an existing parent. Detach
- // before adding to another parent.
- (clockView.parent as? ViewGroup)?.removeView(clockView)
- singleClockHostView.addView(clockView)
- }
- }
}
}
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 aa6cc91..2d18ab3 100644
--- a/src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt
+++ b/src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt
@@ -114,6 +114,7 @@
}
adapter = ClockCarouselAdapter(clockSize, clocks, clockViewFactory, onClockSelected)
+ carousel.isInfinite = clocks.size >= MIN_CLOCKS_TO_ENABLE_INFINITE_CAROUSEL
carousel.setAdapter(adapter)
val indexOfSelectedClock =
clocks
@@ -470,6 +471,8 @@
}
companion object {
+ // The carousel needs to have at least 5 different clock faces to be infinite
+ const val MIN_CLOCKS_TO_ENABLE_INFINITE_CAROUSEL = 5
const val CLOCK_CAROUSEL_VIEW_SCALE = 0.5f
val itemViewIds =
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 7922054..b2dfa61 100644
--- a/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModel.kt
+++ b/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModel.kt
@@ -27,7 +27,6 @@
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
-import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapLatest
@@ -39,8 +38,7 @@
* Clock carousel view model that provides data for the carousel of clock previews. When there is
* only one item, we should show a single clock preview instead of a carousel.
*/
-class ClockCarouselViewModel
-constructor(
+class ClockCarouselViewModel(
private val interactor: ClockPickerInteractor,
private val backgroundDispatcher: CoroutineDispatcher,
) : ViewModel() {
@@ -58,8 +56,6 @@
val seedColor: Flow<Int?> = interactor.seedColor
- val isCarouselVisible: Flow<Boolean> = allClocks.map { it.size > 1 }.distinctUntilChanged()
-
@OptIn(ExperimentalCoroutinesApi::class)
val selectedIndex: Flow<Int> =
allClocks
@@ -77,15 +73,6 @@
}
.mapNotNull { it }
- // Handle the case when there is only one clock in the carousel
- val isSingleClockViewVisible: Flow<Boolean> =
- allClocks.map { it.size == 1 }.distinctUntilChanged()
-
- val clockId: Flow<String> =
- allClocks
- .map { allClockIds -> if (allClockIds.size == 1) allClockIds[0].clockId else null }
- .mapNotNull { it }
-
private var setSelectedClockJob: Job? = null
fun setSelectedClock(clockId: String) {
setSelectedClockJob?.cancel()
diff --git a/src/com/android/customization/picker/color/ui/binder/ColorSectionViewBinder.kt b/src/com/android/customization/picker/color/ui/binder/ColorSectionViewBinder.kt
index 45e3cde..5b0e4d4 100644
--- a/src/com/android/customization/picker/color/ui/binder/ColorSectionViewBinder.kt
+++ b/src/com/android/customization/picker/color/ui/binder/ColorSectionViewBinder.kt
@@ -112,22 +112,20 @@
val optionSelectedView = itemView.findViewById<ImageView>(R.id.option_selected)
lifecycleOwner.lifecycleScope.launch {
- lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
- launch {
- item.isSelected.collect { isSelected ->
- optionSelectedView.isVisible = isSelected
- }
+ launch {
+ item.isSelected.collect { isSelected ->
+ optionSelectedView.isVisible = isSelected
}
- launch {
- item.onClicked.collect { onClicked ->
- itemView.setOnClickListener(
- if (onClicked != null) {
- View.OnClickListener { onClicked.invoke() }
- } else {
- null
- }
- )
- }
+ }
+ launch {
+ item.onClicked.collect { onClicked ->
+ itemView.setOnClickListener(
+ if (onClicked != null) {
+ View.OnClickListener { onClicked.invoke() }
+ } else {
+ null
+ }
+ )
}
}
}
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 fa87029..2174ba7 100644
--- a/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
+++ b/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
@@ -23,7 +23,6 @@
import android.view.TouchDelegate
import android.view.View
import android.view.View.OnAttachStateChangeListener
-import android.view.ViewGroup
import android.view.ViewStub
import androidx.activity.ComponentActivity
import androidx.constraintlayout.helper.widget.Carousel
@@ -156,12 +155,6 @@
guidelineEnd.layoutParams = layoutParams
}
- // TODO (b/270716937) We should handle the single clock case in the clock carousel
- // itself
- val singleClockViewStub: ViewStub = view.requireViewById(R.id.single_clock_view_stub)
- singleClockViewStub.layoutResource = R.layout.single_clock_view
- val singleClockView = singleClockViewStub.inflate() as ViewGroup
-
/**
* Only bind after [Carousel.onAttachedToWindow]. This is to avoid the race condition
* that the flow emits before attached to window where [Carousel.mMotionLayout] is still
@@ -177,7 +170,6 @@
ClockCarouselViewBinder.bind(
context = context,
carouselView = carouselView,
- singleClockView = singleClockView,
screenPreviewClickView = screenPreviewClickView,
viewModel = viewModel,
clockViewFactory = clockViewFactory,
diff --git a/tests/robotests/src/com/android/customization/model/grid/data/repository/FakeGridRepository.kt b/tests/robotests/src/com/android/customization/model/grid/data/repository/FakeGridRepository.kt
index 5953937..0c80e28 100644
--- a/tests/robotests/src/com/android/customization/model/grid/data/repository/FakeGridRepository.kt
+++ b/tests/robotests/src/com/android/customization/model/grid/data/repository/FakeGridRepository.kt
@@ -17,6 +17,7 @@
package com.android.customization.model.grid.data.repository
+import com.android.customization.model.grid.GridOption
import com.android.customization.model.grid.shared.model.GridOptionItemModel
import com.android.customization.model.grid.shared.model.GridOptionItemsModel
import kotlinx.coroutines.CoroutineScope
@@ -51,6 +52,8 @@
return options
}
+ override fun getSelectedOption(): GridOption? = null
+
fun setOptions(
count: Int,
selectedIndex: Int = 0,
diff --git a/tests/robotests/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModelTest.kt b/tests/robotests/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModelTest.kt
index 1b1eb9a..ca6f8c7 100644
--- a/tests/robotests/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModelTest.kt
+++ b/tests/robotests/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModelTest.kt
@@ -88,38 +88,6 @@
assertThat(observedSelectedIndex()).isEqualTo(2)
}
- @Test
- fun multipleClockCase() = runTest {
- underTest =
- ClockCarouselViewModel(
- getClockPickerInteractor(repositoryWithMultipleClocks),
- testDispatcher
- )
- val observedIsCarouselVisible = collectLastValue(underTest.isCarouselVisible)
- val observedIsSingleClockViewVisible = collectLastValue(underTest.isSingleClockViewVisible)
-
- advanceTimeBy(ClockCarouselViewModel.CLOCKS_EVENT_UPDATE_DELAY_MILLIS)
-
- assertThat(observedIsCarouselVisible()).isTrue()
- assertThat(observedIsSingleClockViewVisible()).isFalse()
- }
-
- @Test
- fun singleClockCase() = runTest {
- underTest =
- ClockCarouselViewModel(
- getClockPickerInteractor(repositoryWithSingleClock),
- testDispatcher
- )
- val observedIsCarouselVisible = collectLastValue(underTest.isCarouselVisible)
- val observedIsSingleClockViewVisible = collectLastValue(underTest.isSingleClockViewVisible)
-
- advanceTimeBy(ClockCarouselViewModel.CLOCKS_EVENT_UPDATE_DELAY_MILLIS)
-
- assertThat(observedIsCarouselVisible()).isFalse()
- assertThat(observedIsSingleClockViewVisible()).isTrue()
- }
-
private fun getClockPickerInteractor(repository: ClockPickerRepository): ClockPickerInteractor {
return ClockPickerInteractor(
repository = repository,