Loading res/layout/fragment_clock_settings.xml +27 −8 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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" Loading src/com/android/customization/picker/clock/data/repository/ClockPickerRepository.kt +2 −0 Original line number Diff line number Diff line Loading @@ -33,5 +33,7 @@ interface ClockPickerRepository { fun setSelectedClock(clockId: String) fun setClockColor(color: Int?) fun setClockSize(size: ClockSize) } src/com/android/customization/picker/clock/data/repository/ClockPickerRepositoryImpl.kt +8 −4 Original line number Diff line number Diff line Loading @@ -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. */ Loading @@ -56,7 +56,7 @@ class ClockPickerRepositoryImpl( registry .getClocks() .find { clockMetadata -> clockMetadata.clockId == currentClockId } ?.toModel() ?.toModel(registry.seedColor) if (model == null) { Log.w( TAG, Loading @@ -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() Loading @@ -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 { Loading src/com/android/customization/picker/clock/domain/interactor/ClockPickerInteractor.kt +7 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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) } Loading src/com/android/customization/picker/clock/shared/model/ClockMetadataModel.kt +1 −0 Original line number Diff line number Diff line Loading @@ -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
res/layout/fragment_clock_settings.xml +27 −8 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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" Loading
src/com/android/customization/picker/clock/data/repository/ClockPickerRepository.kt +2 −0 Original line number Diff line number Diff line Loading @@ -33,5 +33,7 @@ interface ClockPickerRepository { fun setSelectedClock(clockId: String) fun setClockColor(color: Int?) fun setClockSize(size: ClockSize) }
src/com/android/customization/picker/clock/data/repository/ClockPickerRepositoryImpl.kt +8 −4 Original line number Diff line number Diff line Loading @@ -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. */ Loading @@ -56,7 +56,7 @@ class ClockPickerRepositoryImpl( registry .getClocks() .find { clockMetadata -> clockMetadata.clockId == currentClockId } ?.toModel() ?.toModel(registry.seedColor) if (model == null) { Log.w( TAG, Loading @@ -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() Loading @@ -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 { Loading
src/com/android/customization/picker/clock/domain/interactor/ClockPickerInteractor.kt +7 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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) } Loading
src/com/android/customization/picker/clock/shared/model/ClockMetadataModel.kt +1 −0 Original line number Diff line number Diff line Loading @@ -21,4 +21,5 @@ package com.android.customization.picker.clock.shared.model data class ClockMetadataModel( val clockId: String, val name: String, val color: Int?, )