blob: 4e06ff9440f6dbeb2fbce70027a7be65bb17fe0e [file] [log] [blame]
Winson Chungb3800242013-10-24 11:01:54 -07001/*
2 * Copyright (C) 2008 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
17package com.android.launcher3;
18
Alex Chaua02eddc2021-04-29 00:36:06 +010019import static android.util.DisplayMetrics.DENSITY_DEVICE_STABLE;
Sunny Goyal35c7b192021-04-20 16:51:10 -070020
Jon Mirandae126d722021-02-25 10:45:20 -050021import static com.android.launcher3.ResourceUtils.pxFromDp;
Jon Miranda58561d42021-03-17 10:51:54 -040022import static com.android.launcher3.Utilities.dpiFromPx;
Jon Mirandaaf3aed02021-05-06 18:28:45 -070023import static com.android.launcher3.Utilities.pxFromSp;
Jon Miranda92c1b5d2021-07-20 13:57:16 -070024import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.ICON_OVERLAP_FACTOR;
Alex Chaua02eddc2021-04-29 00:36:06 +010025import static com.android.launcher3.util.WindowManagerCompat.MIN_TABLET_WIDTH;
Jon Miranda228877d2021-02-09 11:05:00 -050026
Sunny Goyal35c7b192021-04-20 16:51:10 -070027import android.annotation.SuppressLint;
Winson Chungb3800242013-10-24 11:01:54 -070028import android.content.Context;
Jon Mirandab28c4fc2017-06-20 10:58:36 -070029import android.content.res.Configuration;
Winson Chungb3800242013-10-24 11:01:54 -070030import android.content.res.Resources;
Sunny Goyal8b9919d2021-04-07 14:45:17 -070031import android.graphics.Path;
Winson Chungb3800242013-10-24 11:01:54 -070032import android.graphics.Point;
Jon Miranda7ae64ff2016-11-21 16:18:46 -080033import android.graphics.PointF;
Winson Chungb3800242013-10-24 11:01:54 -070034import android.graphics.Rect;
Sunny Goyal35c7b192021-04-20 16:51:10 -070035import android.util.DisplayMetrics;
Sunny Goyal59d086c2018-05-07 17:31:40 -070036import android.view.Surface;
Winson Chungb3800242013-10-24 11:01:54 -070037
Sunny Goyalc13403c2016-11-18 23:44:48 -080038import com.android.launcher3.CellLayout.ContainerType;
Jon Miranda228877d2021-02-09 11:05:00 -050039import com.android.launcher3.DevicePaddings.DevicePadding;
Tony Wickham15883892021-02-12 11:24:40 -080040import com.android.launcher3.config.FeatureFlags;
Tony Wickham8912b042018-11-29 15:28:53 -080041import com.android.launcher3.icons.DotRenderer;
Sunny Goyal8b9919d2021-04-07 14:45:17 -070042import com.android.launcher3.icons.GraphicsUtils;
Hyunyoung Song48cb7bc2018-09-25 17:03:34 -070043import com.android.launcher3.icons.IconNormalizer;
Sunny Goyal57b22792021-05-25 14:35:01 -070044import com.android.launcher3.uioverrides.ApiWrapper;
Sunny Goyalfd58da62020-08-11 12:06:49 -070045import com.android.launcher3.util.DisplayController;
46import com.android.launcher3.util.DisplayController.Info;
Sunny Goyalb46703d2020-05-27 17:52:03 -070047import com.android.launcher3.util.WindowBounds;
Winson1f064272016-07-18 17:18:02 -070048
Jon Miranda58561d42021-03-17 10:51:54 -040049import java.io.PrintWriter;
50
Sunny Goyal35c7b192021-04-20 16:51:10 -070051@SuppressLint("NewApi")
Winson Chungb3800242013-10-24 11:01:54 -070052public class DeviceProfile {
Adam Cohen2e6da152015-05-06 11:42:25 -070053
Sunny Goyal8b9919d2021-04-07 14:45:17 -070054 private static final int DEFAULT_DOT_SIZE = 100;
Sunny Goyal57b22792021-05-25 14:35:01 -070055 // Ratio of empty space, qsb should take up to appear visually centered.
56 private static final float QSB_CENTER_FACTOR = .325f;
Sunny Goyal1890f672020-04-30 12:28:00 -070057
Adam Cohen2e6da152015-05-06 11:42:25 -070058 public final InvariantDeviceProfile inv;
Sunny Goyalfd58da62020-08-11 12:06:49 -070059 private final Info mInfo;
Sunny Goyal35c7b192021-04-20 16:51:10 -070060 private final DisplayMetrics mMetrics;
Winson Chungbe876472014-05-14 14:15:20 -070061
Sunny Goyalc6205602015-05-21 20:46:33 -070062 // Device properties
63 public final boolean isTablet;
Sunny Goyalc6205602015-05-21 20:46:33 -070064 public final boolean isPhone;
65 public final boolean transposeLayoutWithOrientation;
Sunny Goyal19ff7282021-04-22 10:12:54 -070066 public final boolean isTwoPanels;
Alex Chaua02eddc2021-04-29 00:36:06 +010067 public final boolean allowRotation;
Hyunyoung Song18bfaaf2015-03-17 11:32:21 -070068
Sunny Goyalc6205602015-05-21 20:46:33 -070069 // Device properties in current orientation
Sunny Goyald792a772018-04-05 13:37:46 -070070 public final boolean isLandscape;
Sunny Goyald70e75a2018-02-22 10:07:32 -080071 public final boolean isMultiWindowMode;
72
Sunny Goyal0addbf02020-04-28 14:17:35 -070073 public final int windowX;
74 public final int windowY;
Sunny Goyalc6205602015-05-21 20:46:33 -070075 public final int widthPx;
76 public final int heightPx;
77 public final int availableWidthPx;
78 public final int availableHeightPx;
Jon Mirandabba64512019-03-27 10:54:17 -070079
80 public final float aspectRatio;
81
Jon Mirandae126d722021-02-25 10:45:20 -050082 public final boolean isScalableGrid;
83
Tony Wickhamd6b40372015-09-23 18:37:57 -070084 /**
85 * The maximum amount of left/right workspace padding as a percentage of the screen width.
86 * To be clear, this means that up to 7% of the screen width can be used as left padding, and
87 * 7% of the screen width can be used as right padding.
88 */
89 private static final float MAX_HORIZONTAL_PADDING_PERCENT = 0.14f;
Winson Chungb3800242013-10-24 11:01:54 -070090
Jon Miranda3f9bab22017-07-28 14:50:17 -070091 private static final float TALL_DEVICE_ASPECT_RATIO_THRESHOLD = 2.0f;
Jon Miranda80cddbc2021-07-22 13:51:16 -070092 private static final float TALLER_DEVICE_ASPECT_RATIO_THRESHOLD = 2.15f;
Jon Miranda80dda302021-07-28 14:14:59 -070093 private static final float TALL_DEVICE_EXTRA_SPACE_THRESHOLD_DP = 252;
94 private static final float TALL_DEVICE_MORE_EXTRA_SPACE_THRESHOLD_DP = 268;
Jon Miranda30d0aa22017-07-25 15:55:29 -070095
Jon Miranda5eacbb72018-07-31 11:14:46 -070096 // To evenly space the icons, increase the left/right margins for tablets in portrait mode.
97 private static final int PORTRAIT_TABLET_LEFT_RIGHT_PADDING_MULTIPLIER = 4;
98
Sunny Goyalc6205602015-05-21 20:46:33 -070099 // Workspace
Thales Limad90faab2021-09-21 17:18:47 +0100100 public final int desiredWorkspaceHorizontalMarginOriginalPx;
101 public int desiredWorkspaceHorizontalMarginPx;
Thales Lima78d00ad2021-09-30 11:29:06 +0100102 public Point cellLayoutBorderSpaceOriginalPx;
103 public Point cellLayoutBorderSpacePx;
Jon Miranda28032002017-07-13 16:18:56 -0700104 public final int cellLayoutPaddingLeftRightPx;
Jon Miranda18751b62017-07-31 17:25:27 -0700105 public final int cellLayoutBottomPaddingPx;
Sunny Goyalc6205602015-05-21 20:46:33 -0700106 public final int edgeMarginPx;
Sunny Goyal47328fd2016-05-25 18:56:41 -0700107 public float workspaceSpringLoadShrinkFactor;
108 public final int workspaceSpringLoadedBottomSpace;
Sunny Goyalc6205602015-05-21 20:46:33 -0700109
Jon Miranda58561d42021-03-17 10:51:54 -0400110 private final int extraSpace;
Jon Miranda228877d2021-02-09 11:05:00 -0500111 public int workspaceTopPadding;
112 public int workspaceBottomPadding;
Jon Miranda58561d42021-03-17 10:51:54 -0400113 public int extraHotseatBottomPadding;
Jon Miranda228877d2021-02-09 11:05:00 -0500114
Tony Wickham5edf9e22020-03-27 20:06:52 -0700115 // Workspace page indicator
116 public final int workspacePageIndicatorHeight;
117 private final int mWorkspacePageIndicatorOverlapWorkspace;
Winson1f064272016-07-18 17:18:02 -0700118
Sunny Goyalc6205602015-05-21 20:46:33 -0700119 // Workspace icons
Jon Mirandac9e69fa2021-03-22 17:13:34 -0400120 public float iconScale;
Sunny Goyalc6205602015-05-21 20:46:33 -0700121 public int iconSizePx;
122 public int iconTextSizePx;
123 public int iconDrawablePaddingPx;
Winson Chung5f4e0fd2015-05-22 11:12:27 -0700124 public int iconDrawablePaddingOriginalPx;
Winson Chungb3800242013-10-24 11:01:54 -0700125
Jon Mirandaab3c6812021-06-28 15:42:28 -0700126 public float cellScaleToFit;
Adam Cohen59400422014-03-05 18:07:04 -0800127 public int cellWidthPx;
128 public int cellHeightPx;
Jon Mirandab28c4fc2017-06-20 10:58:36 -0700129 public int workspaceCellPaddingXPx;
Adam Cohen59400422014-03-05 18:07:04 -0800130
Jon Mirandae126d722021-02-25 10:45:20 -0500131 public int cellYPaddingPx;
Jon Mirandae126d722021-02-25 10:45:20 -0500132
Sunny Goyalc6205602015-05-21 20:46:33 -0700133 // Folder
Jon Mirandae126d722021-02-25 10:45:20 -0500134 public float folderLabelTextScale;
135 public int folderLabelTextSizePx;
Sunny Goyalc6205602015-05-21 20:46:33 -0700136 public int folderIconSizePx;
Jon Miranda591e3602018-03-28 11:37:00 -0700137 public int folderIconOffsetYPx;
Jon Mirandabf7d8122016-11-03 15:29:29 -0700138
Jon Mirandae126d722021-02-25 10:45:20 -0500139 // Folder content
Thales Lima78d00ad2021-09-30 11:29:06 +0100140 public Point folderCellLayoutBorderSpacePx;
141 public int folderCellLayoutBorderSpaceOriginalPx;
Jon Mirandae126d722021-02-25 10:45:20 -0500142 public int folderContentPaddingLeftRight;
143 public int folderContentPaddingTop;
144
Jon Mirandabf7d8122016-11-03 15:29:29 -0700145 // Folder cell
Sunny Goyalc6205602015-05-21 20:46:33 -0700146 public int folderCellWidthPx;
147 public int folderCellHeightPx;
Jon Mirandabf7d8122016-11-03 15:29:29 -0700148
149 // Folder child
150 public int folderChildIconSizePx;
151 public int folderChildTextSizePx;
Sunny Goyalbaec6ff2016-09-14 11:26:21 -0700152 public int folderChildDrawablePaddingPx;
Winson Chungb3800242013-10-24 11:01:54 -0700153
Sunny Goyalc6205602015-05-21 20:46:33 -0700154 // Hotseat
Jon Miranda80cddbc2021-07-22 13:51:16 -0700155 public int hotseatBarSizeExtraSpacePx;
Tony Wickhamb87f3cd2021-04-07 15:02:37 -0700156 public final int numShownHotseatIcons;
Sunny Goyalc6205602015-05-21 20:46:33 -0700157 public int hotseatCellHeightPx;
Jon Miranda0d284852021-06-22 14:50:55 -0700158 private final int hotseatExtraVerticalSize;
Jon Miranda18751b62017-07-31 17:25:27 -0700159 // In portrait: size = height, in landscape: size = width
160 public int hotseatBarSizePx;
Jon Miranda80cddbc2021-07-22 13:51:16 -0700161 public int hotseatBarTopPaddingPx;
Jon Miranda0d284852021-06-22 14:50:55 -0700162 public final int hotseatBarBottomPaddingPx;
Tony Wickham1eeffbe2018-06-12 15:01:15 -0700163 // Start is the side next to the nav bar, end is the side next to the workspace
164 public final int hotseatBarSidePaddingStartPx;
165 public final int hotseatBarSidePaddingEndPx;
Sunny Goyal57b22792021-05-25 14:35:01 -0700166 public final int hotseatQsbHeight;
Adam Cohen2e6da152015-05-06 11:42:25 -0700167
Jon Miranda8bdb2222021-06-23 18:10:10 -0700168 public final float qsbBottomMarginOriginalPx;
169 public int qsbBottomMarginPx;
170
Sunny Goyalc6205602015-05-21 20:46:33 -0700171 // All apps
sfufa@google.comde013292021-09-21 18:22:44 -0700172 public int allAppsCellSpacingPx;
Samuel Fufaee9aff92021-04-05 13:30:40 -0500173 public int allAppsOpenVerticalTranslate;
Jon Mirandab28c4fc2017-06-20 10:58:36 -0700174 public int allAppsCellHeightPx;
Samuel Fufaf1424a32019-10-04 15:15:19 -0700175 public int allAppsCellWidthPx;
Winson1f064272016-07-18 17:18:02 -0700176 public int allAppsIconSizePx;
177 public int allAppsIconDrawablePaddingPx;
sfufa@google.comde013292021-09-21 18:22:44 -0700178 public int allAppsLeftRightPadding;
Sunny Goyal19ff7282021-04-22 10:12:54 -0700179 public final int numShownAllAppsColumns;
Winson1f064272016-07-18 17:18:02 -0700180 public float allAppsIconTextSizePx;
181
Zak Cohen334efeb2021-03-19 16:42:07 -0700182 // Overview
Alex Chau646f8042021-07-26 11:56:22 +0100183 public final boolean overviewShowAsGrid;
Zak Cohen334efeb2021-03-19 16:42:07 -0700184 public int overviewTaskMarginPx;
Alex Chaueaa6d682021-08-17 12:56:15 +0100185 public int overviewTaskMarginGridPx;
Alex Chaudedbc8a2021-03-17 16:53:26 +0000186 public int overviewTaskIconSizePx;
Alex Chauac9df382021-08-02 19:08:41 +0100187 public int overviewTaskIconDrawableSizePx;
188 public int overviewTaskIconDrawableSizeGridPx;
Alex Chaudedbc8a2021-03-17 16:53:26 +0000189 public int overviewTaskThumbnailTopMarginPx;
zakcohendad8a802021-05-20 09:52:26 -0700190 public final int overviewActionsMarginThreeButtonPx;
Alex Chau5fd9d492021-07-22 17:27:11 +0100191 public final int overviewActionsTopMarginGesturePx;
192 public final int overviewActionsBottomMarginGesturePx;
193 public int overviewPageSpacing;
194 public int overviewRowSpacing;
Zak Cohen334efeb2021-03-19 16:42:07 -0700195
Jon Miranda7ae64ff2016-11-21 16:18:46 -0800196 // Widgets
197 public final PointF appWidgetScale = new PointF(1.0f, 1.0f);
198
Sunny Goyal47328fd2016-05-25 18:56:41 -0700199 // Drop Target
200 public int dropTargetBarSizePx;
Alex Chaua02eddc2021-04-29 00:36:06 +0100201 public int dropTargetDragPaddingPx;
202 public int dropTargetTextSizePx;
Adam Cohen4ae96ce2014-08-29 15:05:48 -0700203
Winson1f064272016-07-18 17:18:02 -0700204 // Insets
Sunny Goyal07b69292018-01-08 14:19:34 -0800205 private final Rect mInsets = new Rect();
206 public final Rect workspacePadding = new Rect();
Sunny Goyal81b4c7b2018-03-26 12:10:31 -0700207 private final Rect mHotseatPadding = new Rect();
Jon Miranda0bd63d12019-03-06 17:29:29 -0800208 // When true, nav bar is on the left side of the screen.
Sunny Goyal59d086c2018-05-07 17:31:40 -0700209 private boolean mIsSeascape;
Winson1f064272016-07-18 17:18:02 -0700210
Tony Wickhamf34bee82018-12-03 18:11:39 -0800211 // Notification dots
Samuel Fufac96fa242019-09-26 23:06:32 -0700212 public DotRenderer mDotRendererWorkSpace;
213 public DotRenderer mDotRendererAllApps;
Tony Wickham9a8d11f2017-01-11 09:53:12 -0800214
Pierre Barbier de Reuille578deba2021-09-24 13:47:44 +0100215 // Taskbar
Tony Wickham15883892021-02-12 11:24:40 -0800216 public boolean isTaskbarPresent;
Tony Wickham635e1802021-07-22 14:28:04 -1000217 // Whether Taskbar will inset the bottom of apps by taskbarSize.
218 public boolean isTaskbarPresentInApps;
Tony Wickham15883892021-02-12 11:24:40 -0800219 public int taskbarSize;
220
Alex Chaua02eddc2021-04-29 00:36:06 +0100221 // DragController
222 public int flingToDeleteThresholdVelocity;
223
Vinit Nayak17c4b332021-08-05 12:54:58 -0700224 /** TODO: Once we fully migrate to staged split, remove "isMultiWindowMode" */
Sunny Goyal19ff7282021-04-22 10:12:54 -0700225 DeviceProfile(Context context, InvariantDeviceProfile inv, Info info, WindowBounds windowBounds,
Sunny Goyal0addbf02020-04-28 14:17:35 -0700226 boolean isMultiWindowMode, boolean transposeLayoutWithOrientation,
Sunny Goyal19ff7282021-04-22 10:12:54 -0700227 boolean useTwoPanels) {
Sunny Goyalfee35bb2015-05-11 11:38:19 -0700228
Adam Cohen2e6da152015-05-06 11:42:25 -0700229 this.inv = inv;
Sunny Goyal19ff7282021-04-22 10:12:54 -0700230 this.isLandscape = windowBounds.isLandscape();
Sunny Goyald70e75a2018-02-22 10:07:32 -0800231 this.isMultiWindowMode = isMultiWindowMode;
Jon Mirandae126d722021-02-25 10:45:20 -0500232 this.transposeLayoutWithOrientation = transposeLayoutWithOrientation;
Sunny Goyal19ff7282021-04-22 10:12:54 -0700233 windowX = windowBounds.bounds.left;
234 windowY = windowBounds.bounds.top;
Winson Chungb3800242013-10-24 11:01:54 -0700235
Jon Mirandae126d722021-02-25 10:45:20 -0500236 isScalableGrid = inv.isScalable && !isVerticalBarLayout() && !isMultiWindowMode;
237
Jon Miranda7e183c32018-06-20 11:05:27 -0700238 // Determine sizes.
Sunny Goyal19ff7282021-04-22 10:12:54 -0700239 widthPx = windowBounds.bounds.width();
240 heightPx = windowBounds.bounds.height();
241 availableWidthPx = windowBounds.availableSize.x;
Tony Wickham21970cc2021-09-15 15:44:05 -0700242 availableHeightPx = windowBounds.availableSize.y;
Jon Miranda7e183c32018-06-20 11:05:27 -0700243
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700244 mInfo = info;
Alex Chaua02eddc2021-04-29 00:36:06 +0100245 // If the device's pixel density was scaled (usually via settings for A11y), use the
246 // original dimensions to determine if rotation is allowed of not.
247 float originalSmallestWidth = dpiFromPx(Math.min(widthPx, heightPx), DENSITY_DEVICE_STABLE);
248 allowRotation = originalSmallestWidth >= MIN_TABLET_WIDTH;
249 // Tablet UI does not support emulated landscape.
250 isTablet = allowRotation && info.isTablet(windowBounds);
Sunny Goyal19ff7282021-04-22 10:12:54 -0700251 isPhone = !isTablet;
Alex Chaub1c36ce2021-08-25 11:54:08 +0100252 isTwoPanels = isTablet && useTwoPanels
253 && (isLandscape || FeatureFlags.ENABLE_TWO_PANEL_HOME_IN_PORTRAIT.get());
Adam Cohen2e6da152015-05-06 11:42:25 -0700254
Jon Mirandabba64512019-03-27 10:54:17 -0700255 aspectRatio = ((float) Math.max(widthPx, heightPx)) / Math.min(widthPx, heightPx);
Jon Miranda7e183c32018-06-20 11:05:27 -0700256 boolean isTallDevice = Float.compare(aspectRatio, TALL_DEVICE_ASPECT_RATIO_THRESHOLD) >= 0;
Sunny Goyalc6205602015-05-21 20:46:33 -0700257
258 // Some more constants
Sunny Goyal1890f672020-04-30 12:28:00 -0700259 context = getContext(context, info, isVerticalBarLayout()
Jon Mirandab28c4fc2017-06-20 10:58:36 -0700260 ? Configuration.ORIENTATION_LANDSCAPE
261 : Configuration.ORIENTATION_PORTRAIT);
Sunny Goyal35c7b192021-04-20 16:51:10 -0700262 mMetrics = context.getResources().getDisplayMetrics();
Sunny Goyal1890f672020-04-30 12:28:00 -0700263 final Resources res = context.getResources();
Jon Mirandab28c4fc2017-06-20 10:58:36 -0700264
Sunny Goyal57b22792021-05-25 14:35:01 -0700265 hotseatQsbHeight = res.getDimensionPixelSize(R.dimen.qsb_widget_height);
Sunny Goyal71ef9682021-07-29 12:59:27 -0700266 isTaskbarPresent = isTablet && ApiWrapper.TASKBAR_DRAWN_IN_PROCESS
267 && FeatureFlags.ENABLE_TASKBAR.get();
Tony Wickham15883892021-02-12 11:24:40 -0800268 if (isTaskbarPresent) {
Tony Wickham15883892021-02-12 11:24:40 -0800269 taskbarSize = res.getDimensionPixelSize(R.dimen.taskbar_size);
Tony Wickham15883892021-02-12 11:24:40 -0800270 }
Tony Wickham15883892021-02-12 11:24:40 -0800271
Winson Chungb3800242013-10-24 11:01:54 -0700272 edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
Sunny Goyal58fa4b62019-03-22 16:23:25 -0700273
Thales Limad90faab2021-09-21 17:18:47 +0100274 desiredWorkspaceHorizontalMarginPx = getHorizontalMarginPx(inv, res);
275 desiredWorkspaceHorizontalMarginOriginalPx = desiredWorkspaceHorizontalMarginPx;
Samuel Fufaee9aff92021-04-05 13:30:40 -0500276
277 allAppsOpenVerticalTranslate = res.getDimensionPixelSize(
278 R.dimen.all_apps_open_vertical_translate);
279
Jon Mirandae126d722021-02-25 10:45:20 -0500280 folderLabelTextScale = res.getFloat(R.dimen.folder_label_text_scale);
281 folderContentPaddingLeftRight =
282 res.getDimensionPixelSize(R.dimen.folder_content_padding_left_right);
283 folderContentPaddingTop = res.getDimensionPixelSize(R.dimen.folder_content_padding_top);
284
Thales Lima78d00ad2021-09-30 11:29:06 +0100285 cellLayoutBorderSpacePx = getCellLayoutBorderSpace(inv);
sfufa@google.comde013292021-09-21 18:22:44 -0700286 allAppsCellSpacingPx = pxFromDp(inv.allAppsCellSpacing, mMetrics, 1f);
Thales Lima78d00ad2021-09-30 11:29:06 +0100287 cellLayoutBorderSpaceOriginalPx = new Point(cellLayoutBorderSpacePx);
288 folderCellLayoutBorderSpaceOriginalPx = pxFromDp(inv.folderBorderSpace, mMetrics, 1f);
289 folderCellLayoutBorderSpacePx = new Point(folderCellLayoutBorderSpaceOriginalPx,
290 folderCellLayoutBorderSpaceOriginalPx);
Jon Mirandae126d722021-02-25 10:45:20 -0500291
Jon Miranda5eacbb72018-07-31 11:14:46 -0700292 int cellLayoutPaddingLeftRightMultiplier = !isVerticalBarLayout() && isTablet
293 ? PORTRAIT_TABLET_LEFT_RIGHT_PADDING_MULTIPLIER : 1;
Jon Mirandae126d722021-02-25 10:45:20 -0500294 int cellLayoutPadding = isScalableGrid
295 ? 0
296 : res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_layout_padding);
Andras Kloczl8e57cce2021-02-11 23:51:19 +0100297
Sunny Goyal19ff7282021-04-22 10:12:54 -0700298 if (isTwoPanels) {
Thales Lima7a6752d2021-09-23 14:31:00 +0100299 cellLayoutPaddingLeftRightPx = 0;
Andras Kloczl8e57cce2021-02-11 23:51:19 +0100300 cellLayoutBottomPaddingPx = 0;
301 } else if (isLandscape) {
Sunny Goyal58fa4b62019-03-22 16:23:25 -0700302 cellLayoutPaddingLeftRightPx = 0;
303 cellLayoutBottomPaddingPx = cellLayoutPadding;
304 } else {
305 cellLayoutPaddingLeftRightPx = cellLayoutPaddingLeftRightMultiplier * cellLayoutPadding;
306 cellLayoutBottomPaddingPx = 0;
307 }
308
Tony Wickham5edf9e22020-03-27 20:06:52 -0700309 workspacePageIndicatorHeight = res.getDimensionPixelSize(
310 R.dimen.workspace_page_indicator_height);
311 mWorkspacePageIndicatorOverlapWorkspace =
312 res.getDimensionPixelSize(R.dimen.workspace_page_indicator_overlap_workspace);
Sunny Goyal58fa4b62019-03-22 16:23:25 -0700313
Winson Chungb3800242013-10-24 11:01:54 -0700314 iconDrawablePaddingOriginalPx =
315 res.getDimensionPixelSize(R.dimen.dynamic_grid_icon_drawable_padding);
Alex Chaua02eddc2021-04-29 00:36:06 +0100316
Sunny Goyal47328fd2016-05-25 18:56:41 -0700317 dropTargetBarSizePx = res.getDimensionPixelSize(R.dimen.dynamic_grid_drop_target_size);
Alex Chaua02eddc2021-04-29 00:36:06 +0100318 dropTargetDragPaddingPx = res.getDimensionPixelSize(R.dimen.drop_target_drag_padding);
319 dropTargetTextSizePx = res.getDimensionPixelSize(R.dimen.drop_target_text_size);
320
Sunny Goyal47328fd2016-05-25 18:56:41 -0700321 workspaceSpringLoadedBottomSpace =
322 res.getDimensionPixelSize(R.dimen.dynamic_grid_min_spring_loaded_space);
Sunny Goyald5190522017-04-24 03:06:54 -0700323
Jon Mirandab28c4fc2017-06-20 10:58:36 -0700324 workspaceCellPaddingXPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_padding_x);
Jon Miranda09660722017-06-14 14:20:14 -0700325
Sunny Goyal19ff7282021-04-22 10:12:54 -0700326 numShownHotseatIcons =
327 isTwoPanels ? inv.numDatabaseHotseatIcons : inv.numShownHotseatIcons;
328 numShownAllAppsColumns =
329 isTwoPanels ? inv.numDatabaseAllAppsColumns : inv.numAllAppsColumns;
Jon Miranda80cddbc2021-07-22 13:51:16 -0700330 hotseatBarSizeExtraSpacePx = 0;
Winson1f064272016-07-18 17:18:02 -0700331 hotseatBarTopPaddingPx =
332 res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_top_padding);
Jon Miranda7e183c32018-06-20 11:05:27 -0700333 hotseatBarBottomPaddingPx = (isTallDevice ? 0
334 : res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_non_tall_padding))
335 + res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_padding);
Tony Wickham1eeffbe2018-06-12 15:01:15 -0700336 hotseatBarSidePaddingEndPx =
Sunny Goyal228153d2018-01-04 15:35:22 -0800337 res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_side_padding);
Jon Miranda3f411e72019-05-16 17:15:16 -0700338 // Add a bit of space between nav bar and hotseat in vertical bar layout.
Tony Wickham5edf9e22020-03-27 20:06:52 -0700339 hotseatBarSidePaddingStartPx = isVerticalBarLayout() ? workspacePageIndicatorHeight : 0;
Jon Miranda0d284852021-06-22 14:50:55 -0700340 hotseatExtraVerticalSize =
Jon Miranda228877d2021-02-09 11:05:00 -0500341 res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_extra_vertical_size);
Jon Miranda0d284852021-06-22 14:50:55 -0700342 updateHotseatIconSize(pxFromDp(inv.iconSize, mMetrics, 1f));
Jon Mirandab28c4fc2017-06-20 10:58:36 -0700343
Jon Miranda8bdb2222021-06-23 18:10:10 -0700344 qsbBottomMarginOriginalPx = isScalableGrid
345 ? res.getDimensionPixelSize(R.dimen.scalable_grid_qsb_bottom_margin)
346 : 0;
347
Alex Chau646f8042021-07-26 11:56:22 +0100348 overviewShowAsGrid = isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get();
Alex Chau5fd9d492021-07-22 17:27:11 +0100349 overviewTaskMarginPx = overviewShowAsGrid
Alex Chaueaa6d682021-08-17 12:56:15 +0100350 ? res.getDimensionPixelSize(R.dimen.overview_task_margin_focused)
Alex Chau5fd9d492021-07-22 17:27:11 +0100351 : res.getDimensionPixelSize(R.dimen.overview_task_margin);
Alex Chaueaa6d682021-08-17 12:56:15 +0100352 overviewTaskMarginGridPx = res.getDimensionPixelSize(R.dimen.overview_task_margin_grid);
Alex Chau5fd9d492021-07-22 17:27:11 +0100353 overviewTaskIconSizePx = res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_size);
Alex Chauac9df382021-08-02 19:08:41 +0100354 overviewTaskIconDrawableSizePx =
355 res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_drawable_size);
356 overviewTaskIconDrawableSizeGridPx =
357 res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_drawable_size_grid);
Alex Chaudedbc8a2021-03-17 16:53:26 +0000358 overviewTaskThumbnailTopMarginPx = overviewTaskIconSizePx + overviewTaskMarginPx * 2;
Alex Chau5fd9d492021-07-22 17:27:11 +0100359 if (overviewShowAsGrid) {
360 if (isLandscape) {
361 overviewActionsTopMarginGesturePx = res.getDimensionPixelSize(
362 R.dimen.overview_actions_top_margin_gesture_grid_landscape);
363 overviewActionsBottomMarginGesturePx = res.getDimensionPixelSize(
364 R.dimen.overview_actions_bottom_margin_gesture_grid_landscape);
365 } else {
366 overviewActionsTopMarginGesturePx = res.getDimensionPixelSize(
367 R.dimen.overview_actions_top_margin_gesture_grid_portrait);
368 overviewActionsBottomMarginGesturePx = res.getDimensionPixelSize(
369 R.dimen.overview_actions_bottom_margin_gesture_grid_portrait);
370 }
371 } else {
372 overviewActionsTopMarginGesturePx = res.getDimensionPixelSize(
373 R.dimen.overview_actions_margin_gesture);
374 overviewActionsBottomMarginGesturePx = overviewActionsTopMarginGesturePx;
375 }
zakcohendad8a802021-05-20 09:52:26 -0700376 overviewActionsMarginThreeButtonPx = res.getDimensionPixelSize(
Alex Chau5fd9d492021-07-22 17:27:11 +0100377 R.dimen.overview_actions_margin_three_button);
378 overviewPageSpacing = overviewShowAsGrid
Pierre Barbier de Reuille578deba2021-09-24 13:47:44 +0100379 ? res.getDimensionPixelSize(R.dimen.recents_page_spacing_grid)
380 : res.getDimensionPixelSize(R.dimen.recents_page_spacing);
Alex Chau5fd9d492021-07-22 17:27:11 +0100381 overviewRowSpacing = isLandscape
382 ? res.getDimensionPixelSize(R.dimen.overview_grid_row_spacing_landscape)
383 : res.getDimensionPixelSize(R.dimen.overview_grid_row_spacing_portrait);
Zak Cohen334efeb2021-03-19 16:42:07 -0700384
Jon Miranda2ed276e2017-06-29 11:36:34 -0700385 // Calculate all of the remaining variables.
Jon Miranda58561d42021-03-17 10:51:54 -0400386 extraSpace = updateAvailableDimensions(res);
Jon Miranda80cddbc2021-07-22 13:51:16 -0700387
Jon Miranda2ed276e2017-06-29 11:36:34 -0700388 // Now that we have all of the variables calculated, we can tune certain sizes.
Jon Mirandac9e69fa2021-03-22 17:13:34 -0400389 if (isScalableGrid && inv.devicePaddings != null) {
390 // Paddings were created assuming no scaling, so we first unscale the extra space.
Jon Mirandaab3c6812021-06-28 15:42:28 -0700391 int unscaledExtraSpace = (int) (extraSpace / cellScaleToFit);
Jon Mirandac9e69fa2021-03-22 17:13:34 -0400392 DevicePadding padding = inv.devicePaddings.getDevicePadding(unscaledExtraSpace);
Jon Miranda228877d2021-02-09 11:05:00 -0500393
Jon Mirandac9e69fa2021-03-22 17:13:34 -0400394 int paddingWorkspaceTop = padding.getWorkspaceTopPadding(unscaledExtraSpace);
395 int paddingWorkspaceBottom = padding.getWorkspaceBottomPadding(unscaledExtraSpace);
396 int paddingHotseatBottom = padding.getHotseatBottomPadding(unscaledExtraSpace);
397
Jon Mirandaab3c6812021-06-28 15:42:28 -0700398 workspaceTopPadding = Math.round(paddingWorkspaceTop * cellScaleToFit);
399 workspaceBottomPadding = Math.round(paddingWorkspaceBottom * cellScaleToFit);
400 extraHotseatBottomPadding = Math.round(paddingHotseatBottom * cellScaleToFit);
Jon Mirandac9e69fa2021-03-22 17:13:34 -0400401
Jon Miranda58561d42021-03-17 10:51:54 -0400402 hotseatBarSizePx += extraHotseatBottomPadding;
Jon Miranda8bdb2222021-06-23 18:10:10 -0700403
Jon Mirandaab3c6812021-06-28 15:42:28 -0700404 qsbBottomMarginPx = Math.round(qsbBottomMarginOriginalPx * cellScaleToFit);
Jon Miranda228877d2021-02-09 11:05:00 -0500405 } else if (!isVerticalBarLayout() && isPhone && isTallDevice) {
Jon Miranda3f9bab22017-07-28 14:50:17 -0700406 // We increase the hotseat size when there is extra space.
Jon Miranda80cddbc2021-07-22 13:51:16 -0700407
Jon Miranda80dda302021-07-28 14:14:59 -0700408 if (Float.compare(aspectRatio, TALLER_DEVICE_ASPECT_RATIO_THRESHOLD) >= 0
409 && extraSpace >= Utilities.dpToPx(TALL_DEVICE_EXTRA_SPACE_THRESHOLD_DP)) {
410 // For taller devices, we will take a piece of the extra space from each row,
Jon Miranda80cddbc2021-07-22 13:51:16 -0700411 // and add it to the space above and below the hotseat.
Jon Miranda80dda302021-07-28 14:14:59 -0700412
413 // For devices with more extra space, we take a larger piece from each cell.
414 int piece = extraSpace < Utilities.dpToPx(TALL_DEVICE_MORE_EXTRA_SPACE_THRESHOLD_DP)
Jon Mirandaa56cb842021-08-03 17:26:44 -0700415 ? 7 : 5;
Jon Miranda80dda302021-07-28 14:14:59 -0700416
Jon Miranda80cddbc2021-07-22 13:51:16 -0700417 int extraSpace = ((getCellSize().y - iconSizePx - iconDrawablePaddingPx * 2)
Jon Miranda80dda302021-07-28 14:14:59 -0700418 * inv.numRows) / piece;
Jon Miranda80cddbc2021-07-22 13:51:16 -0700419
Jon Mirandaa56cb842021-08-03 17:26:44 -0700420 workspaceTopPadding = extraSpace / 8;
421 int halfLeftOver = (extraSpace - workspaceTopPadding) / 2;
422 hotseatBarTopPaddingPx += halfLeftOver;
423 hotseatBarSizeExtraSpacePx = halfLeftOver;
Jon Miranda80cddbc2021-07-22 13:51:16 -0700424 } else {
425 // ie. For a display with a large aspect ratio, we can keep the icons on the
426 // workspace in portrait mode closer together by adding more height to the hotseat.
427 // Note: This calculation was created after noticing a pattern in the design spec.
428 hotseatBarSizeExtraSpacePx = getCellSize().y - iconSizePx
429 - iconDrawablePaddingPx * 2 - workspacePageIndicatorHeight;
430 }
431
432 updateHotseatIconSize(iconSizePx);
Jon Miranda30d0aa22017-07-25 15:55:29 -0700433
Jon Miranda3f9bab22017-07-28 14:50:17 -0700434 // Recalculate the available dimensions using the new hotseat size.
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700435 updateAvailableDimensions(res);
Jon Miranda2ed276e2017-06-29 11:36:34 -0700436 }
Sunny Goyal07b69292018-01-08 14:19:34 -0800437 updateWorkspacePadding();
Tony Wickham1237df02017-02-24 08:59:36 -0800438
Alex Chaua02eddc2021-04-29 00:36:06 +0100439 flingToDeleteThresholdVelocity = res.getDimensionPixelSize(
440 R.dimen.drag_flingToDeleteMinVelocity);
441
Tony Wickham1237df02017-02-24 08:59:36 -0800442 // This is done last, after iconSizePx is calculated above.
Sunny Goyal8b9919d2021-04-07 14:45:17 -0700443 Path dotPath = GraphicsUtils.getShapePath(DEFAULT_DOT_SIZE);
444 mDotRendererWorkSpace = new DotRenderer(iconSizePx, dotPath, DEFAULT_DOT_SIZE);
Samuel Fufac96fa242019-09-26 23:06:32 -0700445 mDotRendererAllApps = iconSizePx == allAppsIconSizePx ? mDotRendererWorkSpace :
Sunny Goyal8b9919d2021-04-07 14:45:17 -0700446 new DotRenderer(allAppsIconSizePx, dotPath, DEFAULT_DOT_SIZE);
Adam Cohen63f1ec02014-08-12 09:23:13 -0700447 }
448
Thales Limad90faab2021-09-21 17:18:47 +0100449 private int getHorizontalMarginPx(InvariantDeviceProfile idp, Resources res) {
450 if (isVerticalBarLayout()) {
451 return 0;
452 }
453
454 int horizontalMarginPx;
455
456 if (isScalableGrid) {
457 if (isTwoPanels) {
458 if (isLandscape) {
459 horizontalMarginPx = pxFromDp(idp.twoPanelLandscapeHorizontalMargin, mMetrics);
460 } else {
461 horizontalMarginPx = pxFromDp(idp.twoPanelPortraitHorizontalMargin, mMetrics);
462 }
463 } else {
464 horizontalMarginPx = pxFromDp(idp.horizontalMargin, mMetrics);
465 }
466 } else {
467 horizontalMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_left_right_margin);
468 }
469 return horizontalMarginPx;
470 }
471
Jon Miranda0d284852021-06-22 14:50:55 -0700472 private void updateHotseatIconSize(int hotseatIconSizePx) {
Jon Miranda92c1b5d2021-07-20 13:57:16 -0700473 // Ensure there is enough space for folder icons, which have a slightly larger radius.
474 hotseatCellHeightPx = (int) Math.ceil(hotseatIconSizePx * ICON_OVERLAP_FACTOR);
Jon Miranda0d284852021-06-22 14:50:55 -0700475 if (isVerticalBarLayout()) {
476 hotseatBarSizePx = hotseatIconSizePx + hotseatBarSidePaddingStartPx
477 + hotseatBarSidePaddingEndPx;
478 } else {
479 hotseatBarSizePx = hotseatIconSizePx + hotseatBarTopPaddingPx
Jon Miranda80cddbc2021-07-22 13:51:16 -0700480 + hotseatBarBottomPaddingPx + (isScalableGrid ? 0 : hotseatExtraVerticalSize)
481 + hotseatBarSizeExtraSpacePx;
Jon Miranda0d284852021-06-22 14:50:55 -0700482 }
483 }
484
Thales Lima78d00ad2021-09-30 11:29:06 +0100485 private Point getCellLayoutBorderSpace(InvariantDeviceProfile idp) {
486 if (!isScalableGrid) {
487 return new Point(0, 0);
488 }
489
490 int horizontalSpacePx;
491 int verticalSpacePx;
492
493 if (isTwoPanels) {
494 if (isLandscape) {
495 horizontalSpacePx = pxFromDp(idp.twoPanelLandscapeBorderSpace.x, mMetrics);
496 verticalSpacePx = pxFromDp(idp.twoPanelLandscapeBorderSpace.y, mMetrics);
497 } else {
498 horizontalSpacePx = pxFromDp(idp.twoPanelPortraitBorderSpace.x, mMetrics);
499 verticalSpacePx = pxFromDp(idp.twoPanelPortraitBorderSpace.y, mMetrics);
500 }
501 } else {
502 horizontalSpacePx = pxFromDp(idp.borderSpace.x, mMetrics);
503 verticalSpacePx = pxFromDp(idp.borderSpace.y, mMetrics);
504 }
505
506 return new Point(horizontalSpacePx, verticalSpacePx);
507 }
508
509 private Point getCellLayoutBorderSpaceScaled(InvariantDeviceProfile idp, float scale) {
510 Point original = getCellLayoutBorderSpace(idp);
511 return new Point((int) (original.x * scale), (int) (original.y * scale));
Jon Mirandae126d722021-02-25 10:45:20 -0500512 }
513
Sunny Goyal69a8eec2021-07-22 10:02:50 -0700514 public Info getDisplayInfo() {
515 return mInfo;
516 }
517
Jon Miranda611dba42021-03-02 14:12:13 -0500518 /**
519 * We inset the widget padding added by the system and instead rely on the border spacing
520 * between cells to create reliable consistency between widgets
521 */
522 public boolean shouldInsetWidgets() {
523 Rect widgetPadding = inv.defaultWidgetPadding;
524
Jon Miranda49811182021-06-03 09:52:40 -0700525 // Check all sides to ensure that the widget won't overlap into another cell, or into
526 // status bar.
527 return workspaceTopPadding > widgetPadding.top
Thales Lima78d00ad2021-09-30 11:29:06 +0100528 && cellLayoutBorderSpacePx.x > widgetPadding.left
529 && cellLayoutBorderSpacePx.y > widgetPadding.top
530 && cellLayoutBorderSpacePx.x > widgetPadding.right
531 && cellLayoutBorderSpacePx.y > widgetPadding.bottom;
Jon Miranda611dba42021-03-02 14:12:13 -0500532 }
Jon Mirandae126d722021-02-25 10:45:20 -0500533
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700534 public Builder toBuilder(Context context) {
Sunny Goyal19ff7282021-04-22 10:12:54 -0700535 WindowBounds bounds =
536 new WindowBounds(widthPx, heightPx, availableWidthPx, availableHeightPx);
537 bounds.bounds.offsetTo(windowX, windowY);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700538 return new Builder(context, inv, mInfo)
Sunny Goyal19ff7282021-04-22 10:12:54 -0700539 .setWindowBounds(bounds)
540 .setUseTwoPanels(isTwoPanels)
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700541 .setMultiWindowMode(isMultiWindowMode);
Sunny Goyal1a52ef52018-01-11 10:15:03 -0800542 }
543
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700544 public DeviceProfile copy(Context context) {
545 return toBuilder(context).build();
546 }
547
548 /**
549 * TODO: Move this to the builder as part of setMultiWindowMode
550 */
Sunny Goyalb46703d2020-05-27 17:52:03 -0700551 public DeviceProfile getMultiWindowProfile(Context context, WindowBounds windowBounds) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700552 DeviceProfile profile = toBuilder(context)
Sunny Goyal19ff7282021-04-22 10:12:54 -0700553 .setWindowBounds(windowBounds)
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700554 .setMultiWindowMode(true)
555 .build();
Jon Miranda93e1f042016-11-11 14:13:04 -0800556
Jon Miranda941375e2021-03-31 13:10:45 -0400557 profile.hideWorkspaceLabelsIfNotEnoughSpace();
Jon Miranda93e1f042016-11-11 14:13:04 -0800558
Jon Miranda7ae64ff2016-11-21 16:18:46 -0800559 // We use these scales to measure and layout the widgets using their full invariant profile
560 // sizes and then draw them scaled and centered to fit in their multi-window mode cellspans.
561 float appWidgetScaleX = (float) profile.getCellSize().x / getCellSize().x;
562 float appWidgetScaleY = (float) profile.getCellSize().y / getCellSize().y;
563 profile.appWidgetScale.set(appWidgetScaleX, appWidgetScaleY);
Sunny Goyal07b69292018-01-08 14:19:34 -0800564 profile.updateWorkspacePadding();
Jon Miranda7ae64ff2016-11-21 16:18:46 -0800565
Jon Miranda93e1f042016-11-11 14:13:04 -0800566 return profile;
Jon Mirandacc42c5b2016-10-27 17:15:27 -0700567 }
568
Adam Cohen63f1ec02014-08-12 09:23:13 -0700569 /**
Jon Miranda941375e2021-03-31 13:10:45 -0400570 * Checks if there is enough space for labels on the workspace.
571 * If there is not, labels on the Workspace are hidden.
Jon Miranda1091e532017-07-21 13:31:50 -0700572 * It is important to call this method after the All Apps variables have been set.
573 */
Jon Miranda941375e2021-03-31 13:10:45 -0400574 private void hideWorkspaceLabelsIfNotEnoughSpace() {
575 float iconTextHeight = Utilities.calculateTextHeight(iconTextSizePx);
576 float workspaceCellPaddingY = getCellSize().y - iconSizePx - iconDrawablePaddingPx
577 - iconTextHeight;
578
579 // We want enough space so that the text is closer to its corresponding icon.
580 if (workspaceCellPaddingY < iconTextHeight) {
581 iconTextSizePx = 0;
582 iconDrawablePaddingPx = 0;
Jon Miranda92c1b5d2021-07-20 13:57:16 -0700583 cellHeightPx = (int) Math.ceil(iconSizePx * ICON_OVERLAP_FACTOR);
Jon Miranda941375e2021-03-31 13:10:45 -0400584 autoResizeAllAppsCells();
585 }
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700586 }
Jon Miranda1091e532017-07-21 13:31:50 -0700587
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700588 /**
589 * Re-computes the all-apps cell size to be independent of workspace
590 */
591 public void autoResizeAllAppsCells() {
Jon Miranda941375e2021-03-31 13:10:45 -0400592 int textHeight = Utilities.calculateTextHeight(allAppsIconTextSizePx);
593 int topBottomPadding = textHeight;
Jon Miranda1091e532017-07-21 13:31:50 -0700594 allAppsCellHeightPx = allAppsIconSizePx + allAppsIconDrawablePaddingPx
Jon Miranda941375e2021-03-31 13:10:45 -0400595 + textHeight + (topBottomPadding * 2);
Jon Miranda1091e532017-07-21 13:31:50 -0700596 }
597
sfufa@google.comde013292021-09-21 18:22:44 -0700598 private void updateAllAppsWidth() {
599 if (isTwoPanels) {
600 int usedWidth = (allAppsCellWidthPx * numShownAllAppsColumns)
601 + (allAppsCellSpacingPx * (numShownAllAppsColumns + 1));
602 allAppsLeftRightPadding = Math.max(1, (availableWidthPx - usedWidth) / 2);
603 } else {
604 allAppsLeftRightPadding =
Thales Limad90faab2021-09-21 17:18:47 +0100605 desiredWorkspaceHorizontalMarginPx + cellLayoutPaddingLeftRightPx;
sfufa@google.comde013292021-09-21 18:22:44 -0700606 }
607 }
608
Jon Miranda228877d2021-02-09 11:05:00 -0500609 /**
610 * Returns the amount of extra (or unused) vertical space.
611 */
612 private int updateAvailableDimensions(Resources res) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700613 updateIconSize(1f, res);
Winson Chung59a488a2013-12-10 12:32:14 -0800614
Jon Mirandae126d722021-02-25 10:45:20 -0500615 Point workspacePadding = getTotalWorkspacePadding();
616
617 // Check to see if the icons fit within the available height.
618 float usedHeight = getCellLayoutHeight();
619 final int maxHeight = availableHeightPx - workspacePadding.y;
Jon Miranda228877d2021-02-09 11:05:00 -0500620 float extraHeight = Math.max(0, maxHeight - usedHeight);
Jon Mirandae126d722021-02-25 10:45:20 -0500621 float scaleY = maxHeight / usedHeight;
622 boolean shouldScale = scaleY < 1f;
623
624 float scaleX = 1f;
625 if (isScalableGrid) {
626 // We scale to fit the cellWidth and cellHeight in the available space.
627 // The benefit of scalable grids is that we can get consistent aspect ratios between
628 // devices.
Thales Limad1df5fc2021-09-03 18:37:19 +0100629 int numColumns = isTwoPanels ? inv.numColumns * 2 : inv.numColumns;
630 float usedWidth = (cellWidthPx * numColumns)
Thales Lima78d00ad2021-09-30 11:29:06 +0100631 + (cellLayoutBorderSpacePx.x * (numColumns - 1))
Thales Limad90faab2021-09-21 17:18:47 +0100632 + (desiredWorkspaceHorizontalMarginPx * 2);
Jon Mirandae126d722021-02-25 10:45:20 -0500633 // We do not subtract padding here, as we also scale the workspace padding if needed.
634 scaleX = availableWidthPx / usedWidth;
635 shouldScale = true;
Winson Chungb3800242013-10-24 11:01:54 -0700636 }
Jon Mirandae126d722021-02-25 10:45:20 -0500637
638 if (shouldScale) {
639 float scale = Math.min(scaleX, scaleY);
640 updateIconSize(scale, res);
641 extraHeight = Math.max(0, maxHeight - getCellLayoutHeight());
642 }
643
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700644 updateAvailableFolderCellDimensions(res);
Jon Miranda228877d2021-02-09 11:05:00 -0500645 return Math.round(extraHeight);
Winson Chungb3800242013-10-24 11:01:54 -0700646 }
647
Jon Mirandae126d722021-02-25 10:45:20 -0500648 private int getCellLayoutHeight() {
Thales Lima78d00ad2021-09-30 11:29:06 +0100649 return (cellHeightPx * inv.numRows) + (cellLayoutBorderSpacePx.y * (inv.numRows - 1));
Jon Mirandae126d722021-02-25 10:45:20 -0500650 }
651
Jon Miranda6f7e9702019-09-16 14:44:14 -0700652 /**
653 * Updating the iconSize affects many aspects of the launcher layout, such as: iconSizePx,
654 * iconTextSizePx, iconDrawablePaddingPx, cellWidth/Height, allApps* variants,
655 * hotseat sizes, workspaceSpringLoadedShrinkFactor, folderIconSizePx, and folderIconOffsetYPx.
656 */
Tony Wickham7ba547c2021-02-02 17:12:08 -0800657 public void updateIconSize(float scale, Resources res) {
Jon Mirandaab3c6812021-06-28 15:42:28 -0700658 // Icon scale should never exceed 1, otherwise pixellation may occur.
659 iconScale = Math.min(1f, scale);
660 cellScaleToFit = scale;
661
Jon Miranda18751b62017-07-31 17:25:27 -0700662 // Workspace
Sunny Goyal07b69292018-01-08 14:19:34 -0800663 final boolean isVerticalLayout = isVerticalBarLayout();
Andras Kloczl30fe9152021-08-05 18:02:29 +0200664 float invIconSizeDp;
665 float invIconTextSizeSp;
666
667 if (isTwoPanels) {
668 if (isLandscape) {
669 invIconSizeDp = inv.twoPanelLandscapeIconSize;
670 invIconTextSizeSp = inv.twoPanelLandscapeIconTextSize;
671 } else {
672 invIconSizeDp = inv.twoPanelPortraitIconSize;
673 invIconTextSizeSp = inv.twoPanelPortraitIconTextSize;
674 }
675 } else {
676 if (isLandscape) {
677 invIconSizeDp = inv.landscapeIconSize;
678 invIconTextSizeSp = inv.landscapeIconTextSize;
679 } else {
680 invIconSizeDp = inv.iconSize;
681 invIconTextSizeSp = inv.iconTextSize;
682 }
683 }
684
Jon Mirandaab3c6812021-06-28 15:42:28 -0700685 iconSizePx = Math.max(1, pxFromDp(invIconSizeDp, mMetrics, iconScale));
Jon Mirandaab3c6812021-06-28 15:42:28 -0700686 iconTextSizePx = (int) (pxFromSp(invIconTextSizeSp, mMetrics) * iconScale);
687 iconDrawablePaddingPx = (int) (iconDrawablePaddingOriginalPx * iconScale);
Jon Mirandab28c4fc2017-06-20 10:58:36 -0700688
Thales Lima78d00ad2021-09-30 11:29:06 +0100689 cellLayoutBorderSpacePx = getCellLayoutBorderSpaceScaled(inv, scale);
Jon Mirandae126d722021-02-25 10:45:20 -0500690
691 if (isScalableGrid) {
Thales Limad1df5fc2021-09-03 18:37:19 +0100692 PointF minCellHeightAndWidth = getMinCellHeightAndWidth();
693 cellWidthPx = pxFromDp(minCellHeightAndWidth.x, mMetrics, scale);
694 cellHeightPx = pxFromDp(minCellHeightAndWidth.y, mMetrics, scale);
Jon Mirandae126d722021-02-25 10:45:20 -0500695 int cellContentHeight = iconSizePx + iconDrawablePaddingPx
696 + Utilities.calculateTextHeight(iconTextSizePx);
697 cellYPaddingPx = Math.max(0, cellHeightPx - cellContentHeight) / 2;
Thales Limad90faab2021-09-21 17:18:47 +0100698 desiredWorkspaceHorizontalMarginPx =
699 (int) (desiredWorkspaceHorizontalMarginOriginalPx * scale);
Jon Miranda228877d2021-02-09 11:05:00 -0500700 } else {
Jon Mirandae126d722021-02-25 10:45:20 -0500701 cellWidthPx = iconSizePx + iconDrawablePaddingPx;
Jon Miranda92c1b5d2021-07-20 13:57:16 -0700702 cellHeightPx = (int) Math.ceil(iconSizePx * ICON_OVERLAP_FACTOR)
703 + iconDrawablePaddingPx
Jon Miranda228877d2021-02-09 11:05:00 -0500704 + Utilities.calculateTextHeight(iconTextSizePx);
705 int cellPaddingY = (getCellSize().y - cellHeightPx) / 2;
706 if (iconDrawablePaddingPx > cellPaddingY && !isVerticalLayout
707 && !isMultiWindowMode) {
708 // Ensures that the label is closer to its corresponding icon. This is not an issue
709 // with vertical bar layout or multi-window mode since the issue is handled
710 // separately with their calls to {@link #adjustToHideWorkspaceLabels}.
711 cellHeightPx -= (iconDrawablePaddingPx - cellPaddingY);
712 iconDrawablePaddingPx = cellPaddingY;
713 }
Jon Miranda846455e2017-10-02 14:58:52 -0700714 }
Jon Miranda18751b62017-07-31 17:25:27 -0700715
Sunny Goyalae190ff2020-04-14 00:19:01 +0000716 // All apps
Sunny Goyal19ff7282021-04-22 10:12:54 -0700717 if (numShownAllAppsColumns != inv.numColumns) {
Sunny Goyal35c7b192021-04-20 16:51:10 -0700718 allAppsIconSizePx = pxFromDp(inv.allAppsIconSize, mMetrics);
Jon Mirandaaf3aed02021-05-06 18:28:45 -0700719 allAppsIconTextSizePx = pxFromSp(inv.allAppsIconTextSize, mMetrics);
Sunny Goyalae190ff2020-04-14 00:19:01 +0000720 allAppsIconDrawablePaddingPx = iconDrawablePaddingOriginalPx;
Jon Miranda941375e2021-03-31 13:10:45 -0400721 autoResizeAllAppsCells();
Sunny Goyalae190ff2020-04-14 00:19:01 +0000722 } else {
723 allAppsIconSizePx = iconSizePx;
724 allAppsIconTextSizePx = iconTextSizePx;
725 allAppsIconDrawablePaddingPx = iconDrawablePaddingPx;
726 allAppsCellHeightPx = getCellSize().y;
727 }
728 allAppsCellWidthPx = allAppsIconSizePx + allAppsIconDrawablePaddingPx;
sfufa@google.comde013292021-09-21 18:22:44 -0700729 updateAllAppsWidth();
Jon Mirandab28c4fc2017-06-20 10:58:36 -0700730
Jon Miranda941375e2021-03-31 13:10:45 -0400731 if (isVerticalLayout) {
732 hideWorkspaceLabelsIfNotEnoughSpace();
Jon Mirandab28c4fc2017-06-20 10:58:36 -0700733 }
Winson Chungb3800242013-10-24 11:01:54 -0700734
Winson Chungb3800242013-10-24 11:01:54 -0700735 // Hotseat
Jon Miranda0d284852021-06-22 14:50:55 -0700736 updateHotseatIconSize(iconSizePx);
Winson Chungb3800242013-10-24 11:01:54 -0700737
Sunny Goyal07b69292018-01-08 14:19:34 -0800738 if (!isVerticalLayout) {
Jon Miranda18751b62017-07-31 17:25:27 -0700739 int expectedWorkspaceHeight = availableHeightPx - hotseatBarSizePx
Tony Wickham5edf9e22020-03-27 20:06:52 -0700740 - workspacePageIndicatorHeight - edgeMarginPx;
Sunny Goyal47328fd2016-05-25 18:56:41 -0700741 float minRequiredHeight = dropTargetBarSizePx + workspaceSpringLoadedBottomSpace;
742 workspaceSpringLoadShrinkFactor = Math.min(
743 res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f,
744 1 - (minRequiredHeight / expectedWorkspaceHeight));
745 } else {
746 workspaceSpringLoadShrinkFactor =
747 res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f;
748 }
749
Sunny Goyalbaec6ff2016-09-14 11:26:21 -0700750 // Folder icon
Jon Miranda591e3602018-03-28 11:37:00 -0700751 folderIconSizePx = IconNormalizer.getNormalizedCircleSize(iconSizePx);
752 folderIconOffsetYPx = (iconSizePx - folderIconSizePx) / 2;
Winson Chung0f785722015-04-08 10:27:49 -0700753 }
754
Thales Limad1df5fc2021-09-03 18:37:19 +0100755 /**
756 * Returns the minimum cell height and width as a pair.
757 */
758 private PointF getMinCellHeightAndWidth() {
759 PointF result = new PointF();
760
761 if (isTwoPanels) {
762 if (isLandscape) {
763 result.x = inv.twoPanelLandscapeMinCellWidthDps;
764 result.y = inv.twoPanelLandscapeMinCellHeightDps;
765 } else {
766 result.x = inv.twoPanelPortraitMinCellWidthDps;
767 result.y = inv.twoPanelPortraitMinCellHeightDps;
768 }
769 } else {
770 result.x = inv.minCellWidth;
771 result.y = inv.minCellHeight;
772 }
773
774 return result;
775 }
776
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700777 private void updateAvailableFolderCellDimensions(Resources res) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700778 updateFolderCellSize(1f, res);
Jon Mirandabf7d8122016-11-03 15:29:29 -0700779
Jon Mirandae126d722021-02-25 10:45:20 -0500780 final int folderBottomPanelSize = res.getDimensionPixelSize(R.dimen.folder_label_height);
781
Jon Mirandac1b23992016-12-13 08:57:36 -0800782 // Don't let the folder get too close to the edges of the screen.
Jon Miranda1786df32018-09-25 13:05:23 -0700783 int folderMargin = edgeMarginPx * 2;
Sunny Goyal07b69292018-01-08 14:19:34 -0800784 Point totalWorkspacePadding = getTotalWorkspacePadding();
Jon Mirandac1b23992016-12-13 08:57:36 -0800785
786 // Check if the icons fit within the available height.
Jon Miranda228877d2021-02-09 11:05:00 -0500787 float contentUsedHeight = folderCellHeightPx * inv.numFolderRows
Thales Lima78d00ad2021-09-30 11:29:06 +0100788 + ((inv.numFolderRows - 1) * folderCellLayoutBorderSpacePx.y);
Samuel Fufa1c8d90a2019-11-12 17:54:58 -0800789 int contentMaxHeight = availableHeightPx - totalWorkspacePadding.y - folderBottomPanelSize
Jon Mirandae126d722021-02-25 10:45:20 -0500790 - folderMargin - folderContentPaddingTop;
Samuel Fufa1c8d90a2019-11-12 17:54:58 -0800791 float scaleY = contentMaxHeight / contentUsedHeight;
Jon Mirandac1b23992016-12-13 08:57:36 -0800792
793 // Check if the icons fit within the available width.
Jon Miranda228877d2021-02-09 11:05:00 -0500794 float contentUsedWidth = folderCellWidthPx * inv.numFolderColumns
Thales Lima78d00ad2021-09-30 11:29:06 +0100795 + ((inv.numFolderColumns - 1) * folderCellLayoutBorderSpacePx.x);
Jon Mirandae126d722021-02-25 10:45:20 -0500796 int contentMaxWidth = availableWidthPx - totalWorkspacePadding.x - folderMargin
797 - folderContentPaddingLeftRight * 2;
Samuel Fufa1c8d90a2019-11-12 17:54:58 -0800798 float scaleX = contentMaxWidth / contentUsedWidth;
Jon Mirandac1b23992016-12-13 08:57:36 -0800799
800 float scale = Math.min(scaleX, scaleY);
801 if (scale < 1f) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700802 updateFolderCellSize(scale, res);
Jon Mirandabf7d8122016-11-03 15:29:29 -0700803 }
804 }
805
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700806 private void updateFolderCellSize(float scale, Resources res) {
Jon Mirandae126d722021-02-25 10:45:20 -0500807 float invIconSizeDp = isVerticalBarLayout() ? inv.landscapeIconSize : inv.iconSize;
Sunny Goyal35c7b192021-04-20 16:51:10 -0700808 folderChildIconSizePx = Math.max(1, pxFromDp(invIconSizeDp, mMetrics, scale));
Jon Mirandaaf3aed02021-05-06 18:28:45 -0700809 folderChildTextSizePx = pxFromSp(inv.iconTextSize, mMetrics, scale);
Jon Mirandae126d722021-02-25 10:45:20 -0500810 folderLabelTextSizePx = (int) (folderChildTextSizePx * folderLabelTextScale);
Jon Mirandabf7d8122016-11-03 15:29:29 -0700811
812 int textHeight = Utilities.calculateTextHeight(folderChildTextSizePx);
Jon Mirandabf7d8122016-11-03 15:29:29 -0700813
Jon Miranda823da222021-03-23 08:08:45 -0400814 if (isScalableGrid) {
Jon Mirandaf33f5b32021-07-22 17:15:31 -0700815 int minWidth = folderChildIconSizePx + iconDrawablePaddingPx * 2;
816 int minHeight = folderChildIconSizePx + iconDrawablePaddingPx * 2 + textHeight;
817
818 folderCellWidthPx = (int) Math.max(minWidth, cellWidthPx * scale);
819 folderCellHeightPx = (int) Math.max(minHeight, cellHeightPx * scale);
Jon Miranda823da222021-03-23 08:08:45 -0400820
Thales Lima78d00ad2021-09-30 11:29:06 +0100821 int scaledSpace = (int) (folderCellLayoutBorderSpaceOriginalPx * scale);
822 folderCellLayoutBorderSpacePx = new Point(scaledSpace, scaledSpace);
823 folderContentPaddingLeftRight = scaledSpace;
824 folderContentPaddingTop = scaledSpace;
Jon Miranda823da222021-03-23 08:08:45 -0400825 } else {
826 int cellPaddingX = (int) (res.getDimensionPixelSize(R.dimen.folder_cell_x_padding)
827 * scale);
828 int cellPaddingY = (int) (res.getDimensionPixelSize(R.dimen.folder_cell_y_padding)
829 * scale);
830
831 folderCellWidthPx = folderChildIconSizePx + 2 * cellPaddingX;
832 folderCellHeightPx = folderChildIconSizePx + 2 * cellPaddingY + textHeight;
833 }
834
Jonathan Miranda9ad87462017-07-26 17:41:02 +0000835 folderChildDrawablePaddingPx = Math.max(0,
836 (folderCellHeightPx - folderChildIconSizePx - textHeight) / 3);
Jon Mirandabf7d8122016-11-03 15:29:29 -0700837 }
838
Winson1f064272016-07-18 17:18:02 -0700839 public void updateInsets(Rect insets) {
840 mInsets.set(insets);
Sunny Goyal07b69292018-01-08 14:19:34 -0800841 updateWorkspacePadding();
Winson1f064272016-07-18 17:18:02 -0700842 }
843
Sunny Goyalae6e3182019-04-30 12:04:37 -0700844 /**
845 * The current device insets. This is generally same as the insets being dispatched to
846 * {@link Insettable} elements, but can differ if the element is using a different profile.
847 */
Sunny Goyal1a52ef52018-01-11 10:15:03 -0800848 public Rect getInsets() {
849 return mInsets;
850 }
851
Sunny Goyal756cd262015-08-20 12:33:21 -0700852 public Point getCellSize() {
Sunny Goyal19ff7282021-04-22 10:12:54 -0700853 return getCellSize(null);
Jon Miranda6f7e9702019-09-16 14:44:14 -0700854 }
855
Sunny Goyal19ff7282021-04-22 10:12:54 -0700856 public Point getCellSize(Point result) {
857 if (result == null) {
858 result = new Point();
859 }
Thales Limad1df5fc2021-09-03 18:37:19 +0100860
Sunny Goyal756cd262015-08-20 12:33:21 -0700861 // Since we are only concerned with the overall padding, layout direction does
862 // not matter.
Sunny Goyal6c2975e2016-07-06 09:47:56 -0700863 Point padding = getTotalWorkspacePadding();
Thales Limad1df5fc2021-09-03 18:37:19 +0100864
865 int numColumns = isTwoPanels ? inv.numColumns * 2 : inv.numColumns;
Thales Lima7a6752d2021-09-23 14:31:00 +0100866 int cellLayoutTotalPadding =
867 isTwoPanels ? 4 * cellLayoutPaddingLeftRightPx : 2 * cellLayoutPaddingLeftRightPx;
868 int screenWidthPx = availableWidthPx - padding.x - cellLayoutTotalPadding;
Thales Lima78d00ad2021-09-30 11:29:06 +0100869 result.x = calculateCellWidth(screenWidthPx, cellLayoutBorderSpacePx.x, numColumns);
Jon Miranda18751b62017-07-31 17:25:27 -0700870 result.y = calculateCellHeight(availableHeightPx - padding.y
Thales Lima78d00ad2021-09-30 11:29:06 +0100871 - cellLayoutBottomPaddingPx, cellLayoutBorderSpacePx.y, inv.numRows);
Sunny Goyal756cd262015-08-20 12:33:21 -0700872 return result;
873 }
874
Sunny Goyal6c2975e2016-07-06 09:47:56 -0700875 public Point getTotalWorkspacePadding() {
Sunny Goyal07b69292018-01-08 14:19:34 -0800876 updateWorkspacePadding();
877 return new Point(workspacePadding.left + workspacePadding.right,
878 workspacePadding.top + workspacePadding.bottom);
Sunny Goyal6c2975e2016-07-06 09:47:56 -0700879 }
880
881 /**
Sunny Goyal07b69292018-01-08 14:19:34 -0800882 * Updates {@link #workspacePadding} as a result of any internal value change to reflect the
883 * new workspace padding
Sunny Goyal6c2975e2016-07-06 09:47:56 -0700884 */
Sunny Goyal07b69292018-01-08 14:19:34 -0800885 private void updateWorkspacePadding() {
886 Rect padding = workspacePadding;
Tony Wickham3a3517f2015-10-06 11:27:04 -0700887 if (isVerticalBarLayout()) {
Sunny Goyal228153d2018-01-04 15:35:22 -0800888 padding.top = 0;
889 padding.bottom = edgeMarginPx;
Sunny Goyal7e2e67f2018-01-26 13:40:08 -0800890 if (isSeascape()) {
Tony Wickham1eeffbe2018-06-12 15:01:15 -0700891 padding.left = hotseatBarSizePx;
Tony Wickham5edf9e22020-03-27 20:06:52 -0700892 padding.right = hotseatBarSidePaddingStartPx;
Winson1f064272016-07-18 17:18:02 -0700893 } else {
Tony Wickham5edf9e22020-03-27 20:06:52 -0700894 padding.left = hotseatBarSidePaddingStartPx;
Tony Wickham1eeffbe2018-06-12 15:01:15 -0700895 padding.right = hotseatBarSizePx;
Winson1f064272016-07-18 17:18:02 -0700896 }
Winson Chungb3800242013-10-24 11:01:54 -0700897 } else {
Thales Lima7a6752d2021-09-23 14:31:00 +0100898 // Pad the bottom of the workspace with search/hotseat bar sizes
Tony Wickham21970cc2021-09-15 15:44:05 -0700899 int hotseatTop = hotseatBarSizePx;
Tony Wickhama29a0462021-03-02 12:28:25 -0800900 int paddingBottom = hotseatTop + workspacePageIndicatorHeight
Jon Miranda228877d2021-02-09 11:05:00 -0500901 + workspaceBottomPadding - mWorkspacePageIndicatorOverlapWorkspace;
Andras Kloczl8e57cce2021-02-11 23:51:19 +0100902
Thales Limad90faab2021-09-21 17:18:47 +0100903 padding.set(desiredWorkspaceHorizontalMarginPx,
Thales Lima7a6752d2021-09-23 14:31:00 +0100904 (isScalableGrid ? workspaceTopPadding : edgeMarginPx),
Thales Limad90faab2021-09-21 17:18:47 +0100905 desiredWorkspaceHorizontalMarginPx,
Thales Lima7a6752d2021-09-23 14:31:00 +0100906 paddingBottom);
Winson Chungb3800242013-10-24 11:01:54 -0700907 }
Winson Chungb3800242013-10-24 11:01:54 -0700908 }
909
Sunny Goyal57b22792021-05-25 14:35:01 -0700910 /**
911 * Returns the padding for hotseat view
912 */
913 public Rect getHotseatLayoutPadding(Context context) {
Sunny Goyal81b4c7b2018-03-26 12:10:31 -0700914 if (isVerticalBarLayout()) {
915 if (isSeascape()) {
Tony Wickham1eeffbe2018-06-12 15:01:15 -0700916 mHotseatPadding.set(mInsets.left + hotseatBarSidePaddingStartPx,
917 mInsets.top, hotseatBarSidePaddingEndPx, mInsets.bottom);
Sunny Goyal81b4c7b2018-03-26 12:10:31 -0700918 } else {
Tony Wickham1eeffbe2018-06-12 15:01:15 -0700919 mHotseatPadding.set(hotseatBarSidePaddingEndPx, mInsets.top,
920 mInsets.right + hotseatBarSidePaddingStartPx, mInsets.bottom);
Sunny Goyal81b4c7b2018-03-26 12:10:31 -0700921 }
Sunny Goyal57b22792021-05-25 14:35:01 -0700922 } else if (isTaskbarPresent) {
Tony Wickham21970cc2021-09-15 15:44:05 -0700923 int hotseatHeight = workspacePadding.bottom;
Sunny Goyal57b22792021-05-25 14:35:01 -0700924 int taskbarOffset = getTaskbarOffsetY();
Tony Wickham21970cc2021-09-15 15:44:05 -0700925 int hotseatTopDiff = hotseatHeight - taskbarOffset;
Sunny Goyal57b22792021-05-25 14:35:01 -0700926
Vinit Nayak8dcbde82021-07-19 12:53:28 -0700927 int endOffset = ApiWrapper.getHotseatEndOffset(context);
Sunny Goyal57b22792021-05-25 14:35:01 -0700928 int requiredWidth = iconSizePx * numShownHotseatIcons;
929
930 Resources res = context.getResources();
931 float taskbarIconSize = res.getDimension(R.dimen.taskbar_icon_size);
932 float taskbarIconSpacing = 2 * res.getDimension(R.dimen.taskbar_icon_spacing);
933 int maxSize = (int) (requiredWidth
934 * (taskbarIconSize + taskbarIconSpacing) / taskbarIconSize);
Vinit Nayak8dcbde82021-07-19 12:53:28 -0700935 int hotseatSize = Math.min(maxSize, availableWidthPx - endOffset);
Sunny Goyal57b22792021-05-25 14:35:01 -0700936 int sideSpacing = (availableWidthPx - hotseatSize) / 2;
937 mHotseatPadding.set(sideSpacing, hotseatTopDiff, sideSpacing, taskbarOffset);
938
Vinit Nayak8dcbde82021-07-19 12:53:28 -0700939 if (endOffset > sideSpacing) {
Sunny Goyal57b22792021-05-25 14:35:01 -0700940 int diff = Utilities.isRtl(context.getResources())
Vinit Nayak8dcbde82021-07-19 12:53:28 -0700941 ? sideSpacing - endOffset
942 : endOffset - sideSpacing;
943 mHotseatPadding.left -= diff;
944 mHotseatPadding.right += diff;
Sunny Goyal57b22792021-05-25 14:35:01 -0700945 }
Sunny Goyal81b4c7b2018-03-26 12:10:31 -0700946 } else {
Sunny Goyal81b4c7b2018-03-26 12:10:31 -0700947 // We want the edges of the hotseat to line up with the edges of the workspace, but the
948 // icons in the hotseat are a different size, and so don't line up perfectly. To account
949 // for this, we pad the left and right of the hotseat with half of the difference of a
950 // workspace cell vs a hotseat cell.
951 float workspaceCellWidth = (float) widthPx / inv.numColumns;
Sunny Goyal19ff7282021-04-22 10:12:54 -0700952 float hotseatCellWidth = (float) widthPx / numShownHotseatIcons;
Sunny Goyal81b4c7b2018-03-26 12:10:31 -0700953 int hotseatAdjustment = Math.round((workspaceCellWidth - hotseatCellWidth) / 2);
954 mHotseatPadding.set(
Sunny Goyal786940a2020-06-02 02:31:31 -0700955 hotseatAdjustment + workspacePadding.left + cellLayoutPaddingLeftRightPx
956 + mInsets.left,
Sunny Goyal81b4c7b2018-03-26 12:10:31 -0700957 hotseatBarTopPaddingPx,
Sunny Goyal786940a2020-06-02 02:31:31 -0700958 hotseatAdjustment + workspacePadding.right + cellLayoutPaddingLeftRightPx
959 + mInsets.right,
Jon Miranda0d284852021-06-22 14:50:55 -0700960 hotseatBarSizePx - hotseatCellHeightPx - hotseatBarTopPaddingPx
961 + cellLayoutBottomPaddingPx + mInsets.bottom);
Sunny Goyal81b4c7b2018-03-26 12:10:31 -0700962 }
963 return mHotseatPadding;
964 }
965
Winsonfadbe8f2016-07-22 16:35:37 -0700966 /**
Sunny Goyal57b22792021-05-25 14:35:01 -0700967 * Returns the number of pixels the QSB is translated from the bottom of the screen.
968 */
969 public int getQsbOffsetY() {
970 int freeSpace = isTaskbarPresent
971 ? workspacePadding.bottom
972 : hotseatBarSizePx - hotseatCellHeightPx - hotseatQsbHeight;
Jonathan Miranda7a273e22021-06-24 21:29:10 +0000973
Jonathan Miranda8f16a772021-07-23 23:10:37 +0000974 if (isScalableGrid && qsbBottomMarginPx > mInsets.bottom) {
Tony Wickham21970cc2021-09-15 15:44:05 -0700975 // Note that taskbarSize = 0 unless isTaskbarPresent.
976 return Math.min(qsbBottomMarginPx + taskbarSize, freeSpace);
Jonathan Miranda8f16a772021-07-23 23:10:37 +0000977 } else {
Jonathan Miranda7a273e22021-06-24 21:29:10 +0000978 return (int) (freeSpace * QSB_CENTER_FACTOR)
Pierre Barbier de Reuille578deba2021-09-24 13:47:44 +0100979 + (isTaskbarPresent ? taskbarSize : mInsets.bottom);
Jonathan Miranda7a273e22021-06-24 21:29:10 +0000980 }
Sunny Goyal57b22792021-05-25 14:35:01 -0700981 }
982
983 /**
984 * Returns the number of pixels the taskbar is translated from the bottom of the screen.
985 */
986 public int getTaskbarOffsetY() {
987 return (getQsbOffsetY() - taskbarSize) / 2;
988 }
989
990 /**
Winsonfadbe8f2016-07-22 16:35:37 -0700991 * @return the bounds for which the open folders should be contained within
992 */
993 public Rect getAbsoluteOpenFolderBounds() {
994 if (isVerticalBarLayout()) {
995 // Folders should only appear right of the drop target bar and left of the hotseat
996 return new Rect(mInsets.left + dropTargetBarSizePx + edgeMarginPx,
997 mInsets.top,
Jon Miranda18751b62017-07-31 17:25:27 -0700998 mInsets.left + availableWidthPx - hotseatBarSizePx - edgeMarginPx,
Winsonfadbe8f2016-07-22 16:35:37 -0700999 mInsets.top + availableHeightPx);
1000 } else {
1001 // Folders should only appear below the drop target bar and above the hotseat
Tony Wickhamae72b462021-03-10 16:18:40 -08001002 int hotseatTop = isTaskbarPresent ? taskbarSize : hotseatBarSizePx;
Tony Wickhamb4b7e202018-01-12 17:39:24 -08001003 return new Rect(mInsets.left + edgeMarginPx,
Winsonfadbe8f2016-07-22 16:35:37 -07001004 mInsets.top + dropTargetBarSizePx + edgeMarginPx,
Tony Wickhamb4b7e202018-01-12 17:39:24 -08001005 mInsets.left + availableWidthPx - edgeMarginPx,
Tony Wickhamae72b462021-03-10 16:18:40 -08001006 mInsets.top + availableHeightPx - hotseatTop
Tony Wickham5edf9e22020-03-27 20:06:52 -07001007 - workspacePageIndicatorHeight - edgeMarginPx);
Winsonfadbe8f2016-07-22 16:35:37 -07001008 }
1009 }
1010
Jon Miranda228877d2021-02-09 11:05:00 -05001011 public static int calculateCellWidth(int width, int borderSpacing, int countX) {
1012 return (width - ((countX - 1) * borderSpacing)) / countX;
Winson Chungb3800242013-10-24 11:01:54 -07001013 }
Pierre Barbier de Reuille578deba2021-09-24 13:47:44 +01001014
Jon Miranda228877d2021-02-09 11:05:00 -05001015 public static int calculateCellHeight(int height, int borderSpacing, int countY) {
1016 return (height - ((countY - 1) * borderSpacing)) / countY;
Winson Chungb3800242013-10-24 11:01:54 -07001017 }
1018
Hyunyoung Song18bfaaf2015-03-17 11:32:21 -07001019 /**
Tony Wickham55616cd2015-09-23 14:55:17 -07001020 * When {@code true}, the device is in landscape mode and the hotseat is on the right column.
1021 * When {@code false}, either device is in portrait mode or the device is in landscape mode and
1022 * the hotseat is on the bottom row.
Hyunyoung Song18bfaaf2015-03-17 11:32:21 -07001023 */
Tony Wickhamab946a12015-09-16 15:38:16 -07001024 public boolean isVerticalBarLayout() {
Winson Chungb3800242013-10-24 11:01:54 -07001025 return isLandscape && transposeLayoutWithOrientation;
1026 }
1027
Sunny Goyal59d086c2018-05-07 17:31:40 -07001028 /**
1029 * Updates orientation information and returns true if it has changed from the previous value.
1030 */
Winson Chung13c1c2c2019-09-06 11:46:19 -07001031 public boolean updateIsSeascape(Context context) {
Sunny Goyal59d086c2018-05-07 17:31:40 -07001032 if (isVerticalBarLayout()) {
Sunny Goyal35c7b192021-04-20 16:51:10 -07001033 boolean isSeascape = DisplayController.INSTANCE.get(context)
1034 .getInfo().rotation == Surface.ROTATION_270;
Sunny Goyal59d086c2018-05-07 17:31:40 -07001035 if (mIsSeascape != isSeascape) {
1036 mIsSeascape = isSeascape;
1037 return true;
1038 }
1039 }
1040 return false;
1041 }
1042
Sunny Goyal7e2e67f2018-01-26 13:40:08 -08001043 public boolean isSeascape() {
Sunny Goyal59d086c2018-05-07 17:31:40 -07001044 return isVerticalBarLayout() && mIsSeascape;
Sunny Goyal7e2e67f2018-01-26 13:40:08 -08001045 }
1046
Sunny Goyal07b69292018-01-08 14:19:34 -08001047 public boolean shouldFadeAdjacentWorkspaceScreens() {
Sunny Goyal19ff7282021-04-22 10:12:54 -07001048 return isVerticalBarLayout();
Winson Chungb3800242013-10-24 11:01:54 -07001049 }
1050
Jon Miranda92c1b5d2021-07-20 13:57:16 -07001051 public int getCellContentHeight(@ContainerType int containerType) {
Sunny Goyalc13403c2016-11-18 23:44:48 -08001052 switch (containerType) {
1053 case CellLayout.WORKSPACE:
1054 return cellHeightPx;
1055 case CellLayout.FOLDER:
1056 return folderCellHeightPx;
1057 case CellLayout.HOTSEAT:
Jon Miranda92c1b5d2021-07-20 13:57:16 -07001058 // The hotseat is the only container where the cell height is going to be
1059 // different from the content within that cell.
1060 return iconSizePx;
Sunny Goyalc13403c2016-11-18 23:44:48 -08001061 default:
1062 // ??
1063 return 0;
1064 }
1065 }
Sunny Goyal13178ac2016-04-04 16:35:22 -07001066
Jon Miranda58561d42021-03-17 10:51:54 -04001067 private String pxToDpStr(String name, float value) {
Sunny Goyal35c7b192021-04-20 16:51:10 -07001068 return "\t" + name + ": " + value + "px (" + dpiFromPx(value, mMetrics.densityDpi) + "dp)";
Jon Miranda58561d42021-03-17 10:51:54 -04001069 }
1070
1071 public void dump(String prefix, PrintWriter writer) {
1072 writer.println(prefix + "DeviceProfile:");
Sunny Goyal35c7b192021-04-20 16:51:10 -07001073 writer.println(prefix + "\t1 dp = " + mMetrics.density + " px");
Jon Miranda58561d42021-03-17 10:51:54 -04001074
Alex Chaua02eddc2021-04-29 00:36:06 +01001075 writer.println(prefix + "\tallowRotation:" + allowRotation);
Jon Miranda58561d42021-03-17 10:51:54 -04001076 writer.println(prefix + "\tisTablet:" + isTablet);
Jon Miranda58561d42021-03-17 10:51:54 -04001077 writer.println(prefix + "\tisPhone:" + isPhone);
1078 writer.println(prefix + "\ttransposeLayoutWithOrientation:"
1079 + transposeLayoutWithOrientation);
1080
1081 writer.println(prefix + "\tisLandscape:" + isLandscape);
1082 writer.println(prefix + "\tisMultiWindowMode:" + isMultiWindowMode);
Sunny Goyal19ff7282021-04-22 10:12:54 -07001083 writer.println(prefix + "\tisTwoPanels:" + isTwoPanels);
Jon Miranda58561d42021-03-17 10:51:54 -04001084
1085 writer.println(prefix + pxToDpStr("windowX", windowX));
1086 writer.println(prefix + pxToDpStr("windowY", windowY));
1087 writer.println(prefix + pxToDpStr("widthPx", widthPx));
1088 writer.println(prefix + pxToDpStr("heightPx", heightPx));
1089
1090 writer.println(prefix + pxToDpStr("availableWidthPx", availableWidthPx));
1091 writer.println(prefix + pxToDpStr("availableHeightPx", availableHeightPx));
1092
1093 writer.println(prefix + "\taspectRatio:" + aspectRatio);
1094
1095 writer.println(prefix + "\tisScalableGrid:" + isScalableGrid);
1096
1097 writer.println(prefix + "\tinv.minCellWidth:" + inv.minCellWidth + "dp");
1098 writer.println(prefix + "\tinv.minCellHeight:" + inv.minCellHeight + "dp");
Thales Limad1df5fc2021-09-03 18:37:19 +01001099 writer.println(prefix + "\tinv.twoPanelPortraitMinCellHeightDps:"
1100 + inv.twoPanelPortraitMinCellHeightDps + "dp");
1101 writer.println(prefix + "\tinv.twoPanelPortraitMinCellWidthDps:"
1102 + inv.twoPanelPortraitMinCellWidthDps + "dp");
1103 writer.println(prefix + "\tinv.twoPanelLandscapeMinCellHeightDps:"
1104 + inv.twoPanelLandscapeMinCellHeightDps + "dp");
1105 writer.println(prefix + "\tinv.twoPanelLandscapeMinCellWidthDps:"
1106 + inv.twoPanelLandscapeMinCellWidthDps + "dp");
Jon Miranda58561d42021-03-17 10:51:54 -04001107
Jon Mirandaab3c6812021-06-28 15:42:28 -07001108 writer.println(prefix + "\tinv.numColumns:" + inv.numColumns);
1109 writer.println(prefix + "\tinv.numRows:" + inv.numRows);
1110
Jon Miranda58561d42021-03-17 10:51:54 -04001111 writer.println(prefix + pxToDpStr("cellWidthPx", cellWidthPx));
1112 writer.println(prefix + pxToDpStr("cellHeightPx", cellHeightPx));
1113
1114 writer.println(prefix + pxToDpStr("getCellSize().x", getCellSize().x));
1115 writer.println(prefix + pxToDpStr("getCellSize().y", getCellSize().y));
1116
1117 writer.println(prefix + "\tinv.iconSize:" + inv.iconSize + "dp");
1118 writer.println(prefix + pxToDpStr("iconSizePx", iconSizePx));
1119 writer.println(prefix + pxToDpStr("iconTextSizePx", iconTextSizePx));
1120 writer.println(prefix + pxToDpStr("iconDrawablePaddingPx", iconDrawablePaddingPx));
1121
1122 writer.println(prefix + pxToDpStr("folderCellWidthPx", folderCellWidthPx));
1123 writer.println(prefix + pxToDpStr("folderCellHeightPx", folderCellHeightPx));
1124 writer.println(prefix + pxToDpStr("folderChildIconSizePx", folderChildIconSizePx));
1125 writer.println(prefix + pxToDpStr("folderChildTextSizePx", folderChildTextSizePx));
1126 writer.println(prefix + pxToDpStr("folderChildDrawablePaddingPx",
1127 folderChildDrawablePaddingPx));
Thales Lima78d00ad2021-09-30 11:29:06 +01001128 writer.println(prefix + pxToDpStr("folderCellLayoutBorderSpaceOriginalPx",
1129 folderCellLayoutBorderSpaceOriginalPx));
1130 writer.println(prefix + pxToDpStr("folderCellLayoutBorderSpacePx Horizontal",
1131 folderCellLayoutBorderSpacePx.x));
1132 writer.println(prefix + pxToDpStr("folderCellLayoutBorderSpacePx Vertical",
1133 folderCellLayoutBorderSpacePx.y));
Jon Miranda58561d42021-03-17 10:51:54 -04001134
Thales Lima78d00ad2021-09-30 11:29:06 +01001135 writer.println(prefix + pxToDpStr("cellLayoutBorderSpacePx Horizontal",
1136 cellLayoutBorderSpacePx.x));
1137 writer.println(prefix + pxToDpStr("cellLayoutBorderSpacePx Vertical",
1138 cellLayoutBorderSpacePx.y));
1139
Thales Limad90faab2021-09-21 17:18:47 +01001140 writer.println(prefix + pxToDpStr("desiredWorkspaceHorizontalMarginPx",
1141 desiredWorkspaceHorizontalMarginPx));
Jon Miranda58561d42021-03-17 10:51:54 -04001142
1143 writer.println(prefix + pxToDpStr("allAppsIconSizePx", allAppsIconSizePx));
1144 writer.println(prefix + pxToDpStr("allAppsIconTextSizePx", allAppsIconTextSizePx));
1145 writer.println(prefix + pxToDpStr("allAppsIconDrawablePaddingPx",
1146 allAppsIconDrawablePaddingPx));
1147 writer.println(prefix + pxToDpStr("allAppsCellHeightPx", allAppsCellHeightPx));
Sunny Goyal19ff7282021-04-22 10:12:54 -07001148 writer.println(prefix + "\tnumShownAllAppsColumns: " + numShownAllAppsColumns);
Jon Miranda58561d42021-03-17 10:51:54 -04001149
1150 writer.println(prefix + pxToDpStr("hotseatBarSizePx", hotseatBarSizePx));
1151 writer.println(prefix + pxToDpStr("hotseatCellHeightPx", hotseatCellHeightPx));
1152 writer.println(prefix + pxToDpStr("hotseatBarTopPaddingPx", hotseatBarTopPaddingPx));
1153 writer.println(prefix + pxToDpStr("hotseatBarBottomPaddingPx", hotseatBarBottomPaddingPx));
1154 writer.println(prefix + pxToDpStr("hotseatBarSidePaddingStartPx",
1155 hotseatBarSidePaddingStartPx));
1156 writer.println(prefix + pxToDpStr("hotseatBarSidePaddingEndPx",
1157 hotseatBarSidePaddingEndPx));
Sunny Goyal19ff7282021-04-22 10:12:54 -07001158 writer.println(prefix + "\tnumShownHotseatIcons: " + numShownHotseatIcons);
Jon Miranda58561d42021-03-17 10:51:54 -04001159
1160 writer.println(prefix + "\tisTaskbarPresent:" + isTaskbarPresent);
Tony Wickham635e1802021-07-22 14:28:04 -10001161 writer.println(prefix + "\tisTaskbarPresentInApps:" + isTaskbarPresentInApps);
Jon Miranda58561d42021-03-17 10:51:54 -04001162 writer.println(prefix + pxToDpStr("taskbarSize", taskbarSize));
Jon Miranda58561d42021-03-17 10:51:54 -04001163
1164 writer.println(prefix + pxToDpStr("workspacePadding.left", workspacePadding.left));
1165 writer.println(prefix + pxToDpStr("workspacePadding.top", workspacePadding.top));
1166 writer.println(prefix + pxToDpStr("workspacePadding.right", workspacePadding.right));
1167 writer.println(prefix + pxToDpStr("workspacePadding.bottom", workspacePadding.bottom));
1168
Jon Mirandaab3c6812021-06-28 15:42:28 -07001169 writer.println(prefix + pxToDpStr("iconScale", iconScale));
1170 writer.println(prefix + pxToDpStr("cellScaleToFit ", cellScaleToFit));
Jon Miranda58561d42021-03-17 10:51:54 -04001171 writer.println(prefix + pxToDpStr("extraSpace", extraSpace));
Thales Lima7a6752d2021-09-23 14:31:00 +01001172 writer.println(prefix + pxToDpStr("unscaled extraSpace", extraSpace / iconScale));
Jon Mirandac9e69fa2021-03-22 17:13:34 -04001173
1174 if (inv.devicePaddings != null) {
1175 int unscaledExtraSpace = (int) (extraSpace / iconScale);
1176 writer.println(prefix + pxToDpStr("maxEmptySpace",
1177 inv.devicePaddings.getDevicePadding(unscaledExtraSpace).getMaxEmptySpacePx()));
1178 }
Jon Miranda58561d42021-03-17 10:51:54 -04001179 writer.println(prefix + pxToDpStr("workspaceTopPadding", workspaceTopPadding));
1180 writer.println(prefix + pxToDpStr("workspaceBottomPadding", workspaceBottomPadding));
1181 writer.println(prefix + pxToDpStr("extraHotseatBottomPadding", extraHotseatBottomPadding));
1182 }
1183
Sunny Goyalfd58da62020-08-11 12:06:49 -07001184 private static Context getContext(Context c, Info info, int orientation) {
Sunny Goyal1890f672020-04-30 12:28:00 -07001185 Configuration config = new Configuration(c.getResources().getConfiguration());
1186 config.orientation = orientation;
Sunny Goyal35c7b192021-04-20 16:51:10 -07001187 config.densityDpi = info.densityDpi;
Sunny Goyal1890f672020-04-30 12:28:00 -07001188 return c.createConfigurationContext(config);
Jon Mirandab28c4fc2017-06-20 10:58:36 -07001189 }
Sunny Goyalfde55052018-02-01 14:46:13 -08001190
1191 /**
1192 * Callback when a component changes the DeviceProfile associated with it, as a result of
1193 * configuration change
1194 */
1195 public interface OnDeviceProfileChangeListener {
1196
1197 /**
1198 * Called when the device profile is reassigned. Note that for layout and measurements, it
1199 * is sufficient to listen for inset changes. Use this callback when you need to perform
1200 * a one time operation.
1201 */
1202 void onDeviceProfileChanged(DeviceProfile dp);
1203 }
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001204
1205 public static class Builder {
1206 private Context mContext;
1207 private InvariantDeviceProfile mInv;
Sunny Goyalfd58da62020-08-11 12:06:49 -07001208 private Info mInfo;
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001209
Sunny Goyal19ff7282021-04-22 10:12:54 -07001210 private WindowBounds mWindowBounds;
1211 private boolean mUseTwoPanels;
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001212
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001213 private boolean mIsMultiWindowMode = false;
Sunny Goyal19ff7282021-04-22 10:12:54 -07001214 private Boolean mTransposeLayoutWithOrientation;
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001215
Sunny Goyalfd58da62020-08-11 12:06:49 -07001216 public Builder(Context context, InvariantDeviceProfile inv, Info info) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001217 mContext = context;
1218 mInv = inv;
1219 mInfo = info;
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001220 }
1221
1222 public Builder setMultiWindowMode(boolean isMultiWindowMode) {
1223 mIsMultiWindowMode = isMultiWindowMode;
1224 return this;
1225 }
1226
Sunny Goyal19ff7282021-04-22 10:12:54 -07001227 public Builder setUseTwoPanels(boolean useTwoPanels) {
1228 mUseTwoPanels = useTwoPanels;
1229 return this;
1230 }
1231
1232
1233 public Builder setWindowBounds(WindowBounds bounds) {
1234 mWindowBounds = bounds;
Sunny Goyal0addbf02020-04-28 14:17:35 -07001235 return this;
1236 }
1237
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001238 public Builder setTransposeLayoutWithOrientation(boolean transposeLayoutWithOrientation) {
1239 mTransposeLayoutWithOrientation = transposeLayoutWithOrientation;
1240 return this;
1241 }
1242
1243 public DeviceProfile build() {
Sunny Goyal19ff7282021-04-22 10:12:54 -07001244 if (mWindowBounds == null) {
1245 throw new IllegalArgumentException("Window bounds not set");
1246 }
1247 if (mTransposeLayoutWithOrientation == null) {
1248 mTransposeLayoutWithOrientation = !mInfo.isTablet(mWindowBounds);
1249 }
1250 return new DeviceProfile(mContext, mInv, mInfo, mWindowBounds,
1251 mIsMultiWindowMode, mTransposeLayoutWithOrientation, mUseTwoPanels);
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001252 }
1253 }
1254
Winson Chungb3800242013-10-24 11:01:54 -07001255}