• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package com.android.server.display.color;
18 
19 import android.animation.ValueAnimator;
20 import android.content.Context;
21 
22 import java.io.PrintWriter;
23 
24 abstract class TintController {
25 
26     private ValueAnimator mAnimator;
27     private Boolean mIsActivated;
28 
getAnimator()29     public ValueAnimator getAnimator() {
30         return mAnimator;
31     }
32 
setAnimator(ValueAnimator animator)33     public void setAnimator(ValueAnimator animator) {
34         mAnimator = animator;
35     }
36 
37     /**
38      * Cancel the animator if it's still running.
39      */
cancelAnimator()40     public void cancelAnimator() {
41         if (mAnimator != null) {
42             mAnimator.cancel();
43         }
44     }
45 
46     /**
47      * End the animator if it's still running, jumping to the end state.
48      */
endAnimator()49     public void endAnimator() {
50         if (mAnimator != null) {
51             mAnimator.end();
52             mAnimator = null;
53         }
54     }
55 
setActivated(Boolean isActivated)56     public void setActivated(Boolean isActivated) {
57         mIsActivated = isActivated;
58     }
59 
isActivated()60     public boolean isActivated() {
61         return mIsActivated != null && mIsActivated;
62     }
63 
isActivatedStateNotSet()64     public boolean isActivatedStateNotSet() {
65         return mIsActivated == null;
66     }
67 
68     /**
69      * Dump debug information.
70      */
dump(PrintWriter pw)71     public void dump(PrintWriter pw) {
72     }
73 
74     /**
75      * Set up any constants needed for computing the matrix.
76      */
setUp(Context context, boolean needsLinear)77     public abstract void setUp(Context context, boolean needsLinear);
78 
79     /**
80      * Sets the 4x4 matrix to apply.
81      */
setMatrix(int value)82     public abstract void setMatrix(int value);
83 
84     /**
85      * Get the 4x4 matrix to apply.
86      */
getMatrix()87     public abstract float[] getMatrix();
88 
89     /**
90      * Get the color transform level to apply the matrix.
91      */
getLevel()92     public abstract int getLevel();
93 
94     /**
95      * Returns whether or not this transform type is available on this device.
96      */
isAvailable(Context context)97     public abstract boolean isAvailable(Context context);
98 }
99