Loading res/layout/clock_section_view.xml +2 −3 Original line number Diff line number Diff line Loading @@ -33,14 +33,13 @@ <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/clock_settings_title" android:text="@string/clock_color_and_size_title" style="@style/SectionTitleTextStyle" /> <TextView android:id="@+id/selected_clock_text" android:id="@+id/selected_clock_color_and_size" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/clock_description" style="@style/SectionSubtitleTextStyle"/> </LinearLayout> Loading res/values/strings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,12 @@ <!-- Title of a section of the customization picker where the user can configure Clock face. [CHAR LIMIT=19] --> <string name="clock_settings_title">Clock Settings</string> <!-- Title of a section of the customization picker where the user can configure clock color and size. [CHAR LIMIT=20] --> <string name="clock_color_and_size_title">Clock color & size</string> <!-- Description of a section of the customization picker where the user can configure clock color and size, e.g. Violet, small. [CHAR LIMIT=NONE] --> <string name="clock_color_and_size_description"><xliff:g name="color">%1$s</xliff:g>, <xliff:g name="size">%2$s</xliff:g></string> <!-- Title of a tab to change the clock color. [CHAR LIMIT=15] --> <string name="clock_color">Color</string> Loading src/com/android/customization/module/ThemePickerInjector.kt +1 −1 Original line number Diff line number Diff line Loading @@ -311,7 +311,7 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject override fun getClockSectionViewModel(context: Context): ClockSectionViewModel { return clockSectionViewModel ?: ClockSectionViewModel(getClockPickerInteractor(context)).also { ?: ClockSectionViewModel(context, getClockPickerInteractor(context)).also { clockSectionViewModel = it } } Loading src/com/android/customization/picker/clock/ui/binder/ClockSectionViewBinder.kt +9 −6 Original line number Diff line number Diff line Loading @@ -21,8 +21,8 @@ import android.view.View import android.widget.TextView import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle import com.android.customization.picker.clock.ui.viewmodel.ClockSectionViewModel import com.android.wallpaper.R import kotlinx.coroutines.flow.collectLatest Loading @@ -37,13 +37,16 @@ object ClockSectionViewBinder { ) { view.setOnClickListener { onClicked() } val selectedClockTextView: TextView = view.requireViewById(R.id.selected_clock_text) val selectedClockColorAndSize: TextView = view.requireViewById(R.id.selected_clock_color_and_size) lifecycleOwner.lifecycleScope.launch { viewModel.selectedClockName .flowWithLifecycle(lifecycleOwner.lifecycle, Lifecycle.State.STARTED) .collectLatest { selectedClockName -> selectedClockTextView.text = selectedClockName lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) { launch { viewModel.selectedClockColorAndSizeText.collectLatest { selectedClockColorAndSize.text = it } } } } } Loading src/com/android/customization/picker/clock/ui/viewmodel/ClockSectionViewModel.kt +22 −3 Original line number Diff line number Diff line Loading @@ -16,12 +16,31 @@ */ package com.android.customization.picker.clock.ui.viewmodel import android.content.Context import com.android.customization.picker.clock.domain.interactor.ClockPickerInteractor import com.android.customization.picker.clock.shared.ClockSize import com.android.wallpaper.R import java.util.Locale import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map /** View model for the clock section view on the lockscreen customization surface. */ class ClockSectionViewModel(interactor: ClockPickerInteractor) { val selectedClockName: Flow<String> = interactor.selectedClock.map { it.name } class ClockSectionViewModel(context: Context, interactor: ClockPickerInteractor) { val appContext: Context = context.applicationContext val selectedClockColorAndSizeText: Flow<String> = interactor.selectedClockSize.map { selectedClockSize -> // TODO (b/241966062) Finalize the colors and their names val colorText = "Violet" val sizeText = when (selectedClockSize) { ClockSize.SMALL -> appContext.getString(R.string.clock_size_small) ClockSize.DYNAMIC -> appContext.getString(R.string.clock_size_dynamic) } appContext .getString(R.string.clock_color_and_size_description, colorText, sizeText) .lowercase() .replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } } } Loading
res/layout/clock_section_view.xml +2 −3 Original line number Diff line number Diff line Loading @@ -33,14 +33,13 @@ <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/clock_settings_title" android:text="@string/clock_color_and_size_title" style="@style/SectionTitleTextStyle" /> <TextView android:id="@+id/selected_clock_text" android:id="@+id/selected_clock_color_and_size" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/clock_description" style="@style/SectionSubtitleTextStyle"/> </LinearLayout> Loading
res/values/strings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,12 @@ <!-- Title of a section of the customization picker where the user can configure Clock face. [CHAR LIMIT=19] --> <string name="clock_settings_title">Clock Settings</string> <!-- Title of a section of the customization picker where the user can configure clock color and size. [CHAR LIMIT=20] --> <string name="clock_color_and_size_title">Clock color & size</string> <!-- Description of a section of the customization picker where the user can configure clock color and size, e.g. Violet, small. [CHAR LIMIT=NONE] --> <string name="clock_color_and_size_description"><xliff:g name="color">%1$s</xliff:g>, <xliff:g name="size">%2$s</xliff:g></string> <!-- Title of a tab to change the clock color. [CHAR LIMIT=15] --> <string name="clock_color">Color</string> Loading
src/com/android/customization/module/ThemePickerInjector.kt +1 −1 Original line number Diff line number Diff line Loading @@ -311,7 +311,7 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject override fun getClockSectionViewModel(context: Context): ClockSectionViewModel { return clockSectionViewModel ?: ClockSectionViewModel(getClockPickerInteractor(context)).also { ?: ClockSectionViewModel(context, getClockPickerInteractor(context)).also { clockSectionViewModel = it } } Loading
src/com/android/customization/picker/clock/ui/binder/ClockSectionViewBinder.kt +9 −6 Original line number Diff line number Diff line Loading @@ -21,8 +21,8 @@ import android.view.View import android.widget.TextView import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle import com.android.customization.picker.clock.ui.viewmodel.ClockSectionViewModel import com.android.wallpaper.R import kotlinx.coroutines.flow.collectLatest Loading @@ -37,13 +37,16 @@ object ClockSectionViewBinder { ) { view.setOnClickListener { onClicked() } val selectedClockTextView: TextView = view.requireViewById(R.id.selected_clock_text) val selectedClockColorAndSize: TextView = view.requireViewById(R.id.selected_clock_color_and_size) lifecycleOwner.lifecycleScope.launch { viewModel.selectedClockName .flowWithLifecycle(lifecycleOwner.lifecycle, Lifecycle.State.STARTED) .collectLatest { selectedClockName -> selectedClockTextView.text = selectedClockName lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) { launch { viewModel.selectedClockColorAndSizeText.collectLatest { selectedClockColorAndSize.text = it } } } } } Loading
src/com/android/customization/picker/clock/ui/viewmodel/ClockSectionViewModel.kt +22 −3 Original line number Diff line number Diff line Loading @@ -16,12 +16,31 @@ */ package com.android.customization.picker.clock.ui.viewmodel import android.content.Context import com.android.customization.picker.clock.domain.interactor.ClockPickerInteractor import com.android.customization.picker.clock.shared.ClockSize import com.android.wallpaper.R import java.util.Locale import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map /** View model for the clock section view on the lockscreen customization surface. */ class ClockSectionViewModel(interactor: ClockPickerInteractor) { val selectedClockName: Flow<String> = interactor.selectedClock.map { it.name } class ClockSectionViewModel(context: Context, interactor: ClockPickerInteractor) { val appContext: Context = context.applicationContext val selectedClockColorAndSizeText: Flow<String> = interactor.selectedClockSize.map { selectedClockSize -> // TODO (b/241966062) Finalize the colors and their names val colorText = "Violet" val sizeText = when (selectedClockSize) { ClockSize.SMALL -> appContext.getString(R.string.clock_size_small) ClockSize.DYNAMIC -> appContext.getString(R.string.clock_size_dynamic) } appContext .getString(R.string.clock_color_and_size_description, colorText, sizeText) .lowercase() .replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } } }