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

Commit c98daa60 authored by George Lin's avatar George Lin Committed by Android (Google) Code Review
Browse files

Merge "[TP] Clock color picker" into tm-qpr-dev

parents 34956c41 7e5ed447
Loading
Loading
Loading
Loading
+27 −8
Original line number Diff line number Diff line
@@ -19,11 +19,11 @@
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/section_header_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <include layout="@layout/section_header" />
    </FrameLayout>

@@ -94,16 +94,35 @@
        </FrameLayout>

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="16dp">

            <FrameLayout
                android:id="@+id/color_options_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <androidx.recyclerview.widget.RecyclerView
                android:id="@id/affordances"
                    android:id="@+id/color_options"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:clipToPadding="false"
                android:paddingHorizontal="16dp"
                android:visibility="gone"/>
                    android:paddingHorizontal="16dp" />

                <!--
                This is just an invisible placeholder put in place so that the parent keeps its
                height stable as the RecyclerView updates from 0 items to N items. Keeping it stable
                allows the layout logic to keep the size of the preview container stable as well,
                which bodes well for setting up the SurfaceView for remote rendering without
                changing its size after the content is loaded into the RecyclerView.
                -->
                <include
                    layout="@layout/color_option_with_background"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:visibility="invisible" />
            </FrameLayout>

            <com.android.customization.picker.clock.ui.view.ClockSizeRadioButtonGroup
                android:id="@+id/clock_size_radio_button_group"
+2 −0
Original line number Diff line number Diff line
@@ -33,5 +33,7 @@ interface ClockPickerRepository {

    fun setSelectedClock(clockId: String)

    fun setClockColor(color: Int?)

    fun setClockSize(size: ClockSize)
}
+8 −4
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ class ClockPickerRepositoryImpl(
        registry
            .getClocks()
            .filter { "NOT_IN_USE" !in it.clockId }
            .map { it.toModel() }
            .map { it.toModel(null) }
            .toTypedArray()

    /** The currently-selected clock. */
@@ -56,7 +56,7 @@ class ClockPickerRepositoryImpl(
                        registry
                            .getClocks()
                            .find { clockMetadata -> clockMetadata.clockId == currentClockId }
                            ?.toModel()
                            ?.toModel(registry.seedColor)
                    if (model == null) {
                        Log.w(
                            TAG,
@@ -77,6 +77,10 @@ class ClockPickerRepositoryImpl(
        registry.currentClockId = clockId
    }

    override fun setClockColor(color: Int?) {
        registry.seedColor = color
    }

    // TODO(b/262924055): Use the shared system UI component to query the clock size
    private val _selectedClockSize = MutableStateFlow(ClockSize.DYNAMIC)
    override val selectedClockSize: Flow<ClockSize> = _selectedClockSize.asStateFlow()
@@ -85,8 +89,8 @@ class ClockPickerRepositoryImpl(
        _selectedClockSize.value = size
    }

    private fun ClockMetadata.toModel(): ClockMetadataModel {
        return ClockMetadataModel(clockId = clockId, name = name)
    private fun ClockMetadata.toModel(color: Int?): ClockMetadataModel {
        return ClockMetadataModel(clockId = clockId, name = name, color = color)
    }

    companion object {
+7 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.customization.picker.clock.data.repository.ClockPickerReposit
import com.android.customization.picker.clock.shared.ClockSize
import com.android.customization.picker.clock.shared.model.ClockMetadataModel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map

/**
 * Interactor for accessing application clock settings, as well as selecting and configuring custom
@@ -31,12 +32,18 @@ class ClockPickerInteractor(private val repository: ClockPickerRepository) {

    val selectedClock: Flow<ClockMetadataModel> = repository.selectedClock

    val selectedClockColor: Flow<Int?> = repository.selectedClock.map { clock -> clock.color }

    val selectedClockSize: Flow<ClockSize> = repository.selectedClockSize

    fun setSelectedClock(clockId: String) {
        repository.setSelectedClock(clockId)
    }

    fun setClockColor(color: Int?) {
        repository.setClockColor(color)
    }

    fun setClockSize(size: ClockSize) {
        repository.setClockSize(size)
    }
+1 −0
Original line number Diff line number Diff line
@@ -21,4 +21,5 @@ package com.android.customization.picker.clock.shared.model
data class ClockMetadataModel(
    val clockId: String,
    val name: String,
    val color: Int?,
)
Loading