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

Commit a6bb420b authored by Abdullah Tabassum's avatar Abdullah Tabassum Committed by Android (Google) Code Review
Browse files

Merge "Update position of clock style list" into main

parents 4b768c71 e036f356
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.get
import androidx.core.view.isEmpty
import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
@@ -428,6 +430,19 @@ object ClockFloatingSheetBinder {
                    }
                }

                launch {
                    viewModel.previewingClockStyleOptionIndex.collect { indexToFocus ->
                        val offset =
                            if (!clockStyleList.isEmpty()) {
                                clockStyleList.get(0).width
                            } else {
                                0
                            }
                        (clockStyleList.layoutManager as LinearLayoutManager)
                            .scrollToPositionWithOffset(indexToFocus, offset)
                    }
                }

                launch {
                    var binding: SwitchColorBinder.Binding? = null
                    viewModel.previewingClockSize.collect { size ->
+8 −2
Original line number Diff line number Diff line
@@ -153,6 +153,9 @@ constructor(
    val _previewingClockColorOptionIndex = MutableStateFlow<Int>(0)
    val previewingClockColorOptionIndex = _previewingClockColorOptionIndex.asStateFlow()

    val _previewingClockStyleOptionIndex = MutableStateFlow<Int>(0)
    val previewingClockStyleOptionIndex = _previewingClockStyleOptionIndex.asStateFlow()

    // Represents show and hide of the clock view provided by the picker side.
    private val _showPickerClockControllerView: MutableStateFlow<Boolean> = MutableStateFlow(false)
    val showPickerClockControllerView: Flow<Boolean> = _showPickerClockControllerView.asStateFlow()
@@ -195,8 +198,9 @@ constructor(
                delay(CLOCKS_EVENT_UPDATE_DELAY_MILLIS)
                val allClockMap = allClocks.groupBy { it.axisPresetConfig != null }
                buildList {
                    allClockMap[true]?.map { add(it.toOption(resources, true)) }
                    allClockMap[false]?.map { add(it.toOption(resources, false)) }
                    var index = 0
                    allClockMap[true]?.forEach { add(it.toOption(resources, true, index++)) }
                    allClockMap[false]?.forEach { add(it.toOption(resources, false, index++)) }
                }
            }
            // makes sure that the operations above this statement are executed on I/O dispatcher
@@ -292,6 +296,7 @@ constructor(
    private suspend fun ClockMetadataModel.toOption(
        resources: Resources,
        hasPresets: Boolean,
        index: Int,
    ): OptionItemViewModel2<ClockStyleModel> {
        val isSelectedFlow = previewingClock.map { it.clockId == clockId }.stateIn(viewModelScope)
        val contentDescription =
@@ -308,6 +313,7 @@ constructor(
                        null
                    } else {
                        fun() {
                            _previewingClockStyleOptionIndex.value = index
                            overridingClock.value = this
                        }
                    }