Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8a0638c6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Snackbar for clock style update (1/2)" into main

parents 8f56daff 7cd9ad9d
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -111,6 +111,15 @@
    <!-- Description for clock font editor axis revert button. [CHAR LIMIT=NONE] -->
    <string name="clock_font_editor_revert">Undo clock font changes</string>

    <!-- Toast message to notify that the clock style is updated when they tap on the clock face. They can tap again to undo. [CHAR LIMIT=NONE] -->
    <string name="clock_style_update_toast">Style changed to <xliff:g name="font_name">%1$s</xliff:g>. Tap again to undo.</string>

    <!-- Clock font style of round. It is used in the style update toast message. [CHAR LIMIT=NONE] -->
    <string name="clock_style_round">round</string>

    <!-- Clock font style of sharp. It is used in the style update toast message. [CHAR LIMIT=NONE] -->
    <string name="clock_style_sharp">sharp</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>
+19 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ import com.android.wallpaper.picker.customization.ui.viewmodel.CustomizationOpti
import com.android.wallpaper.picker.customization.ui.viewmodel.CustomizationPickerViewModel2
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.google.android.material.snackbar.Snackbar
import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.Dispatchers
@@ -559,6 +560,7 @@ constructor(private val defaultCustomizationOptionsBinder: DefaultCustomizationO

    override fun bindClockPreview(
        context: Context,
        rootView: View,
        clockHostView: View,
        clockFaceClickDelegateView: View,
        viewModel: CustomizationPickerViewModel2,
@@ -650,6 +652,23 @@ constructor(private val defaultCustomizationOptionsBinder: DefaultCustomizationO
                            }
                        }
                }

                launch {
                    clockPickerViewModel.showClockFacePresetGroupIndexUpdateToast.collect {
                        presetGroupIndex ->
                        val clockStyle: String =
                            rootView.resources.getString(
                                if (presetGroupIndex == 0) R.string.clock_style_round
                                else R.string.clock_style_sharp
                            )
                        val toastMessage: String =
                            rootView.resources.getString(
                                R.string.clock_style_update_toast,
                                clockStyle,
                            )
                        Snackbar.make(rootView, toastMessage, Snackbar.LENGTH_SHORT).show()
                    }
                }
            }
        }
    }
+8 −0
Original line number Diff line number Diff line
@@ -252,6 +252,13 @@ constructor(
        }
    val axisPresetsSliderSelectedValue: Flow<Float> =
        previewingClockPresetIndexedStyle.map { it?.presetIndex?.toFloat() }.filterNotNull()

    private val _showClockFacePresetGroupIndexUpdateToast: MutableStateFlow<Int?> =
        MutableStateFlow(null)
    // When it emits, show clock face style change toast. This is emitted when clock face is clicked
    // and the clock style preset group index changes. The integer is the updated group index.
    val showClockFacePresetGroupIndexUpdateToast: Flow<Int> =
        _showClockFacePresetGroupIndexUpdateToast.asStateFlow().filterNotNull()
    val onClockFaceClicked: Flow<() -> Unit> =
        combine(groups, previewingClockPresetIndexedStyle) { groups, previewingIndexedStyle ->
            if (groups.isNullOrEmpty()) {
@@ -272,6 +279,7 @@ constructor(
                                presetIndex = nextPresetIndex,
                                style = nextGroup.presets[nextPresetIndex],
                            )
                        _showClockFacePresetGroupIndexUpdateToast.value = nextGroupIndex
                    }
                }
            }