1 /*
2  * Copyright (C) 2024 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.view.Surface
19 import com.android.launcher3.util.DisplayController.Info
20 import com.android.launcher3.util.NavigationMode
21 import com.android.launcher3.util.NavigationMode.NO_BUTTON
22 
23 /** Utility class to check nav bar position. */
24 data class NavBarPosition(
25     val isTablet: Boolean,
26     val displayRotation: Int,
27     val mode: NavigationMode
28 ) {
29     constructor(
30         mode: NavigationMode,
31         info: Info
32     ) : this(info.isTablet(info.realBounds), info.rotation, mode)
33 
34     val isRightEdge: Boolean
35         get() = mode != NO_BUTTON && displayRotation == Surface.ROTATION_90 && !isTablet
36     val isLeftEdge: Boolean
37         get() = mode != NO_BUTTON && displayRotation == Surface.ROTATION_270 && !isTablet
38 
39     val rotation: Float
40         get() = if (isLeftEdge) 90f else if (isRightEdge) -90f else 0f
41 }
42