blob: 2c34b3f8226be41997b167388588f5c5174d5c36 [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
Thales Lima12d0eff2022-03-25 17:06:11 +000019import static com.android.launcher3.InvariantDeviceProfile.INDEX_DEFAULT;
20import static com.android.launcher3.InvariantDeviceProfile.INDEX_LANDSCAPE;
21import static com.android.launcher3.InvariantDeviceProfile.INDEX_TWO_PANEL_LANDSCAPE;
22import static com.android.launcher3.InvariantDeviceProfile.INDEX_TWO_PANEL_PORTRAIT;
Jon Miranda58561d42021-03-17 10:51:54 -040023import static com.android.launcher3.Utilities.dpiFromPx;
Jon Mirandaaf3aed02021-05-06 18:28:45 -070024import static com.android.launcher3.Utilities.pxFromSp;
Alex Chau3d2c0622022-09-01 21:28:14 +010025import static com.android.launcher3.anim.Interpolators.LINEAR;
Alex Chauab800f72022-12-13 17:46:06 +000026import static com.android.launcher3.config.FeatureFlags.ENABLE_MULTI_DISPLAY_PARTIAL_DEPTH;
Jon Miranda92c1b5d2021-07-20 13:57:16 -070027import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.ICON_OVERLAP_FACTOR;
Sunny Goyal65190ae2022-08-02 14:16:26 -070028import static com.android.launcher3.icons.GraphicsUtils.getShapePath;
Thales Limab35faed2022-09-05 16:30:01 -030029import static com.android.launcher3.testing.shared.ResourceUtils.INVALID_RESOURCE_HANDLE;
Pat Manning5f74bfd2022-07-20 12:08:54 +010030import static com.android.launcher3.testing.shared.ResourceUtils.pxFromDp;
Jon Miranda228877d2021-02-09 11:05:00 -050031
Sunny Goyal35c7b192021-04-20 16:51:10 -070032import android.annotation.SuppressLint;
Winson Chungb3800242013-10-24 11:01:54 -070033import android.content.Context;
Jon Mirandab28c4fc2017-06-20 10:58:36 -070034import android.content.res.Configuration;
Winson Chungb3800242013-10-24 11:01:54 -070035import android.content.res.Resources;
Thales Limab35faed2022-09-05 16:30:01 -030036import android.content.res.TypedArray;
Winson Chungb3800242013-10-24 11:01:54 -070037import android.graphics.Point;
Jon Miranda7ae64ff2016-11-21 16:18:46 -080038import android.graphics.PointF;
Winson Chungb3800242013-10-24 11:01:54 -070039import android.graphics.Rect;
Sunny Goyal35c7b192021-04-20 16:51:10 -070040import android.util.DisplayMetrics;
Sunny Goyal65190ae2022-08-02 14:16:26 -070041import android.util.SparseArray;
Sunny Goyal59d086c2018-05-07 17:31:40 -070042import android.view.Surface;
Winson Chungb3800242013-10-24 11:01:54 -070043
Sunny Goyal65190ae2022-08-02 14:16:26 -070044import androidx.annotation.NonNull;
Sihua Mae04aa202022-07-18 12:43:56 -070045import androidx.annotation.Nullable;
Sunny Goyal65190ae2022-08-02 14:16:26 -070046
Sunny Goyalc13403c2016-11-18 23:44:48 -080047import com.android.launcher3.CellLayout.ContainerType;
Jon Miranda228877d2021-02-09 11:05:00 -050048import com.android.launcher3.DevicePaddings.DevicePadding;
Alex Chaud67ddc42022-09-30 18:15:56 +010049import com.android.launcher3.config.FeatureFlags;
Tony Wickham8912b042018-11-29 15:28:53 -080050import com.android.launcher3.icons.DotRenderer;
Hyunyoung Song48cb7bc2018-09-25 17:03:34 -070051import com.android.launcher3.icons.IconNormalizer;
Sihua Mae04aa202022-07-18 12:43:56 -070052import com.android.launcher3.model.data.ItemInfo;
Sunny Goyal57b22792021-05-25 14:35:01 -070053import com.android.launcher3.uioverrides.ApiWrapper;
Sunny Goyalfd58da62020-08-11 12:06:49 -070054import com.android.launcher3.util.DisplayController;
55import com.android.launcher3.util.DisplayController.Info;
Sunny Goyalb46703d2020-05-27 17:52:03 -070056import com.android.launcher3.util.WindowBounds;
Winson1f064272016-07-18 17:18:02 -070057
Jon Miranda58561d42021-03-17 10:51:54 -040058import java.io.PrintWriter;
Alex Chaue818bcb2022-09-02 17:27:11 +010059import java.util.Locale;
Jon Miranda2b25ded2023-02-02 14:48:45 -080060import java.util.function.Consumer;
Jon Miranda58561d42021-03-17 10:51:54 -040061
Sunny Goyal35c7b192021-04-20 16:51:10 -070062@SuppressLint("NewApi")
Winson Chungb3800242013-10-24 11:01:54 -070063public class DeviceProfile {
Adam Cohen2e6da152015-05-06 11:42:25 -070064
Sunny Goyal8b9919d2021-04-07 14:45:17 -070065 private static final int DEFAULT_DOT_SIZE = 100;
Alex Chau206ede92022-08-01 17:46:12 +010066 private static final float ALL_APPS_TABLET_MAX_ROWS = 5.5f;
Thales Limab35faed2022-09-05 16:30:01 -030067 private static final float MIN_FOLDER_TEXT_SIZE_SP = 16f;
Alex Chau206ede92022-08-01 17:46:12 +010068
Sihua Mae04aa202022-07-18 12:43:56 -070069 public static final PointF DEFAULT_SCALE = new PointF(1.0f, 1.0f);
70 public static final ViewScaleProvider DEFAULT_PROVIDER = itemInfo -> DEFAULT_SCALE;
Jon Miranda2b25ded2023-02-02 14:48:45 -080071 public static final Consumer<DeviceProfile> DEFAULT_DIMENSION_PROVIDER = dp -> {};
Sihua Mae04aa202022-07-18 12:43:56 -070072
Sunny Goyal57b22792021-05-25 14:35:01 -070073 // Ratio of empty space, qsb should take up to appear visually centered.
Pratyush9afe1ea2021-10-13 11:13:27 +000074 private final float mQsbCenterFactor;
Sunny Goyal1890f672020-04-30 12:28:00 -070075
Adam Cohen2e6da152015-05-06 11:42:25 -070076 public final InvariantDeviceProfile inv;
Sunny Goyalfd58da62020-08-11 12:06:49 -070077 private final Info mInfo;
Sunny Goyal35c7b192021-04-20 16:51:10 -070078 private final DisplayMetrics mMetrics;
Winson Chungbe876472014-05-14 14:15:20 -070079
Sunny Goyalc6205602015-05-21 20:46:33 -070080 // Device properties
81 public final boolean isTablet;
Sunny Goyalc6205602015-05-21 20:46:33 -070082 public final boolean isPhone;
83 public final boolean transposeLayoutWithOrientation;
Alex Chauab800f72022-12-13 17:46:06 +000084 public final boolean isMultiDisplay;
Sunny Goyal19ff7282021-04-22 10:12:54 -070085 public final boolean isTwoPanels;
Thales Limaa1012902022-01-13 17:58:42 +000086 public final boolean isQsbInline;
Hyunyoung Song18bfaaf2015-03-17 11:32:21 -070087
Sunny Goyalc6205602015-05-21 20:46:33 -070088 // Device properties in current orientation
Sunny Goyald792a772018-04-05 13:37:46 -070089 public final boolean isLandscape;
Sunny Goyald70e75a2018-02-22 10:07:32 -080090 public final boolean isMultiWindowMode;
Alex Chau6ed408f2022-03-04 12:58:05 +000091 public final boolean isGestureMode;
Sunny Goyald70e75a2018-02-22 10:07:32 -080092
Sunny Goyal0addbf02020-04-28 14:17:35 -070093 public final int windowX;
94 public final int windowY;
Sunny Goyalc6205602015-05-21 20:46:33 -070095 public final int widthPx;
96 public final int heightPx;
97 public final int availableWidthPx;
98 public final int availableHeightPx;
Sunny Goyal187b16c2022-03-01 16:53:23 -080099 public final int rotationHint;
Jon Mirandabba64512019-03-27 10:54:17 -0700100
101 public final float aspectRatio;
102
Jon Mirandae126d722021-02-25 10:45:20 -0500103 public final boolean isScalableGrid;
Thales Lima83bedbf2021-10-05 17:47:39 +0100104 private final int mTypeIndex;
Jon Mirandae126d722021-02-25 10:45:20 -0500105
Tony Wickhamd6b40372015-09-23 18:37:57 -0700106 /**
107 * The maximum amount of left/right workspace padding as a percentage of the screen width.
108 * To be clear, this means that up to 7% of the screen width can be used as left padding, and
109 * 7% of the screen width can be used as right padding.
110 */
111 private static final float MAX_HORIZONTAL_PADDING_PERCENT = 0.14f;
Winson Chungb3800242013-10-24 11:01:54 -0700112
Jon Miranda3f9bab22017-07-28 14:50:17 -0700113 private static final float TALL_DEVICE_ASPECT_RATIO_THRESHOLD = 2.0f;
Jon Miranda80cddbc2021-07-22 13:51:16 -0700114 private static final float TALLER_DEVICE_ASPECT_RATIO_THRESHOLD = 2.15f;
Jon Miranda80dda302021-07-28 14:14:59 -0700115 private static final float TALL_DEVICE_EXTRA_SPACE_THRESHOLD_DP = 252;
116 private static final float TALL_DEVICE_MORE_EXTRA_SPACE_THRESHOLD_DP = 268;
Jon Miranda30d0aa22017-07-25 15:55:29 -0700117
Sunny Goyalc6205602015-05-21 20:46:33 -0700118 // Workspace
Thales Limad90faab2021-09-21 17:18:47 +0100119 public final int desiredWorkspaceHorizontalMarginOriginalPx;
120 public int desiredWorkspaceHorizontalMarginPx;
Alex Chau51da2192022-05-20 13:32:10 +0100121 public int gridVisualizationPaddingX;
122 public int gridVisualizationPaddingY;
Thales Lima78d00ad2021-09-30 11:29:06 +0100123 public Point cellLayoutBorderSpaceOriginalPx;
124 public Point cellLayoutBorderSpacePx;
Pat Manning08610ca2022-04-05 21:03:16 +0100125 public Rect cellLayoutPaddingPx = new Rect();
126
Sunny Goyalc6205602015-05-21 20:46:33 -0700127 public final int edgeMarginPx;
Alex Chau0c4e11b2022-07-08 18:41:36 +0100128 public final float workspaceContentScale;
Alex Chau906d8822022-05-23 10:42:25 +0100129 public final int workspaceSpringLoadedMinNextPageVisiblePx;
Sunny Goyalc6205602015-05-21 20:46:33 -0700130
Jon Miranda58561d42021-03-17 10:51:54 -0400131 private final int extraSpace;
Thales Lima171ee662022-11-22 15:52:49 +0000132 private int maxEmptySpace;
Jon Miranda228877d2021-02-09 11:05:00 -0500133 public int workspaceTopPadding;
134 public int workspaceBottomPadding;
135
Tony Wickham5edf9e22020-03-27 20:06:52 -0700136 // Workspace page indicator
137 public final int workspacePageIndicatorHeight;
138 private final int mWorkspacePageIndicatorOverlapWorkspace;
Winson1f064272016-07-18 17:18:02 -0700139
Sunny Goyalc6205602015-05-21 20:46:33 -0700140 // Workspace icons
Jon Mirandac9e69fa2021-03-22 17:13:34 -0400141 public float iconScale;
Sunny Goyalc6205602015-05-21 20:46:33 -0700142 public int iconSizePx;
143 public int iconTextSizePx;
144 public int iconDrawablePaddingPx;
Winson Chung5f4e0fd2015-05-22 11:12:27 -0700145 public int iconDrawablePaddingOriginalPx;
Winson Chungb3800242013-10-24 11:01:54 -0700146
Jon Mirandaab3c6812021-06-28 15:42:28 -0700147 public float cellScaleToFit;
Adam Cohen59400422014-03-05 18:07:04 -0800148 public int cellWidthPx;
149 public int cellHeightPx;
Jon Mirandab28c4fc2017-06-20 10:58:36 -0700150 public int workspaceCellPaddingXPx;
Adam Cohen59400422014-03-05 18:07:04 -0800151
Jon Mirandae126d722021-02-25 10:45:20 -0500152 public int cellYPaddingPx;
Jon Mirandae126d722021-02-25 10:45:20 -0500153
Sunny Goyalc6205602015-05-21 20:46:33 -0700154 // Folder
Jon Mirandae126d722021-02-25 10:45:20 -0500155 public float folderLabelTextScale;
156 public int folderLabelTextSizePx;
Thales Limab35faed2022-09-05 16:30:01 -0300157 public int folderFooterHeightPx;
Sunny Goyalc6205602015-05-21 20:46:33 -0700158 public int folderIconSizePx;
Jon Miranda591e3602018-03-28 11:37:00 -0700159 public int folderIconOffsetYPx;
Jon Mirandabf7d8122016-11-03 15:29:29 -0700160
Jon Mirandae126d722021-02-25 10:45:20 -0500161 // Folder content
Thales Limab35faed2022-09-05 16:30:01 -0300162 public int folderCellLayoutBorderSpacePx;
Jon Mirandae126d722021-02-25 10:45:20 -0500163 public int folderContentPaddingLeftRight;
164 public int folderContentPaddingTop;
165
Jon Mirandabf7d8122016-11-03 15:29:29 -0700166 // Folder cell
Sunny Goyalc6205602015-05-21 20:46:33 -0700167 public int folderCellWidthPx;
168 public int folderCellHeightPx;
Jon Mirandabf7d8122016-11-03 15:29:29 -0700169
170 // Folder child
171 public int folderChildIconSizePx;
172 public int folderChildTextSizePx;
Sunny Goyalbaec6ff2016-09-14 11:26:21 -0700173 public int folderChildDrawablePaddingPx;
Winson Chungb3800242013-10-24 11:01:54 -0700174
Sunny Goyalc6205602015-05-21 20:46:33 -0700175 // Hotseat
Thales Lima9938c2f2022-07-25 14:38:16 +0100176 public int numShownHotseatIcons;
Sunny Goyalc6205602015-05-21 20:46:33 -0700177 public int hotseatCellHeightPx;
Pat Manning26f70f72022-07-07 13:50:39 +0100178 public final boolean areNavButtonsInline;
Jon Miranda18751b62017-07-31 17:25:27 -0700179 // In portrait: size = height, in landscape: size = width
180 public int hotseatBarSizePx;
Thales Limab8c05952022-05-23 16:58:38 +0100181 public int hotseatBarBottomSpacePx;
Pat Manning26f70f72022-07-07 13:50:39 +0100182 public int hotseatBarEndOffset;
Thales Limab8c05952022-05-23 16:58:38 +0100183 public int hotseatQsbSpace;
Pat Manningde25c0d2022-04-05 19:11:26 +0100184 public int springLoadedHotseatBarTopMarginPx;
Tony Wickham1eeffbe2018-06-12 15:01:15 -0700185 // Start is the side next to the nav bar, end is the side next to the workspace
186 public final int hotseatBarSidePaddingStartPx;
187 public final int hotseatBarSidePaddingEndPx;
Alex Chau206ede92022-08-01 17:46:12 +0100188 public int hotseatQsbWidth; // only used when isQsbInline
Sunny Goyal57b22792021-05-25 14:35:01 -0700189 public final int hotseatQsbHeight;
Thales Limab8c05952022-05-23 16:58:38 +0100190 public final int hotseatQsbVisualHeight;
191 private final int hotseatQsbShadowHeight;
Thales Limadd027342022-01-07 12:54:37 +0000192 public int hotseatBorderSpace;
Thales Lima6a590062022-11-22 15:52:49 +0000193 private int minHotseatIconSpacePx;
194 private int minHotseatQsbWidthPx;
195 private final int maxHotseatIconSpacePx;
196 private int inlineNavButtonsEndSpacing;
Adam Cohen2e6da152015-05-06 11:42:25 -0700197
Alex Chau3d2c0622022-09-01 21:28:14 +0100198 // Bottom sheets
199 public int bottomSheetTopPadding;
200 public int bottomSheetOpenDuration;
201 public int bottomSheetCloseDuration;
202 public float bottomSheetWorkspaceScale;
203 public float bottomSheetDepth;
204
Sunny Goyalc6205602015-05-21 20:46:33 -0700205 // All apps
Thales Lima85c942f2021-12-31 13:04:20 +0000206 public Point allAppsBorderSpacePx;
Alex Chaub8c22e12022-02-14 18:35:58 +0000207 public int allAppsShiftRange;
208 public int allAppsTopPadding;
Alex Chau3d2c0622022-09-01 21:28:14 +0100209 public int allAppsOpenDuration;
210 public int allAppsCloseDuration;
Jon Mirandab28c4fc2017-06-20 10:58:36 -0700211 public int allAppsCellHeightPx;
Samuel Fufaf1424a32019-10-04 15:15:19 -0700212 public int allAppsCellWidthPx;
Winson1f064272016-07-18 17:18:02 -0700213 public int allAppsIconSizePx;
214 public int allAppsIconDrawablePaddingPx;
sfufa@google.comde013292021-09-21 18:22:44 -0700215 public int allAppsLeftRightPadding;
Alex Chau27b39b92022-01-14 18:02:18 +0000216 public int allAppsLeftRightMargin;
Sunny Goyal19ff7282021-04-22 10:12:54 -0700217 public final int numShownAllAppsColumns;
Winson1f064272016-07-18 17:18:02 -0700218 public float allAppsIconTextSizePx;
219
Zak Cohen334efeb2021-03-19 16:42:07 -0700220 // Overview
Zak Cohen334efeb2021-03-19 16:42:07 -0700221 public int overviewTaskMarginPx;
Alex Chaudedbc8a2021-03-17 16:53:26 +0000222 public int overviewTaskIconSizePx;
Alex Chauac9df382021-08-02 19:08:41 +0100223 public int overviewTaskIconDrawableSizePx;
224 public int overviewTaskIconDrawableSizeGridPx;
Alex Chaudedbc8a2021-03-17 16:53:26 +0000225 public int overviewTaskThumbnailTopMarginPx;
Alex Chau19c6eca2022-03-10 20:12:56 +0000226 public final int overviewActionsHeight;
Alex Chaua2fc7642022-04-21 14:20:23 +0100227 public final int overviewActionsTopMarginPx;
Alex Chau1bf0fe12021-11-30 15:32:45 +0000228 public final int overviewActionsButtonSpacing;
Alex Chau5fd9d492021-07-22 17:27:11 +0100229 public int overviewPageSpacing;
230 public int overviewRowSpacing;
Alex Chau56bd2572021-11-03 18:48:18 +0000231 public int overviewGridSideMargin;
Zak Cohen334efeb2021-03-19 16:42:07 -0700232
Jeremy Sim0ac47082022-10-10 13:59:40 -0700233 // Split staging
234 public int splitPlaceholderInset;
235
Jon Miranda7ae64ff2016-11-21 16:18:46 -0800236 // Widgets
Sihua Mae04aa202022-07-18 12:43:56 -0700237 private final ViewScaleProvider mViewScaleProvider;
Jon Miranda7ae64ff2016-11-21 16:18:46 -0800238
Sunny Goyal47328fd2016-05-25 18:56:41 -0700239 // Drop Target
240 public int dropTargetBarSizePx;
Pat Manningde25c0d2022-04-05 19:11:26 +0100241 public int dropTargetBarTopMarginPx;
242 public int dropTargetBarBottomMarginPx;
Alex Chaua02eddc2021-04-29 00:36:06 +0100243 public int dropTargetDragPaddingPx;
244 public int dropTargetTextSizePx;
Pat Manningde25c0d2022-04-05 19:11:26 +0100245 public int dropTargetHorizontalPaddingPx;
246 public int dropTargetVerticalPaddingPx;
247 public int dropTargetGapPx;
Alex Chau5b019302022-05-23 10:42:25 +0100248 public int dropTargetButtonWorkspaceEdgeGapPx;
Adam Cohen4ae96ce2014-08-29 15:05:48 -0700249
Winson1f064272016-07-18 17:18:02 -0700250 // Insets
Sunny Goyal07b69292018-01-08 14:19:34 -0800251 private final Rect mInsets = new Rect();
252 public final Rect workspacePadding = new Rect();
Jon Miranda0bd63d12019-03-06 17:29:29 -0800253 // When true, nav bar is on the left side of the screen.
Sunny Goyal59d086c2018-05-07 17:31:40 -0700254 private boolean mIsSeascape;
Winson1f064272016-07-18 17:18:02 -0700255
Tony Wickhamf34bee82018-12-03 18:11:39 -0800256 // Notification dots
Sunny Goyal65190ae2022-08-02 14:16:26 -0700257 public final DotRenderer mDotRendererWorkSpace;
258 public final DotRenderer mDotRendererAllApps;
Tony Wickham9a8d11f2017-01-11 09:53:12 -0800259
Pierre Barbier de Reuille578deba2021-09-24 13:47:44 +0100260 // Taskbar
Tony Wickham15883892021-02-12 11:24:40 -0800261 public boolean isTaskbarPresent;
Tony Wickham635e1802021-07-22 14:28:04 -1000262 // Whether Taskbar will inset the bottom of apps by taskbarSize.
263 public boolean isTaskbarPresentInApps;
Tony Wickham15883892021-02-12 11:24:40 -0800264 public int taskbarSize;
Alex Chau85d664e2023-01-16 16:31:59 +0000265 public int transientTaskbarSize;
Alex Chau6a7d1e22022-01-20 19:54:17 +0000266 public int stashedTaskbarSize;
Alex Chau905e0f12022-11-14 21:55:37 +0000267 public int transientTaskbarMargin;
Tony Wickham15883892021-02-12 11:24:40 -0800268
Alex Chaua02eddc2021-04-29 00:36:06 +0100269 // DragController
270 public int flingToDeleteThresholdVelocity;
271
Vinit Nayak17c4b332021-08-05 12:54:58 -0700272 /** TODO: Once we fully migrate to staged split, remove "isMultiWindowMode" */
Sunny Goyal19ff7282021-04-22 10:12:54 -0700273 DeviceProfile(Context context, InvariantDeviceProfile inv, Info info, WindowBounds windowBounds,
Sunny Goyal65190ae2022-08-02 14:16:26 -0700274 SparseArray<DotRenderer> dotRendererCache, boolean isMultiWindowMode,
Alex Chauab800f72022-12-13 17:46:06 +0000275 boolean transposeLayoutWithOrientation, boolean isMultiDisplay, boolean isGestureMode,
Jon Miranda2b25ded2023-02-02 14:48:45 -0800276 @NonNull final ViewScaleProvider viewScaleProvider,
277 @NonNull final Consumer<DeviceProfile> dimensionOverrideProvider) {
Sunny Goyalfee35bb2015-05-11 11:38:19 -0700278
Adam Cohen2e6da152015-05-06 11:42:25 -0700279 this.inv = inv;
Sunny Goyal19ff7282021-04-22 10:12:54 -0700280 this.isLandscape = windowBounds.isLandscape();
Sunny Goyald70e75a2018-02-22 10:07:32 -0800281 this.isMultiWindowMode = isMultiWindowMode;
Jon Mirandae126d722021-02-25 10:45:20 -0500282 this.transposeLayoutWithOrientation = transposeLayoutWithOrientation;
Alex Chauab800f72022-12-13 17:46:06 +0000283 this.isMultiDisplay = isMultiDisplay;
Alex Chau6ed408f2022-03-04 12:58:05 +0000284 this.isGestureMode = isGestureMode;
Sunny Goyal19ff7282021-04-22 10:12:54 -0700285 windowX = windowBounds.bounds.left;
286 windowY = windowBounds.bounds.top;
Sunny Goyal187b16c2022-03-01 16:53:23 -0800287 this.rotationHint = windowBounds.rotationHint;
Alex Chaue0227552022-04-06 19:44:43 +0100288 mInsets.set(windowBounds.insets);
Winson Chungb3800242013-10-24 11:01:54 -0700289
Jon Mirandae126d722021-02-25 10:45:20 -0500290 isScalableGrid = inv.isScalable && !isVerticalBarLayout() && !isMultiWindowMode;
Alex Chaudfc8ddf2022-01-25 11:26:25 +0000291 // Determine device posture.
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700292 mInfo = info;
Alex Chau29983072021-11-19 15:14:20 +0000293 isTablet = info.isTablet(windowBounds);
Sunny Goyal19ff7282021-04-22 10:12:54 -0700294 isPhone = !isTablet;
Alex Chauab800f72022-12-13 17:46:06 +0000295 isTwoPanels = isTablet && isMultiDisplay;
Vinit Nayak58c27cc2022-02-16 17:42:21 -0800296 isTaskbarPresent = isTablet && ApiWrapper.TASKBAR_DRAWN_IN_PROCESS;
Adam Cohen2e6da152015-05-06 11:42:25 -0700297
Alex Chaudfc8ddf2022-01-25 11:26:25 +0000298 // Some more constants.
Alex Chau635b3ab2022-01-26 16:49:10 +0000299 context = getContext(context, info, isVerticalBarLayout() || (isTablet && isLandscape)
Brandon Dayauon07ca8842022-04-27 10:52:28 -0700300 ? Configuration.ORIENTATION_LANDSCAPE
301 : Configuration.ORIENTATION_PORTRAIT,
Alex Chaua6907dc2022-03-18 15:24:07 +0000302 windowBounds);
Sunny Goyal1890f672020-04-30 12:28:00 -0700303 final Resources res = context.getResources();
Alex Chaudfc8ddf2022-01-25 11:26:25 +0000304 mMetrics = res.getDisplayMetrics();
305
306 // Determine sizes.
307 widthPx = windowBounds.bounds.width();
308 heightPx = windowBounds.bounds.height();
309 availableWidthPx = windowBounds.availableSize.x;
Thales Limab8c05952022-05-23 16:58:38 +0100310 availableHeightPx = windowBounds.availableSize.y;
Alex Chaudfc8ddf2022-01-25 11:26:25 +0000311
312 aspectRatio = ((float) Math.max(widthPx, heightPx)) / Math.min(widthPx, heightPx);
313 boolean isTallDevice = Float.compare(aspectRatio, TALL_DEVICE_ASPECT_RATIO_THRESHOLD) >= 0;
314 mQsbCenterFactor = res.getFloat(R.dimen.qsb_center_factor);
Jon Mirandab28c4fc2017-06-20 10:58:36 -0700315
Thales Lima83bedbf2021-10-05 17:47:39 +0100316 if (isTwoPanels) {
317 if (isLandscape) {
Thales Lima12d0eff2022-03-25 17:06:11 +0000318 mTypeIndex = INDEX_TWO_PANEL_LANDSCAPE;
Thales Lima83bedbf2021-10-05 17:47:39 +0100319 } else {
Thales Lima12d0eff2022-03-25 17:06:11 +0000320 mTypeIndex = INDEX_TWO_PANEL_PORTRAIT;
Thales Lima83bedbf2021-10-05 17:47:39 +0100321 }
322 } else {
323 if (isLandscape) {
Thales Lima12d0eff2022-03-25 17:06:11 +0000324 mTypeIndex = INDEX_LANDSCAPE;
Thales Lima83bedbf2021-10-05 17:47:39 +0100325 } else {
Thales Lima12d0eff2022-03-25 17:06:11 +0000326 mTypeIndex = INDEX_DEFAULT;
Thales Lima83bedbf2021-10-05 17:47:39 +0100327 }
328 }
329
Tony Wickham15883892021-02-12 11:24:40 -0800330 if (isTaskbarPresent) {
Alex Chau85d664e2023-01-16 16:31:59 +0000331 transientTaskbarSize = res.getDimensionPixelSize(R.dimen.transient_taskbar_size);
332 transientTaskbarMargin = res.getDimensionPixelSize(R.dimen.transient_taskbar_margin);
Jon Miranda7e819502022-11-03 10:56:32 -0700333 if (DisplayController.isTransientTaskbar(context)) {
Alex Chau85d664e2023-01-16 16:31:59 +0000334 taskbarSize = transientTaskbarSize;
Jon Miranda7e819502022-11-03 10:56:32 -0700335 stashedTaskbarSize =
336 res.getDimensionPixelSize(R.dimen.transient_taskbar_stashed_size);
337 } else {
338 taskbarSize = res.getDimensionPixelSize(R.dimen.taskbar_size);
339 stashedTaskbarSize = res.getDimensionPixelSize(R.dimen.taskbar_stashed_size);
340 }
Tony Wickham15883892021-02-12 11:24:40 -0800341 }
Tony Wickham15883892021-02-12 11:24:40 -0800342
Winson Chungb3800242013-10-24 11:01:54 -0700343 edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
Alex Chau0c4e11b2022-07-08 18:41:36 +0100344 workspaceContentScale = res.getFloat(R.dimen.workspace_content_scale);
Sunny Goyal58fa4b62019-03-22 16:23:25 -0700345
Thales Limad90faab2021-09-21 17:18:47 +0100346 desiredWorkspaceHorizontalMarginPx = getHorizontalMarginPx(inv, res);
347 desiredWorkspaceHorizontalMarginOriginalPx = desiredWorkspaceHorizontalMarginPx;
Alex Chau51da2192022-05-20 13:32:10 +0100348 gridVisualizationPaddingX = res.getDimensionPixelSize(
349 R.dimen.grid_visualization_horizontal_cell_spacing);
350 gridVisualizationPaddingY = res.getDimensionPixelSize(
351 R.dimen.grid_visualization_vertical_cell_spacing);
Samuel Fufaee9aff92021-04-05 13:30:40 -0500352
Alex Chaue0227552022-04-06 19:44:43 +0100353 bottomSheetTopPadding = mInsets.top // statusbar height
Andras Kloczl142b0542022-03-09 21:26:02 +0000354 + res.getDimensionPixelSize(R.dimen.bottom_sheet_extra_top_padding)
355 + (isTablet ? 0 : edgeMarginPx); // phones need edgeMarginPx additional padding
Alex Chau3d2c0622022-09-01 21:28:14 +0100356 bottomSheetOpenDuration = res.getInteger(R.integer.config_bottomSheetOpenDuration);
357 bottomSheetCloseDuration = res.getInteger(R.integer.config_bottomSheetCloseDuration);
358 if (isTablet) {
359 bottomSheetWorkspaceScale = workspaceContentScale;
Alex Chauab800f72022-12-13 17:46:06 +0000360 if (isMultiDisplay && !ENABLE_MULTI_DISPLAY_PARTIAL_DEPTH.get()) {
361 // TODO(b/259893832): Revert to use maxWallpaperScale to calculate bottomSheetDepth
362 // when screen recorder bug is fixed.
363 bottomSheetDepth = 1f;
364 } else {
365 // The goal is to set wallpaper to zoom at workspaceContentScale when in AllApps.
366 // When depth is 0, wallpaper zoom is set to maxWallpaperScale.
367 // When depth is 1, wallpaper zoom is set to 1.
368 // For depth to achieve zoom set to maxWallpaperScale * workspaceContentScale:
369 float maxWallpaperScale = res.getFloat(R.dimen.config_wallpaperMaxScale);
370 bottomSheetDepth = Utilities.mapToRange(maxWallpaperScale * workspaceContentScale,
371 maxWallpaperScale, 1f, 0f, 1f, LINEAR);
372 }
Alex Chau3d2c0622022-09-01 21:28:14 +0100373 } else {
374 bottomSheetWorkspaceScale = 1f;
375 bottomSheetDepth = 0f;
376 }
Andras Kloczl142b0542022-03-09 21:26:02 +0000377
Jon Mirandae126d722021-02-25 10:45:20 -0500378 folderLabelTextScale = res.getFloat(R.dimen.folder_label_text_scale);
Thales Limab35faed2022-09-05 16:30:01 -0300379
380 if (inv.folderStyle != INVALID_RESOURCE_HANDLE) {
381 TypedArray folderStyle = context.obtainStyledAttributes(inv.folderStyle,
Thales Limad852d652023-01-17 14:01:13 +0000382 R.styleable.FolderStyle);
Thales Limab35faed2022-09-05 16:30:01 -0300383 // These are re-set in #updateFolderCellSize if the grid is not scalable
384 folderCellHeightPx = folderStyle.getDimensionPixelSize(
Thales Limad852d652023-01-17 14:01:13 +0000385 R.styleable.FolderStyle_folderCellHeight, 0);
Thales Limab35faed2022-09-05 16:30:01 -0300386 folderCellWidthPx = folderStyle.getDimensionPixelSize(
Thales Limad852d652023-01-17 14:01:13 +0000387 R.styleable.FolderStyle_folderCellWidth, 0);
Thales Limab35faed2022-09-05 16:30:01 -0300388
389 folderContentPaddingTop = folderStyle.getDimensionPixelSize(
Thales Limad852d652023-01-17 14:01:13 +0000390 R.styleable.FolderStyle_folderTopPadding, 0);
Thales Limab35faed2022-09-05 16:30:01 -0300391 folderCellLayoutBorderSpacePx = folderStyle.getDimensionPixelSize(
Thales Limad852d652023-01-17 14:01:13 +0000392 R.styleable.FolderStyle_folderBorderSpace, 0);
Thales Limab35faed2022-09-05 16:30:01 -0300393 folderFooterHeightPx = folderStyle.getDimensionPixelSize(
Thales Limad852d652023-01-17 14:01:13 +0000394 R.styleable.FolderStyle_folderFooterHeight, 0);
Thales Limab35faed2022-09-05 16:30:01 -0300395 folderStyle.recycle();
396 } else {
397 folderCellLayoutBorderSpacePx = 0;
398 folderFooterHeightPx = 0;
399 folderContentPaddingTop = res.getDimensionPixelSize(R.dimen.folder_top_padding_default);
400 }
Jon Mirandae126d722021-02-25 10:45:20 -0500401
Thales Lima78d00ad2021-09-30 11:29:06 +0100402 cellLayoutBorderSpacePx = getCellLayoutBorderSpace(inv);
Thales Limab35faed2022-09-05 16:30:01 -0300403 cellLayoutBorderSpaceOriginalPx = new Point(cellLayoutBorderSpacePx);
Thales Lima85c942f2021-12-31 13:04:20 +0000404 allAppsBorderSpacePx = new Point(
Thales Limabb7d3882021-12-22 12:56:29 +0000405 pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].x, mMetrics),
406 pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].y, mMetrics));
Thales Limae9273ea2023-01-26 12:33:52 +0000407 setupAllAppsStyle(context);
Jon Mirandae126d722021-02-25 10:45:20 -0500408
Tony Wickham5edf9e22020-03-27 20:06:52 -0700409 workspacePageIndicatorHeight = res.getDimensionPixelSize(
410 R.dimen.workspace_page_indicator_height);
411 mWorkspacePageIndicatorOverlapWorkspace =
412 res.getDimensionPixelSize(R.dimen.workspace_page_indicator_overlap_workspace);
Sunny Goyal58fa4b62019-03-22 16:23:25 -0700413
Thales Limad852d652023-01-17 14:01:13 +0000414 TypedArray cellStyle;
415 if (inv.cellStyle != INVALID_RESOURCE_HANDLE) {
416 cellStyle = context.obtainStyledAttributes(inv.cellStyle,
417 R.styleable.CellStyle);
418 } else {
419 cellStyle = context.obtainStyledAttributes(R.style.CellStyleDefault,
420 R.styleable.CellStyle);
421 }
422 iconDrawablePaddingOriginalPx = cellStyle.getDimensionPixelSize(
423 R.styleable.CellStyle_iconDrawablePadding, 0);
424 cellStyle.recycle();
Alex Chaua02eddc2021-04-29 00:36:06 +0100425
Sunny Goyal47328fd2016-05-25 18:56:41 -0700426 dropTargetBarSizePx = res.getDimensionPixelSize(R.dimen.dynamic_grid_drop_target_size);
Pat Manningde25c0d2022-04-05 19:11:26 +0100427 dropTargetBarTopMarginPx = res.getDimensionPixelSize(R.dimen.drop_target_top_margin);
428 dropTargetBarBottomMarginPx = res.getDimensionPixelSize(R.dimen.drop_target_bottom_margin);
Alex Chaua02eddc2021-04-29 00:36:06 +0100429 dropTargetDragPaddingPx = res.getDimensionPixelSize(R.dimen.drop_target_drag_padding);
430 dropTargetTextSizePx = res.getDimensionPixelSize(R.dimen.drop_target_text_size);
Pat Manningde25c0d2022-04-05 19:11:26 +0100431 dropTargetHorizontalPaddingPx = res.getDimensionPixelSize(
432 R.dimen.drop_target_button_drawable_horizontal_padding);
433 dropTargetVerticalPaddingPx = res.getDimensionPixelSize(
434 R.dimen.drop_target_button_drawable_vertical_padding);
435 dropTargetGapPx = res.getDimensionPixelSize(R.dimen.drop_target_button_gap);
Alex Chau5b019302022-05-23 10:42:25 +0100436 dropTargetButtonWorkspaceEdgeGapPx = res.getDimensionPixelSize(
437 R.dimen.drop_target_button_workspace_edge_gap);
Alex Chaua02eddc2021-04-29 00:36:06 +0100438
Alex Chau906d8822022-05-23 10:42:25 +0100439 workspaceSpringLoadedMinNextPageVisiblePx = res.getDimensionPixelSize(
440 R.dimen.dynamic_grid_spring_loaded_min_next_space_visible);
Sunny Goyald5190522017-04-24 03:06:54 -0700441
Jon Mirandab28c4fc2017-06-20 10:58:36 -0700442 workspaceCellPaddingXPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_padding_x);
Jon Miranda09660722017-06-14 14:20:14 -0700443
Thales Limaa1012902022-01-13 17:58:42 +0000444 hotseatQsbHeight = res.getDimensionPixelSize(R.dimen.qsb_widget_height);
Thales Limab8c05952022-05-23 16:58:38 +0100445 hotseatQsbShadowHeight = res.getDimensionPixelSize(R.dimen.qsb_shadow_height);
446 hotseatQsbVisualHeight = hotseatQsbHeight - 2 * hotseatQsbShadowHeight;
447
Thales Lima12d0eff2022-03-25 17:06:11 +0000448 // Whether QSB might be inline in appropriate orientation (e.g. landscape).
449 boolean canQsbInline = (isTwoPanels ? inv.inlineQsb[INDEX_TWO_PANEL_PORTRAIT]
450 || inv.inlineQsb[INDEX_TWO_PANEL_LANDSCAPE]
451 : inv.inlineQsb[INDEX_DEFAULT] || inv.inlineQsb[INDEX_LANDSCAPE])
452 && hotseatQsbHeight > 0;
Thales Lima6a590062022-11-22 15:52:49 +0000453 isQsbInline = isScalableGrid && inv.inlineQsb[mTypeIndex] && canQsbInline;
Alex Chau6ed408f2022-03-04 12:58:05 +0000454
Thales Lima425f6822022-05-10 13:44:58 -0300455 areNavButtonsInline = isTaskbarPresent && !isGestureMode;
Thales Lima9938c2f2022-07-25 14:38:16 +0100456 numShownHotseatIcons =
457 isTwoPanels ? inv.numDatabaseHotseatIcons : inv.numShownHotseatIcons;
Alex Chau6ed408f2022-03-04 12:58:05 +0000458
Sunny Goyal19ff7282021-04-22 10:12:54 -0700459 numShownAllAppsColumns =
460 isTwoPanels ? inv.numDatabaseAllAppsColumns : inv.numAllAppsColumns;
Thales Limab8c05952022-05-23 16:58:38 +0100461
462 int hotseatBarBottomSpace = pxFromDp(inv.hotseatBarBottomSpace[mTypeIndex], mMetrics);
463 int minQsbMargin = res.getDimensionPixelSize(R.dimen.min_qsb_margin);
464 hotseatQsbSpace = pxFromDp(inv.hotseatQsbSpace[mTypeIndex], mMetrics);
465 // Have a little space between the inset and the QSB
466 if (mInsets.bottom + minQsbMargin > hotseatBarBottomSpace) {
467 int availableSpace = hotseatQsbSpace - (mInsets.bottom - hotseatBarBottomSpace);
468
469 // Only change the spaces if there is space
470 if (availableSpace > 0) {
471 // Make sure there is enough space between hotseat/QSB and QSB/navBar
472 if (availableSpace < minQsbMargin * 2) {
473 minQsbMargin = availableSpace / 2;
474 hotseatQsbSpace = minQsbMargin;
475 } else {
476 hotseatQsbSpace -= minQsbMargin;
477 }
478 }
479 hotseatBarBottomSpacePx = mInsets.bottom + minQsbMargin;
480
Thales Limaa1012902022-01-13 17:58:42 +0000481 } else {
Thales Limab8c05952022-05-23 16:58:38 +0100482 hotseatBarBottomSpacePx = hotseatBarBottomSpace;
Thales Limaa1012902022-01-13 17:58:42 +0000483 }
Thales Lima425f6822022-05-10 13:44:58 -0300484
Pat Manningde25c0d2022-04-05 19:11:26 +0100485 springLoadedHotseatBarTopMarginPx = res.getDimensionPixelSize(
486 R.dimen.spring_loaded_hotseat_top_margin);
Tony Wickham1eeffbe2018-06-12 15:01:15 -0700487 hotseatBarSidePaddingEndPx =
Sunny Goyal228153d2018-01-04 15:35:22 -0800488 res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_side_padding);
Jon Miranda3f411e72019-05-16 17:15:16 -0700489 // Add a bit of space between nav bar and hotseat in vertical bar layout.
Tony Wickham5edf9e22020-03-27 20:06:52 -0700490 hotseatBarSidePaddingStartPx = isVerticalBarLayout() ? workspacePageIndicatorHeight : 0;
Thales Limab8c05952022-05-23 16:58:38 +0100491 updateHotseatSizes(pxFromDp(inv.iconSize[INDEX_DEFAULT], mMetrics));
Vinit Nayak8a3d0552022-08-05 10:43:29 -0700492 if (areNavButtonsInline && !isPhone) {
Thales Lima6a590062022-11-22 15:52:49 +0000493 inlineNavButtonsEndSpacing = res.getDimensionPixelSize(inv.inlineNavButtonsEndSpacing);
Pat Manning26f70f72022-07-07 13:50:39 +0100494 /*
495 * 3 nav buttons +
Vinit Nayakc7293172022-07-18 16:41:50 -0700496 * Spacing between nav buttons +
Thales Lima6a590062022-11-22 15:52:49 +0000497 * Space at the end for contextual buttons
Pat Manning26f70f72022-07-07 13:50:39 +0100498 */
499 hotseatBarEndOffset = 3 * res.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size)
Vinit Nayakc7293172022-07-18 16:41:50 -0700500 + 2 * res.getDimensionPixelSize(R.dimen.taskbar_button_space_inbetween)
Thales Lima6a590062022-11-22 15:52:49 +0000501 + inlineNavButtonsEndSpacing;
Pat Manning26f70f72022-07-07 13:50:39 +0100502 } else {
Thales Lima6a590062022-11-22 15:52:49 +0000503 inlineNavButtonsEndSpacing = 0;
Pat Manning26f70f72022-07-07 13:50:39 +0100504 hotseatBarEndOffset = 0;
505 }
Jon Miranda8bdb2222021-06-23 18:10:10 -0700506
Alex Chau635b3ab2022-01-26 16:49:10 +0000507 overviewTaskMarginPx = res.getDimensionPixelSize(R.dimen.overview_task_margin);
Alex Chau5fd9d492021-07-22 17:27:11 +0100508 overviewTaskIconSizePx = res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_size);
Alex Chauac9df382021-08-02 19:08:41 +0100509 overviewTaskIconDrawableSizePx =
510 res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_drawable_size);
511 overviewTaskIconDrawableSizeGridPx =
512 res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_drawable_size_grid);
Jeremy Sim1cfe6d42022-07-15 14:40:38 -0700513 overviewTaskThumbnailTopMarginPx = overviewTaskIconSizePx + overviewTaskMarginPx;
Jeremy Sim3c2c3f12022-05-16 20:37:43 -0700514 overviewActionsTopMarginPx = res.getDimensionPixelSize(R.dimen.overview_actions_top_margin);
Alex Chau635b3ab2022-01-26 16:49:10 +0000515 overviewPageSpacing = res.getDimensionPixelSize(R.dimen.overview_page_spacing);
516 overviewActionsButtonSpacing = res.getDimensionPixelSize(
517 R.dimen.overview_actions_button_spacing);
Alex Chau19c6eca2022-03-10 20:12:56 +0000518 overviewActionsHeight = res.getDimensionPixelSize(R.dimen.overview_actions_height);
Jeremy Sim1cfe6d42022-07-15 14:40:38 -0700519 overviewRowSpacing = res.getDimensionPixelSize(R.dimen.overview_grid_row_spacing);
Alex Chau635b3ab2022-01-26 16:49:10 +0000520 overviewGridSideMargin = res.getDimensionPixelSize(R.dimen.overview_grid_side_margin);
Zak Cohen334efeb2021-03-19 16:42:07 -0700521
Jeremy Sim0ac47082022-10-10 13:59:40 -0700522 splitPlaceholderInset = res.getDimensionPixelSize(R.dimen.split_placeholder_inset);
523
Jon Miranda2ed276e2017-06-29 11:36:34 -0700524 // Calculate all of the remaining variables.
Jon Miranda58561d42021-03-17 10:51:54 -0400525 extraSpace = updateAvailableDimensions(res);
Jon Miranda80cddbc2021-07-22 13:51:16 -0700526
Jon Miranda2ed276e2017-06-29 11:36:34 -0700527 // Now that we have all of the variables calculated, we can tune certain sizes.
Thales Limaae0d7ef2022-11-16 15:53:43 +0000528 if (isScalableGrid && inv.devicePaddingId != INVALID_RESOURCE_HANDLE) {
Jon Mirandac9e69fa2021-03-22 17:13:34 -0400529 // Paddings were created assuming no scaling, so we first unscale the extra space.
Jon Mirandaab3c6812021-06-28 15:42:28 -0700530 int unscaledExtraSpace = (int) (extraSpace / cellScaleToFit);
Thales Limaae0d7ef2022-11-16 15:53:43 +0000531 DevicePaddings devicePaddings = new DevicePaddings(context, inv.devicePaddingId);
532 DevicePadding padding = devicePaddings.getDevicePadding(unscaledExtraSpace);
Thales Lima171ee662022-11-22 15:52:49 +0000533 maxEmptySpace = padding.getMaxEmptySpacePx();
Jon Miranda228877d2021-02-09 11:05:00 -0500534
Jon Mirandac9e69fa2021-03-22 17:13:34 -0400535 int paddingWorkspaceTop = padding.getWorkspaceTopPadding(unscaledExtraSpace);
536 int paddingWorkspaceBottom = padding.getWorkspaceBottomPadding(unscaledExtraSpace);
537 int paddingHotseatBottom = padding.getHotseatBottomPadding(unscaledExtraSpace);
538
Jon Mirandaab3c6812021-06-28 15:42:28 -0700539 workspaceTopPadding = Math.round(paddingWorkspaceTop * cellScaleToFit);
540 workspaceBottomPadding = Math.round(paddingWorkspaceBottom * cellScaleToFit);
Jon Miranda2ed276e2017-06-29 11:36:34 -0700541 }
Pat Manning08610ca2022-04-05 21:03:16 +0100542
543 int cellLayoutPadding =
544 isTwoPanels ? cellLayoutBorderSpacePx.x / 2 : res.getDimensionPixelSize(
545 R.dimen.cell_layout_padding);
546 cellLayoutPaddingPx = new Rect(cellLayoutPadding, cellLayoutPadding, cellLayoutPadding,
547 cellLayoutPadding);
Sunny Goyal07b69292018-01-08 14:19:34 -0800548 updateWorkspacePadding();
Tony Wickham1237df02017-02-24 08:59:36 -0800549
Thales Lima6a590062022-11-22 15:52:49 +0000550 minHotseatIconSpacePx = res.getDimensionPixelSize(R.dimen.min_hotseat_icon_space);
551 minHotseatQsbWidthPx = res.getDimensionPixelSize(R.dimen.min_hotseat_qsb_width);
552 maxHotseatIconSpacePx = areNavButtonsInline
553 ? res.getDimensionPixelSize(R.dimen.max_hotseat_icon_space) : Integer.MAX_VALUE;
Thales Lima425f6822022-05-10 13:44:58 -0300554 // Hotseat and QSB width depends on updated cellSize and workspace padding
Thales Lima6a590062022-11-22 15:52:49 +0000555 recalculateHotseatWidthAndBorderSpace();
Alex Chau206ede92022-08-01 17:46:12 +0100556
557 // AllApps height calculation depends on updated cellSize
558 if (isTablet) {
559 int collapseHandleHeight =
560 res.getDimensionPixelOffset(R.dimen.bottom_sheet_handle_area_height);
561 int contentHeight = heightPx - collapseHandleHeight - hotseatQsbHeight;
562 int targetContentHeight = (int) (allAppsCellHeightPx * ALL_APPS_TABLET_MAX_ROWS);
563 allAppsTopPadding = Math.max(mInsets.top, contentHeight - targetContentHeight);
564 allAppsShiftRange = heightPx - allAppsTopPadding;
565 } else {
566 allAppsTopPadding = 0;
567 allAppsShiftRange =
568 res.getDimensionPixelSize(R.dimen.all_apps_starting_vertical_translate);
569 }
Alex Chau3d2c0622022-09-01 21:28:14 +0100570 allAppsOpenDuration = res.getInteger(R.integer.config_allAppsOpenDuration);
571 allAppsCloseDuration = res.getInteger(R.integer.config_allAppsCloseDuration);
Thales Lima425f6822022-05-10 13:44:58 -0300572
Alex Chaua02eddc2021-04-29 00:36:06 +0100573 flingToDeleteThresholdVelocity = res.getDimensionPixelSize(
574 R.dimen.drag_flingToDeleteMinVelocity);
575
Sihua Mae04aa202022-07-18 12:43:56 -0700576 mViewScaleProvider = viewScaleProvider;
577
Jon Miranda2b25ded2023-02-02 14:48:45 -0800578 dimensionOverrideProvider.accept(this);
579
Tony Wickham1237df02017-02-24 08:59:36 -0800580 // This is done last, after iconSizePx is calculated above.
Sunny Goyal799e1202023-02-09 10:54:28 -0800581 mDotRendererWorkSpace = createDotRenderer(context, iconSizePx, dotRendererCache);
582 mDotRendererAllApps = createDotRenderer(context, allAppsIconSizePx, dotRendererCache);
Sunny Goyal65190ae2022-08-02 14:16:26 -0700583 }
584
585 private static DotRenderer createDotRenderer(
Sunny Goyal799e1202023-02-09 10:54:28 -0800586 @NonNull Context context, int size, @NonNull SparseArray<DotRenderer> cache) {
Sunny Goyal65190ae2022-08-02 14:16:26 -0700587 DotRenderer renderer = cache.get(size);
588 if (renderer == null) {
Sunny Goyal799e1202023-02-09 10:54:28 -0800589 renderer = new DotRenderer(size, getShapePath(context, DEFAULT_DOT_SIZE),
590 DEFAULT_DOT_SIZE);
Sunny Goyal65190ae2022-08-02 14:16:26 -0700591 cache.put(size, renderer);
592 }
593 return renderer;
Adam Cohen63f1ec02014-08-12 09:23:13 -0700594 }
595
Thales Lima425f6822022-05-10 13:44:58 -0300596 /**
597 * QSB width is always calculated because when in 3 button nav the width doesn't follow the
598 * width of the hotseat.
599 */
Thales Lima9938c2f2022-07-25 14:38:16 +0100600 private int calculateQsbWidth(int hotseatBorderSpace) {
Thales Lima425f6822022-05-10 13:44:58 -0300601 if (isQsbInline) {
Alex Chau906d8822022-05-23 10:42:25 +0100602 int columns = getPanelCount() * inv.numColumns;
Thales Lima425f6822022-05-10 13:44:58 -0300603 return getIconToIconWidthForColumns(columns)
604 - iconSizePx * numShownHotseatIcons
605 - hotseatBorderSpace * numShownHotseatIcons;
606 } else {
607 int columns = inv.hotseatColumnSpan[mTypeIndex];
608 return getIconToIconWidthForColumns(columns);
609 }
610 }
Thales Lima2903a622022-03-17 13:52:19 +0000611
Thales Lima425f6822022-05-10 13:44:58 -0300612 private int getIconToIconWidthForColumns(int columns) {
613 return columns * getCellSize().x
614 + (columns - 1) * cellLayoutBorderSpacePx.x
Thales Lima1e8b45f2022-08-25 11:50:59 -0400615 - getCellHorizontalSpace();
Thales Limaa1012902022-01-13 17:58:42 +0000616 }
617
Thales Limad90faab2021-09-21 17:18:47 +0100618 private int getHorizontalMarginPx(InvariantDeviceProfile idp, Resources res) {
619 if (isVerticalBarLayout()) {
620 return 0;
621 }
622
Thales Lima83bedbf2021-10-05 17:47:39 +0100623 return isScalableGrid
624 ? pxFromDp(idp.horizontalMargin[mTypeIndex], mMetrics)
625 : res.getDimensionPixelSize(R.dimen.dynamic_grid_left_right_margin);
Thales Limad90faab2021-09-21 17:18:47 +0100626 }
627
Thales Limab8c05952022-05-23 16:58:38 +0100628 /** Updates hotseatCellHeightPx and hotseatBarSizePx */
629 private void updateHotseatSizes(int hotseatIconSizePx) {
Jon Miranda92c1b5d2021-07-20 13:57:16 -0700630 // Ensure there is enough space for folder icons, which have a slightly larger radius.
631 hotseatCellHeightPx = (int) Math.ceil(hotseatIconSizePx * ICON_OVERLAP_FACTOR);
Thales Limab8c05952022-05-23 16:58:38 +0100632
Jon Miranda0d284852021-06-22 14:50:55 -0700633 if (isVerticalBarLayout()) {
634 hotseatBarSizePx = hotseatIconSizePx + hotseatBarSidePaddingStartPx
635 + hotseatBarSidePaddingEndPx;
Thales Limab8c05952022-05-23 16:58:38 +0100636 } else if (isQsbInline) {
637 hotseatBarSizePx = Math.max(hotseatIconSizePx, hotseatQsbVisualHeight)
638 + hotseatBarBottomSpacePx;
Jon Miranda0d284852021-06-22 14:50:55 -0700639 } else {
Thales Limab8c05952022-05-23 16:58:38 +0100640 hotseatBarSizePx = hotseatIconSizePx
641 + hotseatQsbSpace
642 + hotseatQsbVisualHeight
643 + hotseatBarBottomSpacePx;
Jon Miranda0d284852021-06-22 14:50:55 -0700644 }
645 }
646
Thales Lima6a590062022-11-22 15:52:49 +0000647 /**
648 * Calculates the width of the hotseat, changing spaces between the icons and removing icons if
649 * necessary.
650 */
651 public void recalculateHotseatWidthAndBorderSpace() {
652 if (!isScalableGrid) return;
653
654 int columns = inv.hotseatColumnSpan[mTypeIndex];
655 float hotseatWidthPx = getIconToIconWidthForColumns(columns);
656 hotseatBorderSpace = calculateHotseatBorderSpace(hotseatWidthPx, /* numExtraBorder= */ 0);
Thales Lima9938c2f2022-07-25 14:38:16 +0100657 hotseatQsbWidth = calculateQsbWidth(hotseatBorderSpace);
Thales Lima6a590062022-11-22 15:52:49 +0000658 // Spaces should be correct when the nav buttons are not inline
Thales Lima9938c2f2022-07-25 14:38:16 +0100659 if (!areNavButtonsInline) {
660 return;
661 }
662
Thales Lima6a590062022-11-22 15:52:49 +0000663 // The side space with inline buttons should be what is defined in InvariantDeviceProfile
664 int sideSpace = inlineNavButtonsEndSpacing;
665 int maxHotseatWidth = availableWidthPx - sideSpace - hotseatBarEndOffset;
666 int maxHotseatIconsWidth = maxHotseatWidth - (isQsbInline ? hotseatQsbWidth : 0);
667 hotseatBorderSpace = calculateHotseatBorderSpace(maxHotseatIconsWidth,
668 (isQsbInline ? 1 : 0) + /* border between nav buttons and first icon */ 1);
Thales Lima9938c2f2022-07-25 14:38:16 +0100669
Thales Lima6a590062022-11-22 15:52:49 +0000670 if (hotseatBorderSpace >= minHotseatIconSpacePx) {
Thales Lima9938c2f2022-07-25 14:38:16 +0100671 return;
672 }
673
674 // Border space can't be less than the minimum
Thales Lima6a590062022-11-22 15:52:49 +0000675 hotseatBorderSpace = minHotseatIconSpacePx;
676 int requiredWidth = getHotseatRequiredWidth();
Thales Lima9938c2f2022-07-25 14:38:16 +0100677
678 // If there is an inline qsb, change its size
679 if (isQsbInline) {
680 hotseatQsbWidth -= requiredWidth - maxHotseatWidth;
Thales Lima6a590062022-11-22 15:52:49 +0000681 if (hotseatQsbWidth >= minHotseatQsbWidthPx) {
Thales Lima9938c2f2022-07-25 14:38:16 +0100682 return;
683 }
684
685 // QSB can't be less than the minimum
Thales Lima6a590062022-11-22 15:52:49 +0000686 hotseatQsbWidth = minHotseatQsbWidthPx;
Thales Lima9938c2f2022-07-25 14:38:16 +0100687 }
688
Thales Lima6a590062022-11-22 15:52:49 +0000689 maxHotseatIconsWidth = maxHotseatWidth - (isQsbInline ? hotseatQsbWidth : 0);
690
Thales Lima9938c2f2022-07-25 14:38:16 +0100691 // If it still doesn't fit, start removing icons
692 do {
693 numShownHotseatIcons--;
Thales Lima6a590062022-11-22 15:52:49 +0000694 hotseatBorderSpace = calculateHotseatBorderSpace(maxHotseatIconsWidth,
695 (isQsbInline ? 1 : 0) + /* border between nav buttons and first icon */ 1);
696 } while (hotseatBorderSpace < minHotseatIconSpacePx && numShownHotseatIcons > 1);
Thales Lima9938c2f2022-07-25 14:38:16 +0100697
Thales Lima9938c2f2022-07-25 14:38:16 +0100698 }
699
Thales Lima78d00ad2021-09-30 11:29:06 +0100700 private Point getCellLayoutBorderSpace(InvariantDeviceProfile idp) {
Thales Lima080d8902022-03-28 15:30:29 +0100701 return getCellLayoutBorderSpace(idp, 1f);
Thales Lima080d8902022-03-28 15:30:29 +0100702 }
703
704 private Point getCellLayoutBorderSpace(InvariantDeviceProfile idp, float scale) {
Thales Lima78d00ad2021-09-30 11:29:06 +0100705 if (!isScalableGrid) {
706 return new Point(0, 0);
707 }
708
Thales Lima080d8902022-03-28 15:30:29 +0100709 int horizontalSpacePx = pxFromDp(idp.borderSpaces[mTypeIndex].x, mMetrics, scale);
710 int verticalSpacePx = pxFromDp(idp.borderSpaces[mTypeIndex].y, mMetrics, scale);
Thales Lima78d00ad2021-09-30 11:29:06 +0100711
712 return new Point(horizontalSpacePx, verticalSpacePx);
713 }
714
Sunny Goyal69a8eec2021-07-22 10:02:50 -0700715 public Info getDisplayInfo() {
716 return mInfo;
717 }
718
Jon Miranda611dba42021-03-02 14:12:13 -0500719 /**
720 * We inset the widget padding added by the system and instead rely on the border spacing
721 * between cells to create reliable consistency between widgets
722 */
723 public boolean shouldInsetWidgets() {
724 Rect widgetPadding = inv.defaultWidgetPadding;
725
Jon Miranda49811182021-06-03 09:52:40 -0700726 // Check all sides to ensure that the widget won't overlap into another cell, or into
727 // status bar.
728 return workspaceTopPadding > widgetPadding.top
Thales Lima78d00ad2021-09-30 11:29:06 +0100729 && cellLayoutBorderSpacePx.x > widgetPadding.left
730 && cellLayoutBorderSpacePx.y > widgetPadding.top
731 && cellLayoutBorderSpacePx.x > widgetPadding.right
732 && cellLayoutBorderSpacePx.y > widgetPadding.bottom;
Jon Miranda611dba42021-03-02 14:12:13 -0500733 }
Jon Mirandae126d722021-02-25 10:45:20 -0500734
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700735 public Builder toBuilder(Context context) {
Sunny Goyal187b16c2022-03-01 16:53:23 -0800736 WindowBounds bounds = new WindowBounds(
737 widthPx, heightPx, availableWidthPx, availableHeightPx, rotationHint);
Sunny Goyal19ff7282021-04-22 10:12:54 -0700738 bounds.bounds.offsetTo(windowX, windowY);
Alex Chaue0227552022-04-06 19:44:43 +0100739 bounds.insets.set(mInsets);
Sunny Goyal65190ae2022-08-02 14:16:26 -0700740
741 SparseArray<DotRenderer> dotRendererCache = new SparseArray<>();
742 dotRendererCache.put(iconSizePx, mDotRendererWorkSpace);
743 dotRendererCache.put(allAppsIconSizePx, mDotRendererAllApps);
744
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700745 return new Builder(context, inv, mInfo)
Sunny Goyal19ff7282021-04-22 10:12:54 -0700746 .setWindowBounds(bounds)
Alex Chauab800f72022-12-13 17:46:06 +0000747 .setIsMultiDisplay(isMultiDisplay)
Alex Chau6ed408f2022-03-04 12:58:05 +0000748 .setMultiWindowMode(isMultiWindowMode)
Sunny Goyal65190ae2022-08-02 14:16:26 -0700749 .setDotRendererCache(dotRendererCache)
Alex Chau6ed408f2022-03-04 12:58:05 +0000750 .setGestureMode(isGestureMode);
Sunny Goyal1a52ef52018-01-11 10:15:03 -0800751 }
752
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700753 public DeviceProfile copy(Context context) {
754 return toBuilder(context).build();
755 }
756
757 /**
758 * TODO: Move this to the builder as part of setMultiWindowMode
759 */
Sunny Goyalb46703d2020-05-27 17:52:03 -0700760 public DeviceProfile getMultiWindowProfile(Context context, WindowBounds windowBounds) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700761 DeviceProfile profile = toBuilder(context)
Sunny Goyal19ff7282021-04-22 10:12:54 -0700762 .setWindowBounds(windowBounds)
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700763 .setMultiWindowMode(true)
764 .build();
Jon Miranda93e1f042016-11-11 14:13:04 -0800765
Jon Miranda7ae64ff2016-11-21 16:18:46 -0800766 // We use these scales to measure and layout the widgets using their full invariant profile
767 // sizes and then draw them scaled and centered to fit in their multi-window mode cellspans.
768 float appWidgetScaleX = (float) profile.getCellSize().x / getCellSize().x;
769 float appWidgetScaleY = (float) profile.getCellSize().y / getCellSize().y;
Sihua Mae04aa202022-07-18 12:43:56 -0700770 if (appWidgetScaleX != 1 || appWidgetScaleY != 1) {
771 final PointF p = new PointF(appWidgetScaleX, appWidgetScaleY);
772 profile = profile.toBuilder(context)
773 .setViewScaleProvider(i -> p)
774 .build();
775 }
776
777 profile.hideWorkspaceLabelsIfNotEnoughSpace();
Jon Miranda7ae64ff2016-11-21 16:18:46 -0800778
Jon Miranda93e1f042016-11-11 14:13:04 -0800779 return profile;
Jon Mirandacc42c5b2016-10-27 17:15:27 -0700780 }
781
Adam Cohen63f1ec02014-08-12 09:23:13 -0700782 /**
Jon Miranda941375e2021-03-31 13:10:45 -0400783 * Checks if there is enough space for labels on the workspace.
784 * If there is not, labels on the Workspace are hidden.
Jon Miranda1091e532017-07-21 13:31:50 -0700785 * It is important to call this method after the All Apps variables have been set.
786 */
Jon Miranda941375e2021-03-31 13:10:45 -0400787 private void hideWorkspaceLabelsIfNotEnoughSpace() {
788 float iconTextHeight = Utilities.calculateTextHeight(iconTextSizePx);
789 float workspaceCellPaddingY = getCellSize().y - iconSizePx - iconDrawablePaddingPx
790 - iconTextHeight;
791
792 // We want enough space so that the text is closer to its corresponding icon.
793 if (workspaceCellPaddingY < iconTextHeight) {
794 iconTextSizePx = 0;
795 iconDrawablePaddingPx = 0;
Jon Miranda92c1b5d2021-07-20 13:57:16 -0700796 cellHeightPx = (int) Math.ceil(iconSizePx * ICON_OVERLAP_FACTOR);
Jon Miranda941375e2021-03-31 13:10:45 -0400797 autoResizeAllAppsCells();
798 }
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700799 }
Jon Miranda1091e532017-07-21 13:31:50 -0700800
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700801 /**
802 * Re-computes the all-apps cell size to be independent of workspace
803 */
804 public void autoResizeAllAppsCells() {
Jon Miranda941375e2021-03-31 13:10:45 -0400805 int textHeight = Utilities.calculateTextHeight(allAppsIconTextSizePx);
806 int topBottomPadding = textHeight;
Jon Miranda1091e532017-07-21 13:31:50 -0700807 allAppsCellHeightPx = allAppsIconSizePx + allAppsIconDrawablePaddingPx
Jon Miranda941375e2021-03-31 13:10:45 -0400808 + textHeight + (topBottomPadding * 2);
Jon Miranda1091e532017-07-21 13:31:50 -0700809 }
810
Thales Limab7ef5692022-03-10 10:32:36 +0000811 private void updateAllAppsContainerWidth(Resources res) {
Pat Manning08610ca2022-04-05 21:03:16 +0100812 int cellLayoutHorizontalPadding =
813 (cellLayoutPaddingPx.left + cellLayoutPaddingPx.right) / 2;
Alex Chau27b39b92022-01-14 18:02:18 +0000814 if (isTablet) {
sfufa@google.comde013292021-09-21 18:22:44 -0700815 int usedWidth = (allAppsCellWidthPx * numShownAllAppsColumns)
Thales Limab7ef5692022-03-10 10:32:36 +0000816 + (allAppsBorderSpacePx.x * (numShownAllAppsColumns - 1))
Alex Chau27b39b92022-01-14 18:02:18 +0000817 + allAppsLeftRightPadding * 2;
818 allAppsLeftRightMargin = Math.max(1, (availableWidthPx - usedWidth) / 2);
sfufa@google.comde013292021-09-21 18:22:44 -0700819 } else {
820 allAppsLeftRightPadding =
Pat Manning08610ca2022-04-05 21:03:16 +0100821 desiredWorkspaceHorizontalMarginPx + cellLayoutHorizontalPadding;
sfufa@google.comde013292021-09-21 18:22:44 -0700822 }
823 }
824
Thales Limae9273ea2023-01-26 12:33:52 +0000825 private void setupAllAppsStyle(Context context) {
826 TypedArray allAppsStyle;
827 if (inv.allAppsStyle != INVALID_RESOURCE_HANDLE) {
828 allAppsStyle = context.obtainStyledAttributes(inv.allAppsStyle,
829 R.styleable.AllAppsStyle);
830 } else {
831 allAppsStyle = context.obtainStyledAttributes(R.style.AllAppsStyleDefault,
832 R.styleable.AllAppsStyle);
833 }
834 allAppsLeftRightPadding = allAppsStyle.getDimensionPixelSize(
835 R.styleable.AllAppsStyle_horizontalPadding, 0);
836 allAppsStyle.recycle();
837 }
838
Jon Miranda228877d2021-02-09 11:05:00 -0500839 /**
840 * Returns the amount of extra (or unused) vertical space.
841 */
842 private int updateAvailableDimensions(Resources res) {
Alex Chaua68164d2022-12-15 16:16:03 +0000843 float invIconSizeDp = inv.iconSize[mTypeIndex];
844 float invIconTextSizeSp = inv.iconTextSize[mTypeIndex];
845 iconSizePx = Math.max(1, pxFromDp(invIconSizeDp, mMetrics));
846 iconTextSizePx = pxFromSp(invIconTextSizeSp, mMetrics);
847
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700848 updateIconSize(1f, res);
Winson Chung59a488a2013-12-10 12:32:14 -0800849
Pat Manning08610ca2022-04-05 21:03:16 +0100850 updateWorkspacePadding();
Jon Mirandae126d722021-02-25 10:45:20 -0500851
852 // Check to see if the icons fit within the available height.
Pat Manninga2e14992022-04-22 11:29:17 +0100853 float usedHeight = getCellLayoutHeightSpecification();
Pat Manning25d53342022-05-10 09:58:49 +0000854 final int maxHeight = getCellLayoutHeight();
Jon Miranda228877d2021-02-09 11:05:00 -0500855 float extraHeight = Math.max(0, maxHeight - usedHeight);
Jon Mirandae126d722021-02-25 10:45:20 -0500856 float scaleY = maxHeight / usedHeight;
857 boolean shouldScale = scaleY < 1f;
858
859 float scaleX = 1f;
860 if (isScalableGrid) {
861 // We scale to fit the cellWidth and cellHeight in the available space.
862 // The benefit of scalable grids is that we can get consistent aspect ratios between
863 // devices.
Pat Manninga2e14992022-04-22 11:29:17 +0100864 float usedWidth =
865 getCellLayoutWidthSpecification() + (desiredWorkspaceHorizontalMarginPx * 2);
Jon Mirandae126d722021-02-25 10:45:20 -0500866 // We do not subtract padding here, as we also scale the workspace padding if needed.
867 scaleX = availableWidthPx / usedWidth;
868 shouldScale = true;
Winson Chungb3800242013-10-24 11:01:54 -0700869 }
Jon Mirandae126d722021-02-25 10:45:20 -0500870
871 if (shouldScale) {
872 float scale = Math.min(scaleX, scaleY);
873 updateIconSize(scale, res);
Pat Manninga2e14992022-04-22 11:29:17 +0100874 extraHeight = Math.max(0, maxHeight - getCellLayoutHeightSpecification());
Jon Mirandae126d722021-02-25 10:45:20 -0500875 }
876
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700877 updateAvailableFolderCellDimensions(res);
Jon Miranda228877d2021-02-09 11:05:00 -0500878 return Math.round(extraHeight);
Winson Chungb3800242013-10-24 11:01:54 -0700879 }
880
Pat Manninga2e14992022-04-22 11:29:17 +0100881 private int getCellLayoutHeightSpecification() {
Pat Manning08610ca2022-04-05 21:03:16 +0100882 return (cellHeightPx * inv.numRows) + (cellLayoutBorderSpacePx.y * (inv.numRows - 1))
883 + cellLayoutPaddingPx.top + cellLayoutPaddingPx.bottom;
884 }
885
Pat Manninga2e14992022-04-22 11:29:17 +0100886 private int getCellLayoutWidthSpecification() {
Pat Manning25d53342022-05-10 09:58:49 +0000887 int numColumns = getPanelCount() * inv.numColumns;
Pat Manning08610ca2022-04-05 21:03:16 +0100888 return (cellWidthPx * numColumns) + (cellLayoutBorderSpacePx.x * (numColumns - 1))
889 + cellLayoutPaddingPx.left + cellLayoutPaddingPx.right;
Jon Mirandae126d722021-02-25 10:45:20 -0500890 }
891
Jon Miranda6f7e9702019-09-16 14:44:14 -0700892 /**
893 * Updating the iconSize affects many aspects of the launcher layout, such as: iconSizePx,
894 * iconTextSizePx, iconDrawablePaddingPx, cellWidth/Height, allApps* variants,
895 * hotseat sizes, workspaceSpringLoadedShrinkFactor, folderIconSizePx, and folderIconOffsetYPx.
896 */
Tony Wickham7ba547c2021-02-02 17:12:08 -0800897 public void updateIconSize(float scale, Resources res) {
Jon Mirandaab3c6812021-06-28 15:42:28 -0700898 // Icon scale should never exceed 1, otherwise pixellation may occur.
899 iconScale = Math.min(1f, scale);
900 cellScaleToFit = scale;
901
Jon Miranda18751b62017-07-31 17:25:27 -0700902 // Workspace
Sunny Goyal07b69292018-01-08 14:19:34 -0800903 final boolean isVerticalLayout = isVerticalBarLayout();
Jon Mirandaab3c6812021-06-28 15:42:28 -0700904 iconDrawablePaddingPx = (int) (iconDrawablePaddingOriginalPx * iconScale);
Thales Lima080d8902022-03-28 15:30:29 +0100905 cellLayoutBorderSpacePx = getCellLayoutBorderSpace(inv, scale);
Jon Mirandae126d722021-02-25 10:45:20 -0500906
907 if (isScalableGrid) {
Thales Lima83bedbf2021-10-05 17:47:39 +0100908 cellWidthPx = pxFromDp(inv.minCellSize[mTypeIndex].x, mMetrics, scale);
909 cellHeightPx = pxFromDp(inv.minCellSize[mTypeIndex].y, mMetrics, scale);
Alex Chaube753132022-12-09 16:46:54 +0000910
911 if (cellWidthPx < iconSizePx) {
912 // If cellWidth no longer fit iconSize, reduce borderSpace to make cellWidth bigger.
913 int numColumns = getPanelCount() * inv.numColumns;
914 int numBorders = numColumns - 1;
915 int extraWidthRequired = (iconSizePx - cellWidthPx) * numColumns;
916 if (cellLayoutBorderSpacePx.x * numBorders >= extraWidthRequired) {
917 cellWidthPx = iconSizePx;
918 cellLayoutBorderSpacePx.x -= extraWidthRequired / numBorders;
919 } else {
920 // If it still doesn't fit, set borderSpace to 0 and distribute the space for
921 // cellWidth, and reduce iconSize.
922 cellWidthPx = (cellWidthPx * numColumns
923 + cellLayoutBorderSpacePx.x * numBorders) / numColumns;
924 iconSizePx = Math.min(iconSizePx, cellWidthPx);
925 cellLayoutBorderSpacePx.x = 0;
926 }
927 }
928
929 int cellTextAndPaddingHeight =
930 iconDrawablePaddingPx + Utilities.calculateTextHeight(iconTextSizePx);
931 int cellContentHeight = iconSizePx + cellTextAndPaddingHeight;
932 if (cellHeightPx < cellContentHeight) {
933 // If cellHeight no longer fit iconSize, reduce borderSpace to make cellHeight
934 // bigger.
935 int numBorders = inv.numRows - 1;
936 int extraHeightRequired = (cellContentHeight - cellHeightPx) * inv.numRows;
937 if (cellLayoutBorderSpacePx.y * numBorders >= extraHeightRequired) {
938 cellHeightPx = cellContentHeight;
939 cellLayoutBorderSpacePx.y -= extraHeightRequired / numBorders;
940 } else {
Alex Chau06f36e82023-01-06 10:50:54 +0000941 // If it still doesn't fit, set borderSpace to 0 to recover space.
Alex Chaube753132022-12-09 16:46:54 +0000942 cellHeightPx = (cellHeightPx * inv.numRows
943 + cellLayoutBorderSpacePx.y * numBorders) / inv.numRows;
Alex Chaube753132022-12-09 16:46:54 +0000944 cellLayoutBorderSpacePx.y = 0;
Alex Chau06f36e82023-01-06 10:50:54 +0000945 // Reduce iconDrawablePaddingPx to make cellContentHeight smaller.
946 int cellContentWithoutPadding = cellContentHeight - iconDrawablePaddingPx;
947 if (cellContentWithoutPadding <= cellHeightPx) {
948 iconDrawablePaddingPx = cellContentHeight - cellHeightPx;
949 } else {
950 // If it still doesn't fit, set iconDrawablePaddingPx to 0 to recover space,
951 // then proportional reduce iconSizePx and iconTextSizePx to fit.
952 iconDrawablePaddingPx = 0;
953 float ratio = cellHeightPx / (float) cellContentWithoutPadding;
954 iconSizePx = (int) (iconSizePx * ratio);
955 iconTextSizePx = (int) (iconTextSizePx * ratio);
956 }
957 cellTextAndPaddingHeight =
958 iconDrawablePaddingPx + Utilities.calculateTextHeight(iconTextSizePx);
Alex Chaube753132022-12-09 16:46:54 +0000959 }
960 cellContentHeight = iconSizePx + cellTextAndPaddingHeight;
961 }
Jon Mirandae126d722021-02-25 10:45:20 -0500962 cellYPaddingPx = Math.max(0, cellHeightPx - cellContentHeight) / 2;
Thales Limad90faab2021-09-21 17:18:47 +0100963 desiredWorkspaceHorizontalMarginPx =
964 (int) (desiredWorkspaceHorizontalMarginOriginalPx * scale);
Jon Miranda228877d2021-02-09 11:05:00 -0500965 } else {
Jon Mirandae126d722021-02-25 10:45:20 -0500966 cellWidthPx = iconSizePx + iconDrawablePaddingPx;
Jon Miranda92c1b5d2021-07-20 13:57:16 -0700967 cellHeightPx = (int) Math.ceil(iconSizePx * ICON_OVERLAP_FACTOR)
968 + iconDrawablePaddingPx
Jon Miranda228877d2021-02-09 11:05:00 -0500969 + Utilities.calculateTextHeight(iconTextSizePx);
970 int cellPaddingY = (getCellSize().y - cellHeightPx) / 2;
971 if (iconDrawablePaddingPx > cellPaddingY && !isVerticalLayout
972 && !isMultiWindowMode) {
973 // Ensures that the label is closer to its corresponding icon. This is not an issue
974 // with vertical bar layout or multi-window mode since the issue is handled
975 // separately with their calls to {@link #adjustToHideWorkspaceLabels}.
976 cellHeightPx -= (iconDrawablePaddingPx - cellPaddingY);
977 iconDrawablePaddingPx = cellPaddingY;
978 }
Jon Miranda846455e2017-10-02 14:58:52 -0700979 }
Jon Miranda18751b62017-07-31 17:25:27 -0700980
Sunny Goyalae190ff2020-04-14 00:19:01 +0000981 // All apps
Brian Isganitis25b2ac82022-01-28 16:25:13 -0500982 updateAllAppsIconSize(scale, res);
Winson Chungb3800242013-10-24 11:01:54 -0700983
Thales Limab8c05952022-05-23 16:58:38 +0100984 updateHotseatSizes(iconSizePx);
Winson Chungb3800242013-10-24 11:01:54 -0700985
Sunny Goyalbaec6ff2016-09-14 11:26:21 -0700986 // Folder icon
Jon Miranda591e3602018-03-28 11:37:00 -0700987 folderIconSizePx = IconNormalizer.getNormalizedCircleSize(iconSizePx);
988 folderIconOffsetYPx = (iconSizePx - folderIconSizePx) / 2;
Winson Chung0f785722015-04-08 10:27:49 -0700989 }
990
Thales Lima425f6822022-05-10 13:44:58 -0300991 /**
Thales Lima6a590062022-11-22 15:52:49 +0000992 * This method calculates the space between the icons to achieve a certain width.
Thales Lima425f6822022-05-10 13:44:58 -0300993 */
Thales Lima6a590062022-11-22 15:52:49 +0000994 private int calculateHotseatBorderSpace(float hotseatWidthPx, int numExtraBorder) {
Thales Lima9938c2f2022-07-25 14:38:16 +0100995 float hotseatIconsTotalPx = iconSizePx * numShownHotseatIcons;
Thales Lima6a590062022-11-22 15:52:49 +0000996 int hotseatBorderSpace =
997 (int) (hotseatWidthPx - hotseatIconsTotalPx)
998 / (numShownHotseatIcons - 1 + numExtraBorder);
999 return Math.min(hotseatBorderSpace, maxHotseatIconSpacePx);
Thales Lima425f6822022-05-10 13:44:58 -03001000 }
1001
Brian Isganitis25b2ac82022-01-28 16:25:13 -05001002
1003 /**
1004 * Updates the iconSize for allApps* variants.
1005 */
Brian Isganitisa9a78112022-05-23 18:11:47 -07001006 private void updateAllAppsIconSize(float scale, Resources res) {
Thales Lima080d8902022-03-28 15:30:29 +01001007 allAppsBorderSpacePx = new Point(
1008 pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].x, mMetrics, scale),
1009 pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].y, mMetrics, scale));
Brandon Dayauon07ca8842022-04-27 10:52:28 -07001010 // AllApps cells don't have real space between cells,
1011 // so we add the border space to the cell height
Alex Chaube753132022-12-09 16:46:54 +00001012 allAppsCellHeightPx = pxFromDp(inv.allAppsCellSize[mTypeIndex].y, mMetrics)
Brandon Dayauon07ca8842022-04-27 10:52:28 -07001013 + allAppsBorderSpacePx.y;
1014 // but width is just the cell,
1015 // the border is added in #updateAllAppsContainerWidth
Thales Lima080d8902022-03-28 15:30:29 +01001016 if (isScalableGrid) {
Alex Chaube753132022-12-09 16:46:54 +00001017 allAppsIconSizePx = pxFromDp(inv.allAppsIconSize[mTypeIndex], mMetrics);
1018 allAppsIconTextSizePx = pxFromSp(inv.allAppsIconTextSize[mTypeIndex], mMetrics);
Brian Isganitis25b2ac82022-01-28 16:25:13 -05001019 allAppsIconDrawablePaddingPx = iconDrawablePaddingOriginalPx;
Brandon Dayauon7a8a9ed2022-06-06 14:32:22 -07001020 allAppsCellWidthPx = pxFromDp(inv.allAppsCellSize[mTypeIndex].x, mMetrics, scale);
Alex Chaube753132022-12-09 16:46:54 +00001021
1022 if (allAppsCellWidthPx < allAppsIconSizePx) {
1023 // If allAppsCellWidth no longer fit allAppsIconSize, reduce allAppsBorderSpace to
1024 // make allAppsCellWidth bigger.
1025 int numBorders = inv.numAllAppsColumns - 1;
1026 int extraWidthRequired =
1027 (allAppsIconSizePx - allAppsCellWidthPx) * inv.numAllAppsColumns;
1028 if (allAppsBorderSpacePx.x * numBorders >= extraWidthRequired) {
1029 allAppsCellWidthPx = allAppsIconSizePx;
1030 allAppsBorderSpacePx.x -= extraWidthRequired / numBorders;
1031 } else {
1032 // If it still doesn't fit, set allAppsBorderSpace to 0 and distribute the space
1033 // for allAppsCellWidth, and reduce allAppsIconSize.
1034 allAppsCellWidthPx = (allAppsCellWidthPx * inv.numAllAppsColumns
1035 + allAppsBorderSpacePx.x * numBorders) / inv.numAllAppsColumns;
1036 allAppsIconSizePx = Math.min(allAppsIconSizePx, allAppsCellWidthPx);
1037 allAppsBorderSpacePx.x = 0;
1038 }
1039 }
1040
1041 int cellContentHeight = allAppsIconSizePx
1042 + Utilities.calculateTextHeight(allAppsIconTextSizePx) + allAppsBorderSpacePx.y;
1043 if (allAppsCellHeightPx < cellContentHeight) {
1044 // Increase allAppsCellHeight to fit its content.
1045 allAppsCellHeightPx = cellContentHeight;
1046 }
Brian Isganitis25b2ac82022-01-28 16:25:13 -05001047 } else {
Brandon Dayauon07ca8842022-04-27 10:52:28 -07001048 float invIconSizeDp = inv.allAppsIconSize[mTypeIndex];
1049 float invIconTextSizeSp = inv.allAppsIconTextSize[mTypeIndex];
Brian Isganitis25b2ac82022-01-28 16:25:13 -05001050 allAppsIconSizePx = Math.max(1, pxFromDp(invIconSizeDp, mMetrics, scale));
1051 allAppsIconTextSizePx = (int) (pxFromSp(invIconTextSizeSp, mMetrics) * scale);
Brandon Dayauon07ca8842022-04-27 10:52:28 -07001052 allAppsIconDrawablePaddingPx =
1053 res.getDimensionPixelSize(R.dimen.all_apps_icon_drawable_padding);
Brandon Dayauon7a8a9ed2022-06-06 14:32:22 -07001054 allAppsCellWidthPx = allAppsIconSizePx + (2 * allAppsIconDrawablePaddingPx);
Brian Isganitis25b2ac82022-01-28 16:25:13 -05001055 }
1056
Thales Limab7ef5692022-03-10 10:32:36 +00001057 updateAllAppsContainerWidth(res);
Brian Isganitis25b2ac82022-01-28 16:25:13 -05001058 if (isVerticalBarLayout()) {
1059 hideWorkspaceLabelsIfNotEnoughSpace();
1060 }
1061 }
1062
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001063 private void updateAvailableFolderCellDimensions(Resources res) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001064 updateFolderCellSize(1f, res);
Jon Mirandabf7d8122016-11-03 15:29:29 -07001065
Jon Mirandac1b23992016-12-13 08:57:36 -08001066 // Don't let the folder get too close to the edges of the screen.
Jon Miranda1786df32018-09-25 13:05:23 -07001067 int folderMargin = edgeMarginPx * 2;
Sunny Goyal07b69292018-01-08 14:19:34 -08001068 Point totalWorkspacePadding = getTotalWorkspacePadding();
Jon Mirandac1b23992016-12-13 08:57:36 -08001069
1070 // Check if the icons fit within the available height.
Jon Miranda228877d2021-02-09 11:05:00 -05001071 float contentUsedHeight = folderCellHeightPx * inv.numFolderRows
Thales Limab35faed2022-09-05 16:30:01 -03001072 + ((inv.numFolderRows - 1) * folderCellLayoutBorderSpacePx);
1073 int contentMaxHeight = availableHeightPx - totalWorkspacePadding.y - folderFooterHeightPx
Jon Mirandae126d722021-02-25 10:45:20 -05001074 - folderMargin - folderContentPaddingTop;
Samuel Fufa1c8d90a2019-11-12 17:54:58 -08001075 float scaleY = contentMaxHeight / contentUsedHeight;
Jon Mirandac1b23992016-12-13 08:57:36 -08001076
1077 // Check if the icons fit within the available width.
Jon Miranda228877d2021-02-09 11:05:00 -05001078 float contentUsedWidth = folderCellWidthPx * inv.numFolderColumns
Thales Limab35faed2022-09-05 16:30:01 -03001079 + ((inv.numFolderColumns - 1) * folderCellLayoutBorderSpacePx);
Jon Mirandae126d722021-02-25 10:45:20 -05001080 int contentMaxWidth = availableWidthPx - totalWorkspacePadding.x - folderMargin
1081 - folderContentPaddingLeftRight * 2;
Samuel Fufa1c8d90a2019-11-12 17:54:58 -08001082 float scaleX = contentMaxWidth / contentUsedWidth;
Jon Mirandac1b23992016-12-13 08:57:36 -08001083
1084 float scale = Math.min(scaleX, scaleY);
1085 if (scale < 1f) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001086 updateFolderCellSize(scale, res);
Jon Mirandabf7d8122016-11-03 15:29:29 -07001087 }
1088 }
1089
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001090 private void updateFolderCellSize(float scale, Resources res) {
Alex Chau0d4f1ac2022-12-20 12:31:14 +00001091 float invIconSizeDp = inv.iconSize[mTypeIndex];
Sunny Goyal35c7b192021-04-20 16:51:10 -07001092 folderChildIconSizePx = Math.max(1, pxFromDp(invIconSizeDp, mMetrics, scale));
Alex Chau0d4f1ac2022-12-20 12:31:14 +00001093 folderChildTextSizePx = pxFromSp(inv.iconTextSize[mTypeIndex], mMetrics, scale);
Thales Limab35faed2022-09-05 16:30:01 -03001094 folderLabelTextSizePx = Math.max(pxFromSp(MIN_FOLDER_TEXT_SIZE_SP, mMetrics),
1095 (int) (folderChildTextSizePx * folderLabelTextScale));
Jon Mirandabf7d8122016-11-03 15:29:29 -07001096
1097 int textHeight = Utilities.calculateTextHeight(folderChildTextSizePx);
Jon Mirandabf7d8122016-11-03 15:29:29 -07001098
Jon Miranda823da222021-03-23 08:08:45 -04001099 if (isScalableGrid) {
Thales Limab35faed2022-09-05 16:30:01 -03001100 if (inv.folderStyle == INVALID_RESOURCE_HANDLE) {
1101 folderCellWidthPx = pxFromDp(getCellSize().x, mMetrics, scale);
1102 folderCellHeightPx = pxFromDp(getCellSize().y, mMetrics, scale);
1103 }
Jon Mirandaf33f5b32021-07-22 17:15:31 -07001104
Thales Limab35faed2022-09-05 16:30:01 -03001105 folderContentPaddingLeftRight = folderCellLayoutBorderSpacePx;
Jon Miranda823da222021-03-23 08:08:45 -04001106 } else {
1107 int cellPaddingX = (int) (res.getDimensionPixelSize(R.dimen.folder_cell_x_padding)
1108 * scale);
1109 int cellPaddingY = (int) (res.getDimensionPixelSize(R.dimen.folder_cell_y_padding)
1110 * scale);
1111
1112 folderCellWidthPx = folderChildIconSizePx + 2 * cellPaddingX;
1113 folderCellHeightPx = folderChildIconSizePx + 2 * cellPaddingY + textHeight;
Thales Limab35faed2022-09-05 16:30:01 -03001114 folderContentPaddingLeftRight =
1115 res.getDimensionPixelSize(R.dimen.folder_content_padding_left_right);
1116 folderFooterHeightPx =
1117 res.getDimensionPixelSize(R.dimen.folder_footer_height_default);
Jon Miranda823da222021-03-23 08:08:45 -04001118 }
1119
Jonathan Miranda9ad87462017-07-26 17:41:02 +00001120 folderChildDrawablePaddingPx = Math.max(0,
1121 (folderCellHeightPx - folderChildIconSizePx - textHeight) / 3);
Jon Mirandabf7d8122016-11-03 15:29:29 -07001122 }
1123
Winson1f064272016-07-18 17:18:02 -07001124 public void updateInsets(Rect insets) {
1125 mInsets.set(insets);
1126 }
1127
Sunny Goyalae6e3182019-04-30 12:04:37 -07001128 /**
1129 * The current device insets. This is generally same as the insets being dispatched to
1130 * {@link Insettable} elements, but can differ if the element is using a different profile.
1131 */
Sunny Goyal1a52ef52018-01-11 10:15:03 -08001132 public Rect getInsets() {
1133 return mInsets;
1134 }
1135
Sunny Goyal756cd262015-08-20 12:33:21 -07001136 public Point getCellSize() {
Sunny Goyal19ff7282021-04-22 10:12:54 -07001137 return getCellSize(null);
Jon Miranda6f7e9702019-09-16 14:44:14 -07001138 }
1139
Sunny Goyal19ff7282021-04-22 10:12:54 -07001140 public Point getCellSize(Point result) {
1141 if (result == null) {
1142 result = new Point();
1143 }
Thales Limad1df5fc2021-09-03 18:37:19 +01001144
Pat Manning25d53342022-05-10 09:58:49 +00001145 int shortcutAndWidgetContainerWidth =
1146 getCellLayoutWidth() - (cellLayoutPaddingPx.left + cellLayoutPaddingPx.right);
1147 result.x = calculateCellWidth(shortcutAndWidgetContainerWidth, cellLayoutBorderSpacePx.x,
1148 inv.numColumns);
1149 int shortcutAndWidgetContainerHeight =
1150 getCellLayoutHeight() - (cellLayoutPaddingPx.top + cellLayoutPaddingPx.bottom);
1151 result.y = calculateCellHeight(shortcutAndWidgetContainerHeight, cellLayoutBorderSpacePx.y,
1152 inv.numRows);
Sunny Goyal3e8a04b2022-05-09 19:31:45 +00001153 return result;
Pat Manningb45d6c42022-05-03 14:32:06 +01001154 }
1155
1156 /**
Thales Lima1e8b45f2022-08-25 11:50:59 -04001157 * Returns the left and right space on the cell, which is the cell width - icon size
1158 */
1159 public int getCellHorizontalSpace() {
1160 return getCellSize().x - iconSizePx;
1161 }
1162
1163 /**
Pat Manning25d53342022-05-10 09:58:49 +00001164 * Gets the number of panels within the workspace.
1165 */
1166 public int getPanelCount() {
1167 return isTwoPanels ? 2 : 1;
1168 }
1169
1170 /**
Pat Manningde25c0d2022-04-05 19:11:26 +01001171 * Gets the space in px from the bottom of last item in the vertical-bar hotseat to the
1172 * bottom of the screen.
1173 */
Pat Manning5f74bfd2022-07-20 12:08:54 +01001174 private int getVerticalHotseatLastItemBottomOffset(Context context) {
1175 Rect hotseatBarPadding = getHotseatLayoutPadding(context);
Pat Manningde25c0d2022-04-05 19:11:26 +01001176 int cellHeight = calculateCellHeight(
Pat Manning5f74bfd2022-07-20 12:08:54 +01001177 heightPx - hotseatBarPadding.top - hotseatBarPadding.bottom, hotseatBorderSpace,
Pat Manningde25c0d2022-04-05 19:11:26 +01001178 numShownHotseatIcons);
Pat Manningde25c0d2022-04-05 19:11:26 +01001179 int extraIconEndSpacing = (cellHeight - iconSizePx) / 2;
Pat Manning5f74bfd2022-07-20 12:08:54 +01001180 return extraIconEndSpacing + hotseatBarPadding.bottom;
Pat Manningde25c0d2022-04-05 19:11:26 +01001181 }
1182
1183 /**
1184 * Gets the scaled top of the workspace in px for the spring-loaded edit state.
1185 */
Pat Manning25d53342022-05-10 09:58:49 +00001186 public float getCellLayoutSpringLoadShrunkTop() {
Pat Manning5f74bfd2022-07-20 12:08:54 +01001187 return mInsets.top + dropTargetBarTopMarginPx + dropTargetBarSizePx
Pat Manningde25c0d2022-04-05 19:11:26 +01001188 + dropTargetBarBottomMarginPx;
Pat Manningde25c0d2022-04-05 19:11:26 +01001189 }
1190
1191 /**
1192 * Gets the scaled bottom of the workspace in px for the spring-loaded edit state.
1193 */
Pat Manning5f74bfd2022-07-20 12:08:54 +01001194 public float getCellLayoutSpringLoadShrunkBottom(Context context) {
Pat Manningde25c0d2022-04-05 19:11:26 +01001195 int topOfHotseat = hotseatBarSizePx + springLoadedHotseatBarTopMarginPx;
Pat Manning5f74bfd2022-07-20 12:08:54 +01001196 return heightPx - (isVerticalBarLayout()
1197 ? getVerticalHotseatLastItemBottomOffset(context) : topOfHotseat);
Pat Manningde25c0d2022-04-05 19:11:26 +01001198 }
1199
Pat Manningea5c1d22022-04-14 10:58:16 +01001200 /**
Pat Manninga2e14992022-04-22 11:29:17 +01001201 * Gets the scale of the workspace for the spring-loaded edit state.
1202 */
Pat Manning5f74bfd2022-07-20 12:08:54 +01001203 public float getWorkspaceSpringLoadScale(Context context) {
1204 float scale =
1205 (getCellLayoutSpringLoadShrunkBottom(context) - getCellLayoutSpringLoadShrunkTop())
1206 / getCellLayoutHeight();
Pat Manninga2e14992022-04-22 11:29:17 +01001207 scale = Math.min(scale, 1f);
1208
Pat Manninge63dd252022-08-02 16:15:29 +01001209 // Reduce scale if next pages would not be visible after scaling the workspace.
Pat Manning25d53342022-05-10 09:58:49 +00001210 int workspaceWidth = availableWidthPx;
Pat Manninga2e14992022-04-22 11:29:17 +01001211 float scaledWorkspaceWidth = workspaceWidth * scale;
Alex Chau906d8822022-05-23 10:42:25 +01001212 float maxAvailableWidth = workspaceWidth - (2 * workspaceSpringLoadedMinNextPageVisiblePx);
Pat Manninga2e14992022-04-22 11:29:17 +01001213 if (scaledWorkspaceWidth > maxAvailableWidth) {
1214 scale *= maxAvailableWidth / scaledWorkspaceWidth;
1215 }
1216 return scale;
1217 }
1218
Pat Manning25d53342022-05-10 09:58:49 +00001219 /**
1220 * Gets the width of a single Cell Layout, aka a single panel within a Workspace.
1221 *
1222 * <p>This is the width of a Workspace, less its horizontal padding. Note that two-panel
1223 * layouts have two Cell Layouts per workspace.
1224 */
1225 public int getCellLayoutWidth() {
1226 return (availableWidthPx - getTotalWorkspacePadding().x) / getPanelCount();
Alex Chau60953332021-11-24 12:41:07 +00001227 }
1228
Pat Manning25d53342022-05-10 09:58:49 +00001229 /**
1230 * Gets the height of a single Cell Layout, aka a single panel within a Workspace.
1231 *
1232 * <p>This is the height of a Workspace, less its vertical padding.
1233 */
1234 public int getCellLayoutHeight() {
1235 return availableHeightPx - getTotalWorkspacePadding().y;
Pat Manning08610ca2022-04-05 21:03:16 +01001236 }
1237
Sunny Goyal6c2975e2016-07-06 09:47:56 -07001238 public Point getTotalWorkspacePadding() {
Sunny Goyal07b69292018-01-08 14:19:34 -08001239 return new Point(workspacePadding.left + workspacePadding.right,
1240 workspacePadding.top + workspacePadding.bottom);
Sunny Goyal6c2975e2016-07-06 09:47:56 -07001241 }
1242
1243 /**
Sunny Goyal07b69292018-01-08 14:19:34 -08001244 * Updates {@link #workspacePadding} as a result of any internal value change to reflect the
1245 * new workspace padding
Sunny Goyal6c2975e2016-07-06 09:47:56 -07001246 */
Sunny Goyal07b69292018-01-08 14:19:34 -08001247 private void updateWorkspacePadding() {
1248 Rect padding = workspacePadding;
Tony Wickham3a3517f2015-10-06 11:27:04 -07001249 if (isVerticalBarLayout()) {
Sunny Goyal228153d2018-01-04 15:35:22 -08001250 padding.top = 0;
1251 padding.bottom = edgeMarginPx;
Sunny Goyal7e2e67f2018-01-26 13:40:08 -08001252 if (isSeascape()) {
Tony Wickham1eeffbe2018-06-12 15:01:15 -07001253 padding.left = hotseatBarSizePx;
Tony Wickham5edf9e22020-03-27 20:06:52 -07001254 padding.right = hotseatBarSidePaddingStartPx;
Winson1f064272016-07-18 17:18:02 -07001255 } else {
Tony Wickham5edf9e22020-03-27 20:06:52 -07001256 padding.left = hotseatBarSidePaddingStartPx;
Tony Wickham1eeffbe2018-06-12 15:01:15 -07001257 padding.right = hotseatBarSizePx;
Winson1f064272016-07-18 17:18:02 -07001258 }
Winson Chungb3800242013-10-24 11:01:54 -07001259 } else {
Thales Limab8c05952022-05-23 16:58:38 +01001260 // Pad the bottom of the workspace with hotseat bar
1261 // and leave a bit of space in case a widget go all the way down
1262 int paddingBottom = hotseatBarSizePx + workspaceBottomPadding
1263 + workspacePageIndicatorHeight - mWorkspacePageIndicatorOverlapWorkspace
1264 - mInsets.bottom;
Pat Manning08610ca2022-04-05 21:03:16 +01001265 int paddingTop = workspaceTopPadding + (isScalableGrid ? 0 : edgeMarginPx);
1266 int paddingSide = desiredWorkspaceHorizontalMarginPx;
Andras Kloczl8e57cce2021-02-11 23:51:19 +01001267
Pat Manning08610ca2022-04-05 21:03:16 +01001268 padding.set(paddingSide, paddingTop, paddingSide, paddingBottom);
Winson Chungb3800242013-10-24 11:01:54 -07001269 }
Pat Manning08610ca2022-04-05 21:03:16 +01001270 insetPadding(workspacePadding, cellLayoutPaddingPx);
1271 }
1272
1273 private void insetPadding(Rect paddings, Rect insets) {
1274 insets.left = Math.min(insets.left, paddings.left);
1275 paddings.left -= insets.left;
1276
1277 insets.top = Math.min(insets.top, paddings.top);
1278 paddings.top -= insets.top;
1279
1280 insets.right = Math.min(insets.right, paddings.right);
1281 paddings.right -= insets.right;
1282
1283 insets.bottom = Math.min(insets.bottom, paddings.bottom);
1284 paddings.bottom -= insets.bottom;
Winson Chungb3800242013-10-24 11:01:54 -07001285 }
1286
Sunny Goyal57b22792021-05-25 14:35:01 -07001287 /**
1288 * Returns the padding for hotseat view
1289 */
1290 public Rect getHotseatLayoutPadding(Context context) {
Pat Manning5f74bfd2022-07-20 12:08:54 +01001291 Rect hotseatBarPadding = new Rect();
Sunny Goyal81b4c7b2018-03-26 12:10:31 -07001292 if (isVerticalBarLayout()) {
Sihua Ma38bb3b02022-03-21 22:20:14 -07001293 // The hotseat icons will be placed in the middle of the hotseat cells.
1294 // Changing the hotseatCellHeightPx is not affecting hotseat icon positions
1295 // in vertical bar layout.
1296 // Workspace icons are moved up by a small factor. The variable diffOverlapFactor
1297 // is set to account for that difference.
1298 float diffOverlapFactor = iconSizePx * (ICON_OVERLAP_FACTOR - 1) / 2;
Pat Manning08610ca2022-04-05 21:03:16 +01001299 int paddingTop = Math.max((int) (mInsets.top + cellLayoutPaddingPx.top
1300 - diffOverlapFactor), 0);
1301 int paddingBottom = Math.max((int) (mInsets.bottom + cellLayoutPaddingPx.bottom
Sihua Ma38bb3b02022-03-21 22:20:14 -07001302 + diffOverlapFactor), 0);
1303
Sunny Goyal81b4c7b2018-03-26 12:10:31 -07001304 if (isSeascape()) {
Pat Manning5f74bfd2022-07-20 12:08:54 +01001305 hotseatBarPadding.set(mInsets.left + hotseatBarSidePaddingStartPx, paddingTop,
Pat Manning08610ca2022-04-05 21:03:16 +01001306 hotseatBarSidePaddingEndPx, paddingBottom);
Sunny Goyal81b4c7b2018-03-26 12:10:31 -07001307 } else {
Pat Manning5f74bfd2022-07-20 12:08:54 +01001308 hotseatBarPadding.set(hotseatBarSidePaddingEndPx, paddingTop,
Pat Manning08610ca2022-04-05 21:03:16 +01001309 mInsets.right + hotseatBarSidePaddingStartPx, paddingBottom);
Sunny Goyal81b4c7b2018-03-26 12:10:31 -07001310 }
Sunny Goyal57b22792021-05-25 14:35:01 -07001311 } else if (isTaskbarPresent) {
Alex Chau51da2192022-05-20 13:32:10 +01001312 // Center the QSB vertically with hotseat
Thales Limab8c05952022-05-23 16:58:38 +01001313 int hotseatBarBottomPadding = getHotseatBarBottomPadding();
1314 int hotseatBarTopPadding =
1315 hotseatBarSizePx - hotseatBarBottomPadding - hotseatCellHeightPx;
Alex Chau51da2192022-05-20 13:32:10 +01001316
Thales Lima6a590062022-11-22 15:52:49 +00001317 int hotseatWidth = getHotseatRequiredWidth();
1318 int leftSpacing = (availableWidthPx - hotseatWidth) / 2;
1319 int rightSpacing = leftSpacing;
1320 // Hotseat aligns to the left with nav buttons
1321 if (hotseatBarEndOffset > 0) {
1322 leftSpacing = inlineNavButtonsEndSpacing;
1323 rightSpacing = availableWidthPx - hotseatWidth - leftSpacing + hotseatBorderSpace;
1324 }
Thales Lima612230d2022-03-31 18:04:37 +01001325
Thales Lima6a590062022-11-22 15:52:49 +00001326 hotseatBarPadding.set(leftSpacing, hotseatBarTopPadding, rightSpacing,
Thales Limab8c05952022-05-23 16:58:38 +01001327 hotseatBarBottomPadding);
Alex Chau51da2192022-05-20 13:32:10 +01001328
1329 boolean isRtl = Utilities.isRtl(context.getResources());
Thales Lima612230d2022-03-31 18:04:37 +01001330 if (isRtl) {
Thales Lima9938c2f2022-07-25 14:38:16 +01001331 hotseatBarPadding.right += getAdditionalQsbSpace();
Thales Lima612230d2022-03-31 18:04:37 +01001332 } else {
Thales Lima9938c2f2022-07-25 14:38:16 +01001333 hotseatBarPadding.left += getAdditionalQsbSpace();
Thales Lima612230d2022-03-31 18:04:37 +01001334 }
Thales Lima425f6822022-05-10 13:44:58 -03001335 } else if (isScalableGrid) {
Alex Chau206ede92022-08-01 17:46:12 +01001336 int sideSpacing = (availableWidthPx - hotseatQsbWidth) / 2;
Pat Manning5f74bfd2022-07-20 12:08:54 +01001337 hotseatBarPadding.set(sideSpacing,
Thales Limab8c05952022-05-23 16:58:38 +01001338 0,
Thales Lima425f6822022-05-10 13:44:58 -03001339 sideSpacing,
Thales Limab8c05952022-05-23 16:58:38 +01001340 getHotseatBarBottomPadding());
Sunny Goyal81b4c7b2018-03-26 12:10:31 -07001341 } else {
Sunny Goyal81b4c7b2018-03-26 12:10:31 -07001342 // We want the edges of the hotseat to line up with the edges of the workspace, but the
1343 // icons in the hotseat are a different size, and so don't line up perfectly. To account
1344 // for this, we pad the left and right of the hotseat with half of the difference of a
1345 // workspace cell vs a hotseat cell.
1346 float workspaceCellWidth = (float) widthPx / inv.numColumns;
Sunny Goyal19ff7282021-04-22 10:12:54 -07001347 float hotseatCellWidth = (float) widthPx / numShownHotseatIcons;
Sunny Goyal81b4c7b2018-03-26 12:10:31 -07001348 int hotseatAdjustment = Math.round((workspaceCellWidth - hotseatCellWidth) / 2);
Pat Manning5f74bfd2022-07-20 12:08:54 +01001349 hotseatBarPadding.set(
Thales Limab8c05952022-05-23 16:58:38 +01001350 hotseatAdjustment + workspacePadding.left + cellLayoutPaddingPx.left
1351 + mInsets.left,
1352 0,
Pat Manning08610ca2022-04-05 21:03:16 +01001353 hotseatAdjustment + workspacePadding.right + cellLayoutPaddingPx.right
Sunny Goyal786940a2020-06-02 02:31:31 -07001354 + mInsets.right,
Thales Limab8c05952022-05-23 16:58:38 +01001355 getHotseatBarBottomPadding());
Sunny Goyal81b4c7b2018-03-26 12:10:31 -07001356 }
Pat Manning5f74bfd2022-07-20 12:08:54 +01001357 return hotseatBarPadding;
Sunny Goyal81b4c7b2018-03-26 12:10:31 -07001358 }
1359
Thales Lima9938c2f2022-07-25 14:38:16 +01001360 private int getAdditionalQsbSpace() {
1361 return isQsbInline ? hotseatQsbWidth + hotseatBorderSpace : 0;
1362 }
1363
1364 /**
1365 * Calculate how much space the hotseat needs to be shown completely
1366 */
1367 private int getHotseatRequiredWidth() {
1368 int additionalQsbSpace = getAdditionalQsbSpace();
1369 return iconSizePx * numShownHotseatIcons
Thales Lima6a590062022-11-22 15:52:49 +00001370 + hotseatBorderSpace * (numShownHotseatIcons - (areNavButtonsInline ? 0 : 1))
Thales Lima9938c2f2022-07-25 14:38:16 +01001371 + additionalQsbSpace;
1372 }
1373
Winsonfadbe8f2016-07-22 16:35:37 -07001374 /**
Sunny Goyal57b22792021-05-25 14:35:01 -07001375 * Returns the number of pixels the QSB is translated from the bottom of the screen.
1376 */
1377 public int getQsbOffsetY() {
Thales Limaa1012902022-01-13 17:58:42 +00001378 if (isQsbInline) {
Thales Limab8c05952022-05-23 16:58:38 +01001379 return getHotseatBarBottomPadding() - ((hotseatQsbHeight - hotseatCellHeightPx) / 2);
1380 } else if (isTaskbarPresent) { // QSB on top
1381 return hotseatBarSizePx - hotseatQsbHeight + hotseatQsbShadowHeight;
Jonathan Miranda8f16a772021-07-23 23:10:37 +00001382 } else {
Thales Limab8c05952022-05-23 16:58:38 +01001383 return hotseatBarBottomSpacePx - hotseatQsbShadowHeight;
Jonathan Miranda7a273e22021-06-24 21:29:10 +00001384 }
Sunny Goyal57b22792021-05-25 14:35:01 -07001385 }
1386
Thales Limab8c05952022-05-23 16:58:38 +01001387 /**
1388 * Returns the number of pixels the hotseat is translated from the bottom of the screen.
1389 */
1390 private int getHotseatBarBottomPadding() {
1391 if (isTaskbarPresent) { // QSB on top or inline
1392 return hotseatBarBottomSpacePx - (Math.abs(hotseatCellHeightPx - iconSizePx) / 2);
Thales Limaa1012902022-01-13 17:58:42 +00001393 } else {
Thales Limab8c05952022-05-23 16:58:38 +01001394 return hotseatBarSizePx - hotseatCellHeightPx;
Thales Limaa1012902022-01-13 17:58:42 +00001395 }
Sunny Goyal57b22792021-05-25 14:35:01 -07001396 }
1397
1398 /**
Alex Chau51da2192022-05-20 13:32:10 +01001399 * Returns the number of pixels the taskbar is translated from the bottom of the screen.
1400 */
1401 public int getTaskbarOffsetY() {
1402 int taskbarIconBottomSpace = (taskbarSize - iconSizePx) / 2;
1403 int launcherIconBottomSpace =
1404 Math.min((hotseatCellHeightPx - iconSizePx) / 2, gridVisualizationPaddingY);
Thales Limab8c05952022-05-23 16:58:38 +01001405 return getHotseatBarBottomPadding() + launcherIconBottomSpace - taskbarIconBottomSpace;
Alex Chau51da2192022-05-20 13:32:10 +01001406 }
1407
1408 /**
Alex Chaua2fc7642022-04-21 14:20:23 +01001409 * Returns the number of pixels required below OverviewActions excluding insets.
1410 */
1411 public int getOverviewActionsClaimedSpaceBelow() {
Alex Chaud67ddc42022-09-30 18:15:56 +01001412 if (isTaskbarPresent) {
Alex Chau905e0f12022-11-14 21:55:37 +00001413 if (FeatureFlags.ENABLE_TASKBAR_IN_OVERVIEW.get()) {
Alex Chau85d664e2023-01-16 16:31:59 +00001414 return transientTaskbarSize + transientTaskbarMargin * 2;
Alex Chau905e0f12022-11-14 21:55:37 +00001415 }
1416
1417 return isGestureMode
1418 ? stashedTaskbarSize
1419 // Align vertically to where nav buttons are.
1420 : ((taskbarSize - overviewActionsHeight) / 2) + getTaskbarOffsetY();
Alex Chaud67ddc42022-09-30 18:15:56 +01001421 }
1422 return mInsets.bottom;
Alex Chaua2fc7642022-04-21 14:20:23 +01001423 }
1424
1425 /** Gets the space that the overview actions will take, including bottom margin. */
1426 public int getOverviewActionsClaimedSpace() {
Pat Manning7b8f7662023-01-18 14:48:30 +00001427 int overviewActionsSpace = isTablet && FeatureFlags.ENABLE_GRID_ONLY_OVERVIEW.get()
1428 ? 0
1429 : (overviewActionsTopMarginPx + overviewActionsHeight);
1430 return overviewActionsSpace + getOverviewActionsClaimedSpaceBelow();
Alex Chaua2fc7642022-04-21 14:20:23 +01001431 }
1432
1433 /**
Sihua Mae04aa202022-07-18 12:43:56 -07001434 * Takes the View and return the scales of width and height depending on the DeviceProfile
1435 * specifications
1436 *
1437 * @param itemInfo The tag of the widget view
1438 * @return A PointF instance with the x set to be the scale of width, and y being the scale of
1439 * height
1440 */
1441 @NonNull
1442 public PointF getAppWidgetScale(@Nullable final ItemInfo itemInfo) {
1443 return mViewScaleProvider.getScaleFromItemInfo(itemInfo);
1444 }
1445
1446 /**
Winsonfadbe8f2016-07-22 16:35:37 -07001447 * @return the bounds for which the open folders should be contained within
1448 */
1449 public Rect getAbsoluteOpenFolderBounds() {
1450 if (isVerticalBarLayout()) {
1451 // Folders should only appear right of the drop target bar and left of the hotseat
1452 return new Rect(mInsets.left + dropTargetBarSizePx + edgeMarginPx,
1453 mInsets.top,
Jon Miranda18751b62017-07-31 17:25:27 -07001454 mInsets.left + availableWidthPx - hotseatBarSizePx - edgeMarginPx,
Winsonfadbe8f2016-07-22 16:35:37 -07001455 mInsets.top + availableHeightPx);
1456 } else {
1457 // Folders should only appear below the drop target bar and above the hotseat
Tony Wickhamae72b462021-03-10 16:18:40 -08001458 int hotseatTop = isTaskbarPresent ? taskbarSize : hotseatBarSizePx;
Tony Wickhamb4b7e202018-01-12 17:39:24 -08001459 return new Rect(mInsets.left + edgeMarginPx,
Winsonfadbe8f2016-07-22 16:35:37 -07001460 mInsets.top + dropTargetBarSizePx + edgeMarginPx,
Tony Wickhamb4b7e202018-01-12 17:39:24 -08001461 mInsets.left + availableWidthPx - edgeMarginPx,
Tony Wickhamae72b462021-03-10 16:18:40 -08001462 mInsets.top + availableHeightPx - hotseatTop
Tony Wickham5edf9e22020-03-27 20:06:52 -07001463 - workspacePageIndicatorHeight - edgeMarginPx);
Winsonfadbe8f2016-07-22 16:35:37 -07001464 }
1465 }
1466
Jon Miranda228877d2021-02-09 11:05:00 -05001467 public static int calculateCellWidth(int width, int borderSpacing, int countX) {
1468 return (width - ((countX - 1) * borderSpacing)) / countX;
Winson Chungb3800242013-10-24 11:01:54 -07001469 }
Pierre Barbier de Reuille578deba2021-09-24 13:47:44 +01001470
Jon Miranda228877d2021-02-09 11:05:00 -05001471 public static int calculateCellHeight(int height, int borderSpacing, int countY) {
1472 return (height - ((countY - 1) * borderSpacing)) / countY;
Winson Chungb3800242013-10-24 11:01:54 -07001473 }
1474
Hyunyoung Song18bfaaf2015-03-17 11:32:21 -07001475 /**
Tony Wickham55616cd2015-09-23 14:55:17 -07001476 * When {@code true}, the device is in landscape mode and the hotseat is on the right column.
1477 * When {@code false}, either device is in portrait mode or the device is in landscape mode and
1478 * the hotseat is on the bottom row.
Hyunyoung Song18bfaaf2015-03-17 11:32:21 -07001479 */
Tony Wickhamab946a12015-09-16 15:38:16 -07001480 public boolean isVerticalBarLayout() {
Winson Chungb3800242013-10-24 11:01:54 -07001481 return isLandscape && transposeLayoutWithOrientation;
1482 }
1483
Sunny Goyal59d086c2018-05-07 17:31:40 -07001484 /**
1485 * Updates orientation information and returns true if it has changed from the previous value.
1486 */
Winson Chung13c1c2c2019-09-06 11:46:19 -07001487 public boolean updateIsSeascape(Context context) {
Sunny Goyal59d086c2018-05-07 17:31:40 -07001488 if (isVerticalBarLayout()) {
Sunny Goyal35c7b192021-04-20 16:51:10 -07001489 boolean isSeascape = DisplayController.INSTANCE.get(context)
1490 .getInfo().rotation == Surface.ROTATION_270;
Sunny Goyal59d086c2018-05-07 17:31:40 -07001491 if (mIsSeascape != isSeascape) {
1492 mIsSeascape = isSeascape;
Pat Manning08610ca2022-04-05 21:03:16 +01001493 // Hotseat changing sides requires updating workspace left/right paddings
1494 updateWorkspacePadding();
Sunny Goyal59d086c2018-05-07 17:31:40 -07001495 return true;
1496 }
1497 }
1498 return false;
1499 }
1500
Sunny Goyal7e2e67f2018-01-26 13:40:08 -08001501 public boolean isSeascape() {
Sunny Goyal59d086c2018-05-07 17:31:40 -07001502 return isVerticalBarLayout() && mIsSeascape;
Sunny Goyal7e2e67f2018-01-26 13:40:08 -08001503 }
1504
Sunny Goyal07b69292018-01-08 14:19:34 -08001505 public boolean shouldFadeAdjacentWorkspaceScreens() {
Sunny Goyal19ff7282021-04-22 10:12:54 -07001506 return isVerticalBarLayout();
Winson Chungb3800242013-10-24 11:01:54 -07001507 }
1508
Jon Miranda92c1b5d2021-07-20 13:57:16 -07001509 public int getCellContentHeight(@ContainerType int containerType) {
Sunny Goyalc13403c2016-11-18 23:44:48 -08001510 switch (containerType) {
1511 case CellLayout.WORKSPACE:
1512 return cellHeightPx;
1513 case CellLayout.FOLDER:
1514 return folderCellHeightPx;
1515 case CellLayout.HOTSEAT:
Jon Miranda92c1b5d2021-07-20 13:57:16 -07001516 // The hotseat is the only container where the cell height is going to be
1517 // different from the content within that cell.
1518 return iconSizePx;
Sunny Goyalc13403c2016-11-18 23:44:48 -08001519 default:
1520 // ??
1521 return 0;
1522 }
1523 }
Sunny Goyal13178ac2016-04-04 16:35:22 -07001524
Jon Miranda58561d42021-03-17 10:51:54 -04001525 private String pxToDpStr(String name, float value) {
Sunny Goyal35c7b192021-04-20 16:51:10 -07001526 return "\t" + name + ": " + value + "px (" + dpiFromPx(value, mMetrics.densityDpi) + "dp)";
Jon Miranda58561d42021-03-17 10:51:54 -04001527 }
1528
Alex Chaue818bcb2022-09-02 17:27:11 +01001529 private String dpPointFToString(String name, PointF value) {
1530 return String.format(Locale.ENGLISH, "\t%s: PointF(%.1f, %.1f)dp", name, value.x, value.y);
1531 }
1532
Pat Manning5f74bfd2022-07-20 12:08:54 +01001533 /** Dumps various DeviceProfile variables to the specified writer. */
1534 public void dump(Context context, String prefix, PrintWriter writer) {
Jon Miranda58561d42021-03-17 10:51:54 -04001535 writer.println(prefix + "DeviceProfile:");
Sunny Goyal35c7b192021-04-20 16:51:10 -07001536 writer.println(prefix + "\t1 dp = " + mMetrics.density + " px");
Jon Miranda58561d42021-03-17 10:51:54 -04001537
1538 writer.println(prefix + "\tisTablet:" + isTablet);
Jon Miranda58561d42021-03-17 10:51:54 -04001539 writer.println(prefix + "\tisPhone:" + isPhone);
1540 writer.println(prefix + "\ttransposeLayoutWithOrientation:"
1541 + transposeLayoutWithOrientation);
Alex Chau6ed408f2022-03-04 12:58:05 +00001542 writer.println(prefix + "\tisGestureMode:" + isGestureMode);
Jon Miranda58561d42021-03-17 10:51:54 -04001543
1544 writer.println(prefix + "\tisLandscape:" + isLandscape);
1545 writer.println(prefix + "\tisMultiWindowMode:" + isMultiWindowMode);
Sunny Goyal19ff7282021-04-22 10:12:54 -07001546 writer.println(prefix + "\tisTwoPanels:" + isTwoPanels);
Jon Miranda58561d42021-03-17 10:51:54 -04001547
1548 writer.println(prefix + pxToDpStr("windowX", windowX));
1549 writer.println(prefix + pxToDpStr("windowY", windowY));
1550 writer.println(prefix + pxToDpStr("widthPx", widthPx));
1551 writer.println(prefix + pxToDpStr("heightPx", heightPx));
Jon Miranda58561d42021-03-17 10:51:54 -04001552 writer.println(prefix + pxToDpStr("availableWidthPx", availableWidthPx));
1553 writer.println(prefix + pxToDpStr("availableHeightPx", availableHeightPx));
Alex Chaue0227552022-04-06 19:44:43 +01001554 writer.println(prefix + pxToDpStr("mInsets.left", mInsets.left));
1555 writer.println(prefix + pxToDpStr("mInsets.top", mInsets.top));
1556 writer.println(prefix + pxToDpStr("mInsets.right", mInsets.right));
1557 writer.println(prefix + pxToDpStr("mInsets.bottom", mInsets.bottom));
Jon Miranda58561d42021-03-17 10:51:54 -04001558
1559 writer.println(prefix + "\taspectRatio:" + aspectRatio);
1560
1561 writer.println(prefix + "\tisScalableGrid:" + isScalableGrid);
1562
Thales Lima83bedbf2021-10-05 17:47:39 +01001563 writer.println(prefix + "\tinv.numRows: " + inv.numRows);
Alex Chau9fee3fd2021-12-01 18:43:10 +00001564 writer.println(prefix + "\tinv.numColumns: " + inv.numColumns);
1565 writer.println(prefix + "\tinv.numSearchContainerColumns: "
1566 + inv.numSearchContainerColumns);
Jon Miranda58561d42021-03-17 10:51:54 -04001567
Alex Chaue818bcb2022-09-02 17:27:11 +01001568 writer.println(prefix + dpPointFToString("minCellSize", inv.minCellSize[mTypeIndex]));
Jon Mirandaab3c6812021-06-28 15:42:28 -07001569
Jon Miranda58561d42021-03-17 10:51:54 -04001570 writer.println(prefix + pxToDpStr("cellWidthPx", cellWidthPx));
1571 writer.println(prefix + pxToDpStr("cellHeightPx", cellHeightPx));
1572
1573 writer.println(prefix + pxToDpStr("getCellSize().x", getCellSize().x));
1574 writer.println(prefix + pxToDpStr("getCellSize().y", getCellSize().y));
1575
Thales Lima83bedbf2021-10-05 17:47:39 +01001576 writer.println(prefix + pxToDpStr("cellLayoutBorderSpacePx Horizontal",
1577 cellLayoutBorderSpacePx.x));
1578 writer.println(prefix + pxToDpStr("cellLayoutBorderSpacePx Vertical",
1579 cellLayoutBorderSpacePx.y));
Pat Manning5f74bfd2022-07-20 12:08:54 +01001580 writer.println(
1581 prefix + pxToDpStr("cellLayoutPaddingPx.left", cellLayoutPaddingPx.left));
1582 writer.println(
1583 prefix + pxToDpStr("cellLayoutPaddingPx.top", cellLayoutPaddingPx.top));
1584 writer.println(
1585 prefix + pxToDpStr("cellLayoutPaddingPx.right", cellLayoutPaddingPx.right));
Pat Manning08610ca2022-04-05 21:03:16 +01001586 writer.println(
1587 prefix + pxToDpStr("cellLayoutPaddingPx.bottom", cellLayoutPaddingPx.bottom));
Thales Lima83bedbf2021-10-05 17:47:39 +01001588
Jon Miranda58561d42021-03-17 10:51:54 -04001589 writer.println(prefix + pxToDpStr("iconSizePx", iconSizePx));
1590 writer.println(prefix + pxToDpStr("iconTextSizePx", iconTextSizePx));
1591 writer.println(prefix + pxToDpStr("iconDrawablePaddingPx", iconDrawablePaddingPx));
1592
1593 writer.println(prefix + pxToDpStr("folderCellWidthPx", folderCellWidthPx));
1594 writer.println(prefix + pxToDpStr("folderCellHeightPx", folderCellHeightPx));
1595 writer.println(prefix + pxToDpStr("folderChildIconSizePx", folderChildIconSizePx));
1596 writer.println(prefix + pxToDpStr("folderChildTextSizePx", folderChildTextSizePx));
1597 writer.println(prefix + pxToDpStr("folderChildDrawablePaddingPx",
1598 folderChildDrawablePaddingPx));
Thales Limab35faed2022-09-05 16:30:01 -03001599 writer.println(prefix + pxToDpStr("folderCellLayoutBorderSpacePx",
1600 folderCellLayoutBorderSpacePx));
Thales Limaa08a4432022-08-09 09:55:17 +01001601 writer.println(prefix + pxToDpStr("folderContentPaddingLeftRight",
1602 folderContentPaddingLeftRight));
1603 writer.println(prefix + pxToDpStr("folderTopPadding", folderContentPaddingTop));
Thales Limab35faed2022-09-05 16:30:01 -03001604 writer.println(prefix + pxToDpStr("folderFooterHeight", folderFooterHeightPx));
Jon Miranda58561d42021-03-17 10:51:54 -04001605
Alex Chaue0227552022-04-06 19:44:43 +01001606 writer.println(prefix + pxToDpStr("bottomSheetTopPadding", bottomSheetTopPadding));
Alex Chau3d2c0622022-09-01 21:28:14 +01001607 writer.println(prefix + "\tbottomSheetOpenDuration: " + bottomSheetOpenDuration);
1608 writer.println(prefix + "\tbottomSheetCloseDuration: " + bottomSheetCloseDuration);
1609 writer.println(prefix + "\tbottomSheetWorkspaceScale: " + bottomSheetWorkspaceScale);
1610 writer.println(prefix + "\tbottomSheetDepth: " + bottomSheetDepth);
Alex Chaue0227552022-04-06 19:44:43 +01001611
1612 writer.println(prefix + pxToDpStr("allAppsShiftRange", allAppsShiftRange));
1613 writer.println(prefix + pxToDpStr("allAppsTopPadding", allAppsTopPadding));
Alex Chau3d2c0622022-09-01 21:28:14 +01001614 writer.println(prefix + "\tallAppsOpenDuration: " + allAppsOpenDuration);
1615 writer.println(prefix + "\tallAppsCloseDuration: " + allAppsCloseDuration);
Jon Miranda58561d42021-03-17 10:51:54 -04001616 writer.println(prefix + pxToDpStr("allAppsIconSizePx", allAppsIconSizePx));
1617 writer.println(prefix + pxToDpStr("allAppsIconTextSizePx", allAppsIconTextSizePx));
1618 writer.println(prefix + pxToDpStr("allAppsIconDrawablePaddingPx",
1619 allAppsIconDrawablePaddingPx));
1620 writer.println(prefix + pxToDpStr("allAppsCellHeightPx", allAppsCellHeightPx));
Alex Chau27b39b92022-01-14 18:02:18 +00001621 writer.println(prefix + pxToDpStr("allAppsCellWidthPx", allAppsCellWidthPx));
Pat Manning26f70f72022-07-07 13:50:39 +01001622 writer.println(prefix + pxToDpStr("allAppsBorderSpacePxX", allAppsBorderSpacePx.x));
1623 writer.println(prefix + pxToDpStr("allAppsBorderSpacePxY", allAppsBorderSpacePx.y));
Sunny Goyal19ff7282021-04-22 10:12:54 -07001624 writer.println(prefix + "\tnumShownAllAppsColumns: " + numShownAllAppsColumns);
Alex Chau62572c02022-07-25 18:36:37 +00001625 writer.println(prefix + pxToDpStr("allAppsLeftRightPadding", allAppsLeftRightPadding));
Alex Chau27b39b92022-01-14 18:02:18 +00001626 writer.println(prefix + pxToDpStr("allAppsLeftRightMargin", allAppsLeftRightMargin));
Jon Miranda58561d42021-03-17 10:51:54 -04001627
1628 writer.println(prefix + pxToDpStr("hotseatBarSizePx", hotseatBarSizePx));
Thales Lima425f6822022-05-10 13:44:58 -03001629 writer.println(prefix + "\tinv.hotseatColumnSpan: " + inv.hotseatColumnSpan[mTypeIndex]);
Jon Miranda58561d42021-03-17 10:51:54 -04001630 writer.println(prefix + pxToDpStr("hotseatCellHeightPx", hotseatCellHeightPx));
Alex Chau62572c02022-07-25 18:36:37 +00001631 writer.println(prefix + pxToDpStr("hotseatBarBottomSpacePx", hotseatBarBottomSpacePx));
Jon Miranda58561d42021-03-17 10:51:54 -04001632 writer.println(prefix + pxToDpStr("hotseatBarSidePaddingStartPx",
1633 hotseatBarSidePaddingStartPx));
1634 writer.println(prefix + pxToDpStr("hotseatBarSidePaddingEndPx",
1635 hotseatBarSidePaddingEndPx));
Pat Manning26f70f72022-07-07 13:50:39 +01001636 writer.println(prefix + pxToDpStr("hotseatBarEndOffset", hotseatBarEndOffset));
Thales Limab8c05952022-05-23 16:58:38 +01001637 writer.println(prefix + pxToDpStr("hotseatQsbSpace", hotseatQsbSpace));
1638 writer.println(prefix + pxToDpStr("hotseatQsbHeight", hotseatQsbHeight));
Pat Manningde25c0d2022-04-05 19:11:26 +01001639 writer.println(prefix + pxToDpStr("springLoadedHotseatBarTopMarginPx",
1640 springLoadedHotseatBarTopMarginPx));
Pat Manning5f74bfd2022-07-20 12:08:54 +01001641 Rect hotseatLayoutPadding = getHotseatLayoutPadding(context);
1642 writer.println(prefix + pxToDpStr("getHotseatLayoutPadding(context).top",
1643 hotseatLayoutPadding.top));
1644 writer.println(prefix + pxToDpStr("getHotseatLayoutPadding(context).bottom",
1645 hotseatLayoutPadding.bottom));
1646 writer.println(prefix + pxToDpStr("getHotseatLayoutPadding(context).left",
1647 hotseatLayoutPadding.left));
1648 writer.println(prefix + pxToDpStr("getHotseatLayoutPadding(context).right",
1649 hotseatLayoutPadding.right));
Sunny Goyal19ff7282021-04-22 10:12:54 -07001650 writer.println(prefix + "\tnumShownHotseatIcons: " + numShownHotseatIcons);
Thales Lima116b51a2022-02-03 16:19:47 +00001651 writer.println(prefix + pxToDpStr("hotseatBorderSpace", hotseatBorderSpace));
Thales Limaa1012902022-01-13 17:58:42 +00001652 writer.println(prefix + "\tisQsbInline: " + isQsbInline);
Alex Chau206ede92022-08-01 17:46:12 +01001653 writer.println(prefix + pxToDpStr("hotseatQsbWidth", hotseatQsbWidth));
Jon Miranda58561d42021-03-17 10:51:54 -04001654
1655 writer.println(prefix + "\tisTaskbarPresent:" + isTaskbarPresent);
Tony Wickham635e1802021-07-22 14:28:04 -10001656 writer.println(prefix + "\tisTaskbarPresentInApps:" + isTaskbarPresentInApps);
Jon Miranda58561d42021-03-17 10:51:54 -04001657 writer.println(prefix + pxToDpStr("taskbarSize", taskbarSize));
Jon Miranda58561d42021-03-17 10:51:54 -04001658
Thales Lima83bedbf2021-10-05 17:47:39 +01001659 writer.println(prefix + pxToDpStr("desiredWorkspaceHorizontalMarginPx",
1660 desiredWorkspaceHorizontalMarginPx));
Jon Miranda58561d42021-03-17 10:51:54 -04001661 writer.println(prefix + pxToDpStr("workspacePadding.left", workspacePadding.left));
1662 writer.println(prefix + pxToDpStr("workspacePadding.top", workspacePadding.top));
1663 writer.println(prefix + pxToDpStr("workspacePadding.right", workspacePadding.right));
Alex Chau62572c02022-07-25 18:36:37 +00001664 writer.println(prefix + pxToDpStr("workspacePadding.bottom", workspacePadding.bottom));
Jon Miranda58561d42021-03-17 10:51:54 -04001665
Jon Mirandaab3c6812021-06-28 15:42:28 -07001666 writer.println(prefix + pxToDpStr("iconScale", iconScale));
1667 writer.println(prefix + pxToDpStr("cellScaleToFit ", cellScaleToFit));
Jon Miranda58561d42021-03-17 10:51:54 -04001668 writer.println(prefix + pxToDpStr("extraSpace", extraSpace));
Alex Chau62572c02022-07-25 18:36:37 +00001669 writer.println(prefix + pxToDpStr("unscaled extraSpace", extraSpace / iconScale));
Jon Mirandac9e69fa2021-03-22 17:13:34 -04001670
Thales Lima171ee662022-11-22 15:52:49 +00001671 writer.println(prefix + pxToDpStr("maxEmptySpace", maxEmptySpace));
Jon Miranda58561d42021-03-17 10:51:54 -04001672 writer.println(prefix + pxToDpStr("workspaceTopPadding", workspaceTopPadding));
1673 writer.println(prefix + pxToDpStr("workspaceBottomPadding", workspaceBottomPadding));
Alex Chau635b3ab2022-01-26 16:49:10 +00001674
1675 writer.println(prefix + pxToDpStr("overviewTaskMarginPx", overviewTaskMarginPx));
Alex Chau635b3ab2022-01-26 16:49:10 +00001676 writer.println(prefix + pxToDpStr("overviewTaskIconSizePx", overviewTaskIconSizePx));
1677 writer.println(prefix + pxToDpStr("overviewTaskIconDrawableSizePx",
1678 overviewTaskIconDrawableSizePx));
1679 writer.println(prefix + pxToDpStr("overviewTaskIconDrawableSizeGridPx",
1680 overviewTaskIconDrawableSizeGridPx));
1681 writer.println(prefix + pxToDpStr("overviewTaskThumbnailTopMarginPx",
1682 overviewTaskThumbnailTopMarginPx));
Alex Chaua2fc7642022-04-21 14:20:23 +01001683 writer.println(prefix + pxToDpStr("overviewActionsTopMarginPx",
1684 overviewActionsTopMarginPx));
1685 writer.println(prefix + pxToDpStr("overviewActionsHeight",
1686 overviewActionsHeight));
Alex Chau1b276a12022-12-19 14:01:36 +00001687 writer.println(prefix + pxToDpStr("overviewActionsClaimedSpaceBelow",
1688 getOverviewActionsClaimedSpaceBelow()));
Alex Chau635b3ab2022-01-26 16:49:10 +00001689 writer.println(prefix + pxToDpStr("overviewActionsButtonSpacing",
1690 overviewActionsButtonSpacing));
1691 writer.println(prefix + pxToDpStr("overviewPageSpacing", overviewPageSpacing));
1692 writer.println(prefix + pxToDpStr("overviewRowSpacing", overviewRowSpacing));
1693 writer.println(prefix + pxToDpStr("overviewGridSideMargin", overviewGridSideMargin));
Pat Manningde25c0d2022-04-05 19:11:26 +01001694
Alex Chau62572c02022-07-25 18:36:37 +00001695 writer.println(prefix + pxToDpStr("dropTargetBarTopMarginPx", dropTargetBarTopMarginPx));
Pat Manningde25c0d2022-04-05 19:11:26 +01001696 writer.println(prefix + pxToDpStr("dropTargetBarSizePx", dropTargetBarSizePx));
Alex Chau62572c02022-07-25 18:36:37 +00001697 writer.println(
1698 prefix + pxToDpStr("dropTargetBarBottomMarginPx", dropTargetBarBottomMarginPx));
Pat Manningde25c0d2022-04-05 19:11:26 +01001699
Pat Manning5f74bfd2022-07-20 12:08:54 +01001700 writer.println(prefix + pxToDpStr("getCellLayoutSpringLoadShrunkTop()",
1701 getCellLayoutSpringLoadShrunkTop()));
1702 writer.println(prefix + pxToDpStr("getCellLayoutSpringLoadShrunkBottom()",
1703 getCellLayoutSpringLoadShrunkBottom(context)));
Alex Chau906d8822022-05-23 10:42:25 +01001704 writer.println(prefix + pxToDpStr("workspaceSpringLoadedMinNextPageVisiblePx",
1705 workspaceSpringLoadedMinNextPageVisiblePx));
Pat Manning5f74bfd2022-07-20 12:08:54 +01001706 writer.println(prefix + pxToDpStr("getWorkspaceSpringLoadScale()",
1707 getWorkspaceSpringLoadScale(context)));
Thales Limab8c05952022-05-23 16:58:38 +01001708 writer.println(prefix + pxToDpStr("getCellLayoutHeight()", getCellLayoutHeight()));
1709 writer.println(prefix + pxToDpStr("getCellLayoutWidth()", getCellLayoutWidth()));
Jon Miranda58561d42021-03-17 10:51:54 -04001710 }
1711
Nicolo' Mazzucatocb7bd502023-01-16 19:46:30 +00001712 /** Returns a reduced representation of this DeviceProfile. */
1713 public String toSmallString() {
1714 return "isTablet:" + isTablet + ", "
1715 + "isMultiDisplay:" + isMultiDisplay + ", "
1716 + "widthPx:" + widthPx + ", "
1717 + "heightPx:" + heightPx + ", "
1718 + "insets:" + mInsets + ", "
1719 + "rotationHint:" + rotationHint;
1720 }
1721
Alex Chaua6907dc2022-03-18 15:24:07 +00001722 private static Context getContext(Context c, Info info, int orientation, WindowBounds bounds) {
Sunny Goyal1890f672020-04-30 12:28:00 -07001723 Configuration config = new Configuration(c.getResources().getConfiguration());
1724 config.orientation = orientation;
Thales Lima425f6822022-05-10 13:44:58 -03001725 config.densityDpi = info.getDensityDpi();
Alex Chaua6907dc2022-03-18 15:24:07 +00001726 config.smallestScreenWidthDp = (int) info.smallestSizeDp(bounds);
Sunny Goyal1890f672020-04-30 12:28:00 -07001727 return c.createConfigurationContext(config);
Jon Mirandab28c4fc2017-06-20 10:58:36 -07001728 }
Sunny Goyalfde55052018-02-01 14:46:13 -08001729
1730 /**
1731 * Callback when a component changes the DeviceProfile associated with it, as a result of
1732 * configuration change
1733 */
1734 public interface OnDeviceProfileChangeListener {
1735
1736 /**
1737 * Called when the device profile is reassigned. Note that for layout and measurements, it
1738 * is sufficient to listen for inset changes. Use this callback when you need to perform
1739 * a one time operation.
1740 */
1741 void onDeviceProfileChanged(DeviceProfile dp);
1742 }
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001743
Sihua Mae04aa202022-07-18 12:43:56 -07001744 /**
1745 * Handler that deals with ItemInfo of the views for the DeviceProfile
1746 */
1747 @FunctionalInterface
1748 public interface ViewScaleProvider {
1749 /**
1750 * Get the scales from the view
1751 *
1752 * @param itemInfo The tag of the widget view
1753 * @return PointF instance containing the scale information, or null if using the default
1754 * app widget scale of this device profile.
1755 */
1756 @NonNull
1757 PointF getScaleFromItemInfo(@Nullable ItemInfo itemInfo);
1758 }
1759
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001760 public static class Builder {
1761 private Context mContext;
1762 private InvariantDeviceProfile mInv;
Sunny Goyalfd58da62020-08-11 12:06:49 -07001763 private Info mInfo;
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001764
Sunny Goyal19ff7282021-04-22 10:12:54 -07001765 private WindowBounds mWindowBounds;
Alex Chauab800f72022-12-13 17:46:06 +00001766 private boolean mIsMultiDisplay;
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001767
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001768 private boolean mIsMultiWindowMode = false;
Sunny Goyal19ff7282021-04-22 10:12:54 -07001769 private Boolean mTransposeLayoutWithOrientation;
Alex Chau6ed408f2022-03-04 12:58:05 +00001770 private Boolean mIsGestureMode;
Sihua Mae04aa202022-07-18 12:43:56 -07001771 private ViewScaleProvider mViewScaleProvider = null;
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001772
Sunny Goyal65190ae2022-08-02 14:16:26 -07001773 private SparseArray<DotRenderer> mDotRendererCache;
1774
Jon Miranda2b25ded2023-02-02 14:48:45 -08001775 private Consumer<DeviceProfile> mOverrideProvider;
1776
Sunny Goyalfd58da62020-08-11 12:06:49 -07001777 public Builder(Context context, InvariantDeviceProfile inv, Info info) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001778 mContext = context;
1779 mInv = inv;
1780 mInfo = info;
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001781 }
1782
1783 public Builder setMultiWindowMode(boolean isMultiWindowMode) {
1784 mIsMultiWindowMode = isMultiWindowMode;
1785 return this;
1786 }
1787
Alex Chauab800f72022-12-13 17:46:06 +00001788 public Builder setIsMultiDisplay(boolean isMultiDisplay) {
1789 mIsMultiDisplay = isMultiDisplay;
Sunny Goyal19ff7282021-04-22 10:12:54 -07001790 return this;
1791 }
1792
Sunny Goyal65190ae2022-08-02 14:16:26 -07001793 public Builder setDotRendererCache(SparseArray<DotRenderer> dotRendererCache) {
1794 mDotRendererCache = dotRendererCache;
1795 return this;
1796 }
Sunny Goyal19ff7282021-04-22 10:12:54 -07001797
1798 public Builder setWindowBounds(WindowBounds bounds) {
1799 mWindowBounds = bounds;
Sunny Goyal0addbf02020-04-28 14:17:35 -07001800 return this;
1801 }
1802
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001803 public Builder setTransposeLayoutWithOrientation(boolean transposeLayoutWithOrientation) {
1804 mTransposeLayoutWithOrientation = transposeLayoutWithOrientation;
1805 return this;
1806 }
1807
Alex Chau6ed408f2022-03-04 12:58:05 +00001808 public Builder setGestureMode(boolean isGestureMode) {
1809 mIsGestureMode = isGestureMode;
1810 return this;
1811 }
1812
Jon Miranda2b25ded2023-02-02 14:48:45 -08001813 public Builder withDimensionsOverride(Consumer<DeviceProfile> overrideProvider) {
1814 mOverrideProvider = overrideProvider;
1815 return this;
1816 }
1817
Sihua Mae04aa202022-07-18 12:43:56 -07001818 /**
1819 * Set the viewScaleProvider for the builder
1820 *
1821 * @param viewScaleProvider The viewScaleProvider to be set for the
Thales Limae9273ea2023-01-26 12:33:52 +00001822 * DeviceProfile
Sihua Mae04aa202022-07-18 12:43:56 -07001823 * @return This builder
1824 */
1825 @NonNull
1826 public Builder setViewScaleProvider(@Nullable ViewScaleProvider viewScaleProvider) {
1827 mViewScaleProvider = viewScaleProvider;
1828 return this;
1829 }
1830
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001831 public DeviceProfile build() {
Sunny Goyal19ff7282021-04-22 10:12:54 -07001832 if (mWindowBounds == null) {
1833 throw new IllegalArgumentException("Window bounds not set");
1834 }
1835 if (mTransposeLayoutWithOrientation == null) {
1836 mTransposeLayoutWithOrientation = !mInfo.isTablet(mWindowBounds);
1837 }
Alex Chau6ed408f2022-03-04 12:58:05 +00001838 if (mIsGestureMode == null) {
Alex Chaue818bcb2022-09-02 17:27:11 +01001839 mIsGestureMode = mInfo.navigationMode.hasGestures;
Alex Chau6ed408f2022-03-04 12:58:05 +00001840 }
Sunny Goyal65190ae2022-08-02 14:16:26 -07001841 if (mDotRendererCache == null) {
1842 mDotRendererCache = new SparseArray<>();
1843 }
Sihua Mae04aa202022-07-18 12:43:56 -07001844 if (mViewScaleProvider == null) {
1845 mViewScaleProvider = DEFAULT_PROVIDER;
1846 }
Jon Miranda2b25ded2023-02-02 14:48:45 -08001847 if (mOverrideProvider == null) {
1848 mOverrideProvider = DEFAULT_DIMENSION_PROVIDER;
1849 }
Sunny Goyal65190ae2022-08-02 14:16:26 -07001850 return new DeviceProfile(mContext, mInv, mInfo, mWindowBounds, mDotRendererCache,
Alex Chauab800f72022-12-13 17:46:06 +00001851 mIsMultiWindowMode, mTransposeLayoutWithOrientation, mIsMultiDisplay,
Jon Miranda2b25ded2023-02-02 14:48:45 -08001852 mIsGestureMode, mViewScaleProvider, mOverrideProvider);
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001853 }
1854 }
1855
Winson Chungb3800242013-10-24 11:01:54 -07001856}