blob: 4eaacdc17cb1efc4c9a944e431537d4791c2c4de [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
Stefan Andonian4c9612b2023-02-22 00:00:03 +000019import static com.android.launcher3.LauncherPrefs.GRID_NAME;
Sunny Goyal19ff7282021-04-22 10:12:54 -070020import static com.android.launcher3.Utilities.dpiFromPx;
Thales Limab35faed2022-09-05 16:30:01 -030021import static com.android.launcher3.testing.shared.ResourceUtils.INVALID_RESOURCE_HANDLE;
Sunny Goyal35c7b192021-04-20 16:51:10 -070022import static com.android.launcher3.util.DisplayController.CHANGE_DENSITY;
Alex Chau6ed408f2022-03-04 12:58:05 +000023import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
Sunny Goyal19ff7282021-04-22 10:12:54 -070024import static com.android.launcher3.util.DisplayController.CHANGE_SUPPORTED_BOUNDS;
Sunny Goyal9c2b9602020-01-07 13:07:55 -080025import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
Sunny Goyal87dc48b2018-10-12 11:42:33 -070026
Sunny Goyalc6205602015-05-21 20:46:33 -070027import android.annotation.TargetApi;
Adam Cohen2e6da152015-05-06 11:42:25 -070028import android.content.Context;
Sunny Goyal27835952017-01-13 12:15:53 -080029import android.content.res.Configuration;
Hyunyoung Songc55a3502018-12-04 15:43:16 -080030import android.content.res.Resources;
Sunny Goyal819e1932016-07-07 16:43:58 -070031import android.content.res.TypedArray;
32import android.content.res.XmlResourceParser;
Adam Cohen2e6da152015-05-06 11:42:25 -070033import android.graphics.Point;
Thales Lima78d00ad2021-09-30 11:29:06 +010034import android.graphics.PointF;
Sunny Goyal415f1732018-11-29 10:33:47 -080035import android.text.TextUtils;
36import android.util.AttributeSet;
Adam Cohen2e6da152015-05-06 11:42:25 -070037import android.util.DisplayMetrics;
Thales Lima7ec83822021-08-05 13:32:10 +010038import android.util.Log;
Sunny Goyal5bc18462019-01-07 15:13:39 -080039import android.util.SparseArray;
Sunny Goyal819e1932016-07-07 16:43:58 -070040import android.util.Xml;
Sunny Goyal9c2b9602020-01-07 13:07:55 -080041import android.view.Display;
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -070042
Thales Limab35faed2022-09-05 16:30:01 -030043import androidx.annotation.DimenRes;
Alex Chau1c883d82021-12-01 18:43:10 +000044import androidx.annotation.IntDef;
Thales Limab35faed2022-09-05 16:30:01 -030045import androidx.annotation.StyleRes;
Sunny Goyal6fe3eec2019-08-15 14:53:41 -070046import androidx.annotation.VisibleForTesting;
Thales Limaae0d7ef2022-11-16 15:53:43 +000047import androidx.annotation.XmlRes;
Thales Limab8c05952022-05-23 16:58:38 +010048import androidx.core.content.res.ResourcesCompat;
Sunny Goyal6fe3eec2019-08-15 14:53:41 -070049
Thales Limaec5abba2023-04-05 16:33:50 +010050import com.android.launcher3.config.FeatureFlags;
Sunny Goyal65190ae2022-08-02 14:16:26 -070051import com.android.launcher3.icons.DotRenderer;
Sunny Goyal68031ca2021-08-02 12:23:44 -070052import com.android.launcher3.model.DeviceGridState;
Alex Chau238aaee2021-10-06 16:15:24 +010053import com.android.launcher3.provider.RestoreDbTask;
vadimtf6ef8792022-07-26 13:54:31 -070054import com.android.launcher3.testing.shared.ResourceUtils;
Sunny Goyalfd58da62020-08-11 12:06:49 -070055import com.android.launcher3.util.DisplayController;
56import com.android.launcher3.util.DisplayController.Info;
Stefan Andonian5bd9a222023-02-23 00:58:33 +000057import com.android.launcher3.util.LockedUserState;
Sunny Goyald0e360a2018-06-29 14:40:18 -070058import com.android.launcher3.util.MainThreadInitializedObject;
Sunny Goyal3e58eea2022-11-14 14:30:07 -080059import com.android.launcher3.util.Partner;
Sunny Goyal19ff7282021-04-22 10:12:54 -070060import com.android.launcher3.util.WindowBounds;
Sunny Goyal187b16c2022-03-01 16:53:23 -080061import com.android.launcher3.util.window.WindowManagerProxy;
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -070062
Sunny Goyal819e1932016-07-07 16:43:58 -070063import org.xmlpull.v1.XmlPullParser;
64import org.xmlpull.v1.XmlPullParserException;
65
66import java.io.IOException;
Alex Chau1c883d82021-12-01 18:43:10 +000067import java.lang.annotation.Retention;
68import java.lang.annotation.RetentionPolicy;
Adam Cohen2e6da152015-05-06 11:42:25 -070069import java.util.ArrayList;
Sunny Goyal6e6f7992021-08-24 16:23:29 -070070import java.util.Arrays;
Sunny Goyal6d55f662019-01-02 12:13:43 -080071import java.util.Collections;
Sunny Goyal19ff7282021-04-22 10:12:54 -070072import java.util.List;
Sunny Goyal076e04b2023-04-03 12:38:30 -070073import java.util.stream.Collectors;
Adam Cohen2e6da152015-05-06 11:42:25 -070074
75public class InvariantDeviceProfile {
Adam Cohen2e6da152015-05-06 11:42:25 -070076
Hyunyoung Songc55a3502018-12-04 15:43:16 -080077 public static final String TAG = "IDP";
Sunny Goyald0e360a2018-06-29 14:40:18 -070078 // We do not need any synchronization for this variable as its only written on UI thread.
79 public static final MainThreadInitializedObject<InvariantDeviceProfile> INSTANCE =
Sunny Goyal87dc48b2018-10-12 11:42:33 -070080 new MainThreadInitializedObject<>(InvariantDeviceProfile::new);
Adam Cohen2e6da152015-05-06 11:42:25 -070081
Alex Chau1c883d82021-12-01 18:43:10 +000082 @Retention(RetentionPolicy.SOURCE)
83 @IntDef({TYPE_PHONE, TYPE_MULTI_DISPLAY, TYPE_TABLET})
Thales Limab8c05952022-05-23 16:58:38 +010084 public @interface DeviceType {}
85
Alex Chau1c883d82021-12-01 18:43:10 +000086 public static final int TYPE_PHONE = 0;
87 public static final int TYPE_MULTI_DISPLAY = 1;
88 public static final int TYPE_TABLET = 2;
89
Sunny Goyal53d7ee42015-05-22 12:25:45 -070090 private static final float ICON_SIZE_DEFINED_IN_APP_DP = 48;
91
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -070092 // Constants that affects the interpolation curve between statically defined device profile
93 // buckets.
Hyunyoung Songc55a3502018-12-04 15:43:16 -080094 private static final float KNEARESTNEIGHBOR = 3;
95 private static final float WEIGHT_POWER = 5;
Adam Cohen2e6da152015-05-06 11:42:25 -070096
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -070097 // used to offset float not being able to express extremely small weights in extreme cases.
Hyunyoung Songc55a3502018-12-04 15:43:16 -080098 private static final float WEIGHT_EFFICIENT = 100000f;
99
Thales Lima83bedbf2021-10-05 17:47:39 +0100100 // Used for arrays to specify different sizes (e.g. border spaces, width/height) in different
101 // constraints
Thales Limabb7d3882021-12-22 12:56:29 +0000102 static final int COUNT_SIZES = 4;
Thales Lima83bedbf2021-10-05 17:47:39 +0100103 static final int INDEX_DEFAULT = 0;
104 static final int INDEX_LANDSCAPE = 1;
105 static final int INDEX_TWO_PANEL_PORTRAIT = 2;
106 static final int INDEX_TWO_PANEL_LANDSCAPE = 3;
Thales Lima83bedbf2021-10-05 17:47:39 +0100107
Thales Limaec5abba2023-04-05 16:33:50 +0100108 /** These resources are used to override the device profile */
Sunny Goyal3e58eea2022-11-14 14:30:07 -0800109 private static final String RES_GRID_NUM_ROWS = "grid_num_rows";
110 private static final String RES_GRID_NUM_COLUMNS = "grid_num_columns";
111 private static final String RES_GRID_ICON_SIZE_DP = "grid_icon_size_dp";
112
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700113 /**
114 * Number of icons per row and column in the workspace.
115 */
Adam Cohen2e6da152015-05-06 11:42:25 -0700116 public int numRows;
117 public int numColumns;
Alex Chau9fee3fd2021-12-01 18:43:10 +0000118 public int numSearchContainerColumns;
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700119
120 /**
121 * Number of icons per row and column in the folder.
122 */
Adam Cohen2e6da152015-05-06 11:42:25 -0700123 public int numFolderRows;
124 public int numFolderColumns;
Thales Lima83bedbf2021-10-05 17:47:39 +0100125 public float[] iconSize;
126 public float[] iconTextSize;
Sunny Goyalfc218302015-09-17 14:59:10 -0700127 public int iconBitmapSize;
128 public int fillResIconDpi;
Alex Chau1c883d82021-12-01 18:43:10 +0000129 public @DeviceType int deviceType;
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700130
Thales Lima83bedbf2021-10-05 17:47:39 +0100131 public PointF[] minCellSize;
Thales Lima78d00ad2021-09-30 11:29:06 +0100132
Thales Lima83bedbf2021-10-05 17:47:39 +0100133 public PointF[] borderSpaces;
Thales Limab35faed2022-09-05 16:30:01 -0300134 public @DimenRes int inlineNavButtonsEndSpacing;
Thales Lima78d00ad2021-09-30 11:29:06 +0100135
Thales Limab35faed2022-09-05 16:30:01 -0300136 public @StyleRes int folderStyle;
Thales Limaa08a4432022-08-09 09:55:17 +0100137
Thales Limad852d652023-01-17 14:01:13 +0000138 public @StyleRes int cellStyle;
139
Thales Lima83bedbf2021-10-05 17:47:39 +0100140 public float[] horizontalMargin;
Jon Mirandae126d722021-02-25 10:45:20 -0500141
Thales Limab7ef5692022-03-10 10:32:36 +0000142 public PointF[] allAppsCellSize;
Thales Limabb7d3882021-12-22 12:56:29 +0000143 public float[] allAppsIconSize;
144 public float[] allAppsIconTextSize;
145 public PointF[] allAppsBorderSpaces;
146
Jon Miranda9c478b62023-03-23 21:38:49 -0700147 public float[] transientTaskbarIconSize;
148
Jon Miranda04f05102023-04-04 12:16:31 -0700149 public boolean[] startAlignTaskbar;
150
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700151 /**
152 * Number of icons inside the hotseat area.
153 */
Jon Mirandafd48b0c2022-01-31 16:25:22 -0800154 public int numShownHotseatIcons;
Tony Wickhamb87f3cd2021-04-07 15:02:37 -0700155
156 /**
157 * Number of icons inside the hotseat area that is stored in the database. This is greater than
158 * or equal to numnShownHotseatIcons, allowing for a seamless transition between two hotseat
159 * sizes that share the same DB.
160 */
161 public int numDatabaseHotseatIcons;
Adam Cohen27824492017-09-22 17:10:55 -0700162
Thales Lima425f6822022-05-10 13:44:58 -0300163 public int[] hotseatColumnSpan;
Thales Limab8c05952022-05-23 16:58:38 +0100164 public float[] hotseatBarBottomSpace;
165 public float[] hotseatQsbSpace;
Thales Lima425f6822022-05-10 13:44:58 -0300166
Jon Miranda6f7e9702019-09-16 14:44:14 -0700167 /**
168 * Number of columns in the all apps list.
169 */
170 public int numAllAppsColumns;
Sunny Goyal19ff7282021-04-22 10:12:54 -0700171 public int numDatabaseAllAppsColumns;
Thales Limae9273ea2023-01-26 12:33:52 +0000172 public @StyleRes int allAppsStyle;
Jon Miranda6f7e9702019-09-16 14:44:14 -0700173
Jon Mirandae126d722021-02-25 10:45:20 -0500174 /**
175 * Do not query directly. see {@link DeviceProfile#isScalableGrid}.
176 */
177 protected boolean isScalable;
Thales Limaae0d7ef2022-11-16 15:53:43 +0000178 @XmlRes
179 public int devicePaddingId = INVALID_RESOURCE_HANDLE;
Thales Limaec5abba2023-04-05 16:33:50 +0100180 @XmlRes
181 public int workspaceSpecsId = INVALID_RESOURCE_HANDLE;
Thales Limaabfe3642023-05-24 18:08:53 +0100182 @XmlRes
183 public int allAppsSpecsId = INVALID_RESOURCE_HANDLE;
Jordan Silva637f4eb2023-06-13 11:21:53 +0100184 @XmlRes
185 public int folderSpecsId = INVALID_RESOURCE_HANDLE;
Jon Mirandae126d722021-02-25 10:45:20 -0500186
Tracy Zhou7df93d22020-01-27 13:44:06 -0800187 public String dbFile;
Sunny Goyal415f1732018-11-29 10:33:47 -0800188 public int defaultLayoutId;
Sunny Goyal1ae46ca2023-04-10 15:28:59 -0700189 public int demoModeLayoutId;
Thales Lima9938c2f2022-07-25 14:38:16 +0100190 public boolean[] inlineQsb = new boolean[COUNT_SIZES];
Adam Cohen2e6da152015-05-06 11:42:25 -0700191
Pinyao Ting9cd63c92021-06-16 17:51:39 +0000192 /**
193 * An immutable list of supported profiles.
194 */
195 public List<DeviceProfile> supportedProfiles = Collections.EMPTY_LIST;
Sunny Goyalc6205602015-05-21 20:46:33 -0700196
Sunny Goyal6f866092016-03-17 17:04:15 -0700197 public Point defaultWallpaperSize;
198
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700199 private final ArrayList<OnIDPChangeListener> mChangeListeners = new ArrayList<>();
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700200
Sunny Goyalf633ef52018-03-13 09:57:05 -0700201 @VisibleForTesting
Sunny Goyal187b16c2022-03-01 16:53:23 -0800202 public InvariantDeviceProfile() { }
Adam Cohen2e6da152015-05-06 11:42:25 -0700203
Sunny Goyalbbf01842015-10-08 07:41:15 -0700204 @TargetApi(23)
Sunny Goyald0e360a2018-06-29 14:40:18 -0700205 private InvariantDeviceProfile(Context context) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700206 String gridName = getCurrentGridName(context);
207 String newGridName = initGrid(context, gridName);
208 if (!newGridName.equals(gridName)) {
Stefan Andonian4c9612b2023-02-22 00:00:03 +0000209 LauncherPrefs.get(context).put(GRID_NAME, newGridName);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700210 }
Stefan Andonian5bd9a222023-02-23 00:58:33 +0000211 LockedUserState.get(context).runOnUserUnlocked(() -> {
212 new DeviceGridState(this).writeToPrefs(context);
213 });
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700214
Tracy Zhouc8beebf2021-09-23 10:18:11 -0700215 DisplayController.INSTANCE.get(context).setPriorityListener(
Alex Chaufd6d9422021-04-22 19:10:21 +0100216 (displayContext, info, flags) -> {
Alex Chau6ed408f2022-03-04 12:58:05 +0000217 if ((flags & (CHANGE_DENSITY | CHANGE_SUPPORTED_BOUNDS
218 | CHANGE_NAVIGATION_MODE)) != 0) {
Alex Chaufd6d9422021-04-22 19:10:21 +0100219 onConfigChanged(displayContext);
Sunny Goyal35c7b192021-04-20 16:51:10 -0700220 }
221 });
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700222 }
223
Hyunyoung Songe11eb472019-03-19 15:05:21 -0700224 /**
225 * This constructor should NOT have any monitors by design.
226 */
Sunny Goyaleff44f32019-01-09 17:29:49 -0800227 public InvariantDeviceProfile(Context context, String gridName) {
228 String newName = initGrid(context, gridName);
229 if (newName == null || !newName.equals(gridName)) {
230 throw new IllegalArgumentException("Unknown grid name");
231 }
232 }
233
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700234 /**
Sunny Goyal9c2b9602020-01-07 13:07:55 -0800235 * This constructor should NOT have any monitors by design.
236 */
237 public InvariantDeviceProfile(Context context, Display display) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700238 // Ensure that the main device profile is initialized
Alex Chaufd6d9422021-04-22 19:10:21 +0100239 INSTANCE.get(context);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700240 String gridName = getCurrentGridName(context);
241
242 // Get the display info based on default display and interpolate it to existing display
Alex Chau1c883d82021-12-01 18:43:10 +0000243 Info defaultInfo = DisplayController.INSTANCE.get(context).getInfo();
244 @DeviceType int defaultDeviceType = getDeviceType(defaultInfo);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700245 DisplayOption defaultDisplayOption = invDistWeightedInterpolate(
Alex Chau1c883d82021-12-01 18:43:10 +0000246 defaultInfo,
247 getPredefinedDeviceProfiles(context, gridName, defaultDeviceType,
248 /*allowDisabledGrid=*/false),
249 defaultDeviceType);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700250
Alex Chau661f02d2022-06-07 14:03:43 +0100251 Context displayContext = context.createDisplayContext(display);
252 Info myInfo = new Info(displayContext);
Alex Chau1c883d82021-12-01 18:43:10 +0000253 @DeviceType int deviceType = getDeviceType(myInfo);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700254 DisplayOption myDisplayOption = invDistWeightedInterpolate(
Alex Chau1c883d82021-12-01 18:43:10 +0000255 myInfo,
256 getPredefinedDeviceProfiles(context, gridName, deviceType,
257 /*allowDisabledGrid=*/false),
258 deviceType);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700259
260 DisplayOption result = new DisplayOption(defaultDisplayOption.grid)
261 .add(myDisplayOption);
Thales Lima83bedbf2021-10-05 17:47:39 +0100262 result.iconSizes[INDEX_DEFAULT] =
263 defaultDisplayOption.iconSizes[INDEX_DEFAULT];
264 for (int i = 1; i < COUNT_SIZES; i++) {
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700265 result.iconSizes[i] = Math.min(
266 defaultDisplayOption.iconSizes[i], myDisplayOption.iconSizes[i]);
Alex Chau7c439722021-03-24 11:32:44 +0000267 }
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700268
Thales Lima83bedbf2021-10-05 17:47:39 +0100269 System.arraycopy(defaultDisplayOption.minCellSize, 0, result.minCellSize, 0,
270 COUNT_SIZES);
271 System.arraycopy(defaultDisplayOption.borderSpaces, 0, result.borderSpaces, 0,
272 COUNT_SIZES);
Jon Miranda228877d2021-02-09 11:05:00 -0500273
Alex Chau1c883d82021-12-01 18:43:10 +0000274 initGrid(context, myInfo, result, deviceType);
Sunny Goyal9c2b9602020-01-07 13:07:55 -0800275 }
276
Alex Chau238aaee2021-10-06 16:15:24 +0100277 /**
278 * Reinitialize the current grid after a restore, where some grids might now be disabled.
279 */
280 public void reinitializeAfterRestore(Context context) {
Alex Chau29a96ad2022-02-10 13:12:20 +0000281 String currentGridName = getCurrentGridName(context);
Alex Chau238aaee2021-10-06 16:15:24 +0100282 String currentDbFile = dbFile;
Alex Chau29a96ad2022-02-10 13:12:20 +0000283 String newGridName = initGrid(context, currentGridName);
284 String newDbFile = dbFile;
285 if (!newDbFile.equals(currentDbFile)) {
286 Log.d(TAG, "Restored grid is disabled : " + currentGridName
Alex Chau238aaee2021-10-06 16:15:24 +0100287 + ", migrating to: " + newGridName
288 + ", removing all other grid db files");
289 for (String gridDbFile : LauncherFiles.GRID_DB_FILES) {
290 if (gridDbFile.equals(currentDbFile)) {
291 continue;
292 }
293 if (context.getDatabasePath(gridDbFile).delete()) {
294 Log.d(TAG, "Removed old grid db file: " + gridDbFile);
295 }
296 }
Alex Chau29a96ad2022-02-10 13:12:20 +0000297 setCurrentGrid(context, newGridName);
Alex Chau238aaee2021-10-06 16:15:24 +0100298 }
299 }
300
Alex Chau1c883d82021-12-01 18:43:10 +0000301 private static @DeviceType int getDeviceType(Info displayInfo) {
Sunny Goyal187b16c2022-03-01 16:53:23 -0800302 int flagPhone = 1 << 0;
303 int flagTablet = 1 << 1;
304
305 int type = displayInfo.supportedBounds.stream()
306 .mapToInt(bounds -> displayInfo.isTablet(bounds) ? flagTablet : flagPhone)
307 .reduce(0, (a, b) -> a | b);
Sebastian Franco76a1ceb2023-06-08 13:26:20 -0700308 if ((type == (flagPhone | flagTablet))) {
Sunny Goyal187b16c2022-03-01 16:53:23 -0800309 // device has profiles supporting both phone and table modes
Alex Chau1c883d82021-12-01 18:43:10 +0000310 return TYPE_MULTI_DISPLAY;
Sunny Goyal187b16c2022-03-01 16:53:23 -0800311 } else if (type == flagTablet) {
Alex Chau1c883d82021-12-01 18:43:10 +0000312 return TYPE_TABLET;
313 } else {
314 return TYPE_PHONE;
315 }
316 }
317
Tracy Zhou42255d22020-03-13 00:38:11 -0700318 public static String getCurrentGridName(Context context) {
Stefan Andonian4c9612b2023-02-22 00:00:03 +0000319 return LauncherPrefs.get(context).get(GRID_NAME);
Tracy Zhou42255d22020-03-13 00:38:11 -0700320 }
321
Sunny Goyaleff44f32019-01-09 17:29:49 -0800322 private String initGrid(Context context, String gridName) {
Sunny Goyal35c7b192021-04-20 16:51:10 -0700323 Info displayInfo = DisplayController.INSTANCE.get(context).getInfo();
Alex Chau1c883d82021-12-01 18:43:10 +0000324 @DeviceType int deviceType = getDeviceType(displayInfo);
Sunny Goyal19ff7282021-04-22 10:12:54 -0700325
326 ArrayList<DisplayOption> allOptions =
Alex Chau1c883d82021-12-01 18:43:10 +0000327 getPredefinedDeviceProfiles(context, gridName, deviceType,
Alex Chau238aaee2021-10-06 16:15:24 +0100328 RestoreDbTask.isPending(context));
Sunny Goyal19ff7282021-04-22 10:12:54 -0700329 DisplayOption displayOption =
Alex Chau1c883d82021-12-01 18:43:10 +0000330 invDistWeightedInterpolate(displayInfo, allOptions, deviceType);
331 initGrid(context, displayInfo, displayOption, deviceType);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700332 return displayOption.grid.name;
Sunny Goyal9c2b9602020-01-07 13:07:55 -0800333 }
Adam Cohen2e6da152015-05-06 11:42:25 -0700334
Thales Limab67bfa72022-11-02 15:30:11 +0000335 @VisibleForTesting
336 public static String getDefaultGridName(Context context) {
337 return new InvariantDeviceProfile().initGrid(context, null);
338 }
339
Alex Chau1c883d82021-12-01 18:43:10 +0000340 private void initGrid(Context context, Info displayInfo, DisplayOption displayOption,
341 @DeviceType int deviceType) {
Sunny Goyal35c7b192021-04-20 16:51:10 -0700342 DisplayMetrics metrics = context.getResources().getDisplayMetrics();
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700343 GridOption closestProfile = displayOption.grid;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000344 numRows = closestProfile.numRows;
345 numColumns = closestProfile.numColumns;
Alex Chau9fee3fd2021-12-01 18:43:10 +0000346 numSearchContainerColumns = closestProfile.numSearchContainerColumns;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000347 dbFile = closestProfile.dbFile;
348 defaultLayoutId = closestProfile.defaultLayoutId;
349 demoModeLayoutId = closestProfile.demoModeLayoutId;
Thales Limab35faed2022-09-05 16:30:01 -0300350
Sunny Goyalae190ff2020-04-14 00:19:01 +0000351 numFolderRows = closestProfile.numFolderRows;
352 numFolderColumns = closestProfile.numFolderColumns;
Thales Limab35faed2022-09-05 16:30:01 -0300353 folderStyle = closestProfile.folderStyle;
354
Thales Limad852d652023-01-17 14:01:13 +0000355 cellStyle = closestProfile.cellStyle;
356
Jon Mirandae126d722021-02-25 10:45:20 -0500357 isScalable = closestProfile.isScalable;
Jon Mirandac9e69fa2021-03-22 17:13:34 -0400358 devicePaddingId = closestProfile.devicePaddingId;
Thales Limaec5abba2023-04-05 16:33:50 +0100359 workspaceSpecsId = closestProfile.mWorkspaceSpecsId;
Thales Limaabfe3642023-05-24 18:08:53 +0100360 allAppsSpecsId = closestProfile.mAllAppsSpecsId;
Jordan Silva637f4eb2023-06-13 11:21:53 +0100361 folderSpecsId = closestProfile.mFolderSpecsId;
Alex Chau1c883d82021-12-01 18:43:10 +0000362 this.deviceType = deviceType;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000363
Vinit Nayakc7293172022-07-18 16:41:50 -0700364 inlineNavButtonsEndSpacing = closestProfile.inlineNavButtonsEndSpacing;
365
Thales Lima83bedbf2021-10-05 17:47:39 +0100366 iconSize = displayOption.iconSizes;
Thales Lima6e0005a2021-10-27 15:53:41 +0100367 float maxIconSize = iconSize[0];
368 for (int i = 1; i < iconSize.length; i++) {
369 maxIconSize = Math.max(maxIconSize, iconSize[i]);
370 }
371 iconBitmapSize = ResourceUtils.pxFromDp(maxIconSize, metrics);
Sunny Goyalae190ff2020-04-14 00:19:01 +0000372 fillResIconDpi = getLauncherIconDensity(iconBitmapSize);
373
Thales Lima83bedbf2021-10-05 17:47:39 +0100374 iconTextSize = displayOption.textSizes;
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700375
Thales Lima83bedbf2021-10-05 17:47:39 +0100376 minCellSize = displayOption.minCellSize;
Thales Lima78d00ad2021-09-30 11:29:06 +0100377
Thales Lima83bedbf2021-10-05 17:47:39 +0100378 borderSpaces = displayOption.borderSpaces;
Thales Limaa08a4432022-08-09 09:55:17 +0100379
Thales Limad90faab2021-09-21 17:18:47 +0100380 horizontalMargin = displayOption.horizontalMargin;
Thales Limad90faab2021-09-21 17:18:47 +0100381
Sunny Goyal19ff7282021-04-22 10:12:54 -0700382 numShownHotseatIcons = closestProfile.numHotseatIcons;
Alex Chau1c883d82021-12-01 18:43:10 +0000383 numDatabaseHotseatIcons = deviceType == TYPE_MULTI_DISPLAY
Sunny Goyal19ff7282021-04-22 10:12:54 -0700384 ? closestProfile.numDatabaseHotseatIcons : closestProfile.numHotseatIcons;
Thales Lima425f6822022-05-10 13:44:58 -0300385 hotseatColumnSpan = closestProfile.hotseatColumnSpan;
Thales Limab8c05952022-05-23 16:58:38 +0100386 hotseatBarBottomSpace = displayOption.hotseatBarBottomSpace;
387 hotseatQsbSpace = displayOption.hotseatQsbSpace;
Sunny Goyal19ff7282021-04-22 10:12:54 -0700388
Thales Limae9273ea2023-01-26 12:33:52 +0000389 allAppsStyle = closestProfile.allAppsStyle;
390
Sunny Goyal19ff7282021-04-22 10:12:54 -0700391 numAllAppsColumns = closestProfile.numAllAppsColumns;
Alex Chau1c883d82021-12-01 18:43:10 +0000392 numDatabaseAllAppsColumns = deviceType == TYPE_MULTI_DISPLAY
Sunny Goyal19ff7282021-04-22 10:12:54 -0700393 ? closestProfile.numDatabaseAllAppsColumns : closestProfile.numAllAppsColumns;
Jon Mirandae126d722021-02-25 10:45:20 -0500394
Thales Limab7ef5692022-03-10 10:32:36 +0000395 allAppsCellSize = displayOption.allAppsCellSize;
Thales Limabb7d3882021-12-22 12:56:29 +0000396 allAppsBorderSpaces = displayOption.allAppsBorderSpaces;
397 allAppsIconSize = displayOption.allAppsIconSizes;
398 allAppsIconTextSize = displayOption.allAppsIconTextSizes;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000399
Thales Lima11af7bc2022-08-12 15:24:54 +0100400 inlineQsb = closestProfile.inlineQsb;
Thales Lima12d0eff2022-03-25 17:06:11 +0000401
Jon Miranda9c478b62023-03-23 21:38:49 -0700402 transientTaskbarIconSize = displayOption.transientTaskbarIconSize;
403
Jon Miranda04f05102023-04-04 12:16:31 -0700404 startAlignTaskbar = displayOption.startAlignTaskbar;
405
Sunny Goyalae190ff2020-04-14 00:19:01 +0000406 // If the partner customization apk contains any grid overrides, apply them
407 // Supported overrides: numRows, numColumns, iconSize
Sunny Goyal35c7b192021-04-20 16:51:10 -0700408 applyPartnerDeviceProfileOverrides(context, metrics);
Sunny Goyalc6205602015-05-21 20:46:33 -0700409
Pinyao Ting9cd63c92021-06-16 17:51:39 +0000410 final List<DeviceProfile> localSupportedProfiles = new ArrayList<>();
Sunny Goyal19ff7282021-04-22 10:12:54 -0700411 defaultWallpaperSize = new Point(displayInfo.currentSize);
Sunny Goyal65190ae2022-08-02 14:16:26 -0700412 SparseArray<DotRenderer> dotRendererCache = new SparseArray<>();
Sunny Goyal19ff7282021-04-22 10:12:54 -0700413 for (WindowBounds bounds : displayInfo.supportedBounds) {
Pinyao Ting9cd63c92021-06-16 17:51:39 +0000414 localSupportedProfiles.add(new DeviceProfile.Builder(context, this, displayInfo)
Alex Chauab800f72022-12-13 17:46:06 +0000415 .setIsMultiDisplay(deviceType == TYPE_MULTI_DISPLAY)
Alex Chau6ed408f2022-03-04 12:58:05 +0000416 .setWindowBounds(bounds)
Sunny Goyal65190ae2022-08-02 14:16:26 -0700417 .setDotRendererCache(dotRendererCache)
Alex Chau6ed408f2022-03-04 12:58:05 +0000418 .build());
Sunny Goyalc6205602015-05-21 20:46:33 -0700419
Sunny Goyal19ff7282021-04-22 10:12:54 -0700420 // Wallpaper size should be the maximum of the all possible sizes Launcher expects
421 int displayWidth = bounds.bounds.width();
422 int displayHeight = bounds.bounds.height();
423 defaultWallpaperSize.y = Math.max(defaultWallpaperSize.y, displayHeight);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700424
Sunny Goyal19ff7282021-04-22 10:12:54 -0700425 // We need to ensure that there is enough extra space in the wallpaper
426 // for the intended parallax effects
427 float parallaxFactor =
Thales Lima425f6822022-05-10 13:44:58 -0300428 dpiFromPx(Math.min(displayWidth, displayHeight), displayInfo.getDensityDpi())
429 < 720
Sunny Goyal19ff7282021-04-22 10:12:54 -0700430 ? 2
431 : wallpaperTravelToScreenWidthRatio(displayWidth, displayHeight);
432 defaultWallpaperSize.x =
433 Math.max(defaultWallpaperSize.x, Math.round(parallaxFactor * displayWidth));
Sunny Goyal6f866092016-03-17 17:04:15 -0700434 }
Pinyao Ting9cd63c92021-06-16 17:51:39 +0000435 supportedProfiles = Collections.unmodifiableList(localSupportedProfiles);
Sunny Goyal58fa4b62019-03-22 16:23:25 -0700436
Thales Lima6a590062022-11-22 15:52:49 +0000437 int numMinShownHotseatIconsForTablet = supportedProfiles
438 .stream()
439 .filter(deviceProfile -> deviceProfile.isTablet)
440 .mapToInt(deviceProfile -> deviceProfile.numShownHotseatIcons)
441 .min()
442 .orElse(0);
443
444 supportedProfiles
445 .stream()
446 .filter(deviceProfile -> deviceProfile.isTablet)
447 .forEach(deviceProfile -> {
448 deviceProfile.numShownHotseatIcons = numMinShownHotseatIconsForTablet;
449 deviceProfile.recalculateHotseatWidthAndBorderSpace();
450 });
Adam Cohen2e6da152015-05-06 11:42:25 -0700451 }
452
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700453 public void addOnChangeListener(OnIDPChangeListener listener) {
454 mChangeListeners.add(listener);
455 }
456
Hyunyoung Songb4d1ca42019-01-08 17:15:16 -0800457 public void removeOnChangeListener(OnIDPChangeListener listener) {
458 mChangeListeners.remove(listener);
459 }
460
Hyunyoung Songc55a3502018-12-04 15:43:16 -0800461
Sunny Goyal7d892ff2019-01-11 15:08:44 -0800462 public void setCurrentGrid(Context context, String gridName) {
Stefan Andonian4c9612b2023-02-22 00:00:03 +0000463 LauncherPrefs.get(context).put(GRID_NAME, gridName);
464 MAIN_EXECUTOR.execute(() -> onConfigChanged(context.getApplicationContext()));
Sunny Goyal7d892ff2019-01-11 15:08:44 -0800465 }
466
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700467 private Object[] toModelState() {
sfufa@google.comde013292021-09-21 18:22:44 -0700468 return new Object[]{
Alex Chau9fee3fd2021-12-01 18:43:10 +0000469 numColumns, numRows, numSearchContainerColumns, numDatabaseHotseatIcons,
470 iconBitmapSize, fillResIconDpi, numDatabaseAllAppsColumns, dbFile};
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700471 }
472
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700473 private void onConfigChanged(Context context) {
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700474 Object[] oldState = toModelState();
475
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700476 // Re-init grid
Tracy Zhouc6060e62020-04-27 13:05:34 -0700477 String gridName = getCurrentGridName(context);
Jon Miranda6f7e9702019-09-16 14:44:14 -0700478 initGrid(context, gridName);
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700479
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700480 boolean modelPropsChanged = !Arrays.equals(oldState, toModelState());
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700481 for (OnIDPChangeListener listener : mChangeListeners) {
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700482 listener.onIdpChanged(modelPropsChanged);
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700483 }
484 }
485
Alex Chau1c883d82021-12-01 18:43:10 +0000486 private static ArrayList<DisplayOption> getPredefinedDeviceProfiles(Context context,
487 String gridName, @DeviceType int deviceType, boolean allowDisabledGrid) {
Sunny Goyal415f1732018-11-29 10:33:47 -0800488 ArrayList<DisplayOption> profiles = new ArrayList<>();
Thales Lima1de4d552021-10-13 16:13:25 +0100489
Alex Chau1c883d82021-12-01 18:43:10 +0000490 try (XmlResourceParser parser = context.getResources().getXml(R.xml.device_profiles)) {
Sunny Goyal819e1932016-07-07 16:43:58 -0700491 final int depth = parser.getDepth();
492 int type;
Sunny Goyal819e1932016-07-07 16:43:58 -0700493 while (((type = parser.next()) != XmlPullParser.END_TAG ||
494 parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
Sunny Goyal7d892ff2019-01-11 15:08:44 -0800495 if ((type == XmlPullParser.START_TAG)
496 && GridOption.TAG_NAME.equals(parser.getName())) {
Sunny Goyal415f1732018-11-29 10:33:47 -0800497
Sunny Goyal076e04b2023-04-03 12:38:30 -0700498 GridOption gridOption = new GridOption(context, Xml.asAttributeSet(parser));
499 if (gridOption.isEnabled(deviceType) || allowDisabledGrid) {
Thales Lima7ec83822021-08-05 13:32:10 +0100500 final int displayDepth = parser.getDepth();
501 while (((type = parser.next()) != XmlPullParser.END_TAG
502 || parser.getDepth() > displayDepth)
503 && type != XmlPullParser.END_DOCUMENT) {
504 if ((type == XmlPullParser.START_TAG) && "display-option".equals(
505 parser.getName())) {
506 profiles.add(new DisplayOption(gridOption, context,
Thales Lima1de4d552021-10-13 16:13:25 +0100507 Xml.asAttributeSet(parser)));
Thales Lima7ec83822021-08-05 13:32:10 +0100508 }
Sunny Goyal415f1732018-11-29 10:33:47 -0800509 }
510 }
Sunny Goyal819e1932016-07-07 16:43:58 -0700511 }
512 }
sfufa@google.comde013292021-09-21 18:22:44 -0700513 } catch (IOException | XmlPullParserException e) {
Sunny Goyal819e1932016-07-07 16:43:58 -0700514 throw new RuntimeException(e);
515 }
Sunny Goyal415f1732018-11-29 10:33:47 -0800516
Sunny Goyalae190ff2020-04-14 00:19:01 +0000517 ArrayList<DisplayOption> filteredProfiles = new ArrayList<>();
Sunny Goyal415f1732018-11-29 10:33:47 -0800518 if (!TextUtils.isEmpty(gridName)) {
519 for (DisplayOption option : profiles) {
Alex Chau238aaee2021-10-06 16:15:24 +0100520 if (gridName.equals(option.grid.name)
Sunny Goyal076e04b2023-04-03 12:38:30 -0700521 && (option.grid.isEnabled(deviceType) || allowDisabledGrid)) {
Sunny Goyalae190ff2020-04-14 00:19:01 +0000522 filteredProfiles.add(option);
Sunny Goyal415f1732018-11-29 10:33:47 -0800523 }
524 }
525 }
Sunny Goyalae190ff2020-04-14 00:19:01 +0000526 if (filteredProfiles.isEmpty()) {
527 // No grid found, use the default options
528 for (DisplayOption option : profiles) {
529 if (option.canBeDefault) {
530 filteredProfiles.add(option);
531 }
Sunny Goyal415f1732018-11-29 10:33:47 -0800532 }
533 }
Sunny Goyalae190ff2020-04-14 00:19:01 +0000534 if (filteredProfiles.isEmpty()) {
535 throw new RuntimeException("No display option with canBeDefault=true");
536 }
537 return filteredProfiles;
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700538 }
539
Thales Lima7ec83822021-08-05 13:32:10 +0100540 /**
541 * @return all the grid options that can be shown on the device
542 */
543 public List<GridOption> parseAllGridOptions(Context context) {
Sunny Goyal076e04b2023-04-03 12:38:30 -0700544 return parseAllDefinedGridOptions(context)
545 .stream()
546 .filter(go -> go.isEnabled(deviceType))
547 .collect(Collectors.toList());
548 }
549
550 /**
551 * @return all the grid options that can be shown on the device
552 */
553 public static List<GridOption> parseAllDefinedGridOptions(Context context) {
Thales Lima7ec83822021-08-05 13:32:10 +0100554 List<GridOption> result = new ArrayList<>();
Thales Lima1de4d552021-10-13 16:13:25 +0100555
Alex Chau1c883d82021-12-01 18:43:10 +0000556 try (XmlResourceParser parser = context.getResources().getXml(R.xml.device_profiles)) {
Thales Lima7ec83822021-08-05 13:32:10 +0100557 final int depth = parser.getDepth();
558 int type;
559 while (((type = parser.next()) != XmlPullParser.END_TAG
560 || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
561 if ((type == XmlPullParser.START_TAG)
562 && GridOption.TAG_NAME.equals(parser.getName())) {
Sunny Goyal076e04b2023-04-03 12:38:30 -0700563 result.add(new GridOption(context, Xml.asAttributeSet(parser)));
Thales Lima7ec83822021-08-05 13:32:10 +0100564 }
565 }
566 } catch (IOException | XmlPullParserException e) {
567 Log.e(TAG, "Error parsing device profile", e);
568 return Collections.emptyList();
569 }
570 return result;
571 }
572
Sunny Goyal53d7ee42015-05-22 12:25:45 -0700573 private int getLauncherIconDensity(int requiredSize) {
574 // Densities typically defined by an app.
sfufa@google.comde013292021-09-21 18:22:44 -0700575 int[] densityBuckets = new int[]{
Sunny Goyal53d7ee42015-05-22 12:25:45 -0700576 DisplayMetrics.DENSITY_LOW,
577 DisplayMetrics.DENSITY_MEDIUM,
578 DisplayMetrics.DENSITY_TV,
579 DisplayMetrics.DENSITY_HIGH,
580 DisplayMetrics.DENSITY_XHIGH,
581 DisplayMetrics.DENSITY_XXHIGH,
582 DisplayMetrics.DENSITY_XXXHIGH
583 };
584
585 int density = DisplayMetrics.DENSITY_XXXHIGH;
586 for (int i = densityBuckets.length - 1; i >= 0; i--) {
587 float expectedSize = ICON_SIZE_DEFINED_IN_APP_DP * densityBuckets[i]
588 / DisplayMetrics.DENSITY_DEFAULT;
589 if (expectedSize >= requiredSize) {
590 density = densityBuckets[i];
591 }
592 }
593
594 return density;
595 }
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700596
Adam Cohen2e6da152015-05-06 11:42:25 -0700597 /**
598 * Apply any Partner customization grid overrides.
599 *
600 * Currently we support: all apps row / column count.
601 */
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700602 private void applyPartnerDeviceProfileOverrides(Context context, DisplayMetrics dm) {
603 Partner p = Partner.get(context.getPackageManager());
Sunny Goyal3e58eea2022-11-14 14:30:07 -0800604 if (p == null) {
605 return;
606 }
607 try {
608 int numRows = p.getIntValue(RES_GRID_NUM_ROWS, -1);
609 int numColumns = p.getIntValue(RES_GRID_NUM_COLUMNS, -1);
610 float iconSizePx = p.getDimenValue(RES_GRID_ICON_SIZE_DP, -1);
611
612 if (numRows > 0 && numColumns > 0) {
613 this.numRows = numRows;
614 this.numColumns = numColumns;
615 }
616 if (iconSizePx > 0) {
617 this.iconSize[InvariantDeviceProfile.INDEX_DEFAULT] =
618 Utilities.dpiFromPx(iconSizePx, dm.densityDpi);
619 }
620 } catch (Resources.NotFoundException ex) {
621 Log.e(TAG, "Invalid Partner grid resource!", ex);
Adam Cohen2e6da152015-05-06 11:42:25 -0700622 }
623 }
624
Sunny Goyal415f1732018-11-29 10:33:47 -0800625 private static float dist(float x0, float y0, float x1, float y1) {
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700626 return (float) Math.hypot(x1 - x0, y1 - y0);
Adam Cohen2e6da152015-05-06 11:42:25 -0700627 }
628
Sunny Goyal19ff7282021-04-22 10:12:54 -0700629 private static DisplayOption invDistWeightedInterpolate(
Alex Chau1c883d82021-12-01 18:43:10 +0000630 Info displayInfo, ArrayList<DisplayOption> points, @DeviceType int deviceType) {
Sunny Goyal19ff7282021-04-22 10:12:54 -0700631 int minWidthPx = Integer.MAX_VALUE;
632 int minHeightPx = Integer.MAX_VALUE;
633 for (WindowBounds bounds : displayInfo.supportedBounds) {
634 boolean isTablet = displayInfo.isTablet(bounds);
Alex Chau1c883d82021-12-01 18:43:10 +0000635 if (isTablet && deviceType == TYPE_MULTI_DISPLAY) {
Sunny Goyal19ff7282021-04-22 10:12:54 -0700636 // For split displays, take half width per page
637 minWidthPx = Math.min(minWidthPx, bounds.availableSize.x / 2);
638 minHeightPx = Math.min(minHeightPx, bounds.availableSize.y);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700639
Sunny Goyal19ff7282021-04-22 10:12:54 -0700640 } else if (!isTablet && bounds.isLandscape()) {
641 // We will use transposed layout in this case
642 minWidthPx = Math.min(minWidthPx, bounds.availableSize.y);
643 minHeightPx = Math.min(minHeightPx, bounds.availableSize.x);
644 } else {
645 minWidthPx = Math.min(minWidthPx, bounds.availableSize.x);
646 minHeightPx = Math.min(minHeightPx, bounds.availableSize.y);
647 }
648 }
649
Thales Lima425f6822022-05-10 13:44:58 -0300650 float width = dpiFromPx(minWidthPx, displayInfo.getDensityDpi());
651 float height = dpiFromPx(minHeightPx, displayInfo.getDensityDpi());
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700652
653 // Sort the profiles based on the closeness to the device size
654 Collections.sort(points, (a, b) ->
655 Float.compare(dist(width, height, a.minWidthDps, a.minHeightDps),
656 dist(width, height, b.minWidthDps, b.minHeightDps)));
657
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700658 DisplayOption closestPoint = points.get(0);
659 GridOption closestOption = closestPoint.grid;
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700660 float weights = 0;
661
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700662 if (dist(width, height, closestPoint.minWidthDps, closestPoint.minHeightDps) == 0) {
663 return closestPoint;
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700664 }
665
666 DisplayOption out = new DisplayOption(closestOption);
667 for (int i = 0; i < points.size() && i < KNEARESTNEIGHBOR; ++i) {
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700668 DisplayOption p = points.get(i);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700669 float w = weight(width, height, p.minWidthDps, p.minHeightDps, WEIGHT_POWER);
670 weights += w;
671 out.add(new DisplayOption().add(p).multiply(w));
672 }
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700673 out.multiply(1.0f / weights);
674
Thales Lima6e0005a2021-10-27 15:53:41 +0100675 // Since the bitmaps are persisted, ensure that all bitmap sizes are not larger than
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700676 // predefined size to avoid cache invalidation
Thales Lima6e0005a2021-10-27 15:53:41 +0100677 for (int i = INDEX_DEFAULT; i < COUNT_SIZES; i++) {
678 out.iconSizes[i] = Math.min(out.iconSizes[i], closestPoint.iconSizes[i]);
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700679 }
680
681 return out;
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700682 }
683
Sunny Goyal27835952017-01-13 12:15:53 -0800684 public DeviceProfile getDeviceProfile(Context context) {
Sunny Goyal19ff7282021-04-22 10:12:54 -0700685 Resources res = context.getResources();
686 Configuration config = context.getResources().getConfiguration();
687
Sunny Goyal3e9a29c2021-09-07 15:53:09 -0400688 float screenWidth = config.screenWidthDp * res.getDisplayMetrics().density;
689 float screenHeight = config.screenHeightDp * res.getDisplayMetrics().density;
Alex Chaud3e8cc42022-05-03 17:45:34 +0100690 int rotation = WindowManagerProxy.INSTANCE.get(context).getRotation(context);
691
Alex Chaud3e8cc42022-05-03 17:45:34 +0100692 return getBestMatch(screenWidth, screenHeight, rotation);
Sunny Goyal3e9a29c2021-09-07 15:53:09 -0400693 }
Sunny Goyal19ff7282021-04-22 10:12:54 -0700694
Sunny Goyal187b16c2022-03-01 16:53:23 -0800695 /**
696 * Returns the device profile matching the provided screen configuration
697 */
698 public DeviceProfile getBestMatch(float screenWidth, float screenHeight, int rotation) {
Sunny Goyal19ff7282021-04-22 10:12:54 -0700699 DeviceProfile bestMatch = supportedProfiles.get(0);
700 float minDiff = Float.MAX_VALUE;
701
702 for (DeviceProfile profile : supportedProfiles) {
Sunny Goyal3e9a29c2021-09-07 15:53:09 -0400703 float diff = Math.abs(profile.widthPx - screenWidth)
704 + Math.abs(profile.heightPx - screenHeight);
Sunny Goyal19ff7282021-04-22 10:12:54 -0700705 if (diff < minDiff) {
706 minDiff = diff;
707 bestMatch = profile;
Sunny Goyal187b16c2022-03-01 16:53:23 -0800708 } else if (diff == minDiff && profile.rotationHint == rotation) {
709 bestMatch = profile;
Sunny Goyal19ff7282021-04-22 10:12:54 -0700710 }
711 }
712 return bestMatch;
Sunny Goyal27835952017-01-13 12:15:53 -0800713 }
714
Sunny Goyal415f1732018-11-29 10:33:47 -0800715 private static float weight(float x0, float y0, float x1, float y1, float pow) {
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700716 float d = dist(x0, y0, x1, y1);
717 if (Float.compare(d, 0f) == 0) {
718 return Float.POSITIVE_INFINITY;
719 }
720 return (float) (WEIGHT_EFFICIENT / Math.pow(d, pow));
721 }
Sunny Goyal6f866092016-03-17 17:04:15 -0700722
723 /**
724 * As a ratio of screen height, the total distance we want the parallax effect to span
725 * horizontally
726 */
727 private static float wallpaperTravelToScreenWidthRatio(int width, int height) {
728 float aspectRatio = width / (float) height;
729
730 // At an aspect ratio of 16/10, the wallpaper parallax effect should span 1.5 * screen width
731 // At an aspect ratio of 10/16, the wallpaper parallax effect should span 1.2 * screen width
732 // We will use these two data points to extrapolate how much the wallpaper parallax effect
733 // to span (ie travel) at any aspect ratio:
734
sfufa@google.comde013292021-09-21 18:22:44 -0700735 final float ASPECT_RATIO_LANDSCAPE = 16 / 10f;
736 final float ASPECT_RATIO_PORTRAIT = 10 / 16f;
Sunny Goyal6f866092016-03-17 17:04:15 -0700737 final float WALLPAPER_WIDTH_TO_SCREEN_RATIO_LANDSCAPE = 1.5f;
738 final float WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT = 1.2f;
739
740 // To find out the desired width at different aspect ratios, we use the following two
741 // formulas, where the coefficient on x is the aspect ratio (width/height):
742 // (16/10)x + y = 1.5
743 // (10/16)x + y = 1.2
744 // We solve for x and y and end up with a final formula:
745 final float x =
sfufa@google.comde013292021-09-21 18:22:44 -0700746 (WALLPAPER_WIDTH_TO_SCREEN_RATIO_LANDSCAPE
747 - WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT) /
Sunny Goyal6f866092016-03-17 17:04:15 -0700748 (ASPECT_RATIO_LANDSCAPE - ASPECT_RATIO_PORTRAIT);
749 final float y = WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT - x * ASPECT_RATIO_PORTRAIT;
750 return x * aspectRatio + y;
751 }
752
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700753 public interface OnIDPChangeListener {
754
Sunny Goyalb47172b2021-05-03 19:59:51 -0700755 /**
756 * Called when the device provide changes
757 */
Sunny Goyal6e6f7992021-08-24 16:23:29 -0700758 void onIdpChanged(boolean modelPropertiesChanged);
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700759 }
Sunny Goyal415f1732018-11-29 10:33:47 -0800760
761
Sunny Goyaleff44f32019-01-09 17:29:49 -0800762 public static final class GridOption {
Sunny Goyal415f1732018-11-29 10:33:47 -0800763
Sunny Goyal7d892ff2019-01-11 15:08:44 -0800764 public static final String TAG_NAME = "grid-option";
765
Alex Chau1c883d82021-12-01 18:43:10 +0000766 private static final int DEVICE_CATEGORY_PHONE = 1 << 0;
767 private static final int DEVICE_CATEGORY_TABLET = 1 << 1;
768 private static final int DEVICE_CATEGORY_MULTI_DISPLAY = 1 << 2;
769 private static final int DEVICE_CATEGORY_ALL =
770 DEVICE_CATEGORY_PHONE | DEVICE_CATEGORY_TABLET | DEVICE_CATEGORY_MULTI_DISPLAY;
771
Thales Lima11af7bc2022-08-12 15:24:54 +0100772 private static final int INLINE_QSB_FOR_PORTRAIT = 1 << 0;
773 private static final int INLINE_QSB_FOR_LANDSCAPE = 1 << 1;
774 private static final int INLINE_QSB_FOR_TWO_PANEL_PORTRAIT = 1 << 2;
775 private static final int INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE = 1 << 3;
776 private static final int DONT_INLINE_QSB = 0;
777
Sunny Goyaleff44f32019-01-09 17:29:49 -0800778 public final String name;
779 public final int numRows;
780 public final int numColumns;
Alex Chau9fee3fd2021-12-01 18:43:10 +0000781 public final int numSearchContainerColumns;
Sunny Goyal076e04b2023-04-03 12:38:30 -0700782 public final int deviceCategory;
Sunny Goyal415f1732018-11-29 10:33:47 -0800783
784 private final int numFolderRows;
785 private final int numFolderColumns;
Thales Limab35faed2022-09-05 16:30:01 -0300786 private final @StyleRes int folderStyle;
Thales Limad852d652023-01-17 14:01:13 +0000787 private final @StyleRes int cellStyle;
Sunny Goyal415f1732018-11-29 10:33:47 -0800788
Thales Limae9273ea2023-01-26 12:33:52 +0000789 private final @StyleRes int allAppsStyle;
Sunny Goyal19ff7282021-04-22 10:12:54 -0700790 private final int numAllAppsColumns;
791 private final int numDatabaseAllAppsColumns;
792 private final int numHotseatIcons;
Tony Wickhamb87f3cd2021-04-07 15:02:37 -0700793 private final int numDatabaseHotseatIcons;
Thales Limab8c05952022-05-23 16:58:38 +0100794
Thales Lima425f6822022-05-10 13:44:58 -0300795 private final int[] hotseatColumnSpan = new int[COUNT_SIZES];
Sunny Goyal415f1732018-11-29 10:33:47 -0800796
Thales Lima11af7bc2022-08-12 15:24:54 +0100797 private final boolean[] inlineQsb = new boolean[COUNT_SIZES];
798
Thales Limab35faed2022-09-05 16:30:01 -0300799 private @DimenRes int inlineNavButtonsEndSpacing;
Tracy Zhou7df93d22020-01-27 13:44:06 -0800800 private final String dbFile;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000801
Sunny Goyal415f1732018-11-29 10:33:47 -0800802 private final int defaultLayoutId;
803 private final int demoModeLayoutId;
804
Jon Mirandae126d722021-02-25 10:45:20 -0500805 private final boolean isScalable;
Jon Mirandac9e69fa2021-03-22 17:13:34 -0400806 private final int devicePaddingId;
Thales Limaec5abba2023-04-05 16:33:50 +0100807 private final int mWorkspaceSpecsId;
Thales Limaabfe3642023-05-24 18:08:53 +0100808 private final int mAllAppsSpecsId;
Jordan Silva637f4eb2023-06-13 11:21:53 +0100809 private final int mFolderSpecsId;
Jon Mirandae126d722021-02-25 10:45:20 -0500810
Sunny Goyal076e04b2023-04-03 12:38:30 -0700811 public GridOption(Context context, AttributeSet attrs) {
Sunny Goyal415f1732018-11-29 10:33:47 -0800812 TypedArray a = context.obtainStyledAttributes(
813 attrs, R.styleable.GridDisplayOption);
814 name = a.getString(R.styleable.GridDisplayOption_name);
815 numRows = a.getInt(R.styleable.GridDisplayOption_numRows, 0);
816 numColumns = a.getInt(R.styleable.GridDisplayOption_numColumns, 0);
Alex Chau9fee3fd2021-12-01 18:43:10 +0000817 numSearchContainerColumns = a.getInt(
818 R.styleable.GridDisplayOption_numSearchContainerColumns, numColumns);
Sunny Goyal415f1732018-11-29 10:33:47 -0800819
Tracy Zhou7df93d22020-01-27 13:44:06 -0800820 dbFile = a.getString(R.styleable.GridDisplayOption_dbFile);
Alex Chau766cd2b2022-07-06 17:15:21 +0100821 defaultLayoutId = a.getResourceId(
822 R.styleable.GridDisplayOption_defaultLayoutId, 0);
Sunny Goyal415f1732018-11-29 10:33:47 -0800823 demoModeLayoutId = a.getResourceId(
824 R.styleable.GridDisplayOption_demoModeLayoutId, defaultLayoutId);
Sunny Goyal19ff7282021-04-22 10:12:54 -0700825
Thales Limae9273ea2023-01-26 12:33:52 +0000826 allAppsStyle = a.getResourceId(R.styleable.GridDisplayOption_allAppsStyle,
827 R.style.AllAppsStyleDefault);
Sunny Goyal19ff7282021-04-22 10:12:54 -0700828 numAllAppsColumns = a.getInt(
829 R.styleable.GridDisplayOption_numAllAppsColumns, numColumns);
830 numDatabaseAllAppsColumns = a.getInt(
831 R.styleable.GridDisplayOption_numExtendedAllAppsColumns, 2 * numAllAppsColumns);
832
833 numHotseatIcons = a.getInt(
Sunny Goyal415f1732018-11-29 10:33:47 -0800834 R.styleable.GridDisplayOption_numHotseatIcons, numColumns);
Sunny Goyal19ff7282021-04-22 10:12:54 -0700835 numDatabaseHotseatIcons = a.getInt(
836 R.styleable.GridDisplayOption_numExtendedHotseatIcons, 2 * numHotseatIcons);
Thales Limab8c05952022-05-23 16:58:38 +0100837
Thales Lima425f6822022-05-10 13:44:58 -0300838 hotseatColumnSpan[INDEX_DEFAULT] = a.getInt(
839 R.styleable.GridDisplayOption_hotseatColumnSpan, numColumns);
840 hotseatColumnSpan[INDEX_LANDSCAPE] = a.getInt(
841 R.styleable.GridDisplayOption_hotseatColumnSpanLandscape, numColumns);
842 hotseatColumnSpan[INDEX_TWO_PANEL_LANDSCAPE] = a.getInt(
843 R.styleable.GridDisplayOption_hotseatColumnSpanTwoPanelLandscape,
844 numColumns);
845 hotseatColumnSpan[INDEX_TWO_PANEL_PORTRAIT] = a.getInt(
846 R.styleable.GridDisplayOption_hotseatColumnSpanTwoPanelPortrait,
847 numColumns);
Sunny Goyal19ff7282021-04-22 10:12:54 -0700848
Vinit Nayakc7293172022-07-18 16:41:50 -0700849 inlineNavButtonsEndSpacing =
850 a.getResourceId(R.styleable.GridDisplayOption_inlineNavButtonsEndSpacing,
Thales Limaec5abba2023-04-05 16:33:50 +0100851 R.dimen.taskbar_button_margin_default);
Thales Limab35faed2022-09-05 16:30:01 -0300852
Sunny Goyal415f1732018-11-29 10:33:47 -0800853 numFolderRows = a.getInt(
854 R.styleable.GridDisplayOption_numFolderRows, numRows);
855 numFolderColumns = a.getInt(
856 R.styleable.GridDisplayOption_numFolderColumns, numColumns);
Jon Miranda6f7e9702019-09-16 14:44:14 -0700857
Thales Limab35faed2022-09-05 16:30:01 -0300858 folderStyle = a.getResourceId(R.styleable.GridDisplayOption_folderStyle,
859 INVALID_RESOURCE_HANDLE);
860
Thales Limad852d652023-01-17 14:01:13 +0000861 cellStyle = a.getResourceId(R.styleable.GridDisplayOption_cellStyle,
862 R.style.CellStyleDefault);
863
Jon Mirandae126d722021-02-25 10:45:20 -0500864 isScalable = a.getBoolean(
865 R.styleable.GridDisplayOption_isScalable, false);
Jon Mirandac9e69fa2021-03-22 17:13:34 -0400866 devicePaddingId = a.getResourceId(
Thales Limaae0d7ef2022-11-16 15:53:43 +0000867 R.styleable.GridDisplayOption_devicePaddingId, INVALID_RESOURCE_HANDLE);
Sunny Goyal076e04b2023-04-03 12:38:30 -0700868 deviceCategory = a.getInt(R.styleable.GridDisplayOption_deviceCategory,
Alex Chau1c883d82021-12-01 18:43:10 +0000869 DEVICE_CATEGORY_ALL);
Thales Lima7ec83822021-08-05 13:32:10 +0100870
Thales Limaec5abba2023-04-05 16:33:50 +0100871 if (FeatureFlags.ENABLE_RESPONSIVE_WORKSPACE.get()) {
872 mWorkspaceSpecsId = a.getResourceId(
873 R.styleable.GridDisplayOption_workspaceSpecsId, INVALID_RESOURCE_HANDLE);
Thales Limaabfe3642023-05-24 18:08:53 +0100874 mAllAppsSpecsId = a.getResourceId(
875 R.styleable.GridDisplayOption_allAppsSpecsId, INVALID_RESOURCE_HANDLE);
Jordan Silva637f4eb2023-06-13 11:21:53 +0100876 mFolderSpecsId = a.getResourceId(
877 R.styleable.GridDisplayOption_folderSpecsId, INVALID_RESOURCE_HANDLE);
Thales Limaec5abba2023-04-05 16:33:50 +0100878 } else {
879 mWorkspaceSpecsId = INVALID_RESOURCE_HANDLE;
Thales Limaabfe3642023-05-24 18:08:53 +0100880 mAllAppsSpecsId = INVALID_RESOURCE_HANDLE;
Jordan Silva637f4eb2023-06-13 11:21:53 +0100881 mFolderSpecsId = INVALID_RESOURCE_HANDLE;
Thales Limaec5abba2023-04-05 16:33:50 +0100882 }
883
Thales Lima11af7bc2022-08-12 15:24:54 +0100884 int inlineForRotation = a.getInt(R.styleable.GridDisplayOption_inlineQsb,
885 DONT_INLINE_QSB);
886 inlineQsb[INDEX_DEFAULT] =
887 (inlineForRotation & INLINE_QSB_FOR_PORTRAIT) == INLINE_QSB_FOR_PORTRAIT;
888 inlineQsb[INDEX_LANDSCAPE] =
889 (inlineForRotation & INLINE_QSB_FOR_LANDSCAPE) == INLINE_QSB_FOR_LANDSCAPE;
890 inlineQsb[INDEX_TWO_PANEL_PORTRAIT] =
891 (inlineForRotation & INLINE_QSB_FOR_TWO_PANEL_PORTRAIT)
892 == INLINE_QSB_FOR_TWO_PANEL_PORTRAIT;
893 inlineQsb[INDEX_TWO_PANEL_LANDSCAPE] =
894 (inlineForRotation & INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE)
895 == INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE;
896
Sunny Goyal415f1732018-11-29 10:33:47 -0800897 a.recycle();
Sunny Goyal076e04b2023-04-03 12:38:30 -0700898 }
899
900 public boolean isEnabled(@DeviceType int deviceType) {
901 switch (deviceType) {
902 case TYPE_PHONE:
903 return (deviceCategory & DEVICE_CATEGORY_PHONE) == DEVICE_CATEGORY_PHONE;
904 case TYPE_TABLET:
905 return (deviceCategory & DEVICE_CATEGORY_TABLET) == DEVICE_CATEGORY_TABLET;
906 case TYPE_MULTI_DISPLAY:
907 return (deviceCategory & DEVICE_CATEGORY_MULTI_DISPLAY)
908 == DEVICE_CATEGORY_MULTI_DISPLAY;
909 default:
910 return false;
911 }
Sunny Goyal415f1732018-11-29 10:33:47 -0800912 }
913 }
914
Sunny Goyal19ff7282021-04-22 10:12:54 -0700915 @VisibleForTesting
916 static final class DisplayOption {
Sunny Goyal19ff7282021-04-22 10:12:54 -0700917 public final GridOption grid;
Sunny Goyal415f1732018-11-29 10:33:47 -0800918
Sunny Goyal415f1732018-11-29 10:33:47 -0800919 private final float minWidthDps;
920 private final float minHeightDps;
921 private final boolean canBeDefault;
922
Thales Lima83bedbf2021-10-05 17:47:39 +0100923 private final PointF[] minCellSize = new PointF[COUNT_SIZES];
Thales Lima78d00ad2021-09-30 11:29:06 +0100924
Thales Lima78d00ad2021-09-30 11:29:06 +0100925 private final PointF[] borderSpaces = new PointF[COUNT_SIZES];
Thales Lima83bedbf2021-10-05 17:47:39 +0100926 private final float[] horizontalMargin = new float[COUNT_SIZES];
Thales Limab8c05952022-05-23 16:58:38 +0100927 private final float[] hotseatBarBottomSpace = new float[COUNT_SIZES];
928 private final float[] hotseatQsbSpace = new float[COUNT_SIZES];
Thales Limad90faab2021-09-21 17:18:47 +0100929
Thales Lima78d00ad2021-09-30 11:29:06 +0100930 private final float[] iconSizes = new float[COUNT_SIZES];
931 private final float[] textSizes = new float[COUNT_SIZES];
Sunny Goyal415f1732018-11-29 10:33:47 -0800932
Thales Limab7ef5692022-03-10 10:32:36 +0000933 private final PointF[] allAppsCellSize = new PointF[COUNT_SIZES];
Thales Limabb7d3882021-12-22 12:56:29 +0000934 private final float[] allAppsIconSizes = new float[COUNT_SIZES];
935 private final float[] allAppsIconTextSizes = new float[COUNT_SIZES];
936 private final PointF[] allAppsBorderSpaces = new PointF[COUNT_SIZES];
937
Jon Miranda9c478b62023-03-23 21:38:49 -0700938 private final float[] transientTaskbarIconSize = new float[COUNT_SIZES];
939
Jon Miranda04f05102023-04-04 12:16:31 -0700940 private final boolean[] startAlignTaskbar = new boolean[COUNT_SIZES];
941
Thales Lima1de4d552021-10-13 16:13:25 +0100942 DisplayOption(GridOption grid, Context context, AttributeSet attrs) {
Sunny Goyal415f1732018-11-29 10:33:47 -0800943 this.grid = grid;
944
Jon Miranda9c478b62023-03-23 21:38:49 -0700945 Resources res = context.getResources();
946
Thales Lima1de4d552021-10-13 16:13:25 +0100947 TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProfileDisplayOption);
Sunny Goyal415f1732018-11-29 10:33:47 -0800948
Sunny Goyal415f1732018-11-29 10:33:47 -0800949 minWidthDps = a.getFloat(R.styleable.ProfileDisplayOption_minWidthDps, 0);
950 minHeightDps = a.getFloat(R.styleable.ProfileDisplayOption_minHeightDps, 0);
Sunny Goyal19ff7282021-04-22 10:12:54 -0700951
Thales Lima1de4d552021-10-13 16:13:25 +0100952 canBeDefault = a.getBoolean(R.styleable.ProfileDisplayOption_canBeDefault, false);
Sunny Goyal415f1732018-11-29 10:33:47 -0800953
Thales Lima83bedbf2021-10-05 17:47:39 +0100954 float x;
955 float y;
956
Thales Lima85c942f2021-12-31 13:04:20 +0000957 x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidth, 0);
958 y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeight, 0);
Thales Lima83bedbf2021-10-05 17:47:39 +0100959 minCellSize[INDEX_DEFAULT] = new PointF(x, y);
Thales Limadd027342022-01-07 12:54:37 +0000960
961 x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidthLandscape,
962 minCellSize[INDEX_DEFAULT].x);
963 y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeightLandscape,
964 minCellSize[INDEX_DEFAULT].y);
Thales Lima83bedbf2021-10-05 17:47:39 +0100965 minCellSize[INDEX_LANDSCAPE] = new PointF(x, y);
Thales Lima83bedbf2021-10-05 17:47:39 +0100966
Thales Lima85c942f2021-12-31 13:04:20 +0000967 x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidthTwoPanelPortrait,
Thales Lima83bedbf2021-10-05 17:47:39 +0100968 minCellSize[INDEX_DEFAULT].x);
Thales Lima85c942f2021-12-31 13:04:20 +0000969 y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeightTwoPanelPortrait,
Thales Lima83bedbf2021-10-05 17:47:39 +0100970 minCellSize[INDEX_DEFAULT].y);
971 minCellSize[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y);
972
Thales Lima85c942f2021-12-31 13:04:20 +0000973 x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidthTwoPanelLandscape,
Thales Lima83bedbf2021-10-05 17:47:39 +0100974 minCellSize[INDEX_DEFAULT].x);
Thales Lima85c942f2021-12-31 13:04:20 +0000975 y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeightTwoPanelLandscape,
Thales Lima83bedbf2021-10-05 17:47:39 +0100976 minCellSize[INDEX_DEFAULT].y);
977 minCellSize[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y);
Thales Lima78d00ad2021-09-30 11:29:06 +0100978
Thales Lima85c942f2021-12-31 13:04:20 +0000979 float borderSpace = a.getFloat(R.styleable.ProfileDisplayOption_borderSpace, 0);
Thales Lima44cc3a22022-03-18 14:28:24 +0000980 float borderSpaceLandscape = a.getFloat(
981 R.styleable.ProfileDisplayOption_borderSpaceLandscape, borderSpace);
Thales Lima85c942f2021-12-31 13:04:20 +0000982 float borderSpaceTwoPanelPortrait = a.getFloat(
983 R.styleable.ProfileDisplayOption_borderSpaceTwoPanelPortrait, borderSpace);
984 float borderSpaceTwoPanelLandscape = a.getFloat(
985 R.styleable.ProfileDisplayOption_borderSpaceTwoPanelLandscape, borderSpace);
Thales Lima78d00ad2021-09-30 11:29:06 +0100986
Thales Lima85c942f2021-12-31 13:04:20 +0000987 x = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceHorizontal, borderSpace);
988 y = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceVertical, borderSpace);
Thales Lima78d00ad2021-09-30 11:29:06 +0100989 borderSpaces[INDEX_DEFAULT] = new PointF(x, y);
Thales Lima44cc3a22022-03-18 14:28:24 +0000990
991 x = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceLandscapeHorizontal,
992 borderSpaceLandscape);
993 y = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceLandscapeVertical,
994 borderSpaceLandscape);
Thales Lima78d00ad2021-09-30 11:29:06 +0100995 borderSpaces[INDEX_LANDSCAPE] = new PointF(x, y);
996
997 x = a.getFloat(
Thales Lima85c942f2021-12-31 13:04:20 +0000998 R.styleable.ProfileDisplayOption_borderSpaceTwoPanelPortraitHorizontal,
999 borderSpaceTwoPanelPortrait);
Thales Lima78d00ad2021-09-30 11:29:06 +01001000 y = a.getFloat(
Thales Lima85c942f2021-12-31 13:04:20 +00001001 R.styleable.ProfileDisplayOption_borderSpaceTwoPanelPortraitVertical,
1002 borderSpaceTwoPanelPortrait);
Thales Lima78d00ad2021-09-30 11:29:06 +01001003 borderSpaces[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y);
1004
1005 x = a.getFloat(
Thales Lima85c942f2021-12-31 13:04:20 +00001006 R.styleable.ProfileDisplayOption_borderSpaceTwoPanelLandscapeHorizontal,
1007 borderSpaceTwoPanelLandscape);
Thales Lima78d00ad2021-09-30 11:29:06 +01001008 y = a.getFloat(
Thales Lima85c942f2021-12-31 13:04:20 +00001009 R.styleable.ProfileDisplayOption_borderSpaceTwoPanelLandscapeVertical,
1010 borderSpaceTwoPanelLandscape);
Thales Lima78d00ad2021-09-30 11:29:06 +01001011 borderSpaces[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y);
1012
Thales Limab7ef5692022-03-10 10:32:36 +00001013 x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellWidth,
1014 minCellSize[INDEX_DEFAULT].x);
1015 y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellHeight,
1016 minCellSize[INDEX_DEFAULT].y);
1017 allAppsCellSize[INDEX_DEFAULT] = new PointF(x, y);
1018
1019 x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellWidthLandscape,
1020 allAppsCellSize[INDEX_DEFAULT].x);
1021 y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellHeightLandscape,
1022 allAppsCellSize[INDEX_DEFAULT].y);
1023 allAppsCellSize[INDEX_LANDSCAPE] = new PointF(x, y);
1024
1025 x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellWidthTwoPanelPortrait,
1026 allAppsCellSize[INDEX_DEFAULT].x);
1027 y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellHeightTwoPanelPortrait,
1028 allAppsCellSize[INDEX_DEFAULT].y);
1029 allAppsCellSize[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y);
1030
1031 x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellWidthTwoPanelLandscape,
1032 allAppsCellSize[INDEX_DEFAULT].x);
1033 y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellHeightTwoPanelLandscape,
1034 allAppsCellSize[INDEX_DEFAULT].y);
1035 allAppsCellSize[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y);
1036
Thales Lima080d8902022-03-28 15:30:29 +01001037 float allAppsBorderSpace = a.getFloat(
1038 R.styleable.ProfileDisplayOption_allAppsBorderSpace, borderSpace);
1039 float allAppsBorderSpaceLandscape = a.getFloat(
1040 R.styleable.ProfileDisplayOption_allAppsBorderSpaceLandscape,
1041 allAppsBorderSpace);
1042 float allAppsBorderSpaceTwoPanelPortrait = a.getFloat(
Thales Limabb7d3882021-12-22 12:56:29 +00001043 R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortrait,
Thales Lima080d8902022-03-28 15:30:29 +01001044 allAppsBorderSpace);
1045 float allAppsBorderSpaceTwoPanelLandscape = a.getFloat(
Thales Limabb7d3882021-12-22 12:56:29 +00001046 R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelLandscape,
Thales Lima080d8902022-03-28 15:30:29 +01001047 allAppsBorderSpace);
1048
1049 x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceHorizontal,
1050 allAppsBorderSpace);
1051 y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceVertical,
1052 allAppsBorderSpace);
1053 allAppsBorderSpaces[INDEX_DEFAULT] = new PointF(x, y);
1054
1055 x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceLandscapeHorizontal,
1056 allAppsBorderSpaceLandscape);
1057 y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceLandscapeVertical,
1058 allAppsBorderSpaceLandscape);
1059 allAppsBorderSpaces[INDEX_LANDSCAPE] = new PointF(x, y);
1060
1061 x = a.getFloat(
1062 R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortraitHorizontal,
1063 allAppsBorderSpaceTwoPanelPortrait);
1064 y = a.getFloat(
1065 R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortraitVertical,
1066 allAppsBorderSpaceTwoPanelPortrait);
1067 allAppsBorderSpaces[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y);
1068
1069 x = a.getFloat(
1070 R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelLandscapeHorizontal,
1071 allAppsBorderSpaceTwoPanelLandscape);
1072 y = a.getFloat(
1073 R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelLandscapeVertical,
1074 allAppsBorderSpaceTwoPanelLandscape);
Thales Limabb7d3882021-12-22 12:56:29 +00001075 allAppsBorderSpaces[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y);
Jon Mirandae126d722021-02-25 10:45:20 -05001076
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001077 iconSizes[INDEX_DEFAULT] =
1078 a.getFloat(R.styleable.ProfileDisplayOption_iconImageSize, 0);
1079 iconSizes[INDEX_LANDSCAPE] =
Thales Lima85c942f2021-12-31 13:04:20 +00001080 a.getFloat(R.styleable.ProfileDisplayOption_iconSizeLandscape,
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001081 iconSizes[INDEX_DEFAULT]);
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001082 iconSizes[INDEX_TWO_PANEL_PORTRAIT] =
Thales Lima85c942f2021-12-31 13:04:20 +00001083 a.getFloat(R.styleable.ProfileDisplayOption_iconSizeTwoPanelPortrait,
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001084 iconSizes[INDEX_DEFAULT]);
1085 iconSizes[INDEX_TWO_PANEL_LANDSCAPE] =
Thales Lima85c942f2021-12-31 13:04:20 +00001086 a.getFloat(R.styleable.ProfileDisplayOption_iconSizeTwoPanelLandscape,
Thales Lima83bedbf2021-10-05 17:47:39 +01001087 iconSizes[INDEX_DEFAULT]);
Jon Miranda6f7e9702019-09-16 14:44:14 -07001088
Thales Limabb7d3882021-12-22 12:56:29 +00001089 allAppsIconSizes[INDEX_DEFAULT] = a.getFloat(
1090 R.styleable.ProfileDisplayOption_allAppsIconSize, iconSizes[INDEX_DEFAULT]);
Thales Lima1fb075d2022-08-10 10:47:50 +01001091 allAppsIconSizes[INDEX_LANDSCAPE] = a.getFloat(
1092 R.styleable.ProfileDisplayOption_allAppsIconSizeLandscape,
Thales Limaed8c69b2022-08-17 12:21:21 -04001093 allAppsIconSizes[INDEX_DEFAULT]);
Thales Limabb7d3882021-12-22 12:56:29 +00001094 allAppsIconSizes[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat(
1095 R.styleable.ProfileDisplayOption_allAppsIconSizeTwoPanelPortrait,
1096 allAppsIconSizes[INDEX_DEFAULT]);
1097 allAppsIconSizes[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
1098 R.styleable.ProfileDisplayOption_allAppsIconSizeTwoPanelLandscape,
1099 allAppsIconSizes[INDEX_DEFAULT]);
1100
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001101 textSizes[INDEX_DEFAULT] =
1102 a.getFloat(R.styleable.ProfileDisplayOption_iconTextSize, 0);
1103 textSizes[INDEX_LANDSCAPE] =
Thales Lima85c942f2021-12-31 13:04:20 +00001104 a.getFloat(R.styleable.ProfileDisplayOption_iconTextSizeLandscape,
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001105 textSizes[INDEX_DEFAULT]);
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001106 textSizes[INDEX_TWO_PANEL_PORTRAIT] =
Thales Lima85c942f2021-12-31 13:04:20 +00001107 a.getFloat(R.styleable.ProfileDisplayOption_iconTextSizeTwoPanelPortrait,
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001108 textSizes[INDEX_DEFAULT]);
1109 textSizes[INDEX_TWO_PANEL_LANDSCAPE] =
Thales Lima85c942f2021-12-31 13:04:20 +00001110 a.getFloat(R.styleable.ProfileDisplayOption_iconTextSizeTwoPanelLandscape,
Thales Lima83bedbf2021-10-05 17:47:39 +01001111 textSizes[INDEX_DEFAULT]);
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001112
Thales Limabb7d3882021-12-22 12:56:29 +00001113 allAppsIconTextSizes[INDEX_DEFAULT] = a.getFloat(
1114 R.styleable.ProfileDisplayOption_allAppsIconTextSize, textSizes[INDEX_DEFAULT]);
1115 allAppsIconTextSizes[INDEX_LANDSCAPE] = allAppsIconTextSizes[INDEX_DEFAULT];
1116 allAppsIconTextSizes[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat(
1117 R.styleable.ProfileDisplayOption_allAppsIconTextSizeTwoPanelPortrait,
1118 allAppsIconTextSizes[INDEX_DEFAULT]);
1119 allAppsIconTextSizes[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
1120 R.styleable.ProfileDisplayOption_allAppsIconTextSizeTwoPanelLandscape,
1121 allAppsIconTextSizes[INDEX_DEFAULT]);
1122
Thales Lima83bedbf2021-10-05 17:47:39 +01001123 horizontalMargin[INDEX_DEFAULT] = a.getFloat(
1124 R.styleable.ProfileDisplayOption_horizontalMargin, 0);
Thales Limadd027342022-01-07 12:54:37 +00001125 horizontalMargin[INDEX_LANDSCAPE] = a.getFloat(
1126 R.styleable.ProfileDisplayOption_horizontalMarginLandscape,
1127 horizontalMargin[INDEX_DEFAULT]);
Thales Lima83bedbf2021-10-05 17:47:39 +01001128 horizontalMargin[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
Thales Lima85c942f2021-12-31 13:04:20 +00001129 R.styleable.ProfileDisplayOption_horizontalMarginTwoPanelLandscape,
Thales Lima83bedbf2021-10-05 17:47:39 +01001130 horizontalMargin[INDEX_DEFAULT]);
1131 horizontalMargin[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat(
Thales Lima85c942f2021-12-31 13:04:20 +00001132 R.styleable.ProfileDisplayOption_horizontalMarginTwoPanelPortrait,
Thales Lima83bedbf2021-10-05 17:47:39 +01001133 horizontalMargin[INDEX_DEFAULT]);
Thales Limad90faab2021-09-21 17:18:47 +01001134
Thales Limab8c05952022-05-23 16:58:38 +01001135 hotseatBarBottomSpace[INDEX_DEFAULT] = a.getFloat(
1136 R.styleable.ProfileDisplayOption_hotseatBarBottomSpace,
Jon Miranda9c478b62023-03-23 21:38:49 -07001137 ResourcesCompat.getFloat(res, R.dimen.hotseat_bar_bottom_space_default));
Thales Limab8c05952022-05-23 16:58:38 +01001138 hotseatBarBottomSpace[INDEX_LANDSCAPE] = a.getFloat(
1139 R.styleable.ProfileDisplayOption_hotseatBarBottomSpaceLandscape,
1140 hotseatBarBottomSpace[INDEX_DEFAULT]);
1141 hotseatBarBottomSpace[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
1142 R.styleable.ProfileDisplayOption_hotseatBarBottomSpaceTwoPanelLandscape,
1143 hotseatBarBottomSpace[INDEX_DEFAULT]);
1144 hotseatBarBottomSpace[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat(
1145 R.styleable.ProfileDisplayOption_hotseatBarBottomSpaceTwoPanelPortrait,
1146 hotseatBarBottomSpace[INDEX_DEFAULT]);
1147
1148 hotseatQsbSpace[INDEX_DEFAULT] = a.getFloat(
1149 R.styleable.ProfileDisplayOption_hotseatQsbSpace,
Jon Miranda9c478b62023-03-23 21:38:49 -07001150 ResourcesCompat.getFloat(res, R.dimen.hotseat_qsb_space_default));
Thales Limab8c05952022-05-23 16:58:38 +01001151 hotseatQsbSpace[INDEX_LANDSCAPE] = a.getFloat(
1152 R.styleable.ProfileDisplayOption_hotseatQsbSpaceLandscape,
1153 hotseatQsbSpace[INDEX_DEFAULT]);
1154 hotseatQsbSpace[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
1155 R.styleable.ProfileDisplayOption_hotseatQsbSpaceTwoPanelLandscape,
1156 hotseatQsbSpace[INDEX_DEFAULT]);
1157 hotseatQsbSpace[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat(
1158 R.styleable.ProfileDisplayOption_hotseatQsbSpaceTwoPanelPortrait,
1159 hotseatQsbSpace[INDEX_DEFAULT]);
1160
Jon Miranda9c478b62023-03-23 21:38:49 -07001161 transientTaskbarIconSize[INDEX_DEFAULT] = a.getFloat(
1162 R.styleable.ProfileDisplayOption_transientTaskbarIconSize,
1163 ResourcesCompat.getFloat(res, R.dimen.taskbar_icon_size));
1164 transientTaskbarIconSize[INDEX_LANDSCAPE] = a.getFloat(
1165 R.styleable.ProfileDisplayOption_transientTaskbarIconSizeLandscape,
1166 transientTaskbarIconSize[INDEX_DEFAULT]);
1167 transientTaskbarIconSize[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
1168 R.styleable.ProfileDisplayOption_transientTaskbarIconSizeTwoPanelLandscape,
1169 transientTaskbarIconSize[INDEX_DEFAULT]);
1170 transientTaskbarIconSize[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat(
1171 R.styleable.ProfileDisplayOption_transientTaskbarIconSizeTwoPanelPortrait,
Jon Miranda4d74ad32023-03-27 16:31:11 -07001172 transientTaskbarIconSize[INDEX_DEFAULT]);
Jon Miranda9c478b62023-03-23 21:38:49 -07001173
Jon Miranda04f05102023-04-04 12:16:31 -07001174 startAlignTaskbar[INDEX_DEFAULT] = a.getBoolean(
1175 R.styleable.ProfileDisplayOption_startAlignTaskbar, false);
1176 startAlignTaskbar[INDEX_LANDSCAPE] = a.getBoolean(
1177 R.styleable.ProfileDisplayOption_startAlignTaskbarLandscape,
1178 startAlignTaskbar[INDEX_DEFAULT]);
1179 startAlignTaskbar[INDEX_TWO_PANEL_LANDSCAPE] = a.getBoolean(
1180 R.styleable.ProfileDisplayOption_startAlignTaskbarTwoPanelLandscape,
1181 startAlignTaskbar[INDEX_LANDSCAPE]);
1182 startAlignTaskbar[INDEX_TWO_PANEL_PORTRAIT] = a.getBoolean(
1183 R.styleable.ProfileDisplayOption_startAlignTaskbarTwoPanelPortrait,
1184 startAlignTaskbar[INDEX_DEFAULT]);
1185
Sunny Goyal415f1732018-11-29 10:33:47 -08001186 a.recycle();
1187 }
1188
1189 DisplayOption() {
Sunny Goyal0e7a3382020-04-13 17:15:05 -07001190 this(null);
1191 }
1192
1193 DisplayOption(GridOption grid) {
1194 this.grid = grid;
Sunny Goyal415f1732018-11-29 10:33:47 -08001195 minWidthDps = 0;
1196 minHeightDps = 0;
1197 canBeDefault = false;
Thales Lima78d00ad2021-09-30 11:29:06 +01001198 for (int i = 0; i < COUNT_SIZES; i++) {
1199 iconSizes[i] = 0;
1200 textSizes[i] = 0;
1201 borderSpaces[i] = new PointF();
Thales Lima83bedbf2021-10-05 17:47:39 +01001202 minCellSize[i] = new PointF();
Thales Limab7ef5692022-03-10 10:32:36 +00001203 allAppsCellSize[i] = new PointF();
Thales Limabb7d3882021-12-22 12:56:29 +00001204 allAppsIconSizes[i] = 0;
1205 allAppsIconTextSizes[i] = 0;
1206 allAppsBorderSpaces[i] = new PointF();
Jon Miranda9c478b62023-03-23 21:38:49 -07001207 transientTaskbarIconSize[i] = 0;
Jon Miranda04f05102023-04-04 12:16:31 -07001208 startAlignTaskbar[i] = false;
Thales Lima78d00ad2021-09-30 11:29:06 +01001209 }
Sunny Goyal415f1732018-11-29 10:33:47 -08001210 }
1211
1212 private DisplayOption multiply(float w) {
Thales Lima78d00ad2021-09-30 11:29:06 +01001213 for (int i = 0; i < COUNT_SIZES; i++) {
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001214 iconSizes[i] *= w;
1215 textSizes[i] *= w;
Thales Lima83bedbf2021-10-05 17:47:39 +01001216 borderSpaces[i].x *= w;
1217 borderSpaces[i].y *= w;
1218 minCellSize[i].x *= w;
1219 minCellSize[i].y *= w;
1220 horizontalMargin[i] *= w;
Thales Limab8c05952022-05-23 16:58:38 +01001221 hotseatBarBottomSpace[i] *= w;
1222 hotseatQsbSpace[i] *= w;
Thales Limab7ef5692022-03-10 10:32:36 +00001223 allAppsCellSize[i].x *= w;
1224 allAppsCellSize[i].y *= w;
Thales Limabb7d3882021-12-22 12:56:29 +00001225 allAppsIconSizes[i] *= w;
1226 allAppsIconTextSizes[i] *= w;
1227 allAppsBorderSpaces[i].x *= w;
1228 allAppsBorderSpaces[i].y *= w;
Jon Miranda9c478b62023-03-23 21:38:49 -07001229 transientTaskbarIconSize[i] *= w;
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001230 }
Thales Lima78d00ad2021-09-30 11:29:06 +01001231
Sunny Goyal415f1732018-11-29 10:33:47 -08001232 return this;
1233 }
1234
1235 private DisplayOption add(DisplayOption p) {
Thales Lima78d00ad2021-09-30 11:29:06 +01001236 for (int i = 0; i < COUNT_SIZES; i++) {
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001237 iconSizes[i] += p.iconSizes[i];
1238 textSizes[i] += p.textSizes[i];
Thales Lima83bedbf2021-10-05 17:47:39 +01001239 borderSpaces[i].x += p.borderSpaces[i].x;
1240 borderSpaces[i].y += p.borderSpaces[i].y;
1241 minCellSize[i].x += p.minCellSize[i].x;
1242 minCellSize[i].y += p.minCellSize[i].y;
1243 horizontalMargin[i] += p.horizontalMargin[i];
Thales Limab8c05952022-05-23 16:58:38 +01001244 hotseatBarBottomSpace[i] += p.hotseatBarBottomSpace[i];
1245 hotseatQsbSpace[i] += p.hotseatQsbSpace[i];
Thales Limab7ef5692022-03-10 10:32:36 +00001246 allAppsCellSize[i].x += p.allAppsCellSize[i].x;
1247 allAppsCellSize[i].y += p.allAppsCellSize[i].y;
Thales Limabb7d3882021-12-22 12:56:29 +00001248 allAppsIconSizes[i] += p.allAppsIconSizes[i];
1249 allAppsIconTextSizes[i] += p.allAppsIconTextSizes[i];
1250 allAppsBorderSpaces[i].x += p.allAppsBorderSpaces[i].x;
1251 allAppsBorderSpaces[i].y += p.allAppsBorderSpaces[i].y;
Jon Miranda9c478b62023-03-23 21:38:49 -07001252 transientTaskbarIconSize[i] += p.transientTaskbarIconSize[i];
Jon Miranda04f05102023-04-04 12:16:31 -07001253 startAlignTaskbar[i] |= p.startAlignTaskbar[i];
Sunny Goyal6e6f7992021-08-24 16:23:29 -07001254 }
Thales Lima78d00ad2021-09-30 11:29:06 +01001255
Sunny Goyal415f1732018-11-29 10:33:47 -08001256 return this;
1257 }
1258 }
Sunny Goyalae190ff2020-04-14 00:19:01 +00001259}