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.util;
17 
18 import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
19 
20 import android.view.Surface;
21 
22 import com.android.launcher3.util.DefaultDisplay;
23 import com.android.quickstep.SysUINavigationMode;
24 
25 /**
26  * Utility class to check nav bar position.
27  */
28 public class NavBarPosition {
29 
30     private final SysUINavigationMode.Mode mMode;
31     private final int mDisplayRotation;
32 
NavBarPosition(SysUINavigationMode.Mode mode, DefaultDisplay.Info info)33     public NavBarPosition(SysUINavigationMode.Mode mode, DefaultDisplay.Info info) {
34         mMode = mode;
35         mDisplayRotation = info.rotation;
36     }
37 
NavBarPosition(SysUINavigationMode.Mode mode, int displayRotation)38     public NavBarPosition(SysUINavigationMode.Mode mode, int displayRotation) {
39         mMode = mode;
40         mDisplayRotation = displayRotation;
41     }
42 
isRightEdge()43     public boolean isRightEdge() {
44         return mMode != NO_BUTTON && mDisplayRotation == Surface.ROTATION_90;
45     }
46 
isLeftEdge()47     public boolean isLeftEdge() {
48         return mMode != NO_BUTTON && mDisplayRotation == Surface.ROTATION_270;
49     }
50 
getRotation()51     public float getRotation() {
52         return isLeftEdge() ? 90 : (isRightEdge() ? -90 : 0);
53     }
54 }
55