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