• 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 package com.android.quickstep;
17 
18 import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
19 import static android.view.RemoteAnimationTarget.MODE_CLOSING;
20 
21 import android.app.WindowConfiguration;
22 import android.content.Context;
23 import android.graphics.Rect;
24 import android.os.Bundle;
25 import android.view.RemoteAnimationTarget;
26 
27 import com.android.wm.shell.shared.desktopmode.DesktopModeStatus;
28 
29 import java.io.PrintWriter;
30 
31 /**
32  * Extension of {@link RemoteAnimationTargets} with additional information about swipe
33  * up animation
34  */
35 public class RecentsAnimationTargets extends RemoteAnimationTargets {
36 
37     public final Rect homeContentInsets;
38     public final Rect minimizedHomeBounds;
39 
RecentsAnimationTargets(RemoteAnimationTarget[] apps, RemoteAnimationTarget[] wallpapers, RemoteAnimationTarget[] nonApps, Rect homeContentInsets, Rect minimizedHomeBounds, Bundle extras)40     public RecentsAnimationTargets(RemoteAnimationTarget[] apps,
41             RemoteAnimationTarget[] wallpapers, RemoteAnimationTarget[] nonApps,
42             Rect homeContentInsets, Rect minimizedHomeBounds, Bundle extras) {
43         super(apps, wallpapers, nonApps, MODE_CLOSING, extras);
44         this.homeContentInsets = homeContentInsets;
45         this.minimizedHomeBounds = minimizedHomeBounds;
46     }
47 
hasTargets()48     public boolean hasTargets() {
49         return unfilteredApps.length != 0;
50     }
51 
52     /**
53      * Check if target apps contain desktop tasks which have windowing mode set to {@link
54      * WindowConfiguration#WINDOWING_MODE_FREEFORM}
55      *
56      * @return {@code true} if at least one target app is a desktop task
57      */
hasDesktopTasks(Context context)58     public boolean hasDesktopTasks(Context context) {
59         if (!DesktopModeStatus.canEnterDesktopMode(context)) {
60             return false;
61         }
62         // TODO: b/400866688 - Check if we need to update this such that for an empty desk, we
63         //  receive a list of apps that contain only the Launcher and the `DesktopWallpaperActivity`
64         //  and both are fullscreen windowing mode. A desk can also have transparent modals and
65         //  immersive apps which may not have a "freeform" windowing mode.
66         for (RemoteAnimationTarget target : apps) {
67             if (target.windowConfiguration.getWindowingMode() == WINDOWING_MODE_FREEFORM) {
68                 return true;
69             }
70         }
71         return false;
72     }
73 
74     @Override
dump(String prefix, PrintWriter pw)75     public void dump(String prefix, PrintWriter pw) {
76         super.dump(prefix, pw);
77         prefix += '\t';
78         pw.println(prefix + "RecentsAnimationTargets:");
79 
80         pw.println(prefix + "\thomeContentInsets=" + homeContentInsets);
81         pw.println(prefix + "\tminimizedHomeBounds=" + minimizedHomeBounds);
82     }
83 }
84