1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 package com.android.customization.picker.color.data.repository
18 
19 import com.android.customization.picker.color.shared.model.ColorOptionModel
20 import com.android.customization.picker.color.shared.model.ColorType
21 import kotlinx.coroutines.flow.Flow
22 import kotlinx.coroutines.flow.StateFlow
23 
24 /**
25  * Abstracts access to application state related to functionality for selecting, picking, or setting
26  * system color.
27  */
28 interface ColorPickerRepository {
29     /** Whether the system color is in the process of being updated */
30     val isApplyingSystemColor: StateFlow<Boolean>
31 
32     /** List of wallpaper and preset color options on the device, categorized by Color Type */
33     val colorOptions: Flow<Map<ColorType, List<ColorOptionModel>>>
34 
35     /** Selects a color option with optimistic update */
selectnull36     suspend fun select(colorOptionModel: ColorOptionModel)
37 
38     /** Returns the current selected color option based on system settings */
39     fun getCurrentColorOption(): ColorOptionModel
40 
41     /** Returns the current selected color source based on system settings */
42     fun getCurrentColorSource(): String?
43 }
44