1 /*
2  * Copyright (C) 2021 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.wm.shell.common.split;
17 
18 import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
19 import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
20 import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
21 import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
22 import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
23 import static android.window.TransitionInfo.FLAG_FIRST_CUSTOM;
24 
25 import android.annotation.IntDef;
26 
27 /** Helper utility class of methods and constants that are available to be imported in Launcher. */
28 public class SplitScreenConstants {
29 
30     /**
31      * Split position isn't specified normally meaning to use what ever it is currently set to.
32      */
33     public static final int SPLIT_POSITION_UNDEFINED = -1;
34 
35     /**
36      * Specifies that a split is positioned at the top half of the screen if
37      * in portrait mode or at the left half of the screen if in landscape mode.
38      */
39     public static final int SPLIT_POSITION_TOP_OR_LEFT = 0;
40 
41     /**
42      * Specifies that a split is positioned at the bottom half of the screen if
43      * in portrait mode or at the right half of the screen if in landscape mode.
44      */
45     public static final int SPLIT_POSITION_BOTTOM_OR_RIGHT = 1;
46 
47     /**
48      * Duration used for every split fade-in or fade-out.
49      */
50     public static final int FADE_DURATION = 133;
51 
52     @IntDef(prefix = {"SPLIT_POSITION_"}, value = {
53             SPLIT_POSITION_UNDEFINED,
54             SPLIT_POSITION_TOP_OR_LEFT,
55             SPLIT_POSITION_BOTTOM_OR_RIGHT
56     })
57     public @interface SplitPosition {
58     }
59 
60     public static final int[] CONTROLLED_ACTIVITY_TYPES = {ACTIVITY_TYPE_STANDARD};
61     public static final int[] CONTROLLED_WINDOWING_MODES =
62             {WINDOWING_MODE_FULLSCREEN, WINDOWING_MODE_UNDEFINED};
63     public static final int[] CONTROLLED_WINDOWING_MODES_WHEN_ACTIVE =
64             {WINDOWING_MODE_FULLSCREEN, WINDOWING_MODE_UNDEFINED, WINDOWING_MODE_MULTI_WINDOW,
65             WINDOWING_MODE_FREEFORM};
66 
67     /** Flag applied to a transition change to identify it as a divider bar for animation. */
68     public static final int FLAG_IS_DIVIDER_BAR = FLAG_FIRST_CUSTOM;
69 
splitPositionToString(@plitPosition int pos)70     public static final String splitPositionToString(@SplitPosition int pos) {
71         switch (pos) {
72             case SPLIT_POSITION_UNDEFINED:
73                 return "SPLIT_POSITION_UNDEFINED";
74             case SPLIT_POSITION_TOP_OR_LEFT:
75                 return "SPLIT_POSITION_TOP_OR_LEFT";
76             case SPLIT_POSITION_BOTTOM_OR_RIGHT:
77                 return "SPLIT_POSITION_BOTTOM_OR_RIGHT";
78             default:
79                 return "UNKNOWN";
80         }
81     }
82 }
83