1 /*
2  * Copyright (C) 2022 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 package com.android.customization.model.color;
17 
18 import android.app.WallpaperColors;
19 
20 import androidx.annotation.Nullable;
21 import androidx.annotation.StringDef;
22 
23 import com.android.customization.model.CustomizationManager.OptionsFetchedListener;
24 
25 /**
26  * Interface for a class that can retrieve Colors from the system.
27  */
28 public interface ColorOptionsProvider {
29 
30     /**
31      * Extra setting indicating the source of the color overlays (it can be one of
32      * COLOR_SOURCE_PRESET, COLOR_SOURCE_HOME or COLOR_SOURCE_LOCK)
33      */
34     String OVERLAY_COLOR_SOURCE = "android.theme.customization.color_source";
35 
36     /**
37      * Extra setting indicating the style of the color overlays (it can be one of
38      * {@link com.android.systemui.monet.Style}).
39      */
40     String OVERLAY_THEME_STYLE = "android.theme.customization.theme_style";
41 
42     /**
43      * Users selected color option, its value starts from 1 (which means first option).
44      */
45     String OVERLAY_COLOR_INDEX = "android.theme.customization.color_index";
46 
47     /**
48      * Users selected color from both home and lock screen.
49      * Example value: 0 means home or lock screen, 1 means both.
50      */
51     String OVERLAY_COLOR_BOTH = "android.theme.customization.color_both";
52 
53     String COLOR_SOURCE_PRESET = "preset";
54     String COLOR_SOURCE_HOME = "home_wallpaper";
55     String COLOR_SOURCE_LOCK = "lock_wallpaper";
56 
57     @StringDef({COLOR_SOURCE_PRESET, COLOR_SOURCE_HOME, COLOR_SOURCE_LOCK})
58     @interface ColorSource{}
59 
60 
61     /**
62      * Returns whether themes are available in the current setup.
63      */
isAvailable()64     boolean isAvailable();
65 
66     /**
67      * Retrieve the available themes.
68      * @param callback called when the themes have been retrieved (or immediately if cached)
69      * @param reload whether to reload themes if they're cached.
70      * @param homeWallpaperColors to get seed colors from
71      * @param lockWallpaperColors WallpaperColors from the lockscreen wallpaper to get seeds from,
72      *                            if different than homeWallpaperColors
73      */
fetch(OptionsFetchedListener<ColorOption> callback, boolean reload, @Nullable WallpaperColors homeWallpaperColors, @Nullable WallpaperColors lockWallpaperColors )74     void fetch(OptionsFetchedListener<ColorOption> callback, boolean reload,
75             @Nullable WallpaperColors homeWallpaperColors,
76             @Nullable WallpaperColors lockWallpaperColors
77     );
78 }
79