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 ): Point { 36 val p = Point() 37 // Taskbar for large screen 38 if (!isPhoneMode) { 39 p.x = ViewGroup.LayoutParams.MATCH_PARENT 40 p.y = deviceProfile.taskbarHeight 41 return p 42 } 43 44 // Taskbar on phone using gesture nav, it will always be stashed 45 if (deviceProfile.isGestureMode) { 46 p.x = ViewGroup.LayoutParams.MATCH_PARENT 47 p.y = res.getDimensionPixelSize(R.dimen.taskbar_stashed_size) 48 return p 49 } 50 51 // Taskbar on phone, portrait 52 if (!deviceProfile.isLandscape) { 53 p.x = ViewGroup.LayoutParams.MATCH_PARENT 54 p.y = res.getDimensionPixelSize(R.dimen.taskbar_phone_size) 55 return p 56 } 57 58 // Taskbar on phone, landscape 59 p.x = res.getDimensionPixelSize(R.dimen.taskbar_phone_size) 60 p.y = ViewGroup.LayoutParams.MATCH_PARENT 61 return p 62 } 63 } 64