1 /*
2  * Copyright (C) 2018 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.quickstep.util;
17 
18 import android.animation.AnimatorSet;
19 
20 import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
21 
22 public abstract class RemoteAnimationProvider {
23 
createWindowAnimation(RemoteAnimationTargetCompat[] appTargets, RemoteAnimationTargetCompat[] wallpaperTargets)24     public abstract AnimatorSet createWindowAnimation(RemoteAnimationTargetCompat[] appTargets,
25             RemoteAnimationTargetCompat[] wallpaperTargets);
26 
27     /**
28      * @return the target with the lowest opaque layer for a certain app animation, or null.
29      */
findLowestOpaqueLayerTarget( RemoteAnimationTargetCompat[] appTargets, int mode)30     public static RemoteAnimationTargetCompat findLowestOpaqueLayerTarget(
31             RemoteAnimationTargetCompat[] appTargets, int mode) {
32         int lowestLayer = Integer.MAX_VALUE;
33         int lowestLayerIndex = -1;
34         for (int i = appTargets.length - 1; i >= 0; i--) {
35             RemoteAnimationTargetCompat target = appTargets[i];
36             if (target.mode == mode && !target.isTranslucent) {
37                 int layer = target.prefixOrderIndex;
38                 if (layer < lowestLayer) {
39                     lowestLayer = layer;
40                     lowestLayerIndex = i;
41                 }
42             }
43         }
44         return lowestLayerIndex != -1
45                 ? appTargets[lowestLayerIndex]
46                 : null;
47     }
48 }
49