1 /*
2  * Copyright (C) 2019 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.theme;
17 
18 import androidx.annotation.Nullable;
19 
20 import com.android.customization.model.CustomizationManager.OptionsFetchedListener;
21 import com.android.customization.model.theme.custom.CustomTheme;
22 
23 import org.json.JSONException;
24 
25 /**
26  * Interface for a class that can retrieve Themes from the system.
27  */
28 public interface ThemeBundleProvider {
29 
30     /**
31      * Returns whether themes are available in the current setup.
32      */
isAvailable()33     boolean isAvailable();
34 
35     /**
36      * Retrieve the available themes.
37      * @param callback called when the themes have been retrieved (or immediately if cached)
38      * @param reload whether to reload themes if they're cached.
39      */
fetch(OptionsFetchedListener<ThemeBundle> callback, boolean reload)40     void fetch(OptionsFetchedListener<ThemeBundle> callback, boolean reload);
41 
storeCustomTheme(CustomTheme theme)42     void storeCustomTheme(CustomTheme theme);
43 
removeCustomTheme(CustomTheme theme)44     void removeCustomTheme(CustomTheme theme);
45 
parseCustomTheme(String serializedTheme)46     @Nullable CustomTheme.Builder parseCustomTheme(String serializedTheme) throws JSONException;
47 
findEquivalent(ThemeBundle other)48     ThemeBundle findEquivalent(ThemeBundle other);
49 }
50