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