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

Commit 1b6aab6e authored by George Lin's avatar George Lin
Browse files

Log the clock features that are edited

We have clock style, color and size for clock customization. We only log
the features that are edited.

Test: Manually tested
Bug: 419063311
Flag: com.android.systemui.shared.new_customization_picker_ui
Change-Id: I4680301f051939f9e9d1886b277cba381eebccc1
parent da9f53ca
Loading
Loading
Loading
Loading
+58 −50
Original line number Diff line number Diff line
@@ -149,6 +149,7 @@ constructor(
        combine(overridingClock, selectedClock) { overridingClock, selectedClock ->
                overridingClock != null && overridingClock.clockId != selectedClock.clockId
            }
            .distinctUntilChanged()

    val _previewingClockColorOptionIndex = MutableStateFlow<Int>(0)
    val previewingClockColorOptionIndex = _previewingClockColorOptionIndex.asStateFlow()
@@ -223,8 +224,10 @@ constructor(
                overridingClockPresetIndexedStyle,
                selectedClockPresetIndexedStyle ->
                overridingClockPresetIndexedStyle != null &&
                (overridingClockPresetIndexedStyle.style != selectedClockPresetIndexedStyle?.style)
                    (overridingClockPresetIndexedStyle.style !=
                        selectedClockPresetIndexedStyle?.style)
            }
            .distinctUntilChanged()

    private val groups: Flow<List<AxisPresetConfig.Group>?> =
        previewingClock.map { it.axisPresetConfig?.groups }
@@ -323,6 +326,7 @@ constructor(
                selectedClockSize ->
                overridingClockSize != null && overridingClockSize != selectedClockSize
            }
            .distinctUntilChanged()
    val previewingClockSize =
        combine(overridingClockSize, clockPickerInteractor.selectedClockSize) {
            overridingClockSize,
@@ -347,6 +351,7 @@ constructor(
                selectedColorId ->
                overridingClockColorId != null && (overridingClockColorId != selectedColorId)
            }
            .distinctUntilChanged()
    private val previewingClockColorId =
        combine(overridingClockColorId, clockPickerInteractor.selectedColorId) {
            overridingClockColorId,
@@ -366,6 +371,7 @@ constructor(
                overridingColorSliderTouchUpProgress != null &&
                    (overridingColorSliderTouchUpProgress != colorToneProgress)
            }
            .distinctUntilChanged()
    // Note that this flow emits as frequently as user drags the slider.
    val previewingColorSliderProgress: Flow<Int> =
        combine(overridingColorSliderProgress, clockPickerInteractor.colorToneProgress) {
@@ -519,41 +525,37 @@ constructor(
        )
    }

    private val isEdited =
    val onApply: Flow<(suspend () -> Unit)?> =
        combine(
            isClockEdited,
            isClockAxisStyleEdited,
            isClockSizeEdited,
            isClockColorIdEdited,
            isSliderProgressEdited,
        ) {
            isClockEdited,
            isClockAxisStyleEdited,
            isClockSizeEdited,
            isClockColorEdited,
            isSliderProgressEdited ->
            isClockEdited ||
                isClockAxisStyleEdited ||
                isClockSizeEdited ||
                isClockColorEdited ||
                isSliderProgressEdited
        }
    val onApply: Flow<(suspend () -> Unit)?> =
        combine(
            isEdited,
            previewingClock,
            previewingClockSize,
            previewingClockColorId,
            previewingColorSliderTouchUpProgress,
            previewingClockPresetIndexedStyle,
        ) { array ->
            val isEdited: Boolean = array[0] as Boolean
            val clock: ClockMetadataModel = array[1] as ClockMetadataModel
            val size: ClockSize = array[2] as ClockSize
            val previewingColorId: String = array[3] as String
            val previewingColorSliderProgress: Int = array[4] as Int
            val isClockEdited: Boolean = array[0] as Boolean
            val isClockAxisStyleEdited: Boolean = array[1] as Boolean
            val isClockSizeEdited: Boolean = array[2] as Boolean
            val isClockColorIdEdited: Boolean = array[3] as Boolean
            val isSliderProgressEdited: Boolean = array[4] as Boolean
            val clock: ClockMetadataModel = array[5] as ClockMetadataModel
            val size: ClockSize = array[6] as ClockSize
            val previewingColorId: String = array[7] as String
            val previewingColorSliderProgress: Int = array[8] as Int
            val clockAxisStyle: ClockAxisStyle =
                (array[5] as? IndexedStyle)?.style ?: ClockAxisStyle()
                (array[9] as? IndexedStyle)?.style ?: ClockAxisStyle()

            val isEdited =
                isClockEdited ||
                    isClockAxisStyleEdited ||
                    isClockSizeEdited ||
                    isClockColorIdEdited ||
                    isSliderProgressEdited
            if (isEdited) {
                {
                    val clockId: String = clock.clockId
@@ -572,15 +574,21 @@ constructor(
                        seedColor = seedColor,
                        axisSettings = clockAxisStyle,
                    )
                    logger.logClockApplied(clockId)
                    if (isClockEdited) {
                        logger.logClockApplied(clockId = clockId)
                    }
                    if (isClockSizeEdited) {
                        logger.logClockSizeApplied(
                            when (size) {
                                ClockSize.SMALL -> StyleEnums.CLOCK_SIZE_SMALL
                                ClockSize.DYNAMIC -> StyleEnums.CLOCK_SIZE_DYNAMIC
                            }
                        )
                    }
                    if (isClockColorIdEdited) {
                        seedColor?.let { logger.logClockColorApplied(it) }
                    }
                }
            } else {
                null
            }