1 /* 2 * Copyright (C) 2022 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 17 package com.android.launcher3.util 18 19 import android.content.res.Resources 20 import android.graphics.Point 21 import android.view.ViewGroup 22 import com.android.launcher3.DeviceProfile 23 import com.android.launcher3.R 24 25 object DimensionUtils { 26 /** 27 * Point where x is width, and y is height of taskbar based on provided [deviceProfile] x or y 28 * could also be -1 to indicate there is no dimension specified 29 */ 30 @JvmStatic getTaskbarPhoneDimensionsnull31 fun getTaskbarPhoneDimensions( 32 deviceProfile: DeviceProfile, 33 res: Resources, 34 isPhoneMode: Boolean, 35 isGestureNav: Boolean, 36 ): Point { 37 val p = Point() 38 // Taskbar for large screen 39 if (!isPhoneMode) { 40 p.x = ViewGroup.LayoutParams.MATCH_PARENT 41 p.y = deviceProfile.taskbarHeight 42 return p 43 } 44 45 // Taskbar on phone using gesture nav, it will always be stashed 46 if (isGestureNav) { 47 p.x = ViewGroup.LayoutParams.MATCH_PARENT 48 p.y = res.getDimensionPixelSize(R.dimen.taskbar_stashed_size) 49 return p 50 } 51 52 // Taskbar on phone, portrait 53 if (!deviceProfile.isLandscape) { 54 p.x = ViewGroup.LayoutParams.MATCH_PARENT 55 p.y = res.getDimensionPixelSize(R.dimen.taskbar_phone_size) 56 return p 57 } 58 59 // Taskbar on phone, landscape 60 p.x = res.getDimensionPixelSize(R.dimen.taskbar_phone_size) 61 p.y = ViewGroup.LayoutParams.MATCH_PARENT 62 return p 63 } 64 } 65