1 /*
2  * Copyright (C) 2016 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 android.content.res;
18 
19 import android.annotation.ColorInt;
20 import android.content.res.Resources.Theme;
21 import android.graphics.Color;
22 
23 /**
24  * Defines an abstract class for the complex color information, like
25  * {@link android.content.res.ColorStateList} or {@link android.content.res.GradientColor}
26  * @hide
27  */
28 public abstract class ComplexColor {
29     private int mChangingConfigurations;
30 
31     /**
32      * @return {@code true}  if this ComplexColor changes color based on state, {@code false}
33      * otherwise.
34      */
isStateful()35     public boolean isStateful() { return false; }
36 
37     /**
38      * @return the default color.
39      */
40     @ColorInt
getDefaultColor()41     public abstract int getDefaultColor();
42 
43     /**
44      * @hide only for resource preloading
45      *
46      */
getConstantState()47     public abstract ConstantState<ComplexColor> getConstantState();
48 
49     /**
50      * @hide only for resource preloading
51      */
canApplyTheme()52     public abstract boolean canApplyTheme();
53 
54     /**
55      * @hide only for resource preloading
56      */
obtainForTheme(Theme t)57     public abstract ComplexColor obtainForTheme(Theme t);
58 
59     /**
60      * @hide only for resource preloading
61      */
setBaseChangingConfigurations(int changingConfigurations)62     final void setBaseChangingConfigurations(int changingConfigurations) {
63         mChangingConfigurations = changingConfigurations;
64     }
65 
66     /**
67      * Returns a mask of the configuration parameters for which this color
68      * may change, requiring that it be re-created.
69      *
70      * @return a mask of the changing configuration parameters, as defined by
71      *         {@link android.content.pm.ActivityInfo}
72      *
73      * @see android.content.pm.ActivityInfo
74      */
getChangingConfigurations()75     public int getChangingConfigurations() {
76         return mChangingConfigurations;
77     }
78 }
79