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

Commit e036f356 authored by abdullahirum's avatar abdullahirum
Browse files

Update position of clock style list

This CL updates the position of the clock style list such that it enables single handed navigation

Bug: 417394392
Flag: com.android.systemui.shared.new_customization_picker_ui
Test: manual
Change-Id: I3e22c7460efadd5db554589246b72fcea51942d2
parent 43e84aee
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
                        }
                    }