blob: e18862a493bb2a69c2093612ef1bbae4d84f2dca [file] [log] [blame]
Adam Cohen2e6da152015-05-06 11:42:25 -07001/*
Thales Lima1de4d552021-10-13 16:13:25 +01002 * Copyright (C) 2021 The Android Open Source Project
Adam Cohen2e6da152015-05-06 11:42:25 -07003 *
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
Sebastian Franco9e4c99b2024-10-02 15:16:37 -070019import static com.android.launcher3.LauncherPrefs.FIXED_LANDSCAPE_MODE;
Stefan Andonian4c9612b2023-02-22 00:00:03 +000020import static com.android.launcher3.LauncherPrefs.GRID_NAME;
Sunny Goyal19ff7282021-04-22 10:12:54 -070021import static com.android.launcher3.Utilities.dpiFromPx;
Thales Limab35faed2022-09-05 16:30:01 -030022import static com.android.launcher3.testing.shared.ResourceUtils.INVALID_RESOURCE_HANDLE;
Sunny Goyal35c7b192021-04-20 16:51:10 -070023import static com.android.launcher3.util.DisplayController.CHANGE_DENSITY;
Jagrut Desai2e8ca872024-04-17 15:27:30 -070024import static com.android.launcher3.util.DisplayController.CHANGE_DESKTOP_MODE;
Alex Chau6ed408f2022-03-04 12:58:05 +000025import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
Sunny Goyal19ff7282021-04-22 10:12:54 -070026import static com.android.launcher3.util.DisplayController.CHANGE_SUPPORTED_BOUNDS;
Jagrut Desai3a7d1392023-09-06 15:56:19 -070027import static com.android.launcher3.util.DisplayController.CHANGE_TASKBAR_PINNING;
Sunny Goyal9c2b9602020-01-07 13:07:55 -080028import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
Sunny Goyal87dc48b2018-10-12 11:42:33 -070029
Sunny Goyalc6205602015-05-21 20:46:33 -070030import android.annotation.TargetApi;
Adam Cohen2e6da152015-05-06 11:42:25 -070031import android.content.Context;
Hyunyoung Songc55a3502018-12-04 15:43:16 -080032import android.content.res.Resources;
Sunny Goyal819e1932016-07-07 16:43:58 -070033import android.content.res.TypedArray;
34import android.content.res.XmlResourceParser;
Adam Cohen2e6da152015-05-06 11:42:25 -070035import android.graphics.Point;
Thales Lima78d00ad2021-09-30 11:29:06 +010036import android.graphics.PointF;
Alex Chauc09a98a2023-11-14 12:51:42 +000037import android.graphics.Rect;
Brandon Dayauon51db65e2024-10-23 15:07:37 -070038import android.os.Trace;
Sunny Goyal415f1732018-11-29 10:33:47 -080039import android.text.TextUtils;
40import android.util.AttributeSet;
Adam Cohen2e6da152015-05-06 11:42:25 -070041import android.util.DisplayMetrics;
Thales Lima7ec83822021-08-05 13:32:10 +010042import android.util.Log;
Sunny Goyal5bc18462019-01-07 15:13:39 -080043import android.util.SparseArray;
Sunny Goyal819e1932016-07-07 16:43:58 -070044import android.util.Xml;
Sunny Goyal9c2b9602020-01-07 13:07:55 -080045import android.view.Display;
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -070046
Thales Limab35faed2022-09-05 16:30:01 -030047import androidx.annotation.DimenRes;
Alex Chau1c883d82021-12-01 18:43:10 +000048import androidx.annotation.IntDef;
Thales Limab35faed2022-09-05 16:30:01 -030049import androidx.annotation.StyleRes;
Sunny Goyal6fe3eec2019-08-15 14:53:41 -070050import androidx.annotation.VisibleForTesting;
Thales Limaae0d7ef2022-11-16 15:53:43 +000051import androidx.annotation.XmlRes;
Thales Limab8c05952022-05-23 16:58:38 +010052import androidx.core.content.res.ResourcesCompat;
Sunny Goyal6fe3eec2019-08-15 14:53:41 -070053
Thales Limaec5abba2023-04-05 16:33:50 +010054import com.android.launcher3.config.FeatureFlags;
Sunny Goyal65190ae2022-08-02 14:16:26 -070055import com.android.launcher3.icons.DotRenderer;
Sunny Goyal68031ca2021-08-02 12:23:44 -070056import com.android.launcher3.model.DeviceGridState;
Alex Chau238aaee2021-10-06 16:15:24 +010057import com.android.launcher3.provider.RestoreDbTask;
vadimtf6ef8792022-07-26 13:54:31 -070058import com.android.launcher3.testing.shared.ResourceUtils;
Sunny Goyalfd58da62020-08-11 12:06:49 -070059import com.android.launcher3.util.DisplayController;
60import com.android.launcher3.util.DisplayController.Info;
Sunny Goyald0e360a2018-06-29 14:40:18 -070061import com.android.launcher3.util.MainThreadInitializedObject;
Sunny Goyal3e58eea2022-11-14 14:30:07 -080062import com.android.launcher3.util.Partner;
fbaronebc10c92024-09-03 12:51:41 -070063import com.android.launcher3.util.ResourceHelper;
Sunny Goyal10fa0162024-04-21 00:13:35 -070064import com.android.launcher3.util.SafeCloseable;
Sunny Goyal19ff7282021-04-22 10:12:54 -070065import com.android.launcher3.util.WindowBounds;
Sunny Goyal187b16c2022-03-01 16:53:23 -080066import com.android.launcher3.util.window.WindowManagerProxy;
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -070067
Sunny Goyal819e1932016-07-07 16:43:58 -070068import org.xmlpull.v1.XmlPullParser;
69import org.xmlpull.v1.XmlPullParserException;
70
71import java.io.IOException;
Alex Chau1c883d82021-12-01 18:43:10 +000072import java.lang.annotation.Retention;
73import java.lang.annotation.RetentionPolicy;
Adam Cohen2e6da152015-05-06 11:42:25 -070074import java.util.ArrayList;
Sunny Goyal6e6f7992021-08-24 16:23:29 -070075import java.util.Arrays;
Sunny Goyal6d55f662019-01-02 12:13:43 -080076import java.util.Collections;
Sunny Goyal19ff7282021-04-22 10:12:54 -070077import java.util.List;
Sebastián Francoad46eb72024-03-11 20:56:57 +000078import java.util.Objects;
Sunny Goyal076e04b2023-04-03 12:38:30 -070079import java.util.stream.Collectors;
Adam Cohen2e6da152015-05-06 11:42:25 -070080
Sunny Goyal10fa0162024-04-21 00:13:35 -070081public class InvariantDeviceProfile implements SafeCloseable {
Adam Cohen2e6da152015-05-06 11:42:25 -070082
Hyunyoung Songc55a3502018-12-04 15:43:16 -080083 public static final String TAG = "IDP";
Sunny Goyald0e360a2018-06-29 14:40:18 -070084 // We do not need any synchronization for this variable as its only written on UI thread.
85 public static final MainThreadInitializedObject<InvariantDeviceProfile> INSTANCE =
Sunny Goyal87dc48b2018-10-12 11:42:33 -070086 new MainThreadInitializedObject<>(InvariantDeviceProfile::new);
Adam Cohen2e6da152015-05-06 11:42:25 -070087
Alex Chau1c883d82021-12-01 18:43:10 +000088 @Retention(RetentionPolicy.SOURCE)
89 @IntDef({TYPE_PHONE, TYPE_MULTI_DISPLAY, TYPE_TABLET})
Sebastian Franco9e4c99b2024-10-02 15:16:37 -070090 public @interface DeviceType {
91 }
Thales Limab8c05952022-05-23 16:58:38 +010092
Alex Chau1c883d82021-12-01 18:43:10 +000093 public static final int TYPE_PHONE = 0;
94 public static final int TYPE_MULTI_DISPLAY = 1;
95 public static final int TYPE_TABLET = 2;
96
Sunny Goyal53d7ee42015-05-22 12:25:45 -070097 private static final float ICON_SIZE_DEFINED_IN_APP_DP = 48;
98
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -070099 // Constants that affects the interpolation curve between statically defined device profile
100 // buckets.
Hyunyoung Songc55a3502018-12-04 15:43:16 -0800101 private static final float KNEARESTNEIGHBOR = 3;
102 private static final float WEIGHT_POWER = 5;
Adam Cohen2e6da152015-05-06 11:42:25 -0700103
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700104 // used to offset float not being able to express extremely small weights in extreme cases.
Hyunyoung Songc55a3502018-12-04 15:43:16 -0800105 private static final float WEIGHT_EFFICIENT = 100000f;
106
Thales Lima83bedbf2021-10-05 17:47:39 +0100107 // Used for arrays to specify different sizes (e.g. border spaces, width/height) in different
108 // constraints
Thales Limabb7d3882021-12-22 12:56:29 +0000109 static final int COUNT_SIZES = 4;
Thales Lima83bedbf2021-10-05 17:47:39 +0100110 static final int INDEX_DEFAULT = 0;
111 static final int INDEX_LANDSCAPE = 1;
112 static final int INDEX_TWO_PANEL_PORTRAIT = 2;
113 static final int INDEX_TWO_PANEL_LANDSCAPE = 3;
Thales Lima83bedbf2021-10-05 17:47:39 +0100114
Thales Limaec5abba2023-04-05 16:33:50 +0100115 /** These resources are used to override the device profile */
Sunny Goyal3e58eea2022-11-14 14:30:07 -0800116 private static final String RES_GRID_NUM_ROWS = "grid_num_rows";
117 private static final String RES_GRID_NUM_COLUMNS = "grid_num_columns";
118 private static final String RES_GRID_ICON_SIZE_DP = "grid_icon_size_dp";
119
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700120 /**
121 * Number of icons per row and column in the workspace.
122 */
Adam Cohen2e6da152015-05-06 11:42:25 -0700123 public int numRows;
124 public int numColumns;
Alex Chau9fee3fd2021-12-01 18:43:10 +0000125 public int numSearchContainerColumns;
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700126
127 /**
128 * Number of icons per row and column in the folder.
129 */
Thales Lima1faa4ed2023-12-01 16:48:19 +0000130 public int[] numFolderRows;
131 public int[] numFolderColumns;
Thales Lima83bedbf2021-10-05 17:47:39 +0100132 public float[] iconSize;
133 public float[] iconTextSize;
Sunny Goyalfc218302015-09-17 14:59:10 -0700134 public int iconBitmapSize;
135 public int fillResIconDpi;
Alex Chau1c883d82021-12-01 18:43:10 +0000136 public @DeviceType int deviceType;
Federico Baron56307d22024-11-06 18:48:48 +0000137 public Info displayInfo;
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700138
Thales Lima83bedbf2021-10-05 17:47:39 +0100139 public PointF[] minCellSize;
Thales Lima78d00ad2021-09-30 11:29:06 +0100140
Thales Lima83bedbf2021-10-05 17:47:39 +0100141 public PointF[] borderSpaces;
Thales Limab35faed2022-09-05 16:30:01 -0300142 public @DimenRes int inlineNavButtonsEndSpacing;
Thales Lima78d00ad2021-09-30 11:29:06 +0100143
Thales Limab35faed2022-09-05 16:30:01 -0300144 public @StyleRes int folderStyle;
Thales Limaa08a4432022-08-09 09:55:17 +0100145
Thales Limad852d652023-01-17 14:01:13 +0000146 public @StyleRes int cellStyle;
147
Thales Lima83bedbf2021-10-05 17:47:39 +0100148 public float[] horizontalMargin;
Jon Mirandae126d722021-02-25 10:45:20 -0500149
Thales Limab7ef5692022-03-10 10:32:36 +0000150 public PointF[] allAppsCellSize;
Thales Limabb7d3882021-12-22 12:56:29 +0000151 public float[] allAppsIconSize;
152 public float[] allAppsIconTextSize;
153 public PointF[] allAppsBorderSpaces;
154
Jon Miranda9c478b62023-03-23 21:38:49 -0700155 public float[] transientTaskbarIconSize;
156
Jon Miranda04f05102023-04-04 12:16:31 -0700157 public boolean[] startAlignTaskbar;
158
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700159 /**
160 * Number of icons inside the hotseat area.
161 */
Jon Mirandafd48b0c2022-01-31 16:25:22 -0800162 public int numShownHotseatIcons;
Tony Wickhamb87f3cd2021-04-07 15:02:37 -0700163
164 /**
165 * Number of icons inside the hotseat area that is stored in the database. This is greater than
166 * or equal to numnShownHotseatIcons, allowing for a seamless transition between two hotseat
167 * sizes that share the same DB.
168 */
169 public int numDatabaseHotseatIcons;
Adam Cohen27824492017-09-22 17:10:55 -0700170
Thales Limab8c05952022-05-23 16:58:38 +0100171 public float[] hotseatBarBottomSpace;
172 public float[] hotseatQsbSpace;
Thales Lima425f6822022-05-10 13:44:58 -0300173
Jon Miranda6f7e9702019-09-16 14:44:14 -0700174 /**
175 * Number of columns in the all apps list.
176 */
177 public int numAllAppsColumns;
Jordan Silva2de6a272024-01-04 14:44:20 -0300178 public int numAllAppsRowsForCellHeightCalculation;
Sunny Goyal19ff7282021-04-22 10:12:54 -0700179 public int numDatabaseAllAppsColumns;
Thales Limae9273ea2023-01-26 12:33:52 +0000180 public @StyleRes int allAppsStyle;
Jon Miranda6f7e9702019-09-16 14:44:14 -0700181
Jon Mirandae126d722021-02-25 10:45:20 -0500182 /**
183 * Do not query directly. see {@link DeviceProfile#isScalableGrid}.
184 */
185 protected boolean isScalable;
Thales Limaae0d7ef2022-11-16 15:53:43 +0000186 @XmlRes
187 public int devicePaddingId = INVALID_RESOURCE_HANDLE;
Thales Limaec5abba2023-04-05 16:33:50 +0100188 @XmlRes
189 public int workspaceSpecsId = INVALID_RESOURCE_HANDLE;
Thales Limaabfe3642023-05-24 18:08:53 +0100190 @XmlRes
fbaronebc10c92024-09-03 12:51:41 -0700191 public int rowCountSpecsId = INVALID_RESOURCE_HANDLE;;
192 @XmlRes
Jordan Silva575c3bd2023-07-21 12:00:43 +0100193 public int workspaceSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
194 @XmlRes
Thales Limaabfe3642023-05-24 18:08:53 +0100195 public int allAppsSpecsId = INVALID_RESOURCE_HANDLE;
Jordan Silva637f4eb2023-06-13 11:21:53 +0100196 @XmlRes
Jordan Silva575c3bd2023-07-21 12:00:43 +0100197 public int allAppsSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
198 @XmlRes
Jordan Silva637f4eb2023-06-13 11:21:53 +0100199 public int folderSpecsId = INVALID_RESOURCE_HANDLE;
Jordan Silva575c3bd2023-07-21 12:00:43 +0100200 @XmlRes
201 public int folderSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
Jordan Silva999dd2a2023-11-17 19:31:43 +0000202 @XmlRes
Thales Limaf8bfb032023-07-24 15:08:05 +0100203 public int hotseatSpecsId = INVALID_RESOURCE_HANDLE;
Jordan Silva999dd2a2023-11-17 19:31:43 +0000204 @XmlRes
Thales Limaf8bfb032023-07-24 15:08:05 +0100205 public int hotseatSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
Jordan Silva999dd2a2023-11-17 19:31:43 +0000206 @XmlRes
207 public int workspaceCellSpecsId = INVALID_RESOURCE_HANDLE;
208 @XmlRes
209 public int workspaceCellSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
210 @XmlRes
211 public int allAppsCellSpecsId = INVALID_RESOURCE_HANDLE;
212 @XmlRes
213 public int allAppsCellSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
Jon Mirandae126d722021-02-25 10:45:20 -0500214
Sebastian Franco9e4c99b2024-10-02 15:16:37 -0700215
216 /**
217 * Fixed landscape mode is the landscape on the phones.
218 */
219 public boolean isFixedLandscapeMode = false;
220 private LauncherPrefChangeListener mLandscapeModePreferenceListener;
221
Tracy Zhou7df93d22020-01-27 13:44:06 -0800222 public String dbFile;
Sunny Goyal415f1732018-11-29 10:33:47 -0800223 public int defaultLayoutId;
Sunny Goyal1ae46ca2023-04-10 15:28:59 -0700224 public int demoModeLayoutId;
Thales Lima9938c2f2022-07-25 14:38:16 +0100225 public boolean[] inlineQsb = new boolean[COUNT_SIZES];
Adam Cohen2e6da152015-05-06 11:42:25 -0700226
Pinyao Ting9cd63c92021-06-16 17:51:39 +0000227 /**
228 * An immutable list of supported profiles.
229 */
230 public List<DeviceProfile> supportedProfiles = Collections.EMPTY_LIST;
Sunny Goyalc6205602015-05-21 20:46:33 -0700231
Sunny Goyal6f866092016-03-17 17:04:15 -0700232 public Point defaultWallpaperSize;
233
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700234 private final ArrayList<OnIDPChangeListener> mChangeListeners = new ArrayList<>();
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700235
Sunny Goyalf633ef52018-03-13 09:57:05 -0700236 @VisibleForTesting
Sebastian Franco9e4c99b2024-10-02 15:16:37 -0700237 public InvariantDeviceProfile() {
238 }
Adam Cohen2e6da152015-05-06 11:42:25 -0700239
Sunny Goyalbbf01842015-10-08 07:41:15 -0700240 @TargetApi(23)
Sunny Goyald0e360a2018-06-29 14:40:18 -0700241 private InvariantDeviceProfile(Context context) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700242 String gridName = getCurrentGridName(context);
243 String newGridName = initGrid(context, gridName);
244 if (!newGridName.equals(gridName)) {
Stefan Andonian4c9612b2023-02-22 00:00:03 +0000245 LauncherPrefs.get(context).put(GRID_NAME, newGridName);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700246 }
247
Tracy Zhouc8beebf2021-09-23 10:18:11 -0700248 DisplayController.INSTANCE.get(context).setPriorityListener(
Alex Chaufd6d9422021-04-22 19:10:21 +0100249 (displayContext, info, flags) -> {
Alex Chau6ed408f2022-03-04 12:58:05 +0000250 if ((flags & (CHANGE_DENSITY | CHANGE_SUPPORTED_BOUNDS
Jagrut Desai2e8ca872024-04-17 15:27:30 -0700251 | CHANGE_NAVIGATION_MODE | CHANGE_TASKBAR_PINNING
252 | CHANGE_DESKTOP_MODE)) != 0) {
Alex Chaufd6d9422021-04-22 19:10:21 +0100253 onConfigChanged(displayContext);
Sunny Goyal35c7b192021-04-20 16:51:10 -0700254 }
255 });
Sebastian Franco9e4c99b2024-10-02 15:16:37 -0700256 if (Flags.oneGridSpecs()) {
257 mLandscapeModePreferenceListener = (String s) -> {
258 boolean newFixedLandscapeValue = FIXED_LANDSCAPE_MODE.get(context);
259 if (isFixedLandscapeMode != newFixedLandscapeValue) {
260 setFixedLandscape(context, newFixedLandscapeValue);
261 }
262 };
263 LauncherPrefs.INSTANCE.get(context).addListener(
264 mLandscapeModePreferenceListener,
265 FIXED_LANDSCAPE_MODE
266 );
267 }
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700268 }
269
Hyunyoung Songe11eb472019-03-19 15:05:21 -0700270 /**
271 * This constructor should NOT have any monitors by design.
272 */
Sunny Goyaleff44f32019-01-09 17:29:49 -0800273 public InvariantDeviceProfile(Context context, String gridName) {
274 String newName = initGrid(context, gridName);
275 if (newName == null || !newName.equals(gridName)) {
Andy Wickham99d7d4f2023-11-15 08:09:09 +0000276 throw new IllegalArgumentException("Unknown grid name: " + gridName);
Sunny Goyaleff44f32019-01-09 17:29:49 -0800277 }
278 }
279
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700280 /**
Sunny Goyal9c2b9602020-01-07 13:07:55 -0800281 * This constructor should NOT have any monitors by design.
282 */
283 public InvariantDeviceProfile(Context context, Display display) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700284 // Ensure that the main device profile is initialized
Alex Chaufd6d9422021-04-22 19:10:21 +0100285 INSTANCE.get(context);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700286 String gridName = getCurrentGridName(context);
287
288 // Get the display info based on default display and interpolate it to existing display
Alex Chau1c883d82021-12-01 18:43:10 +0000289 Info defaultInfo = DisplayController.INSTANCE.get(context).getInfo();
Sunny Goyal25c42762024-04-16 19:31:31 -0700290 @DeviceType int defaultDeviceType = defaultInfo.getDeviceType();
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700291 DisplayOption defaultDisplayOption = invDistWeightedInterpolate(
Alex Chau1c883d82021-12-01 18:43:10 +0000292 defaultInfo,
Sebastian Franco9e4c99b2024-10-02 15:16:37 -0700293 getPredefinedDeviceProfiles(
294 context,
295 gridName,
296 defaultInfo,
297 /*allowDisabledGrid=*/false,
298 isFixedLandscapeMode
299 ),
Alex Chau1c883d82021-12-01 18:43:10 +0000300 defaultDeviceType);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700301
Alex Chau661f02d2022-06-07 14:03:43 +0100302 Context displayContext = context.createDisplayContext(display);
303 Info myInfo = new Info(displayContext);
Sunny Goyal25c42762024-04-16 19:31:31 -0700304 @DeviceType int deviceType = myInfo.getDeviceType();
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700305 DisplayOption myDisplayOption = invDistWeightedInterpolate(
Alex Chau1c883d82021-12-01 18:43:10 +0000306 myInfo,
Sebastian Franco9e4c99b2024-10-02 15:16:37 -0700307 getPredefinedDeviceProfiles(
308 context,
309 gridName,
310 myInfo,
311 /*allowDisabledGrid=*/false,
312 isFixedLandscapeMode
313 ),
Alex Chau1c883d82021-12-01 18:43:10 +0000314 deviceType);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700315
316 DisplayOption result = new DisplayOption(defaultDisplayOption.grid)
317 .add(myDisplayOption);
Thales Lima83bedbf2021-10-05 17:47:39 +0100318 result.iconSizes[INDEX_DEFAULT] =
319 defaultDisplayOption.iconSizes[INDEX_DEFAULT];
320 for (int i = 1; i < COUNT_SIZES; i++) {
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700321 result.iconSizes[i] = Math.min(
322 defaultDisplayOption.iconSizes[i], myDisplayOption.iconSizes[i]);
Alex Chau7c439722021-03-24 11:32:44 +0000323 }
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700324
Thales Lima83bedbf2021-10-05 17:47:39 +0100325 System.arraycopy(defaultDisplayOption.minCellSize, 0, result.minCellSize, 0,
326 COUNT_SIZES);
327 System.arraycopy(defaultDisplayOption.borderSpaces, 0, result.borderSpaces, 0,
328 COUNT_SIZES);
Jon Miranda228877d2021-02-09 11:05:00 -0500329
Federico Baron56307d22024-11-06 18:48:48 +0000330 initGrid(context, myInfo, result);
Sunny Goyal9c2b9602020-01-07 13:07:55 -0800331 }
332
Sunny Goyal10fa0162024-04-21 00:13:35 -0700333 @Override
334 public void close() {
335 DisplayController.INSTANCE.executeIfCreated(dc -> dc.setPriorityListener(null));
Sebastian Franco9e4c99b2024-10-02 15:16:37 -0700336 if (mLandscapeModePreferenceListener != null) {
337 LauncherPrefs.INSTANCE.executeIfCreated(
338 lp -> lp.removeListener(mLandscapeModePreferenceListener, FIXED_LANDSCAPE_MODE)
339 );
340 }
Sunny Goyal10fa0162024-04-21 00:13:35 -0700341 }
342
Tracy Zhou42255d22020-03-13 00:38:11 -0700343 public static String getCurrentGridName(Context context) {
Stefan Andonian4c9612b2023-02-22 00:00:03 +0000344 return LauncherPrefs.get(context).get(GRID_NAME);
Tracy Zhou42255d22020-03-13 00:38:11 -0700345 }
346
Sunny Goyaleff44f32019-01-09 17:29:49 -0800347 private String initGrid(Context context, String gridName) {
fbaronc1b68f42024-11-08 18:10:46 -0800348 if (!Flags.oneGridSpecs() && (isFixedLandscapeMode || FIXED_LANDSCAPE_MODE.get(context))) {
349 LauncherPrefs.get(context).put(FIXED_LANDSCAPE_MODE, false);
350 isFixedLandscapeMode = false;
351 }
352
Sunny Goyal35c7b192021-04-20 16:51:10 -0700353 Info displayInfo = DisplayController.INSTANCE.get(context).getInfo();
Sunny Goyal19ff7282021-04-22 10:12:54 -0700354
Sebastian Franco9e4c99b2024-10-02 15:16:37 -0700355 List<DisplayOption> allOptions = getPredefinedDeviceProfiles(
356 context,
357 gridName,
358 displayInfo,
359 RestoreDbTask.isPending(context),
360 FIXED_LANDSCAPE_MODE.get(context)
361 );
fbaronebc10c92024-09-03 12:51:41 -0700362
363 // Filter out options that don't have the same number of columns as the grid
364 DeviceGridState deviceGridState = new DeviceGridState(context);
365 List<DisplayOption> allOptionsFilteredByColCount =
366 filterByColumnCount(allOptions, deviceGridState.getColumns());
367
Sunny Goyal19ff7282021-04-22 10:12:54 -0700368 DisplayOption displayOption =
fbaronebc10c92024-09-03 12:51:41 -0700369 invDistWeightedInterpolate(displayInfo, allOptionsFilteredByColCount.isEmpty()
Sebastian Franco9e4c99b2024-10-02 15:16:37 -0700370 ? new ArrayList<>(allOptions)
371 : new ArrayList<>(allOptionsFilteredByColCount),
Federico Baron56307d22024-11-06 18:48:48 +0000372 displayInfo.getDeviceType());
373 initGrid(context, displayInfo, displayOption);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700374 return displayOption.grid.name;
Sunny Goyal9c2b9602020-01-07 13:07:55 -0800375 }
Adam Cohen2e6da152015-05-06 11:42:25 -0700376
fbaronebc10c92024-09-03 12:51:41 -0700377 private List<DisplayOption> filterByColumnCount(
378 List<DisplayOption> allOptions, int numColumns) {
379 return allOptions.stream().filter(
380 option -> option.grid.numColumns == numColumns).toList();
381 }
382
Sebastian Francodf7d2b02024-04-04 15:12:18 -0700383 /**
384 * @deprecated This is a temporary solution because on the backup and restore case we modify the
385 * IDP, this resets it. b/332974074
386 */
387 @Deprecated
388 public void reset(Context context) {
fbaronb633b9a2024-09-23 18:35:29 -0700389 initGrid(context, getDefaultGridName(context));
Sebastian Francodf7d2b02024-04-04 15:12:18 -0700390 }
391
Thales Limab67bfa72022-11-02 15:30:11 +0000392 @VisibleForTesting
393 public static String getDefaultGridName(Context context) {
394 return new InvariantDeviceProfile().initGrid(context, null);
395 }
396
Federico Baron56307d22024-11-06 18:48:48 +0000397 private void initGrid(Context context, Info displayInfo, DisplayOption displayOption) {
Sunny Goyal35c7b192021-04-20 16:51:10 -0700398 DisplayMetrics metrics = context.getResources().getDisplayMetrics();
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700399 GridOption closestProfile = displayOption.grid;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000400 numRows = closestProfile.numRows;
401 numColumns = closestProfile.numColumns;
Alex Chau9fee3fd2021-12-01 18:43:10 +0000402 numSearchContainerColumns = closestProfile.numSearchContainerColumns;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000403 dbFile = closestProfile.dbFile;
404 defaultLayoutId = closestProfile.defaultLayoutId;
405 demoModeLayoutId = closestProfile.demoModeLayoutId;
Thales Limab35faed2022-09-05 16:30:01 -0300406
Sunny Goyalae190ff2020-04-14 00:19:01 +0000407 numFolderRows = closestProfile.numFolderRows;
408 numFolderColumns = closestProfile.numFolderColumns;
Thales Limab35faed2022-09-05 16:30:01 -0300409 folderStyle = closestProfile.folderStyle;
410
Thales Limad852d652023-01-17 14:01:13 +0000411 cellStyle = closestProfile.cellStyle;
412
Jon Mirandae126d722021-02-25 10:45:20 -0500413 isScalable = closestProfile.isScalable;
Jon Mirandac9e69fa2021-03-22 17:13:34 -0400414 devicePaddingId = closestProfile.devicePaddingId;
Thales Limaec5abba2023-04-05 16:33:50 +0100415 workspaceSpecsId = closestProfile.mWorkspaceSpecsId;
fbaronebc10c92024-09-03 12:51:41 -0700416 rowCountSpecsId = closestProfile.mRowCountSpecsId;
Jordan Silva575c3bd2023-07-21 12:00:43 +0100417 workspaceSpecsTwoPanelId = closestProfile.mWorkspaceSpecsTwoPanelId;
Thales Limaabfe3642023-05-24 18:08:53 +0100418 allAppsSpecsId = closestProfile.mAllAppsSpecsId;
Jordan Silva575c3bd2023-07-21 12:00:43 +0100419 allAppsSpecsTwoPanelId = closestProfile.mAllAppsSpecsTwoPanelId;
Jordan Silva637f4eb2023-06-13 11:21:53 +0100420 folderSpecsId = closestProfile.mFolderSpecsId;
Jordan Silva575c3bd2023-07-21 12:00:43 +0100421 folderSpecsTwoPanelId = closestProfile.mFolderSpecsTwoPanelId;
Thales Limaf8bfb032023-07-24 15:08:05 +0100422 hotseatSpecsId = closestProfile.mHotseatSpecsId;
423 hotseatSpecsTwoPanelId = closestProfile.mHotseatSpecsTwoPanelId;
Jordan Silva999dd2a2023-11-17 19:31:43 +0000424 workspaceCellSpecsId = closestProfile.mWorkspaceCellSpecsId;
425 workspaceCellSpecsTwoPanelId = closestProfile.mWorkspaceCellSpecsTwoPanelId;
426 allAppsCellSpecsId = closestProfile.mAllAppsCellSpecsId;
427 allAppsCellSpecsTwoPanelId = closestProfile.mAllAppsCellSpecsTwoPanelId;
Jordan Silva2de6a272024-01-04 14:44:20 -0300428 numAllAppsRowsForCellHeightCalculation =
429 closestProfile.mNumAllAppsRowsForCellHeightCalculation;
Federico Baron56307d22024-11-06 18:48:48 +0000430 this.deviceType = displayInfo.getDeviceType();
431 this.displayInfo = displayInfo;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000432
Vinit Nayakc7293172022-07-18 16:41:50 -0700433 inlineNavButtonsEndSpacing = closestProfile.inlineNavButtonsEndSpacing;
434
Thales Lima83bedbf2021-10-05 17:47:39 +0100435 iconSize = displayOption.iconSizes;
Thales Lima6e0005a2021-10-27 15:53:41 +0100436 float maxIconSize = iconSize[0];
437 for (int i = 1; i < iconSize.length; i++) {
438 maxIconSize = Math.max(maxIconSize, iconSize[i]);
439 }
440 iconBitmapSize = ResourceUtils.pxFromDp(maxIconSize, metrics);
Sunny Goyalae190ff2020-04-14 00:19:01 +0000441 fillResIconDpi = getLauncherIconDensity(iconBitmapSize);
442
Thales Lima83bedbf2021-10-05 17:47:39 +0100443 iconTextSize = displayOption.textSizes;
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700444
Thales Lima83bedbf2021-10-05 17:47:39 +0100445 minCellSize = displayOption.minCellSize;
Thales Lima78d00ad2021-09-30 11:29:06 +0100446
Thales Lima83bedbf2021-10-05 17:47:39 +0100447 borderSpaces = displayOption.borderSpaces;
Thales Limaa08a4432022-08-09 09:55:17 +0100448
Thales Limad90faab2021-09-21 17:18:47 +0100449 horizontalMargin = displayOption.horizontalMargin;
Thales Limad90faab2021-09-21 17:18:47 +0100450
Sunny Goyal19ff7282021-04-22 10:12:54 -0700451 numShownHotseatIcons = closestProfile.numHotseatIcons;
Alex Chau1c883d82021-12-01 18:43:10 +0000452 numDatabaseHotseatIcons = deviceType == TYPE_MULTI_DISPLAY
Sunny Goyal19ff7282021-04-22 10:12:54 -0700453 ? closestProfile.numDatabaseHotseatIcons : closestProfile.numHotseatIcons;
Thales Limab8c05952022-05-23 16:58:38 +0100454 hotseatBarBottomSpace = displayOption.hotseatBarBottomSpace;
455 hotseatQsbSpace = displayOption.hotseatQsbSpace;
Sunny Goyal19ff7282021-04-22 10:12:54 -0700456
Thales Limae9273ea2023-01-26 12:33:52 +0000457 allAppsStyle = closestProfile.allAppsStyle;
458
Sunny Goyal19ff7282021-04-22 10:12:54 -0700459 numAllAppsColumns = closestProfile.numAllAppsColumns;
Jordan Silva2de6a272024-01-04 14:44:20 -0300460
Alex Chau1c883d82021-12-01 18:43:10 +0000461 numDatabaseAllAppsColumns = deviceType == TYPE_MULTI_DISPLAY
Sunny Goyal19ff7282021-04-22 10:12:54 -0700462 ? closestProfile.numDatabaseAllAppsColumns : closestProfile.numAllAppsColumns;
Jon Mirandae126d722021-02-25 10:45:20 -0500463
Thales Limab7ef5692022-03-10 10:32:36 +0000464 allAppsCellSize = displayOption.allAppsCellSize;
Thales Limabb7d3882021-12-22 12:56:29 +0000465 allAppsBorderSpaces = displayOption.allAppsBorderSpaces;
466 allAppsIconSize = displayOption.allAppsIconSizes;
467 allAppsIconTextSize = displayOption.allAppsIconTextSizes;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000468
Thales Lima11af7bc2022-08-12 15:24:54 +0100469 inlineQsb = closestProfile.inlineQsb;
Thales Lima12d0eff2022-03-25 17:06:11 +0000470
Jon Miranda9c478b62023-03-23 21:38:49 -0700471 transientTaskbarIconSize = displayOption.transientTaskbarIconSize;
472
Jon Miranda04f05102023-04-04 12:16:31 -0700473 startAlignTaskbar = displayOption.startAlignTaskbar;
474
Sebastian Franco9e4c99b2024-10-02 15:16:37 -0700475 // Fixed Landscape mode
476 isFixedLandscapeMode = FIXED_LANDSCAPE_MODE.get(context) && Flags.oneGridSpecs();
477
Sunny Goyalae190ff2020-04-14 00:19:01 +0000478 // If the partner customization apk contains any grid overrides, apply them
479 // Supported overrides: numRows, numColumns, iconSize
Sunny Goyal35c7b192021-04-20 16:51:10 -0700480 applyPartnerDeviceProfileOverrides(context, metrics);
Sunny Goyalc6205602015-05-21 20:46:33 -0700481
Pinyao Ting9cd63c92021-06-16 17:51:39 +0000482 final List<DeviceProfile> localSupportedProfiles = new ArrayList<>();
Sunny Goyal19ff7282021-04-22 10:12:54 -0700483 defaultWallpaperSize = new Point(displayInfo.currentSize);
Sunny Goyal65190ae2022-08-02 14:16:26 -0700484 SparseArray<DotRenderer> dotRendererCache = new SparseArray<>();
Sunny Goyal19ff7282021-04-22 10:12:54 -0700485 for (WindowBounds bounds : displayInfo.supportedBounds) {
Pinyao Ting9cd63c92021-06-16 17:51:39 +0000486 localSupportedProfiles.add(new DeviceProfile.Builder(context, this, displayInfo)
Alex Chauab800f72022-12-13 17:46:06 +0000487 .setIsMultiDisplay(deviceType == TYPE_MULTI_DISPLAY)
Alex Chau6ed408f2022-03-04 12:58:05 +0000488 .setWindowBounds(bounds)
Sunny Goyal65190ae2022-08-02 14:16:26 -0700489 .setDotRendererCache(dotRendererCache)
Alex Chau6ed408f2022-03-04 12:58:05 +0000490 .build());
Sunny Goyalc6205602015-05-21 20:46:33 -0700491
Sunny Goyal19ff7282021-04-22 10:12:54 -0700492 // Wallpaper size should be the maximum of the all possible sizes Launcher expects
493 int displayWidth = bounds.bounds.width();
494 int displayHeight = bounds.bounds.height();
495 defaultWallpaperSize.y = Math.max(defaultWallpaperSize.y, displayHeight);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700496
Sunny Goyal19ff7282021-04-22 10:12:54 -0700497 // We need to ensure that there is enough extra space in the wallpaper
498 // for the intended parallax effects
499 float parallaxFactor =
Thales Lima425f6822022-05-10 13:44:58 -0300500 dpiFromPx(Math.min(displayWidth, displayHeight), displayInfo.getDensityDpi())
501 < 720
Sunny Goyal19ff7282021-04-22 10:12:54 -0700502 ? 2
503 : wallpaperTravelToScreenWidthRatio(displayWidth, displayHeight);
504 defaultWallpaperSize.x =
505 Math.max(defaultWallpaperSize.x, Math.round(parallaxFactor * displayWidth));
Sunny Goyal6f866092016-03-17 17:04:15 -0700506 }
Pinyao Ting9cd63c92021-06-16 17:51:39 +0000507 supportedProfiles = Collections.unmodifiableList(localSupportedProfiles);
Sunny Goyal58fa4b62019-03-22 16:23:25 -0700508
Thales Lima6a590062022-11-22 15:52:49 +0000509 int numMinShownHotseatIconsForTablet = supportedProfiles
510 .stream()
511 .filter(deviceProfile -> deviceProfile.isTablet)
512 .mapToInt(deviceProfile -> deviceProfile.numShownHotseatIcons)
513 .min()
514 .orElse(0);
515
516 supportedProfiles
517 .stream()
518 .filter(deviceProfile -> deviceProfile.isTablet)
519 .forEach(deviceProfile -> {
520 deviceProfile.numShownHotseatIcons = numMinShownHotseatIconsForTablet;
521 deviceProfile.recalculateHotseatWidthAndBorderSpace();
522 });
Adam Cohen2e6da152015-05-06 11:42:25 -0700523 }
524
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700525 public void addOnChangeListener(OnIDPChangeListener listener) {
526 mChangeListeners.add(listener);
527 }
528
Hyunyoung Songb4d1ca42019-01-08 17:15:16 -0800529 public void removeOnChangeListener(OnIDPChangeListener listener) {
530 mChangeListeners.remove(listener);
531 }
532
Sebastian Franco9e4c99b2024-10-02 15:16:37 -0700533 /**
534 * Updates the current grid, this triggers a new IDP, reloads the database and triggers a grid
535 * migration.
536 */
537 public void setCurrentGrid(Context context, String newGridName) {
538 LauncherPrefs.get(context).put(GRID_NAME, newGridName);
Brandon Dayauon51db65e2024-10-23 15:07:37 -0700539 MAIN_EXECUTOR.execute(() -> {
540 Trace.beginSection("InvariantDeviceProfile#setCurrentGrid");
541 onConfigChanged(context.getApplicationContext());
542 Trace.endSection();
543 });
Sunny Goyal7d892ff2019-01-11 15:08:44 -0800544 }
545
Sebastian Franco9e4c99b2024-10-02 15:16:37 -0700546 /**
fbaronc1b68f42024-11-08 18:10:46 -0800547 * Updates the fixed landscape mode, this triggers a new IDP, reloads the database and triggers
548 * a grid migration.
Sebastian Franco9e4c99b2024-10-02 15:16:37 -0700549 */
550 public void setFixedLandscape(Context context, boolean isFixedLandscape) {
551 this.isFixedLandscapeMode = isFixedLandscape;
552 if (isFixedLandscape) {
553 // When in isFixedLandscape there should only be one default grid to choose from
554 MAIN_EXECUTOR.execute(() -> {
555 Trace.beginSection("InvariantDeviceProfile#setFixedLandscape");
556 onConfigChanged(context.getApplicationContext());
557 Trace.endSection();
558 });
559 } else {
560 setCurrentGrid(context, LauncherPrefs.get(context).get(GRID_NAME));
561 }
562 }
563
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700564 private Object[] toModelState() {
sfufa@google.comde013292021-09-21 18:22:44 -0700565 return new Object[]{
Alex Chau9fee3fd2021-12-01 18:43:10 +0000566 numColumns, numRows, numSearchContainerColumns, numDatabaseHotseatIcons,
567 iconBitmapSize, fillResIconDpi, numDatabaseAllAppsColumns, dbFile};
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700568 }
569
Pat Manning24cec692023-10-13 10:36:57 +0000570 /** Updates IDP using the provided context. Notifies listeners of change. */
571 @VisibleForTesting
572 public void onConfigChanged(Context context) {
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700573 Object[] oldState = toModelState();
574
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700575 // Re-init grid
Tracy Zhouc6060e62020-04-27 13:05:34 -0700576 String gridName = getCurrentGridName(context);
Jon Miranda6f7e9702019-09-16 14:44:14 -0700577 initGrid(context, gridName);
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700578
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700579 boolean modelPropsChanged = !Arrays.equals(oldState, toModelState());
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700580 for (OnIDPChangeListener listener : mChangeListeners) {
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700581 listener.onIdpChanged(modelPropsChanged);
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700582 }
583 }
584
Sebastian Franco9e4c99b2024-10-02 15:16:37 -0700585 private static boolean firstGridFilter(GridOption gridOption, int deviceType,
586 boolean allowDisabledGrid, boolean isFixedLandscapeMode) {
587 return (gridOption.isEnabled(deviceType) || allowDisabledGrid)
fbaronc1b68f42024-11-08 18:10:46 -0800588 && gridOption.filterByFlag(deviceType, isFixedLandscapeMode);
Sebastian Franco9e4c99b2024-10-02 15:16:37 -0700589 }
590
591 private static List<DisplayOption> getPredefinedDeviceProfiles(
592 Context context,
593 String gridName,
594 Info displayInfo,
595 boolean allowDisabledGrid,
596 boolean isFixedLandscapeMode
597 ) {
Sunny Goyal415f1732018-11-29 10:33:47 -0800598 ArrayList<DisplayOption> profiles = new ArrayList<>();
Thales Lima1de4d552021-10-13 16:13:25 +0100599
Alex Chau1c883d82021-12-01 18:43:10 +0000600 try (XmlResourceParser parser = context.getResources().getXml(R.xml.device_profiles)) {
Sunny Goyal819e1932016-07-07 16:43:58 -0700601 final int depth = parser.getDepth();
602 int type;
Sunny Goyal819e1932016-07-07 16:43:58 -0700603 while (((type = parser.next()) != XmlPullParser.END_TAG ||
604 parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
Sunny Goyal7d892ff2019-01-11 15:08:44 -0800605 if ((type == XmlPullParser.START_TAG)
606 && GridOption.TAG_NAME.equals(parser.getName())) {
Federico Baron56307d22024-11-06 18:48:48 +0000607 GridOption gridOption = new GridOption(
608 context, Xml.asAttributeSet(parser), displayInfo);
Sebastian Franco9e4c99b2024-10-02 15:16:37 -0700609 if (firstGridFilter(gridOption, displayInfo.getDeviceType(), allowDisabledGrid,
610 isFixedLandscapeMode)) {
Thales Lima7ec83822021-08-05 13:32:10 +0100611 final int displayDepth = parser.getDepth();
612 while (((type = parser.next()) != XmlPullParser.END_TAG
613 || parser.getDepth() > displayDepth)
614 && type != XmlPullParser.END_DOCUMENT) {
615 if ((type == XmlPullParser.START_TAG) && "display-option".equals(
616 parser.getName())) {
617 profiles.add(new DisplayOption(gridOption, context,
Thales Lima1de4d552021-10-13 16:13:25 +0100618 Xml.asAttributeSet(parser)));
Thales Lima7ec83822021-08-05 13:32:10 +0100619 }
Sunny Goyal415f1732018-11-29 10:33:47 -0800620 }
621 }
Sunny Goyal819e1932016-07-07 16:43:58 -0700622 }
623 }
sfufa@google.comde013292021-09-21 18:22:44 -0700624 } catch (IOException | XmlPullParserException e) {
Sunny Goyal819e1932016-07-07 16:43:58 -0700625 throw new RuntimeException(e);
626 }
Sunny Goyalae190ff2020-04-14 00:19:01 +0000627 ArrayList<DisplayOption> filteredProfiles = new ArrayList<>();
Sunny Goyal415f1732018-11-29 10:33:47 -0800628 if (!TextUtils.isEmpty(gridName)) {
629 for (DisplayOption option : profiles) {
Federico Baron56307d22024-11-06 18:48:48 +0000630 if (gridName.equals(option.grid.name) && (option.grid.isEnabled(
631 displayInfo.getDeviceType()) || allowDisabledGrid)) {
Sunny Goyalae190ff2020-04-14 00:19:01 +0000632 filteredProfiles.add(option);
Sunny Goyal415f1732018-11-29 10:33:47 -0800633 }
634 }
635 }
fbaronebc10c92024-09-03 12:51:41 -0700636 if (filteredProfiles.isEmpty() && TextUtils.isEmpty(gridName)) {
637 // Use the default options since gridName is empty and there's no valid grids.
Sunny Goyalae190ff2020-04-14 00:19:01 +0000638 for (DisplayOption option : profiles) {
639 if (option.canBeDefault) {
640 filteredProfiles.add(option);
641 }
Sunny Goyal415f1732018-11-29 10:33:47 -0800642 }
fbaronebc10c92024-09-03 12:51:41 -0700643 } else if (filteredProfiles.isEmpty()) {
644 // In this case we had a grid selected but we couldn't find it.
645 filteredProfiles.addAll(profiles);
Sunny Goyal415f1732018-11-29 10:33:47 -0800646 }
Sunny Goyalae190ff2020-04-14 00:19:01 +0000647 if (filteredProfiles.isEmpty()) {
648 throw new RuntimeException("No display option with canBeDefault=true");
649 }
650 return filteredProfiles;
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700651 }
652
Thales Lima7ec83822021-08-05 13:32:10 +0100653 /**
fbaronebc10c92024-09-03 12:51:41 -0700654 * Parses through the xml to find NumRows specs. Then calls findBestRowCount to get the correct
655 * row count for this GridOption.
656 *
Federico Baron56307d22024-11-06 18:48:48 +0000657 * @return the result of {@link #findBestRowCount(List, Info)}.
fbaronebc10c92024-09-03 12:51:41 -0700658 */
659 public static NumRows getRowCount(ResourceHelper resourceHelper, Context context,
Federico Baron56307d22024-11-06 18:48:48 +0000660 Info displayInfo) {
fbaronebc10c92024-09-03 12:51:41 -0700661 ArrayList<NumRows> rowCounts = new ArrayList<>();
662
663 try (XmlResourceParser parser = resourceHelper.getXml()) {
664 final int depth = parser.getDepth();
665 int type;
666 while (((type = parser.next()) != XmlPullParser.END_TAG
667 || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
668 if ((type == XmlPullParser.START_TAG)
669 && "NumRows".equals(parser.getName())) {
670 rowCounts.add(new NumRows(context, Xml.asAttributeSet(parser)));
671 }
672 }
673 } catch (IOException | XmlPullParserException e) {
674 throw new RuntimeException(e);
675 }
676
Federico Baron56307d22024-11-06 18:48:48 +0000677 return findBestRowCount(rowCounts, displayInfo);
fbaronebc10c92024-09-03 12:51:41 -0700678 }
679
680 /**
681 * @return the biggest row count that fits the display dimensions spec using NumRows to
682 * determine that. If no best row count is found, return -1.
683 */
Federico Baron56307d22024-11-06 18:48:48 +0000684 public static NumRows findBestRowCount(List<NumRows> list, Info displayInfo) {
fbaronebc10c92024-09-03 12:51:41 -0700685 int minWidthPx = Integer.MAX_VALUE;
686 int minHeightPx = Integer.MAX_VALUE;
687 for (WindowBounds bounds : displayInfo.supportedBounds) {
688 boolean isTablet = displayInfo.isTablet(bounds);
Federico Baron56307d22024-11-06 18:48:48 +0000689 if (isTablet && displayInfo.getDeviceType() == TYPE_MULTI_DISPLAY) {
fbaronebc10c92024-09-03 12:51:41 -0700690 // For split displays, take half width per page
691 minWidthPx = Math.min(minWidthPx, bounds.availableSize.x / 2);
692 minHeightPx = Math.min(minHeightPx, bounds.availableSize.y);
693 } else if (!isTablet && bounds.isLandscape()) {
694 // We will use transposed layout in this case
695 minWidthPx = Math.min(minWidthPx, bounds.availableSize.y);
696 minHeightPx = Math.min(minHeightPx, bounds.availableSize.x);
697 } else {
698 minWidthPx = Math.min(minWidthPx, bounds.availableSize.x);
699 minHeightPx = Math.min(minHeightPx, bounds.availableSize.y);
700 }
701 }
702
703 NumRows selectedRow = null;
704 for (NumRows item: list) {
705 if (minWidthPx >= item.mMinDeviceWidthPx && minHeightPx >= item.mMinDeviceHeightPx) {
706 if (selectedRow == null || selectedRow.mNumRowsNew < item.mNumRowsNew) {
707 selectedRow = item;
708 }
709 }
710 }
711 if (selectedRow != null) {
712 return selectedRow;
713 }
714 return null;
715 }
716
717 /**
Sebastián Francoad46eb72024-03-11 20:56:57 +0000718 * Returns the GridOption associated to the given file name or null if the fileName is not
719 * supported.
720 * Ej, launcher.db -> "normal grid", launcher_4_by_4.db -> "practical grid"
721 */
722 public GridOption getGridOptionFromFileName(Context context, String fileName) {
723 return parseAllGridOptions(context).stream()
724 .filter(gridOption -> Objects.equals(gridOption.dbFile, fileName))
725 .findFirst()
726 .orElse(null);
727 }
728
729 /**
730 * Returns the name of the given size on the current device or empty string if the size is not
731 * supported. Ej. 4x4 -> normal, 5x4 -> practical, etc.
732 * (Note: the name of the grid can be different for the same grid size depending of
733 * the values of the InvariantDeviceProfile)
Sebastián Francoad46eb72024-03-11 20:56:57 +0000734 */
735 public String getGridNameFromSize(Context context, Point size) {
736 return parseAllGridOptions(context).stream()
737 .filter(gridOption -> gridOption.numColumns == size.x
738 && gridOption.numRows == size.y)
739 .map(gridOption -> gridOption.name)
740 .findFirst()
741 .orElse("");
742 }
743
744 /**
745 * Returns the grid option for the given gridName on the current device (Note: the gridOption
746 * be different for the same gridName depending on the values of the InvariantDeviceProfile).
747 */
748 public GridOption getGridOptionFromName(Context context, String gridName) {
749 return parseAllGridOptions(context).stream()
750 .filter(gridOption -> Objects.equals(gridOption.name, gridName))
751 .findFirst()
752 .orElse(null);
753 }
754
755 /**
Thales Lima7ec83822021-08-05 13:32:10 +0100756 * @return all the grid options that can be shown on the device
757 */
758 public List<GridOption> parseAllGridOptions(Context context) {
Federico Baron56307d22024-11-06 18:48:48 +0000759 return parseAllDefinedGridOptions(context, displayInfo)
Sunny Goyal076e04b2023-04-03 12:38:30 -0700760 .stream()
761 .filter(go -> go.isEnabled(deviceType))
fbaronc1b68f42024-11-08 18:10:46 -0800762 .filter(go -> go.filterByFlag(deviceType, isFixedLandscapeMode))
Sunny Goyal076e04b2023-04-03 12:38:30 -0700763 .collect(Collectors.toList());
764 }
765
766 /**
767 * @return all the grid options that can be shown on the device
768 */
Federico Baron56307d22024-11-06 18:48:48 +0000769 public static List<GridOption> parseAllDefinedGridOptions(Context context, Info displayInfo) {
Thales Lima7ec83822021-08-05 13:32:10 +0100770 List<GridOption> result = new ArrayList<>();
Alex Chau1c883d82021-12-01 18:43:10 +0000771 try (XmlResourceParser parser = context.getResources().getXml(R.xml.device_profiles)) {
Thales Lima7ec83822021-08-05 13:32:10 +0100772 final int depth = parser.getDepth();
773 int type;
774 while (((type = parser.next()) != XmlPullParser.END_TAG
775 || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
776 if ((type == XmlPullParser.START_TAG)
777 && GridOption.TAG_NAME.equals(parser.getName())) {
Federico Baron56307d22024-11-06 18:48:48 +0000778 result.add(new GridOption(context, Xml.asAttributeSet(parser), displayInfo));
Thales Lima7ec83822021-08-05 13:32:10 +0100779 }
780 }
781 } catch (IOException | XmlPullParserException e) {
782 Log.e(TAG, "Error parsing device profile", e);
783 return Collections.emptyList();
784 }
785 return result;
786 }
787
Sunny Goyal53d7ee42015-05-22 12:25:45 -0700788 private int getLauncherIconDensity(int requiredSize) {
789 // Densities typically defined by an app.
sfufa@google.comde013292021-09-21 18:22:44 -0700790 int[] densityBuckets = new int[]{
Sunny Goyal53d7ee42015-05-22 12:25:45 -0700791 DisplayMetrics.DENSITY_LOW,
792 DisplayMetrics.DENSITY_MEDIUM,
793 DisplayMetrics.DENSITY_TV,
794 DisplayMetrics.DENSITY_HIGH,
795 DisplayMetrics.DENSITY_XHIGH,
796 DisplayMetrics.DENSITY_XXHIGH,
797 DisplayMetrics.DENSITY_XXXHIGH
798 };
799
800 int density = DisplayMetrics.DENSITY_XXXHIGH;
801 for (int i = densityBuckets.length - 1; i >= 0; i--) {
802 float expectedSize = ICON_SIZE_DEFINED_IN_APP_DP * densityBuckets[i]
803 / DisplayMetrics.DENSITY_DEFAULT;
804 if (expectedSize >= requiredSize) {
805 density = densityBuckets[i];
806 }
807 }
808
809 return density;
810 }
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700811
Adam Cohen2e6da152015-05-06 11:42:25 -0700812 /**
813 * Apply any Partner customization grid overrides.
814 *
815 * Currently we support: all apps row / column count.
816 */
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700817 private void applyPartnerDeviceProfileOverrides(Context context, DisplayMetrics dm) {
818 Partner p = Partner.get(context.getPackageManager());
Sunny Goyal3e58eea2022-11-14 14:30:07 -0800819 if (p == null) {
820 return;
821 }
822 try {
823 int numRows = p.getIntValue(RES_GRID_NUM_ROWS, -1);
824 int numColumns = p.getIntValue(RES_GRID_NUM_COLUMNS, -1);
825 float iconSizePx = p.getDimenValue(RES_GRID_ICON_SIZE_DP, -1);
826
827 if (numRows > 0 && numColumns > 0) {
828 this.numRows = numRows;
829 this.numColumns = numColumns;
830 }
831 if (iconSizePx > 0) {
832 this.iconSize[InvariantDeviceProfile.INDEX_DEFAULT] =
833 Utilities.dpiFromPx(iconSizePx, dm.densityDpi);
834 }
835 } catch (Resources.NotFoundException ex) {
836 Log.e(TAG, "Invalid Partner grid resource!", ex);
Adam Cohen2e6da152015-05-06 11:42:25 -0700837 }
838 }
839
Sunny Goyal415f1732018-11-29 10:33:47 -0800840 private static float dist(float x0, float y0, float x1, float y1) {
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700841 return (float) Math.hypot(x1 - x0, y1 - y0);
Adam Cohen2e6da152015-05-06 11:42:25 -0700842 }
843
Sunny Goyal19ff7282021-04-22 10:12:54 -0700844 private static DisplayOption invDistWeightedInterpolate(
fbaronebc10c92024-09-03 12:51:41 -0700845 Info displayInfo, List<DisplayOption> points, @DeviceType int deviceType) {
Sunny Goyal19ff7282021-04-22 10:12:54 -0700846 int minWidthPx = Integer.MAX_VALUE;
847 int minHeightPx = Integer.MAX_VALUE;
848 for (WindowBounds bounds : displayInfo.supportedBounds) {
849 boolean isTablet = displayInfo.isTablet(bounds);
Alex Chau1c883d82021-12-01 18:43:10 +0000850 if (isTablet && deviceType == TYPE_MULTI_DISPLAY) {
Sunny Goyal19ff7282021-04-22 10:12:54 -0700851 // For split displays, take half width per page
852 minWidthPx = Math.min(minWidthPx, bounds.availableSize.x / 2);
853 minHeightPx = Math.min(minHeightPx, bounds.availableSize.y);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700854
Sunny Goyal19ff7282021-04-22 10:12:54 -0700855 } else if (!isTablet && bounds.isLandscape()) {
856 // We will use transposed layout in this case
857 minWidthPx = Math.min(minWidthPx, bounds.availableSize.y);
858 minHeightPx = Math.min(minHeightPx, bounds.availableSize.x);
859 } else {
860 minWidthPx = Math.min(minWidthPx, bounds.availableSize.x);
861 minHeightPx = Math.min(minHeightPx, bounds.availableSize.y);
862 }
863 }
864
Thales Lima425f6822022-05-10 13:44:58 -0300865 float width = dpiFromPx(minWidthPx, displayInfo.getDensityDpi());
866 float height = dpiFromPx(minHeightPx, displayInfo.getDensityDpi());
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700867
868 // Sort the profiles based on the closeness to the device size
fbaronebc10c92024-09-03 12:51:41 -0700869 points.sort((a, b) ->
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700870 Float.compare(dist(width, height, a.minWidthDps, a.minHeightDps),
871 dist(width, height, b.minWidthDps, b.minHeightDps)));
872
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700873 DisplayOption closestPoint = points.get(0);
874 GridOption closestOption = closestPoint.grid;
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700875 float weights = 0;
876
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700877 if (dist(width, height, closestPoint.minWidthDps, closestPoint.minHeightDps) == 0) {
878 return closestPoint;
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700879 }
880
881 DisplayOption out = new DisplayOption(closestOption);
882 for (int i = 0; i < points.size() && i < KNEARESTNEIGHBOR; ++i) {
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700883 DisplayOption p = points.get(i);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700884 float w = weight(width, height, p.minWidthDps, p.minHeightDps, WEIGHT_POWER);
885 weights += w;
886 out.add(new DisplayOption().add(p).multiply(w));
887 }
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700888 out.multiply(1.0f / weights);
889
Thales Lima6e0005a2021-10-27 15:53:41 +0100890 // Since the bitmaps are persisted, ensure that all bitmap sizes are not larger than
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700891 // predefined size to avoid cache invalidation
Thales Lima6e0005a2021-10-27 15:53:41 +0100892 for (int i = INDEX_DEFAULT; i < COUNT_SIZES; i++) {
893 out.iconSizes[i] = Math.min(out.iconSizes[i], closestPoint.iconSizes[i]);
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700894 }
895
896 return out;
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700897 }
898
Sunny Goyal27835952017-01-13 12:15:53 -0800899 public DeviceProfile getDeviceProfile(Context context) {
Alex Chauc09a98a2023-11-14 12:51:42 +0000900 WindowManagerProxy windowManagerProxy = WindowManagerProxy.INSTANCE.get(context);
901 Rect bounds = windowManagerProxy.getCurrentBounds(context);
902 int rotation = windowManagerProxy.getRotation(context);
Sunny Goyal19ff7282021-04-22 10:12:54 -0700903
Alex Chauc09a98a2023-11-14 12:51:42 +0000904 return getBestMatch(bounds.width(), bounds.height(), rotation);
Sunny Goyal3e9a29c2021-09-07 15:53:09 -0400905 }
Sunny Goyal19ff7282021-04-22 10:12:54 -0700906
Sunny Goyal187b16c2022-03-01 16:53:23 -0800907 /**
908 * Returns the device profile matching the provided screen configuration
909 */
910 public DeviceProfile getBestMatch(float screenWidth, float screenHeight, int rotation) {
Sunny Goyal19ff7282021-04-22 10:12:54 -0700911 DeviceProfile bestMatch = supportedProfiles.get(0);
912 float minDiff = Float.MAX_VALUE;
913
914 for (DeviceProfile profile : supportedProfiles) {
Sunny Goyal3e9a29c2021-09-07 15:53:09 -0400915 float diff = Math.abs(profile.widthPx - screenWidth)
916 + Math.abs(profile.heightPx - screenHeight);
Sunny Goyal19ff7282021-04-22 10:12:54 -0700917 if (diff < minDiff) {
918 minDiff = diff;
919 bestMatch = profile;
Sunny Goyal187b16c2022-03-01 16:53:23 -0800920 } else if (diff == minDiff && profile.rotationHint == rotation) {
921 bestMatch = profile;
Sunny Goyal19ff7282021-04-22 10:12:54 -0700922 }
923 }
924 return bestMatch;
Sunny Goyal27835952017-01-13 12:15:53 -0800925 }
926
Sunny Goyal415f1732018-11-29 10:33:47 -0800927 private static float weight(float x0, float y0, float x1, float y1, float pow) {
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700928 float d = dist(x0, y0, x1, y1);
929 if (Float.compare(d, 0f) == 0) {
930 return Float.POSITIVE_INFINITY;
931 }
932 return (float) (WEIGHT_EFFICIENT / Math.pow(d, pow));
933 }
Sunny Goyal6f866092016-03-17 17:04:15 -0700934
935 /**
936 * As a ratio of screen height, the total distance we want the parallax effect to span
937 * horizontally
938 */
939 private static float wallpaperTravelToScreenWidthRatio(int width, int height) {
940 float aspectRatio = width / (float) height;
941
942 // At an aspect ratio of 16/10, the wallpaper parallax effect should span 1.5 * screen width
943 // At an aspect ratio of 10/16, the wallpaper parallax effect should span 1.2 * screen width
944 // We will use these two data points to extrapolate how much the wallpaper parallax effect
945 // to span (ie travel) at any aspect ratio:
946
sfufa@google.comde013292021-09-21 18:22:44 -0700947 final float ASPECT_RATIO_LANDSCAPE = 16 / 10f;
948 final float ASPECT_RATIO_PORTRAIT = 10 / 16f;
Sunny Goyal6f866092016-03-17 17:04:15 -0700949 final float WALLPAPER_WIDTH_TO_SCREEN_RATIO_LANDSCAPE = 1.5f;
950 final float WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT = 1.2f;
951
952 // To find out the desired width at different aspect ratios, we use the following two
953 // formulas, where the coefficient on x is the aspect ratio (width/height):
954 // (16/10)x + y = 1.5
955 // (10/16)x + y = 1.2
956 // We solve for x and y and end up with a final formula:
957 final float x =
sfufa@google.comde013292021-09-21 18:22:44 -0700958 (WALLPAPER_WIDTH_TO_SCREEN_RATIO_LANDSCAPE
959 - WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT) /
Sunny Goyal6f866092016-03-17 17:04:15 -0700960 (ASPECT_RATIO_LANDSCAPE - ASPECT_RATIO_PORTRAIT);
961 final float y = WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT - x * ASPECT_RATIO_PORTRAIT;
962 return x * aspectRatio + y;
963 }
964
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700965 public interface OnIDPChangeListener {
966
Sunny Goyalb47172b2021-05-03 19:59:51 -0700967 /**
968 * Called when the device provide changes
969 */
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700970 void onIdpChanged(boolean modelPropertiesChanged);
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700971 }
Sunny Goyal415f1732018-11-29 10:33:47 -0800972
973
Sunny Goyaleff44f32019-01-09 17:29:49 -0800974 public static final class GridOption {
Sunny Goyal415f1732018-11-29 10:33:47 -0800975
Sunny Goyal7d892ff2019-01-11 15:08:44 -0800976 public static final String TAG_NAME = "grid-option";
977
Alex Chau1c883d82021-12-01 18:43:10 +0000978 private static final int DEVICE_CATEGORY_PHONE = 1 << 0;
979 private static final int DEVICE_CATEGORY_TABLET = 1 << 1;
980 private static final int DEVICE_CATEGORY_MULTI_DISPLAY = 1 << 2;
981 private static final int DEVICE_CATEGORY_ALL =
982 DEVICE_CATEGORY_PHONE | DEVICE_CATEGORY_TABLET | DEVICE_CATEGORY_MULTI_DISPLAY;
983
Thales Lima11af7bc2022-08-12 15:24:54 +0100984 private static final int INLINE_QSB_FOR_PORTRAIT = 1 << 0;
985 private static final int INLINE_QSB_FOR_LANDSCAPE = 1 << 1;
986 private static final int INLINE_QSB_FOR_TWO_PANEL_PORTRAIT = 1 << 2;
987 private static final int INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE = 1 << 3;
988 private static final int DONT_INLINE_QSB = 0;
989
Sunny Goyaleff44f32019-01-09 17:29:49 -0800990 public final String name;
fbaronebc10c92024-09-03 12:51:41 -0700991 public final String title;
Sunny Goyaleff44f32019-01-09 17:29:49 -0800992 public final int numRows;
993 public final int numColumns;
Alex Chau9fee3fd2021-12-01 18:43:10 +0000994 public final int numSearchContainerColumns;
Sunny Goyal076e04b2023-04-03 12:38:30 -0700995 public final int deviceCategory;
Sunny Goyal415f1732018-11-29 10:33:47 -0800996
Thales Lima1faa4ed2023-12-01 16:48:19 +0000997 private final int[] numFolderRows = new int[COUNT_SIZES];
998 private final int[] numFolderColumns = new int[COUNT_SIZES];
Thales Limab35faed2022-09-05 16:30:01 -0300999 private final @StyleRes int folderStyle;
Thales Limad852d652023-01-17 14:01:13 +00001000 private final @StyleRes int cellStyle;
Sunny Goyal415f1732018-11-29 10:33:47 -08001001
Thales Limae9273ea2023-01-26 12:33:52 +00001002 private final @StyleRes int allAppsStyle;
Sunny Goyal19ff7282021-04-22 10:12:54 -07001003 private final int numAllAppsColumns;
Jordan Silva2de6a272024-01-04 14:44:20 -03001004 private final int mNumAllAppsRowsForCellHeightCalculation;
Sunny Goyal19ff7282021-04-22 10:12:54 -07001005 private final int numDatabaseAllAppsColumns;
1006 private final int numHotseatIcons;
Tony Wickhamb87f3cd2021-04-07 15:02:37 -07001007 private final int numDatabaseHotseatIcons;
Thales Limab8c05952022-05-23 16:58:38 +01001008
Thales Lima11af7bc2022-08-12 15:24:54 +01001009 private final boolean[] inlineQsb = new boolean[COUNT_SIZES];
1010
Thales Limab35faed2022-09-05 16:30:01 -03001011 private @DimenRes int inlineNavButtonsEndSpacing;
Tracy Zhou7df93d22020-01-27 13:44:06 -08001012 private final String dbFile;
Sunny Goyalae190ff2020-04-14 00:19:01 +00001013
Sunny Goyal415f1732018-11-29 10:33:47 -08001014 private final int defaultLayoutId;
1015 private final int demoModeLayoutId;
1016
Jon Mirandae126d722021-02-25 10:45:20 -05001017 private final boolean isScalable;
fbaron49f7df02024-11-05 16:15:19 -08001018 private final boolean mIsDualGrid;
Jon Mirandac9e69fa2021-03-22 17:13:34 -04001019 private final int devicePaddingId;
Thales Limaec5abba2023-04-05 16:33:50 +01001020 private final int mWorkspaceSpecsId;
Jordan Silva575c3bd2023-07-21 12:00:43 +01001021 private final int mWorkspaceSpecsTwoPanelId;
Thales Limaabfe3642023-05-24 18:08:53 +01001022 private final int mAllAppsSpecsId;
Jordan Silva575c3bd2023-07-21 12:00:43 +01001023 private final int mAllAppsSpecsTwoPanelId;
Jordan Silva637f4eb2023-06-13 11:21:53 +01001024 private final int mFolderSpecsId;
Jordan Silva575c3bd2023-07-21 12:00:43 +01001025 private final int mFolderSpecsTwoPanelId;
Thales Limaf8bfb032023-07-24 15:08:05 +01001026 private final int mHotseatSpecsId;
1027 private final int mHotseatSpecsTwoPanelId;
Jordan Silva999dd2a2023-11-17 19:31:43 +00001028 private final int mWorkspaceCellSpecsId;
1029 private final int mWorkspaceCellSpecsTwoPanelId;
1030 private final int mAllAppsCellSpecsId;
1031 private final int mAllAppsCellSpecsTwoPanelId;
fbaronebc10c92024-09-03 12:51:41 -07001032 private final int mRowCountSpecsId;
Sebastian Franco9e4c99b2024-10-02 15:16:37 -07001033 private final boolean mIsFixedLandscape;
fbaron6c91ef92024-11-12 22:22:43 -08001034 private final boolean mIsOldGrid;
Jon Mirandae126d722021-02-25 10:45:20 -05001035
Federico Baron56307d22024-11-06 18:48:48 +00001036 public GridOption(Context context, AttributeSet attrs, Info displayInfo) {
Sunny Goyal415f1732018-11-29 10:33:47 -08001037 TypedArray a = context.obtainStyledAttributes(
1038 attrs, R.styleable.GridDisplayOption);
1039 name = a.getString(R.styleable.GridDisplayOption_name);
fbaronebc10c92024-09-03 12:51:41 -07001040 title = a.getString(R.styleable.GridDisplayOption_title);
1041 deviceCategory = a.getInt(R.styleable.GridDisplayOption_deviceCategory,
1042 DEVICE_CATEGORY_ALL);
1043 mRowCountSpecsId = a.getResourceId(
1044 R.styleable.GridDisplayOption_rowCountSpecsId, INVALID_RESOURCE_HANDLE);
fbaron49f7df02024-11-05 16:15:19 -08001045 mIsDualGrid = a.getBoolean(R.styleable.GridDisplayOption_isDualGrid, false);
fbaronebc10c92024-09-03 12:51:41 -07001046 if (mRowCountSpecsId != INVALID_RESOURCE_HANDLE) {
1047 ResourceHelper resourceHelper = new ResourceHelper(context, mRowCountSpecsId);
Federico Baron56307d22024-11-06 18:48:48 +00001048 NumRows numR = getRowCount(resourceHelper, context, displayInfo);
fbaronebc10c92024-09-03 12:51:41 -07001049 numRows = numR.mNumRowsNew;
1050 dbFile = numR.mDbFile;
fbaronc1b68f42024-11-08 18:10:46 -08001051 defaultLayoutId = numR.mDefaultLayoutId;
1052 demoModeLayoutId = numR.mDemoModeLayoutId;
fbaronebc10c92024-09-03 12:51:41 -07001053 } else {
1054 numRows = a.getInt(R.styleable.GridDisplayOption_numRows, 0);
1055 dbFile = a.getString(R.styleable.GridDisplayOption_dbFile);
fbaronc1b68f42024-11-08 18:10:46 -08001056 defaultLayoutId = a.getResourceId(
1057 R.styleable.GridDisplayOption_defaultLayoutId, 0);
1058 demoModeLayoutId = a.getResourceId(
1059 R.styleable.GridDisplayOption_demoModeLayoutId, defaultLayoutId);
fbaronebc10c92024-09-03 12:51:41 -07001060 }
1061
Sunny Goyal415f1732018-11-29 10:33:47 -08001062 numColumns = a.getInt(R.styleable.GridDisplayOption_numColumns, 0);
Alex Chau9fee3fd2021-12-01 18:43:10 +00001063 numSearchContainerColumns = a.getInt(
1064 R.styleable.GridDisplayOption_numSearchContainerColumns, numColumns);
Sunny Goyal19ff7282021-04-22 10:12:54 -07001065
Thales Limae9273ea2023-01-26 12:33:52 +00001066 allAppsStyle = a.getResourceId(R.styleable.GridDisplayOption_allAppsStyle,
1067 R.style.AllAppsStyleDefault);
Sunny Goyal19ff7282021-04-22 10:12:54 -07001068 numAllAppsColumns = a.getInt(
1069 R.styleable.GridDisplayOption_numAllAppsColumns, numColumns);
1070 numDatabaseAllAppsColumns = a.getInt(
1071 R.styleable.GridDisplayOption_numExtendedAllAppsColumns, 2 * numAllAppsColumns);
1072
1073 numHotseatIcons = a.getInt(
Sunny Goyal415f1732018-11-29 10:33:47 -08001074 R.styleable.GridDisplayOption_numHotseatIcons, numColumns);
Sunny Goyal19ff7282021-04-22 10:12:54 -07001075 numDatabaseHotseatIcons = a.getInt(
1076 R.styleable.GridDisplayOption_numExtendedHotseatIcons, 2 * numHotseatIcons);
Thales Limab8c05952022-05-23 16:58:38 +01001077
Vinit Nayakc7293172022-07-18 16:41:50 -07001078 inlineNavButtonsEndSpacing =
1079 a.getResourceId(R.styleable.GridDisplayOption_inlineNavButtonsEndSpacing,
Thales Limaec5abba2023-04-05 16:33:50 +01001080 R.dimen.taskbar_button_margin_default);
Thales Limab35faed2022-09-05 16:30:01 -03001081
Thales Lima1faa4ed2023-12-01 16:48:19 +00001082 numFolderRows[INDEX_DEFAULT] = a.getInt(
Sunny Goyal415f1732018-11-29 10:33:47 -08001083 R.styleable.GridDisplayOption_numFolderRows, numRows);
Thales Lima1faa4ed2023-12-01 16:48:19 +00001084 numFolderColumns[INDEX_DEFAULT] = a.getInt(
Sunny Goyal415f1732018-11-29 10:33:47 -08001085 R.styleable.GridDisplayOption_numFolderColumns, numColumns);
Jon Miranda6f7e9702019-09-16 14:44:14 -07001086
Thales Lima1faa4ed2023-12-01 16:48:19 +00001087 if (FeatureFlags.enableResponsiveWorkspace()) {
1088 numFolderRows[INDEX_LANDSCAPE] = a.getInt(
1089 R.styleable.GridDisplayOption_numFolderRowsLandscape,
1090 numFolderRows[INDEX_DEFAULT]);
1091 numFolderColumns[INDEX_LANDSCAPE] = a.getInt(
1092 R.styleable.GridDisplayOption_numFolderColumnsLandscape,
1093 numFolderColumns[INDEX_DEFAULT]);
1094 numFolderRows[INDEX_TWO_PANEL_PORTRAIT] = a.getInt(
1095 R.styleable.GridDisplayOption_numFolderRowsTwoPanelPortrait,
1096 numFolderRows[INDEX_DEFAULT]);
1097 numFolderColumns[INDEX_TWO_PANEL_PORTRAIT] = a.getInt(
1098 R.styleable.GridDisplayOption_numFolderColumnsTwoPanelPortrait,
1099 numFolderColumns[INDEX_DEFAULT]);
1100 numFolderRows[INDEX_TWO_PANEL_LANDSCAPE] = a.getInt(
1101 R.styleable.GridDisplayOption_numFolderRowsTwoPanelLandscape,
1102 numFolderRows[INDEX_DEFAULT]);
1103 numFolderColumns[INDEX_TWO_PANEL_LANDSCAPE] = a.getInt(
1104 R.styleable.GridDisplayOption_numFolderColumnsTwoPanelLandscape,
1105 numFolderColumns[INDEX_DEFAULT]);
1106 } else {
1107 numFolderRows[INDEX_LANDSCAPE] = numFolderRows[INDEX_DEFAULT];
1108 numFolderColumns[INDEX_LANDSCAPE] = numFolderColumns[INDEX_DEFAULT];
1109 numFolderRows[INDEX_TWO_PANEL_PORTRAIT] = numFolderRows[INDEX_DEFAULT];
1110 numFolderColumns[INDEX_TWO_PANEL_PORTRAIT] = numFolderColumns[INDEX_DEFAULT];
1111 numFolderRows[INDEX_TWO_PANEL_LANDSCAPE] = numFolderRows[INDEX_DEFAULT];
1112 numFolderColumns[INDEX_TWO_PANEL_LANDSCAPE] = numFolderColumns[INDEX_DEFAULT];
1113 }
1114
Thales Limab35faed2022-09-05 16:30:01 -03001115 folderStyle = a.getResourceId(R.styleable.GridDisplayOption_folderStyle,
1116 INVALID_RESOURCE_HANDLE);
1117
Thales Limad852d652023-01-17 14:01:13 +00001118 cellStyle = a.getResourceId(R.styleable.GridDisplayOption_cellStyle,
1119 R.style.CellStyleDefault);
1120
Jon Mirandae126d722021-02-25 10:45:20 -05001121 isScalable = a.getBoolean(
1122 R.styleable.GridDisplayOption_isScalable, false);
Jon Mirandac9e69fa2021-03-22 17:13:34 -04001123 devicePaddingId = a.getResourceId(
Thales Limaae0d7ef2022-11-16 15:53:43 +00001124 R.styleable.GridDisplayOption_devicePaddingId, INVALID_RESOURCE_HANDLE);
Thales Lima7ec83822021-08-05 13:32:10 +01001125
Thales Limaca31b612023-09-14 14:25:26 +01001126 if (FeatureFlags.enableResponsiveWorkspace()) {
Thales Limaec5abba2023-04-05 16:33:50 +01001127 mWorkspaceSpecsId = a.getResourceId(
1128 R.styleable.GridDisplayOption_workspaceSpecsId, INVALID_RESOURCE_HANDLE);
Jordan Silva575c3bd2023-07-21 12:00:43 +01001129 mWorkspaceSpecsTwoPanelId = a.getResourceId(
1130 R.styleable.GridDisplayOption_workspaceSpecsTwoPanelId,
Jordan Silvad29f0642024-01-10 15:11:26 -03001131 mWorkspaceSpecsId);
Thales Limaabfe3642023-05-24 18:08:53 +01001132 mAllAppsSpecsId = a.getResourceId(
1133 R.styleable.GridDisplayOption_allAppsSpecsId, INVALID_RESOURCE_HANDLE);
Jordan Silva575c3bd2023-07-21 12:00:43 +01001134 mAllAppsSpecsTwoPanelId = a.getResourceId(
1135 R.styleable.GridDisplayOption_allAppsSpecsTwoPanelId,
Jordan Silvad29f0642024-01-10 15:11:26 -03001136 mAllAppsSpecsId);
Jordan Silva637f4eb2023-06-13 11:21:53 +01001137 mFolderSpecsId = a.getResourceId(
1138 R.styleable.GridDisplayOption_folderSpecsId, INVALID_RESOURCE_HANDLE);
Jordan Silva575c3bd2023-07-21 12:00:43 +01001139 mFolderSpecsTwoPanelId = a.getResourceId(
1140 R.styleable.GridDisplayOption_folderSpecsTwoPanelId,
Jordan Silvad29f0642024-01-10 15:11:26 -03001141 mFolderSpecsId);
Thales Limaf8bfb032023-07-24 15:08:05 +01001142 mHotseatSpecsId = a.getResourceId(
1143 R.styleable.GridDisplayOption_hotseatSpecsId, INVALID_RESOURCE_HANDLE);
1144 mHotseatSpecsTwoPanelId = a.getResourceId(
1145 R.styleable.GridDisplayOption_hotseatSpecsTwoPanelId,
Jordan Silvad29f0642024-01-10 15:11:26 -03001146 mHotseatSpecsId);
Jordan Silva999dd2a2023-11-17 19:31:43 +00001147 mWorkspaceCellSpecsId = a.getResourceId(
1148 R.styleable.GridDisplayOption_workspaceCellSpecsId,
1149 INVALID_RESOURCE_HANDLE);
1150 mWorkspaceCellSpecsTwoPanelId = a.getResourceId(
1151 R.styleable.GridDisplayOption_workspaceCellSpecsTwoPanelId,
Jordan Silvad29f0642024-01-10 15:11:26 -03001152 mWorkspaceCellSpecsId);
Jordan Silva999dd2a2023-11-17 19:31:43 +00001153 mAllAppsCellSpecsId = a.getResourceId(
1154 R.styleable.GridDisplayOption_allAppsCellSpecsId,
1155 INVALID_RESOURCE_HANDLE);
1156 mAllAppsCellSpecsTwoPanelId = a.getResourceId(
1157 R.styleable.GridDisplayOption_allAppsCellSpecsTwoPanelId,
Jordan Silvad29f0642024-01-10 15:11:26 -03001158 mAllAppsCellSpecsId);
Jordan Silva2de6a272024-01-04 14:44:20 -03001159 mNumAllAppsRowsForCellHeightCalculation = a.getInt(
1160 R.styleable.GridDisplayOption_numAllAppsRowsForCellHeightCalculation,
1161 numRows);
Thales Limaec5abba2023-04-05 16:33:50 +01001162 } else {
1163 mWorkspaceSpecsId = INVALID_RESOURCE_HANDLE;
Jordan Silva575c3bd2023-07-21 12:00:43 +01001164 mWorkspaceSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
Thales Limaabfe3642023-05-24 18:08:53 +01001165 mAllAppsSpecsId = INVALID_RESOURCE_HANDLE;
Jordan Silva575c3bd2023-07-21 12:00:43 +01001166 mAllAppsSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
Jordan Silva637f4eb2023-06-13 11:21:53 +01001167 mFolderSpecsId = INVALID_RESOURCE_HANDLE;
Jordan Silva575c3bd2023-07-21 12:00:43 +01001168 mFolderSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
Thales Limaf8bfb032023-07-24 15:08:05 +01001169 mHotseatSpecsId = INVALID_RESOURCE_HANDLE;
1170 mHotseatSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
Jordan Silva999dd2a2023-11-17 19:31:43 +00001171 mWorkspaceCellSpecsId = INVALID_RESOURCE_HANDLE;
1172 mWorkspaceCellSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
1173 mAllAppsCellSpecsId = INVALID_RESOURCE_HANDLE;
1174 mAllAppsCellSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
Jordan Silva2de6a272024-01-04 14:44:20 -03001175 mNumAllAppsRowsForCellHeightCalculation = numRows;
Thales Limaec5abba2023-04-05 16:33:50 +01001176 }
1177
Sebastian Franco9e4c99b2024-10-02 15:16:37 -07001178 mIsFixedLandscape = a.getBoolean(R.styleable.GridDisplayOption_isFixedLandscape, false);
fbaron6c91ef92024-11-12 22:22:43 -08001179 mIsOldGrid = a.getBoolean(R.styleable.GridDisplayOption_isOldGrid, false);
Sebastian Franco9e4c99b2024-10-02 15:16:37 -07001180
Thales Lima11af7bc2022-08-12 15:24:54 +01001181 int inlineForRotation = a.getInt(R.styleable.GridDisplayOption_inlineQsb,
1182 DONT_INLINE_QSB);
1183 inlineQsb[INDEX_DEFAULT] =
1184 (inlineForRotation & INLINE_QSB_FOR_PORTRAIT) == INLINE_QSB_FOR_PORTRAIT;
1185 inlineQsb[INDEX_LANDSCAPE] =
1186 (inlineForRotation & INLINE_QSB_FOR_LANDSCAPE) == INLINE_QSB_FOR_LANDSCAPE;
1187 inlineQsb[INDEX_TWO_PANEL_PORTRAIT] =
1188 (inlineForRotation & INLINE_QSB_FOR_TWO_PANEL_PORTRAIT)
1189 == INLINE_QSB_FOR_TWO_PANEL_PORTRAIT;
1190 inlineQsb[INDEX_TWO_PANEL_LANDSCAPE] =
1191 (inlineForRotation & INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE)
1192 == INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE;
1193
Sunny Goyal415f1732018-11-29 10:33:47 -08001194 a.recycle();
Sunny Goyal076e04b2023-04-03 12:38:30 -07001195 }
1196
1197 public boolean isEnabled(@DeviceType int deviceType) {
1198 switch (deviceType) {
1199 case TYPE_PHONE:
1200 return (deviceCategory & DEVICE_CATEGORY_PHONE) == DEVICE_CATEGORY_PHONE;
1201 case TYPE_TABLET:
1202 return (deviceCategory & DEVICE_CATEGORY_TABLET) == DEVICE_CATEGORY_TABLET;
1203 case TYPE_MULTI_DISPLAY:
1204 return (deviceCategory & DEVICE_CATEGORY_MULTI_DISPLAY)
1205 == DEVICE_CATEGORY_MULTI_DISPLAY;
1206 default:
1207 return false;
1208 }
Sunny Goyal415f1732018-11-29 10:33:47 -08001209 }
fbaronebc10c92024-09-03 12:51:41 -07001210
fbaron6c91ef92024-11-12 22:22:43 -08001211 /**
1212 * Returns true if the grid option should be used given the flags that are toggled on/off.
1213 */
fbaronc1b68f42024-11-08 18:10:46 -08001214 public boolean filterByFlag(int deviceType, boolean isFixedLandscape) {
fbaron49f7df02024-11-05 16:15:19 -08001215 if (deviceType == TYPE_TABLET) {
1216 return Flags.oneGridRotationHandling() == mIsDualGrid;
1217 }
fbaronc1b68f42024-11-08 18:10:46 -08001218
fbaron6c91ef92024-11-12 22:22:43 -08001219 // Here we return true if fixed landscape mode should be on.
1220 if (mIsFixedLandscape || isFixedLandscape) {
1221 return mIsFixedLandscape && isFixedLandscape && Flags.oneGridSpecs();
fbaronc1b68f42024-11-08 18:10:46 -08001222 }
1223
fbaron6c91ef92024-11-12 22:22:43 -08001224 // Here we return true if we want to show the new grids.
1225 if (mRowCountSpecsId != INVALID_RESOURCE_HANDLE) {
1226 return Flags.oneGridSpecs();
1227 }
1228
1229 // Here we return true if we want to show the old grids.
1230 if (mIsOldGrid) {
1231 return !Flags.oneGridSpecs();
1232 }
1233
1234 return true;
fbaron49f7df02024-11-05 16:15:19 -08001235 }
fbaronebc10c92024-09-03 12:51:41 -07001236 }
1237
1238 public static final class NumRows {
1239 final int mNumRowsNew;
1240 final float mMinDeviceWidthPx;
1241 final float mMinDeviceHeightPx;
1242 final String mDbFile;
fbaronc1b68f42024-11-08 18:10:46 -08001243 final int mDefaultLayoutId;
1244 final int mDemoModeLayoutId;
1245
fbaronebc10c92024-09-03 12:51:41 -07001246
1247 NumRows(Context context, AttributeSet attrs) {
1248 TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NumRows);
1249
1250 mNumRowsNew = (int) a.getFloat(R.styleable.NumRows_numRowsNew, 0);
1251 mMinDeviceWidthPx = a.getFloat(R.styleable.NumRows_minDeviceWidthPx, 0);
1252 mMinDeviceHeightPx = a.getFloat(R.styleable.NumRows_minDeviceHeightPx, 0);
1253 mDbFile = a.getString(R.styleable.NumRows_dbFile);
fbaronc1b68f42024-11-08 18:10:46 -08001254 mDefaultLayoutId = a.getResourceId(
1255 R.styleable.NumRows_defaultLayoutId, 0);
1256 mDemoModeLayoutId = a.getResourceId(
1257 R.styleable.NumRows_demoModeLayoutId, mDefaultLayoutId);
fbaronebc10c92024-09-03 12:51:41 -07001258
1259 a.recycle();
1260 }
Sunny Goyal415f1732018-11-29 10:33:47 -08001261 }
1262
Sunny Goyal19ff7282021-04-22 10:12:54 -07001263 @VisibleForTesting
1264 static final class DisplayOption {
Sunny Goyal19ff7282021-04-22 10:12:54 -07001265 public final GridOption grid;
Sunny Goyal415f1732018-11-29 10:33:47 -08001266
Sunny Goyal415f1732018-11-29 10:33:47 -08001267 private final float minWidthDps;
1268 private final float minHeightDps;
1269 private final boolean canBeDefault;
1270
Thales Lima83bedbf2021-10-05 17:47:39 +01001271 private final PointF[] minCellSize = new PointF[COUNT_SIZES];
Thales Lima78d00ad2021-09-30 11:29:06 +01001272
Thales Lima78d00ad2021-09-30 11:29:06 +01001273 private final PointF[] borderSpaces = new PointF[COUNT_SIZES];
Thales Lima83bedbf2021-10-05 17:47:39 +01001274 private final float[] horizontalMargin = new float[COUNT_SIZES];
Thales Limab8c05952022-05-23 16:58:38 +01001275 private final float[] hotseatBarBottomSpace = new float[COUNT_SIZES];
1276 private final float[] hotseatQsbSpace = new float[COUNT_SIZES];
Thales Limad90faab2021-09-21 17:18:47 +01001277
Thales Lima78d00ad2021-09-30 11:29:06 +01001278 private final float[] iconSizes = new float[COUNT_SIZES];
1279 private final float[] textSizes = new float[COUNT_SIZES];
Sunny Goyal415f1732018-11-29 10:33:47 -08001280
Thales Limab7ef5692022-03-10 10:32:36 +00001281 private final PointF[] allAppsCellSize = new PointF[COUNT_SIZES];
Thales Limabb7d3882021-12-22 12:56:29 +00001282 private final float[] allAppsIconSizes = new float[COUNT_SIZES];
1283 private final float[] allAppsIconTextSizes = new float[COUNT_SIZES];
1284 private final PointF[] allAppsBorderSpaces = new PointF[COUNT_SIZES];
1285
Jon Miranda9c478b62023-03-23 21:38:49 -07001286 private final float[] transientTaskbarIconSize = new float[COUNT_SIZES];
1287
Jon Miranda04f05102023-04-04 12:16:31 -07001288 private final boolean[] startAlignTaskbar = new boolean[COUNT_SIZES];
1289
Thales Lima1de4d552021-10-13 16:13:25 +01001290 DisplayOption(GridOption grid, Context context, AttributeSet attrs) {
Sunny Goyal415f1732018-11-29 10:33:47 -08001291 this.grid = grid;
1292
Jon Miranda9c478b62023-03-23 21:38:49 -07001293 Resources res = context.getResources();
1294
Thales Lima1de4d552021-10-13 16:13:25 +01001295 TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProfileDisplayOption);
Sunny Goyal415f1732018-11-29 10:33:47 -08001296
Sunny Goyal415f1732018-11-29 10:33:47 -08001297 minWidthDps = a.getFloat(R.styleable.ProfileDisplayOption_minWidthDps, 0);
1298 minHeightDps = a.getFloat(R.styleable.ProfileDisplayOption_minHeightDps, 0);
Sunny Goyal19ff7282021-04-22 10:12:54 -07001299
Thales Lima1de4d552021-10-13 16:13:25 +01001300 canBeDefault = a.getBoolean(R.styleable.ProfileDisplayOption_canBeDefault, false);
Sunny Goyal415f1732018-11-29 10:33:47 -08001301
Thales Lima83bedbf2021-10-05 17:47:39 +01001302 float x;
1303 float y;
1304
Thales Lima85c942f2021-12-31 13:04:20 +00001305 x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidth, 0);
1306 y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeight, 0);
Thales Lima83bedbf2021-10-05 17:47:39 +01001307 minCellSize[INDEX_DEFAULT] = new PointF(x, y);
Thales Limadd027342022-01-07 12:54:37 +00001308
1309 x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidthLandscape,
1310 minCellSize[INDEX_DEFAULT].x);
1311 y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeightLandscape,
1312 minCellSize[INDEX_DEFAULT].y);
Thales Lima83bedbf2021-10-05 17:47:39 +01001313 minCellSize[INDEX_LANDSCAPE] = new PointF(x, y);
Thales Lima83bedbf2021-10-05 17:47:39 +01001314
Thales Lima85c942f2021-12-31 13:04:20 +00001315 x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidthTwoPanelPortrait,
Thales Lima83bedbf2021-10-05 17:47:39 +01001316 minCellSize[INDEX_DEFAULT].x);
Thales Lima85c942f2021-12-31 13:04:20 +00001317 y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeightTwoPanelPortrait,
Thales Lima83bedbf2021-10-05 17:47:39 +01001318 minCellSize[INDEX_DEFAULT].y);
1319 minCellSize[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y);
1320
Thales Lima85c942f2021-12-31 13:04:20 +00001321 x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidthTwoPanelLandscape,
Thales Lima83bedbf2021-10-05 17:47:39 +01001322 minCellSize[INDEX_DEFAULT].x);
Thales Lima85c942f2021-12-31 13:04:20 +00001323 y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeightTwoPanelLandscape,
Thales Lima83bedbf2021-10-05 17:47:39 +01001324 minCellSize[INDEX_DEFAULT].y);
1325 minCellSize[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y);
Thales Lima78d00ad2021-09-30 11:29:06 +01001326
Thales Lima85c942f2021-12-31 13:04:20 +00001327 float borderSpace = a.getFloat(R.styleable.ProfileDisplayOption_borderSpace, 0);
Thales Lima44cc3a22022-03-18 14:28:24 +00001328 float borderSpaceLandscape = a.getFloat(
1329 R.styleable.ProfileDisplayOption_borderSpaceLandscape, borderSpace);
Thales Lima85c942f2021-12-31 13:04:20 +00001330 float borderSpaceTwoPanelPortrait = a.getFloat(
1331 R.styleable.ProfileDisplayOption_borderSpaceTwoPanelPortrait, borderSpace);
1332 float borderSpaceTwoPanelLandscape = a.getFloat(
1333 R.styleable.ProfileDisplayOption_borderSpaceTwoPanelLandscape, borderSpace);
Thales Lima78d00ad2021-09-30 11:29:06 +01001334
Thales Lima85c942f2021-12-31 13:04:20 +00001335 x = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceHorizontal, borderSpace);
1336 y = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceVertical, borderSpace);
Thales Lima78d00ad2021-09-30 11:29:06 +01001337 borderSpaces[INDEX_DEFAULT] = new PointF(x, y);
Thales Lima44cc3a22022-03-18 14:28:24 +00001338
1339 x = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceLandscapeHorizontal,
1340 borderSpaceLandscape);
1341 y = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceLandscapeVertical,
1342 borderSpaceLandscape);
Thales Lima78d00ad2021-09-30 11:29:06 +01001343 borderSpaces[INDEX_LANDSCAPE] = new PointF(x, y);
1344
1345 x = a.getFloat(
Thales Lima85c942f2021-12-31 13:04:20 +00001346 R.styleable.ProfileDisplayOption_borderSpaceTwoPanelPortraitHorizontal,
1347 borderSpaceTwoPanelPortrait);
Thales Lima78d00ad2021-09-30 11:29:06 +01001348 y = a.getFloat(
Thales Lima85c942f2021-12-31 13:04:20 +00001349 R.styleable.ProfileDisplayOption_borderSpaceTwoPanelPortraitVertical,
1350 borderSpaceTwoPanelPortrait);
Thales Lima78d00ad2021-09-30 11:29:06 +01001351 borderSpaces[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y);
1352
1353 x = a.getFloat(
Thales Lima85c942f2021-12-31 13:04:20 +00001354 R.styleable.ProfileDisplayOption_borderSpaceTwoPanelLandscapeHorizontal,
1355 borderSpaceTwoPanelLandscape);
Thales Lima78d00ad2021-09-30 11:29:06 +01001356 y = a.getFloat(
Thales Lima85c942f2021-12-31 13:04:20 +00001357 R.styleable.ProfileDisplayOption_borderSpaceTwoPanelLandscapeVertical,
1358 borderSpaceTwoPanelLandscape);
Thales Lima78d00ad2021-09-30 11:29:06 +01001359 borderSpaces[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y);
1360
Thales Limab7ef5692022-03-10 10:32:36 +00001361 x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellWidth,
1362 minCellSize[INDEX_DEFAULT].x);
1363 y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellHeight,
1364 minCellSize[INDEX_DEFAULT].y);
1365 allAppsCellSize[INDEX_DEFAULT] = new PointF(x, y);
1366
1367 x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellWidthLandscape,
1368 allAppsCellSize[INDEX_DEFAULT].x);
1369 y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellHeightLandscape,
1370 allAppsCellSize[INDEX_DEFAULT].y);
1371 allAppsCellSize[INDEX_LANDSCAPE] = new PointF(x, y);
1372
1373 x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellWidthTwoPanelPortrait,
1374 allAppsCellSize[INDEX_DEFAULT].x);
1375 y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellHeightTwoPanelPortrait,
1376 allAppsCellSize[INDEX_DEFAULT].y);
1377 allAppsCellSize[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y);
1378
1379 x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellWidthTwoPanelLandscape,
1380 allAppsCellSize[INDEX_DEFAULT].x);
1381 y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellHeightTwoPanelLandscape,
1382 allAppsCellSize[INDEX_DEFAULT].y);
1383 allAppsCellSize[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y);
1384
Thales Lima080d8902022-03-28 15:30:29 +01001385 float allAppsBorderSpace = a.getFloat(
1386 R.styleable.ProfileDisplayOption_allAppsBorderSpace, borderSpace);
1387 float allAppsBorderSpaceLandscape = a.getFloat(
1388 R.styleable.ProfileDisplayOption_allAppsBorderSpaceLandscape,
1389 allAppsBorderSpace);
1390 float allAppsBorderSpaceTwoPanelPortrait = a.getFloat(
Thales Limabb7d3882021-12-22 12:56:29 +00001391 R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortrait,
Thales Lima080d8902022-03-28 15:30:29 +01001392 allAppsBorderSpace);
1393 float allAppsBorderSpaceTwoPanelLandscape = a.getFloat(
Thales Limabb7d3882021-12-22 12:56:29 +00001394 R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelLandscape,
Thales Lima080d8902022-03-28 15:30:29 +01001395 allAppsBorderSpace);
1396
1397 x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceHorizontal,
1398 allAppsBorderSpace);
1399 y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceVertical,
1400 allAppsBorderSpace);
1401 allAppsBorderSpaces[INDEX_DEFAULT] = new PointF(x, y);
1402
1403 x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceLandscapeHorizontal,
1404 allAppsBorderSpaceLandscape);
1405 y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceLandscapeVertical,
1406 allAppsBorderSpaceLandscape);
1407 allAppsBorderSpaces[INDEX_LANDSCAPE] = new PointF(x, y);
1408
1409 x = a.getFloat(
1410 R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortraitHorizontal,
1411 allAppsBorderSpaceTwoPanelPortrait);
1412 y = a.getFloat(
1413 R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortraitVertical,
1414 allAppsBorderSpaceTwoPanelPortrait);
1415 allAppsBorderSpaces[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y);
1416
1417 x = a.getFloat(
1418 R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelLandscapeHorizontal,
1419 allAppsBorderSpaceTwoPanelLandscape);
1420 y = a.getFloat(
1421 R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelLandscapeVertical,
1422 allAppsBorderSpaceTwoPanelLandscape);
Thales Limabb7d3882021-12-22 12:56:29 +00001423 allAppsBorderSpaces[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y);
Jon Mirandae126d722021-02-25 10:45:20 -05001424
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001425 iconSizes[INDEX_DEFAULT] =
1426 a.getFloat(R.styleable.ProfileDisplayOption_iconImageSize, 0);
1427 iconSizes[INDEX_LANDSCAPE] =
Thales Lima85c942f2021-12-31 13:04:20 +00001428 a.getFloat(R.styleable.ProfileDisplayOption_iconSizeLandscape,
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001429 iconSizes[INDEX_DEFAULT]);
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001430 iconSizes[INDEX_TWO_PANEL_PORTRAIT] =
Thales Lima85c942f2021-12-31 13:04:20 +00001431 a.getFloat(R.styleable.ProfileDisplayOption_iconSizeTwoPanelPortrait,
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001432 iconSizes[INDEX_DEFAULT]);
1433 iconSizes[INDEX_TWO_PANEL_LANDSCAPE] =
Thales Lima85c942f2021-12-31 13:04:20 +00001434 a.getFloat(R.styleable.ProfileDisplayOption_iconSizeTwoPanelLandscape,
Thales Lima83bedbf2021-10-05 17:47:39 +01001435 iconSizes[INDEX_DEFAULT]);
Jon Miranda6f7e9702019-09-16 14:44:14 -07001436
Thales Limabb7d3882021-12-22 12:56:29 +00001437 allAppsIconSizes[INDEX_DEFAULT] = a.getFloat(
1438 R.styleable.ProfileDisplayOption_allAppsIconSize, iconSizes[INDEX_DEFAULT]);
Thales Lima1fb075d2022-08-10 10:47:50 +01001439 allAppsIconSizes[INDEX_LANDSCAPE] = a.getFloat(
1440 R.styleable.ProfileDisplayOption_allAppsIconSizeLandscape,
Thales Limaed8c69b2022-08-17 12:21:21 -04001441 allAppsIconSizes[INDEX_DEFAULT]);
Thales Limabb7d3882021-12-22 12:56:29 +00001442 allAppsIconSizes[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat(
1443 R.styleable.ProfileDisplayOption_allAppsIconSizeTwoPanelPortrait,
1444 allAppsIconSizes[INDEX_DEFAULT]);
1445 allAppsIconSizes[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
1446 R.styleable.ProfileDisplayOption_allAppsIconSizeTwoPanelLandscape,
1447 allAppsIconSizes[INDEX_DEFAULT]);
1448
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001449 textSizes[INDEX_DEFAULT] =
1450 a.getFloat(R.styleable.ProfileDisplayOption_iconTextSize, 0);
1451 textSizes[INDEX_LANDSCAPE] =
Thales Lima85c942f2021-12-31 13:04:20 +00001452 a.getFloat(R.styleable.ProfileDisplayOption_iconTextSizeLandscape,
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001453 textSizes[INDEX_DEFAULT]);
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001454 textSizes[INDEX_TWO_PANEL_PORTRAIT] =
Thales Lima85c942f2021-12-31 13:04:20 +00001455 a.getFloat(R.styleable.ProfileDisplayOption_iconTextSizeTwoPanelPortrait,
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001456 textSizes[INDEX_DEFAULT]);
1457 textSizes[INDEX_TWO_PANEL_LANDSCAPE] =
Thales Lima85c942f2021-12-31 13:04:20 +00001458 a.getFloat(R.styleable.ProfileDisplayOption_iconTextSizeTwoPanelLandscape,
Thales Lima83bedbf2021-10-05 17:47:39 +01001459 textSizes[INDEX_DEFAULT]);
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001460
Thales Limabb7d3882021-12-22 12:56:29 +00001461 allAppsIconTextSizes[INDEX_DEFAULT] = a.getFloat(
1462 R.styleable.ProfileDisplayOption_allAppsIconTextSize, textSizes[INDEX_DEFAULT]);
1463 allAppsIconTextSizes[INDEX_LANDSCAPE] = allAppsIconTextSizes[INDEX_DEFAULT];
1464 allAppsIconTextSizes[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat(
1465 R.styleable.ProfileDisplayOption_allAppsIconTextSizeTwoPanelPortrait,
1466 allAppsIconTextSizes[INDEX_DEFAULT]);
1467 allAppsIconTextSizes[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
1468 R.styleable.ProfileDisplayOption_allAppsIconTextSizeTwoPanelLandscape,
1469 allAppsIconTextSizes[INDEX_DEFAULT]);
1470
Thales Lima83bedbf2021-10-05 17:47:39 +01001471 horizontalMargin[INDEX_DEFAULT] = a.getFloat(
1472 R.styleable.ProfileDisplayOption_horizontalMargin, 0);
Thales Limadd027342022-01-07 12:54:37 +00001473 horizontalMargin[INDEX_LANDSCAPE] = a.getFloat(
1474 R.styleable.ProfileDisplayOption_horizontalMarginLandscape,
1475 horizontalMargin[INDEX_DEFAULT]);
Thales Lima83bedbf2021-10-05 17:47:39 +01001476 horizontalMargin[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
Thales Lima85c942f2021-12-31 13:04:20 +00001477 R.styleable.ProfileDisplayOption_horizontalMarginTwoPanelLandscape,
Thales Lima83bedbf2021-10-05 17:47:39 +01001478 horizontalMargin[INDEX_DEFAULT]);
1479 horizontalMargin[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat(
Thales Lima85c942f2021-12-31 13:04:20 +00001480 R.styleable.ProfileDisplayOption_horizontalMarginTwoPanelPortrait,
Thales Lima83bedbf2021-10-05 17:47:39 +01001481 horizontalMargin[INDEX_DEFAULT]);
Thales Limad90faab2021-09-21 17:18:47 +01001482
Thales Limab8c05952022-05-23 16:58:38 +01001483 hotseatBarBottomSpace[INDEX_DEFAULT] = a.getFloat(
1484 R.styleable.ProfileDisplayOption_hotseatBarBottomSpace,
Jon Miranda9c478b62023-03-23 21:38:49 -07001485 ResourcesCompat.getFloat(res, R.dimen.hotseat_bar_bottom_space_default));
Thales Limab8c05952022-05-23 16:58:38 +01001486 hotseatBarBottomSpace[INDEX_LANDSCAPE] = a.getFloat(
1487 R.styleable.ProfileDisplayOption_hotseatBarBottomSpaceLandscape,
1488 hotseatBarBottomSpace[INDEX_DEFAULT]);
1489 hotseatBarBottomSpace[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
1490 R.styleable.ProfileDisplayOption_hotseatBarBottomSpaceTwoPanelLandscape,
1491 hotseatBarBottomSpace[INDEX_DEFAULT]);
1492 hotseatBarBottomSpace[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat(
1493 R.styleable.ProfileDisplayOption_hotseatBarBottomSpaceTwoPanelPortrait,
1494 hotseatBarBottomSpace[INDEX_DEFAULT]);
1495
1496 hotseatQsbSpace[INDEX_DEFAULT] = a.getFloat(
1497 R.styleable.ProfileDisplayOption_hotseatQsbSpace,
Jon Miranda9c478b62023-03-23 21:38:49 -07001498 ResourcesCompat.getFloat(res, R.dimen.hotseat_qsb_space_default));
Thales Limab8c05952022-05-23 16:58:38 +01001499 hotseatQsbSpace[INDEX_LANDSCAPE] = a.getFloat(
1500 R.styleable.ProfileDisplayOption_hotseatQsbSpaceLandscape,
1501 hotseatQsbSpace[INDEX_DEFAULT]);
1502 hotseatQsbSpace[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
1503 R.styleable.ProfileDisplayOption_hotseatQsbSpaceTwoPanelLandscape,
1504 hotseatQsbSpace[INDEX_DEFAULT]);
1505 hotseatQsbSpace[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat(
1506 R.styleable.ProfileDisplayOption_hotseatQsbSpaceTwoPanelPortrait,
1507 hotseatQsbSpace[INDEX_DEFAULT]);
1508
Jon Miranda9c478b62023-03-23 21:38:49 -07001509 transientTaskbarIconSize[INDEX_DEFAULT] = a.getFloat(
1510 R.styleable.ProfileDisplayOption_transientTaskbarIconSize,
1511 ResourcesCompat.getFloat(res, R.dimen.taskbar_icon_size));
1512 transientTaskbarIconSize[INDEX_LANDSCAPE] = a.getFloat(
1513 R.styleable.ProfileDisplayOption_transientTaskbarIconSizeLandscape,
1514 transientTaskbarIconSize[INDEX_DEFAULT]);
1515 transientTaskbarIconSize[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
1516 R.styleable.ProfileDisplayOption_transientTaskbarIconSizeTwoPanelLandscape,
1517 transientTaskbarIconSize[INDEX_DEFAULT]);
1518 transientTaskbarIconSize[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat(
1519 R.styleable.ProfileDisplayOption_transientTaskbarIconSizeTwoPanelPortrait,
Jon Miranda4d74ad32023-03-27 16:31:11 -07001520 transientTaskbarIconSize[INDEX_DEFAULT]);
Jon Miranda9c478b62023-03-23 21:38:49 -07001521
Jon Miranda04f05102023-04-04 12:16:31 -07001522 startAlignTaskbar[INDEX_DEFAULT] = a.getBoolean(
1523 R.styleable.ProfileDisplayOption_startAlignTaskbar, false);
1524 startAlignTaskbar[INDEX_LANDSCAPE] = a.getBoolean(
1525 R.styleable.ProfileDisplayOption_startAlignTaskbarLandscape,
1526 startAlignTaskbar[INDEX_DEFAULT]);
1527 startAlignTaskbar[INDEX_TWO_PANEL_LANDSCAPE] = a.getBoolean(
1528 R.styleable.ProfileDisplayOption_startAlignTaskbarTwoPanelLandscape,
1529 startAlignTaskbar[INDEX_LANDSCAPE]);
1530 startAlignTaskbar[INDEX_TWO_PANEL_PORTRAIT] = a.getBoolean(
1531 R.styleable.ProfileDisplayOption_startAlignTaskbarTwoPanelPortrait,
1532 startAlignTaskbar[INDEX_DEFAULT]);
1533
Sunny Goyal415f1732018-11-29 10:33:47 -08001534 a.recycle();
1535 }
1536
1537 DisplayOption() {
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001538 this(null);
1539 }
1540
1541 DisplayOption(GridOption grid) {
1542 this.grid = grid;
Sunny Goyal415f1732018-11-29 10:33:47 -08001543 minWidthDps = 0;
1544 minHeightDps = 0;
1545 canBeDefault = false;
Thales Lima78d00ad2021-09-30 11:29:06 +01001546 for (int i = 0; i < COUNT_SIZES; i++) {
1547 iconSizes[i] = 0;
1548 textSizes[i] = 0;
1549 borderSpaces[i] = new PointF();
Thales Lima83bedbf2021-10-05 17:47:39 +01001550 minCellSize[i] = new PointF();
Thales Limab7ef5692022-03-10 10:32:36 +00001551 allAppsCellSize[i] = new PointF();
Thales Limabb7d3882021-12-22 12:56:29 +00001552 allAppsIconSizes[i] = 0;
1553 allAppsIconTextSizes[i] = 0;
1554 allAppsBorderSpaces[i] = new PointF();
Jon Miranda9c478b62023-03-23 21:38:49 -07001555 transientTaskbarIconSize[i] = 0;
Jon Miranda04f05102023-04-04 12:16:31 -07001556 startAlignTaskbar[i] = false;
Thales Lima78d00ad2021-09-30 11:29:06 +01001557 }
Sunny Goyal415f1732018-11-29 10:33:47 -08001558 }
1559
1560 private DisplayOption multiply(float w) {
Thales Lima78d00ad2021-09-30 11:29:06 +01001561 for (int i = 0; i < COUNT_SIZES; i++) {
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001562 iconSizes[i] *= w;
1563 textSizes[i] *= w;
Thales Lima83bedbf2021-10-05 17:47:39 +01001564 borderSpaces[i].x *= w;
1565 borderSpaces[i].y *= w;
1566 minCellSize[i].x *= w;
1567 minCellSize[i].y *= w;
1568 horizontalMargin[i] *= w;
Thales Limab8c05952022-05-23 16:58:38 +01001569 hotseatBarBottomSpace[i] *= w;
1570 hotseatQsbSpace[i] *= w;
Thales Limab7ef5692022-03-10 10:32:36 +00001571 allAppsCellSize[i].x *= w;
1572 allAppsCellSize[i].y *= w;
Thales Limabb7d3882021-12-22 12:56:29 +00001573 allAppsIconSizes[i] *= w;
1574 allAppsIconTextSizes[i] *= w;
1575 allAppsBorderSpaces[i].x *= w;
1576 allAppsBorderSpaces[i].y *= w;
Jon Miranda9c478b62023-03-23 21:38:49 -07001577 transientTaskbarIconSize[i] *= w;
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001578 }
Thales Lima78d00ad2021-09-30 11:29:06 +01001579
Sunny Goyal415f1732018-11-29 10:33:47 -08001580 return this;
1581 }
1582
1583 private DisplayOption add(DisplayOption p) {
Thales Lima78d00ad2021-09-30 11:29:06 +01001584 for (int i = 0; i < COUNT_SIZES; i++) {
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001585 iconSizes[i] += p.iconSizes[i];
1586 textSizes[i] += p.textSizes[i];
Thales Lima83bedbf2021-10-05 17:47:39 +01001587 borderSpaces[i].x += p.borderSpaces[i].x;
1588 borderSpaces[i].y += p.borderSpaces[i].y;
1589 minCellSize[i].x += p.minCellSize[i].x;
1590 minCellSize[i].y += p.minCellSize[i].y;
1591 horizontalMargin[i] += p.horizontalMargin[i];
Thales Limab8c05952022-05-23 16:58:38 +01001592 hotseatBarBottomSpace[i] += p.hotseatBarBottomSpace[i];
1593 hotseatQsbSpace[i] += p.hotseatQsbSpace[i];
Thales Limab7ef5692022-03-10 10:32:36 +00001594 allAppsCellSize[i].x += p.allAppsCellSize[i].x;
1595 allAppsCellSize[i].y += p.allAppsCellSize[i].y;
Thales Limabb7d3882021-12-22 12:56:29 +00001596 allAppsIconSizes[i] += p.allAppsIconSizes[i];
1597 allAppsIconTextSizes[i] += p.allAppsIconTextSizes[i];
1598 allAppsBorderSpaces[i].x += p.allAppsBorderSpaces[i].x;
1599 allAppsBorderSpaces[i].y += p.allAppsBorderSpaces[i].y;
Jon Miranda9c478b62023-03-23 21:38:49 -07001600 transientTaskbarIconSize[i] += p.transientTaskbarIconSize[i];
Jon Miranda04f05102023-04-04 12:16:31 -07001601 startAlignTaskbar[i] |= p.startAlignTaskbar[i];
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001602 }
Thales Lima78d00ad2021-09-30 11:29:06 +01001603
Sunny Goyal415f1732018-11-29 10:33:47 -08001604 return this;
1605 }
1606 }
Sunny Goyalae190ff2020-04-14 00:19:01 +00001607}