• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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.window;
18 
19 import android.annotation.ColorInt;
20 import android.annotation.NonNull;
21 import android.annotation.Nullable;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 
25 /**
26  * Data object for animation related override of TaskFragment.
27  * @hide
28  */
29 // TODO(b/206557124): Add more animation customization options.
30 public final class TaskFragmentAnimationParams implements Parcelable {
31 
32     /** The default {@link TaskFragmentAnimationParams} to use when there is no app override. */
33     public static final TaskFragmentAnimationParams DEFAULT =
34             new TaskFragmentAnimationParams.Builder().build();
35 
36     /**
37      * The default value for animation background color, which means to use the theme window
38      * background color.
39      */
40     @ColorInt
41     public static final int DEFAULT_ANIMATION_BACKGROUND_COLOR = 0;
42 
43     @ColorInt
44     private final int mAnimationBackgroundColor;
45 
TaskFragmentAnimationParams(@olorInt int animationBackgroundColor)46     private TaskFragmentAnimationParams(@ColorInt int animationBackgroundColor) {
47         mAnimationBackgroundColor = animationBackgroundColor;
48     }
49 
50     /**
51      * The {@link ColorInt} to use for the background during the animation with this TaskFragment if
52      * the animation requires a background.
53      *
54      * The default value is {@code 0}, which is to use the theme window background.
55      */
56     @ColorInt
getAnimationBackgroundColor()57     public int getAnimationBackgroundColor() {
58         return mAnimationBackgroundColor;
59     }
60 
TaskFragmentAnimationParams(Parcel in)61     private TaskFragmentAnimationParams(Parcel in) {
62         mAnimationBackgroundColor = in.readInt();
63     }
64 
65     @Override
writeToParcel(@onNull Parcel dest, int flags)66     public void writeToParcel(@NonNull Parcel dest, int flags) {
67         dest.writeInt(mAnimationBackgroundColor);
68     }
69 
70     @NonNull
71     public static final Creator<TaskFragmentAnimationParams> CREATOR =
72             new Creator<TaskFragmentAnimationParams>() {
73                 @Override
74                 public TaskFragmentAnimationParams createFromParcel(Parcel in) {
75                     return new TaskFragmentAnimationParams(in);
76                 }
77 
78                 @Override
79                 public TaskFragmentAnimationParams[] newArray(int size) {
80                     return new TaskFragmentAnimationParams[size];
81                 }
82             };
83 
84     @Override
toString()85     public String toString() {
86         return "TaskFragmentAnimationParams{"
87                 + " animationBgColor=" + Integer.toHexString(mAnimationBackgroundColor)
88                 + "}";
89     }
90 
91     @Override
hashCode()92     public int hashCode() {
93         return mAnimationBackgroundColor;
94     }
95 
96     @Override
equals(@ullable Object obj)97     public boolean equals(@Nullable Object obj) {
98         if (!(obj instanceof TaskFragmentAnimationParams)) {
99             return false;
100         }
101         final TaskFragmentAnimationParams other = (TaskFragmentAnimationParams) obj;
102         return mAnimationBackgroundColor == other.mAnimationBackgroundColor;
103     }
104 
105     @Override
describeContents()106     public int describeContents() {
107         return 0;
108     }
109 
110     /** Builder to construct the {@link TaskFragmentAnimationParams}. */
111     public static final class Builder {
112 
113         @ColorInt
114         private int mAnimationBackgroundColor = DEFAULT_ANIMATION_BACKGROUND_COLOR;
115 
116         /**
117          * Sets the {@link ColorInt} to use for the background during the animation with this
118          * TaskFragment if the animation requires a background. The default value is
119          * {@link #DEFAULT_ANIMATION_BACKGROUND_COLOR}, which is to use the theme window background
120          * color.
121          *
122          * @param color a packed color int, {@code AARRGGBB}, for the animation background color.
123          * @return this {@link Builder}.
124          */
125         @NonNull
setAnimationBackgroundColor(@olorInt int color)126         public Builder setAnimationBackgroundColor(@ColorInt int color) {
127             mAnimationBackgroundColor = color;
128             return this;
129         }
130 
131         /** Constructs the {@link TaskFragmentAnimationParams}. */
132         @NonNull
build()133         public TaskFragmentAnimationParams build() {
134             return new TaskFragmentAnimationParams(mAnimationBackgroundColor);
135         }
136     }
137 }
138