Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 1 | /* |
Thales Lima | 1de4d55 | 2021-10-13 16:13:25 +0100 | [diff] [blame] | 2 | * Copyright (C) 2021 The Android Open Source Project |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.launcher3; |
| 18 | |
Stefan Andonian | 4c9612b | 2023-02-22 00:00:03 +0000 | [diff] [blame] | 19 | import static com.android.launcher3.LauncherPrefs.GRID_NAME; |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 20 | import static com.android.launcher3.Utilities.dpiFromPx; |
Thales Lima | b35faed | 2022-09-05 16:30:01 -0300 | [diff] [blame] | 21 | import static com.android.launcher3.testing.shared.ResourceUtils.INVALID_RESOURCE_HANDLE; |
Sunny Goyal | 35c7b19 | 2021-04-20 16:51:10 -0700 | [diff] [blame] | 22 | import static com.android.launcher3.util.DisplayController.CHANGE_DENSITY; |
Jagrut Desai | 2e8ca87 | 2024-04-17 15:27:30 -0700 | [diff] [blame] | 23 | import static com.android.launcher3.util.DisplayController.CHANGE_DESKTOP_MODE; |
Alex Chau | 6ed408f | 2022-03-04 12:58:05 +0000 | [diff] [blame] | 24 | import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE; |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 25 | import static com.android.launcher3.util.DisplayController.CHANGE_SUPPORTED_BOUNDS; |
Jagrut Desai | 3a7d139 | 2023-09-06 15:56:19 -0700 | [diff] [blame] | 26 | import static com.android.launcher3.util.DisplayController.CHANGE_TASKBAR_PINNING; |
Sunny Goyal | 9c2b960 | 2020-01-07 13:07:55 -0800 | [diff] [blame] | 27 | import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 28 | |
Sunny Goyal | c620560 | 2015-05-21 20:46:33 -0700 | [diff] [blame] | 29 | import android.annotation.TargetApi; |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 30 | import android.content.Context; |
Hyunyoung Song | c55a350 | 2018-12-04 15:43:16 -0800 | [diff] [blame] | 31 | import android.content.res.Resources; |
Sunny Goyal | 819e193 | 2016-07-07 16:43:58 -0700 | [diff] [blame] | 32 | import android.content.res.TypedArray; |
| 33 | import android.content.res.XmlResourceParser; |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 34 | import android.graphics.Point; |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 35 | import android.graphics.PointF; |
Alex Chau | c09a98a | 2023-11-14 12:51:42 +0000 | [diff] [blame] | 36 | import android.graphics.Rect; |
Brandon Dayauon | 51db65e | 2024-10-23 15:07:37 -0700 | [diff] [blame^] | 37 | import android.os.Trace; |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 38 | import android.text.TextUtils; |
| 39 | import android.util.AttributeSet; |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 40 | import android.util.DisplayMetrics; |
Thales Lima | 7ec8382 | 2021-08-05 13:32:10 +0100 | [diff] [blame] | 41 | import android.util.Log; |
Sunny Goyal | 5bc1846 | 2019-01-07 15:13:39 -0800 | [diff] [blame] | 42 | import android.util.SparseArray; |
Sunny Goyal | 819e193 | 2016-07-07 16:43:58 -0700 | [diff] [blame] | 43 | import android.util.Xml; |
Sunny Goyal | 9c2b960 | 2020-01-07 13:07:55 -0800 | [diff] [blame] | 44 | import android.view.Display; |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 45 | |
Thales Lima | b35faed | 2022-09-05 16:30:01 -0300 | [diff] [blame] | 46 | import androidx.annotation.DimenRes; |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 47 | import androidx.annotation.IntDef; |
Thales Lima | b35faed | 2022-09-05 16:30:01 -0300 | [diff] [blame] | 48 | import androidx.annotation.StyleRes; |
Sunny Goyal | 6fe3eec | 2019-08-15 14:53:41 -0700 | [diff] [blame] | 49 | import androidx.annotation.VisibleForTesting; |
Thales Lima | ae0d7ef | 2022-11-16 15:53:43 +0000 | [diff] [blame] | 50 | import androidx.annotation.XmlRes; |
Thales Lima | b8c0595 | 2022-05-23 16:58:38 +0100 | [diff] [blame] | 51 | import androidx.core.content.res.ResourcesCompat; |
Sunny Goyal | 6fe3eec | 2019-08-15 14:53:41 -0700 | [diff] [blame] | 52 | |
Thales Lima | ec5abba | 2023-04-05 16:33:50 +0100 | [diff] [blame] | 53 | import com.android.launcher3.config.FeatureFlags; |
Sunny Goyal | 65190ae | 2022-08-02 14:16:26 -0700 | [diff] [blame] | 54 | import com.android.launcher3.icons.DotRenderer; |
Charlie Anderson | c9d11e8 | 2023-08-02 11:41:55 -0400 | [diff] [blame] | 55 | import com.android.launcher3.logging.FileLog; |
Sunny Goyal | 68031ca | 2021-08-02 12:23:44 -0700 | [diff] [blame] | 56 | import com.android.launcher3.model.DeviceGridState; |
Alex Chau | 238aaee | 2021-10-06 16:15:24 +0100 | [diff] [blame] | 57 | import com.android.launcher3.provider.RestoreDbTask; |
vadimt | f6ef879 | 2022-07-26 13:54:31 -0700 | [diff] [blame] | 58 | import com.android.launcher3.testing.shared.ResourceUtils; |
Sunny Goyal | fd58da6 | 2020-08-11 12:06:49 -0700 | [diff] [blame] | 59 | import com.android.launcher3.util.DisplayController; |
| 60 | import com.android.launcher3.util.DisplayController.Info; |
Stefan Andonian | 5bd9a22 | 2023-02-23 00:58:33 +0000 | [diff] [blame] | 61 | import com.android.launcher3.util.LockedUserState; |
Sunny Goyal | d0e360a | 2018-06-29 14:40:18 -0700 | [diff] [blame] | 62 | import com.android.launcher3.util.MainThreadInitializedObject; |
Sunny Goyal | 3e58eea | 2022-11-14 14:30:07 -0800 | [diff] [blame] | 63 | import com.android.launcher3.util.Partner; |
Sunny Goyal | 10fa016 | 2024-04-21 00:13:35 -0700 | [diff] [blame] | 64 | import com.android.launcher3.util.SafeCloseable; |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 65 | import com.android.launcher3.util.WindowBounds; |
Sunny Goyal | 187b16c | 2022-03-01 16:53:23 -0800 | [diff] [blame] | 66 | import com.android.launcher3.util.window.WindowManagerProxy; |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 67 | |
Sunny Goyal | 819e193 | 2016-07-07 16:43:58 -0700 | [diff] [blame] | 68 | import org.xmlpull.v1.XmlPullParser; |
| 69 | import org.xmlpull.v1.XmlPullParserException; |
| 70 | |
| 71 | import java.io.IOException; |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 72 | import java.lang.annotation.Retention; |
| 73 | import java.lang.annotation.RetentionPolicy; |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 74 | import java.util.ArrayList; |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 75 | import java.util.Arrays; |
Sunny Goyal | 6d55f66 | 2019-01-02 12:13:43 -0800 | [diff] [blame] | 76 | import java.util.Collections; |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 77 | import java.util.List; |
Sebastián Franco | ad46eb7 | 2024-03-11 20:56:57 +0000 | [diff] [blame] | 78 | import java.util.Objects; |
Sunny Goyal | 076e04b | 2023-04-03 12:38:30 -0700 | [diff] [blame] | 79 | import java.util.stream.Collectors; |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 80 | |
Sunny Goyal | 10fa016 | 2024-04-21 00:13:35 -0700 | [diff] [blame] | 81 | public class InvariantDeviceProfile implements SafeCloseable { |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 82 | |
Hyunyoung Song | c55a350 | 2018-12-04 15:43:16 -0800 | [diff] [blame] | 83 | public static final String TAG = "IDP"; |
Sunny Goyal | d0e360a | 2018-06-29 14:40:18 -0700 | [diff] [blame] | 84 | // We do not need any synchronization for this variable as its only written on UI thread. |
| 85 | public static final MainThreadInitializedObject<InvariantDeviceProfile> INSTANCE = |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 86 | new MainThreadInitializedObject<>(InvariantDeviceProfile::new); |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 87 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 88 | @Retention(RetentionPolicy.SOURCE) |
| 89 | @IntDef({TYPE_PHONE, TYPE_MULTI_DISPLAY, TYPE_TABLET}) |
Thales Lima | b8c0595 | 2022-05-23 16:58:38 +0100 | [diff] [blame] | 90 | public @interface DeviceType {} |
| 91 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 92 | public static final int TYPE_PHONE = 0; |
| 93 | public static final int TYPE_MULTI_DISPLAY = 1; |
| 94 | public static final int TYPE_TABLET = 2; |
| 95 | |
Sunny Goyal | 53d7ee4 | 2015-05-22 12:25:45 -0700 | [diff] [blame] | 96 | private static final float ICON_SIZE_DEFINED_IN_APP_DP = 48; |
| 97 | |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 98 | // Constants that affects the interpolation curve between statically defined device profile |
| 99 | // buckets. |
Hyunyoung Song | c55a350 | 2018-12-04 15:43:16 -0800 | [diff] [blame] | 100 | private static final float KNEARESTNEIGHBOR = 3; |
| 101 | private static final float WEIGHT_POWER = 5; |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 102 | |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 103 | // used to offset float not being able to express extremely small weights in extreme cases. |
Hyunyoung Song | c55a350 | 2018-12-04 15:43:16 -0800 | [diff] [blame] | 104 | private static final float WEIGHT_EFFICIENT = 100000f; |
| 105 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 106 | // Used for arrays to specify different sizes (e.g. border spaces, width/height) in different |
| 107 | // constraints |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 108 | static final int COUNT_SIZES = 4; |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 109 | static final int INDEX_DEFAULT = 0; |
| 110 | static final int INDEX_LANDSCAPE = 1; |
| 111 | static final int INDEX_TWO_PANEL_PORTRAIT = 2; |
| 112 | static final int INDEX_TWO_PANEL_LANDSCAPE = 3; |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 113 | |
Thales Lima | ec5abba | 2023-04-05 16:33:50 +0100 | [diff] [blame] | 114 | /** These resources are used to override the device profile */ |
Sunny Goyal | 3e58eea | 2022-11-14 14:30:07 -0800 | [diff] [blame] | 115 | private static final String RES_GRID_NUM_ROWS = "grid_num_rows"; |
| 116 | private static final String RES_GRID_NUM_COLUMNS = "grid_num_columns"; |
| 117 | private static final String RES_GRID_ICON_SIZE_DP = "grid_icon_size_dp"; |
| 118 | |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 119 | /** |
| 120 | * Number of icons per row and column in the workspace. |
| 121 | */ |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 122 | public int numRows; |
| 123 | public int numColumns; |
Alex Chau | 9fee3fd | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 124 | public int numSearchContainerColumns; |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 125 | |
| 126 | /** |
| 127 | * Number of icons per row and column in the folder. |
| 128 | */ |
Thales Lima | 1faa4ed | 2023-12-01 16:48:19 +0000 | [diff] [blame] | 129 | public int[] numFolderRows; |
| 130 | public int[] numFolderColumns; |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 131 | public float[] iconSize; |
| 132 | public float[] iconTextSize; |
Sunny Goyal | fc21830 | 2015-09-17 14:59:10 -0700 | [diff] [blame] | 133 | public int iconBitmapSize; |
| 134 | public int fillResIconDpi; |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 135 | public @DeviceType int deviceType; |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 136 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 137 | public PointF[] minCellSize; |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 138 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 139 | public PointF[] borderSpaces; |
Thales Lima | b35faed | 2022-09-05 16:30:01 -0300 | [diff] [blame] | 140 | public @DimenRes int inlineNavButtonsEndSpacing; |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 141 | |
Thales Lima | b35faed | 2022-09-05 16:30:01 -0300 | [diff] [blame] | 142 | public @StyleRes int folderStyle; |
Thales Lima | a08a443 | 2022-08-09 09:55:17 +0100 | [diff] [blame] | 143 | |
Thales Lima | d852d65 | 2023-01-17 14:01:13 +0000 | [diff] [blame] | 144 | public @StyleRes int cellStyle; |
| 145 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 146 | public float[] horizontalMargin; |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 147 | |
Thales Lima | b7ef569 | 2022-03-10 10:32:36 +0000 | [diff] [blame] | 148 | public PointF[] allAppsCellSize; |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 149 | public float[] allAppsIconSize; |
| 150 | public float[] allAppsIconTextSize; |
| 151 | public PointF[] allAppsBorderSpaces; |
| 152 | |
Jon Miranda | 9c478b6 | 2023-03-23 21:38:49 -0700 | [diff] [blame] | 153 | public float[] transientTaskbarIconSize; |
| 154 | |
Jon Miranda | 04f0510 | 2023-04-04 12:16:31 -0700 | [diff] [blame] | 155 | public boolean[] startAlignTaskbar; |
| 156 | |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 157 | /** |
| 158 | * Number of icons inside the hotseat area. |
| 159 | */ |
Jon Miranda | fd48b0c | 2022-01-31 16:25:22 -0800 | [diff] [blame] | 160 | public int numShownHotseatIcons; |
Tony Wickham | b87f3cd | 2021-04-07 15:02:37 -0700 | [diff] [blame] | 161 | |
| 162 | /** |
| 163 | * Number of icons inside the hotseat area that is stored in the database. This is greater than |
| 164 | * or equal to numnShownHotseatIcons, allowing for a seamless transition between two hotseat |
| 165 | * sizes that share the same DB. |
| 166 | */ |
| 167 | public int numDatabaseHotseatIcons; |
Adam Cohen | 2782449 | 2017-09-22 17:10:55 -0700 | [diff] [blame] | 168 | |
Thales Lima | b8c0595 | 2022-05-23 16:58:38 +0100 | [diff] [blame] | 169 | public float[] hotseatBarBottomSpace; |
| 170 | public float[] hotseatQsbSpace; |
Thales Lima | 425f682 | 2022-05-10 13:44:58 -0300 | [diff] [blame] | 171 | |
Jon Miranda | 6f7e970 | 2019-09-16 14:44:14 -0700 | [diff] [blame] | 172 | /** |
| 173 | * Number of columns in the all apps list. |
| 174 | */ |
| 175 | public int numAllAppsColumns; |
Jordan Silva | 2de6a27 | 2024-01-04 14:44:20 -0300 | [diff] [blame] | 176 | public int numAllAppsRowsForCellHeightCalculation; |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 177 | public int numDatabaseAllAppsColumns; |
Thales Lima | e9273ea | 2023-01-26 12:33:52 +0000 | [diff] [blame] | 178 | public @StyleRes int allAppsStyle; |
Jon Miranda | 6f7e970 | 2019-09-16 14:44:14 -0700 | [diff] [blame] | 179 | |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 180 | /** |
| 181 | * Do not query directly. see {@link DeviceProfile#isScalableGrid}. |
| 182 | */ |
| 183 | protected boolean isScalable; |
Thales Lima | ae0d7ef | 2022-11-16 15:53:43 +0000 | [diff] [blame] | 184 | @XmlRes |
| 185 | public int devicePaddingId = INVALID_RESOURCE_HANDLE; |
Thales Lima | ec5abba | 2023-04-05 16:33:50 +0100 | [diff] [blame] | 186 | @XmlRes |
| 187 | public int workspaceSpecsId = INVALID_RESOURCE_HANDLE; |
Thales Lima | abfe364 | 2023-05-24 18:08:53 +0100 | [diff] [blame] | 188 | @XmlRes |
Jordan Silva | 575c3bd | 2023-07-21 12:00:43 +0100 | [diff] [blame] | 189 | public int workspaceSpecsTwoPanelId = INVALID_RESOURCE_HANDLE; |
| 190 | @XmlRes |
Thales Lima | abfe364 | 2023-05-24 18:08:53 +0100 | [diff] [blame] | 191 | public int allAppsSpecsId = INVALID_RESOURCE_HANDLE; |
Jordan Silva | 637f4eb | 2023-06-13 11:21:53 +0100 | [diff] [blame] | 192 | @XmlRes |
Jordan Silva | 575c3bd | 2023-07-21 12:00:43 +0100 | [diff] [blame] | 193 | public int allAppsSpecsTwoPanelId = INVALID_RESOURCE_HANDLE; |
| 194 | @XmlRes |
Jordan Silva | 637f4eb | 2023-06-13 11:21:53 +0100 | [diff] [blame] | 195 | public int folderSpecsId = INVALID_RESOURCE_HANDLE; |
Jordan Silva | 575c3bd | 2023-07-21 12:00:43 +0100 | [diff] [blame] | 196 | @XmlRes |
| 197 | public int folderSpecsTwoPanelId = INVALID_RESOURCE_HANDLE; |
Jordan Silva | 999dd2a | 2023-11-17 19:31:43 +0000 | [diff] [blame] | 198 | @XmlRes |
Thales Lima | f8bfb03 | 2023-07-24 15:08:05 +0100 | [diff] [blame] | 199 | public int hotseatSpecsId = INVALID_RESOURCE_HANDLE; |
Jordan Silva | 999dd2a | 2023-11-17 19:31:43 +0000 | [diff] [blame] | 200 | @XmlRes |
Thales Lima | f8bfb03 | 2023-07-24 15:08:05 +0100 | [diff] [blame] | 201 | public int hotseatSpecsTwoPanelId = INVALID_RESOURCE_HANDLE; |
Jordan Silva | 999dd2a | 2023-11-17 19:31:43 +0000 | [diff] [blame] | 202 | @XmlRes |
| 203 | public int workspaceCellSpecsId = INVALID_RESOURCE_HANDLE; |
| 204 | @XmlRes |
| 205 | public int workspaceCellSpecsTwoPanelId = INVALID_RESOURCE_HANDLE; |
| 206 | @XmlRes |
| 207 | public int allAppsCellSpecsId = INVALID_RESOURCE_HANDLE; |
| 208 | @XmlRes |
| 209 | public int allAppsCellSpecsTwoPanelId = INVALID_RESOURCE_HANDLE; |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 210 | |
Tracy Zhou | 7df93d2 | 2020-01-27 13:44:06 -0800 | [diff] [blame] | 211 | public String dbFile; |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 212 | public int defaultLayoutId; |
Sunny Goyal | 1ae46ca | 2023-04-10 15:28:59 -0700 | [diff] [blame] | 213 | public int demoModeLayoutId; |
Thales Lima | 9938c2f | 2022-07-25 14:38:16 +0100 | [diff] [blame] | 214 | public boolean[] inlineQsb = new boolean[COUNT_SIZES]; |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 215 | |
Pinyao Ting | 9cd63c9 | 2021-06-16 17:51:39 +0000 | [diff] [blame] | 216 | /** |
| 217 | * An immutable list of supported profiles. |
| 218 | */ |
| 219 | public List<DeviceProfile> supportedProfiles = Collections.EMPTY_LIST; |
Sunny Goyal | c620560 | 2015-05-21 20:46:33 -0700 | [diff] [blame] | 220 | |
Sunny Goyal | 6f86609 | 2016-03-17 17:04:15 -0700 | [diff] [blame] | 221 | public Point defaultWallpaperSize; |
| 222 | |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 223 | private final ArrayList<OnIDPChangeListener> mChangeListeners = new ArrayList<>(); |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 224 | |
Sunny Goyal | f633ef5 | 2018-03-13 09:57:05 -0700 | [diff] [blame] | 225 | @VisibleForTesting |
Sunny Goyal | 187b16c | 2022-03-01 16:53:23 -0800 | [diff] [blame] | 226 | public InvariantDeviceProfile() { } |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 227 | |
Sunny Goyal | bbf0184 | 2015-10-08 07:41:15 -0700 | [diff] [blame] | 228 | @TargetApi(23) |
Sunny Goyal | d0e360a | 2018-06-29 14:40:18 -0700 | [diff] [blame] | 229 | private InvariantDeviceProfile(Context context) { |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 230 | String gridName = getCurrentGridName(context); |
| 231 | String newGridName = initGrid(context, gridName); |
| 232 | if (!newGridName.equals(gridName)) { |
Stefan Andonian | 4c9612b | 2023-02-22 00:00:03 +0000 | [diff] [blame] | 233 | LauncherPrefs.get(context).put(GRID_NAME, newGridName); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 234 | } |
Sunny Goyal | 10fa016 | 2024-04-21 00:13:35 -0700 | [diff] [blame] | 235 | LockedUserState.get(context).runOnUserUnlocked(() -> |
| 236 | new DeviceGridState(this).writeToPrefs(context)); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 237 | |
Tracy Zhou | c8beebf | 2021-09-23 10:18:11 -0700 | [diff] [blame] | 238 | DisplayController.INSTANCE.get(context).setPriorityListener( |
Alex Chau | fd6d942 | 2021-04-22 19:10:21 +0100 | [diff] [blame] | 239 | (displayContext, info, flags) -> { |
Alex Chau | 6ed408f | 2022-03-04 12:58:05 +0000 | [diff] [blame] | 240 | if ((flags & (CHANGE_DENSITY | CHANGE_SUPPORTED_BOUNDS |
Jagrut Desai | 2e8ca87 | 2024-04-17 15:27:30 -0700 | [diff] [blame] | 241 | | CHANGE_NAVIGATION_MODE | CHANGE_TASKBAR_PINNING |
| 242 | | CHANGE_DESKTOP_MODE)) != 0) { |
Alex Chau | fd6d942 | 2021-04-22 19:10:21 +0100 | [diff] [blame] | 243 | onConfigChanged(displayContext); |
Sunny Goyal | 35c7b19 | 2021-04-20 16:51:10 -0700 | [diff] [blame] | 244 | } |
| 245 | }); |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 246 | } |
| 247 | |
Hyunyoung Song | e11eb47 | 2019-03-19 15:05:21 -0700 | [diff] [blame] | 248 | /** |
| 249 | * This constructor should NOT have any monitors by design. |
| 250 | */ |
Sunny Goyal | eff44f3 | 2019-01-09 17:29:49 -0800 | [diff] [blame] | 251 | public InvariantDeviceProfile(Context context, String gridName) { |
| 252 | String newName = initGrid(context, gridName); |
| 253 | if (newName == null || !newName.equals(gridName)) { |
Andy Wickham | 99d7d4f | 2023-11-15 08:09:09 +0000 | [diff] [blame] | 254 | throw new IllegalArgumentException("Unknown grid name: " + gridName); |
Sunny Goyal | eff44f3 | 2019-01-09 17:29:49 -0800 | [diff] [blame] | 255 | } |
| 256 | } |
| 257 | |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 258 | /** |
Sunny Goyal | 9c2b960 | 2020-01-07 13:07:55 -0800 | [diff] [blame] | 259 | * This constructor should NOT have any monitors by design. |
| 260 | */ |
| 261 | public InvariantDeviceProfile(Context context, Display display) { |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 262 | // Ensure that the main device profile is initialized |
Alex Chau | fd6d942 | 2021-04-22 19:10:21 +0100 | [diff] [blame] | 263 | INSTANCE.get(context); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 264 | String gridName = getCurrentGridName(context); |
| 265 | |
| 266 | // Get the display info based on default display and interpolate it to existing display |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 267 | Info defaultInfo = DisplayController.INSTANCE.get(context).getInfo(); |
Sunny Goyal | 25c4276 | 2024-04-16 19:31:31 -0700 | [diff] [blame] | 268 | @DeviceType int defaultDeviceType = defaultInfo.getDeviceType(); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 269 | DisplayOption defaultDisplayOption = invDistWeightedInterpolate( |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 270 | defaultInfo, |
| 271 | getPredefinedDeviceProfiles(context, gridName, defaultDeviceType, |
| 272 | /*allowDisabledGrid=*/false), |
| 273 | defaultDeviceType); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 274 | |
Alex Chau | 661f02d | 2022-06-07 14:03:43 +0100 | [diff] [blame] | 275 | Context displayContext = context.createDisplayContext(display); |
| 276 | Info myInfo = new Info(displayContext); |
Sunny Goyal | 25c4276 | 2024-04-16 19:31:31 -0700 | [diff] [blame] | 277 | @DeviceType int deviceType = myInfo.getDeviceType(); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 278 | DisplayOption myDisplayOption = invDistWeightedInterpolate( |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 279 | myInfo, |
| 280 | getPredefinedDeviceProfiles(context, gridName, deviceType, |
| 281 | /*allowDisabledGrid=*/false), |
| 282 | deviceType); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 283 | |
| 284 | DisplayOption result = new DisplayOption(defaultDisplayOption.grid) |
| 285 | .add(myDisplayOption); |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 286 | result.iconSizes[INDEX_DEFAULT] = |
| 287 | defaultDisplayOption.iconSizes[INDEX_DEFAULT]; |
| 288 | for (int i = 1; i < COUNT_SIZES; i++) { |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 289 | result.iconSizes[i] = Math.min( |
| 290 | defaultDisplayOption.iconSizes[i], myDisplayOption.iconSizes[i]); |
Alex Chau | 7c43972 | 2021-03-24 11:32:44 +0000 | [diff] [blame] | 291 | } |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 292 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 293 | System.arraycopy(defaultDisplayOption.minCellSize, 0, result.minCellSize, 0, |
| 294 | COUNT_SIZES); |
| 295 | System.arraycopy(defaultDisplayOption.borderSpaces, 0, result.borderSpaces, 0, |
| 296 | COUNT_SIZES); |
Jon Miranda | 228877d | 2021-02-09 11:05:00 -0500 | [diff] [blame] | 297 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 298 | initGrid(context, myInfo, result, deviceType); |
Sunny Goyal | 9c2b960 | 2020-01-07 13:07:55 -0800 | [diff] [blame] | 299 | } |
| 300 | |
Sunny Goyal | 10fa016 | 2024-04-21 00:13:35 -0700 | [diff] [blame] | 301 | @Override |
| 302 | public void close() { |
| 303 | DisplayController.INSTANCE.executeIfCreated(dc -> dc.setPriorityListener(null)); |
| 304 | } |
| 305 | |
Alex Chau | 238aaee | 2021-10-06 16:15:24 +0100 | [diff] [blame] | 306 | /** |
| 307 | * Reinitialize the current grid after a restore, where some grids might now be disabled. |
| 308 | */ |
| 309 | public void reinitializeAfterRestore(Context context) { |
Alex Chau | 29a96ad | 2022-02-10 13:12:20 +0000 | [diff] [blame] | 310 | String currentGridName = getCurrentGridName(context); |
Alex Chau | 238aaee | 2021-10-06 16:15:24 +0100 | [diff] [blame] | 311 | String currentDbFile = dbFile; |
Alex Chau | 29a96ad | 2022-02-10 13:12:20 +0000 | [diff] [blame] | 312 | String newGridName = initGrid(context, currentGridName); |
| 313 | String newDbFile = dbFile; |
Charlie Anderson | c61288e | 2023-09-21 11:53:50 -0400 | [diff] [blame] | 314 | FileLog.d(TAG, "Reinitializing grid after restore." |
| 315 | + " currentGridName=" + currentGridName |
| 316 | + ", currentDbFile=" + currentDbFile |
| 317 | + ", newGridName=" + newGridName |
| 318 | + ", newDbFile=" + newDbFile); |
Alex Chau | 29a96ad | 2022-02-10 13:12:20 +0000 | [diff] [blame] | 319 | if (!newDbFile.equals(currentDbFile)) { |
Charlie Anderson | c9d11e8 | 2023-08-02 11:41:55 -0400 | [diff] [blame] | 320 | FileLog.d(TAG, "Restored grid is disabled : " + currentGridName |
Alex Chau | 238aaee | 2021-10-06 16:15:24 +0100 | [diff] [blame] | 321 | + ", migrating to: " + newGridName |
| 322 | + ", removing all other grid db files"); |
| 323 | for (String gridDbFile : LauncherFiles.GRID_DB_FILES) { |
| 324 | if (gridDbFile.equals(currentDbFile)) { |
| 325 | continue; |
| 326 | } |
| 327 | if (context.getDatabasePath(gridDbFile).delete()) { |
Charlie Anderson | c9d11e8 | 2023-08-02 11:41:55 -0400 | [diff] [blame] | 328 | FileLog.d(TAG, "Removed old grid db file: " + gridDbFile); |
Alex Chau | 238aaee | 2021-10-06 16:15:24 +0100 | [diff] [blame] | 329 | } |
| 330 | } |
Alex Chau | 29a96ad | 2022-02-10 13:12:20 +0000 | [diff] [blame] | 331 | setCurrentGrid(context, newGridName); |
Alex Chau | 238aaee | 2021-10-06 16:15:24 +0100 | [diff] [blame] | 332 | } |
| 333 | } |
| 334 | |
Tracy Zhou | 42255d2 | 2020-03-13 00:38:11 -0700 | [diff] [blame] | 335 | public static String getCurrentGridName(Context context) { |
Stefan Andonian | 4c9612b | 2023-02-22 00:00:03 +0000 | [diff] [blame] | 336 | return LauncherPrefs.get(context).get(GRID_NAME); |
Tracy Zhou | 42255d2 | 2020-03-13 00:38:11 -0700 | [diff] [blame] | 337 | } |
| 338 | |
Sunny Goyal | eff44f3 | 2019-01-09 17:29:49 -0800 | [diff] [blame] | 339 | private String initGrid(Context context, String gridName) { |
Sunny Goyal | 35c7b19 | 2021-04-20 16:51:10 -0700 | [diff] [blame] | 340 | Info displayInfo = DisplayController.INSTANCE.get(context).getInfo(); |
Sunny Goyal | 25c4276 | 2024-04-16 19:31:31 -0700 | [diff] [blame] | 341 | @DeviceType int deviceType = displayInfo.getDeviceType(); |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 342 | |
| 343 | ArrayList<DisplayOption> allOptions = |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 344 | getPredefinedDeviceProfiles(context, gridName, deviceType, |
Alex Chau | 238aaee | 2021-10-06 16:15:24 +0100 | [diff] [blame] | 345 | RestoreDbTask.isPending(context)); |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 346 | DisplayOption displayOption = |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 347 | invDistWeightedInterpolate(displayInfo, allOptions, deviceType); |
| 348 | initGrid(context, displayInfo, displayOption, deviceType); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 349 | return displayOption.grid.name; |
Sunny Goyal | 9c2b960 | 2020-01-07 13:07:55 -0800 | [diff] [blame] | 350 | } |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 351 | |
Sebastian Franco | df7d2b0 | 2024-04-04 15:12:18 -0700 | [diff] [blame] | 352 | /** |
| 353 | * @deprecated This is a temporary solution because on the backup and restore case we modify the |
| 354 | * IDP, this resets it. b/332974074 |
| 355 | */ |
| 356 | @Deprecated |
| 357 | public void reset(Context context) { |
fbaron | b633b9a | 2024-09-23 18:35:29 -0700 | [diff] [blame] | 358 | initGrid(context, getDefaultGridName(context)); |
Sebastian Franco | df7d2b0 | 2024-04-04 15:12:18 -0700 | [diff] [blame] | 359 | } |
| 360 | |
Thales Lima | b67bfa7 | 2022-11-02 15:30:11 +0000 | [diff] [blame] | 361 | @VisibleForTesting |
| 362 | public static String getDefaultGridName(Context context) { |
| 363 | return new InvariantDeviceProfile().initGrid(context, null); |
| 364 | } |
| 365 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 366 | private void initGrid(Context context, Info displayInfo, DisplayOption displayOption, |
| 367 | @DeviceType int deviceType) { |
Sunny Goyal | 35c7b19 | 2021-04-20 16:51:10 -0700 | [diff] [blame] | 368 | DisplayMetrics metrics = context.getResources().getDisplayMetrics(); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 369 | GridOption closestProfile = displayOption.grid; |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 370 | numRows = closestProfile.numRows; |
| 371 | numColumns = closestProfile.numColumns; |
Alex Chau | 9fee3fd | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 372 | numSearchContainerColumns = closestProfile.numSearchContainerColumns; |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 373 | dbFile = closestProfile.dbFile; |
| 374 | defaultLayoutId = closestProfile.defaultLayoutId; |
| 375 | demoModeLayoutId = closestProfile.demoModeLayoutId; |
Thales Lima | b35faed | 2022-09-05 16:30:01 -0300 | [diff] [blame] | 376 | |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 377 | numFolderRows = closestProfile.numFolderRows; |
| 378 | numFolderColumns = closestProfile.numFolderColumns; |
Thales Lima | b35faed | 2022-09-05 16:30:01 -0300 | [diff] [blame] | 379 | folderStyle = closestProfile.folderStyle; |
| 380 | |
Thales Lima | d852d65 | 2023-01-17 14:01:13 +0000 | [diff] [blame] | 381 | cellStyle = closestProfile.cellStyle; |
| 382 | |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 383 | isScalable = closestProfile.isScalable; |
Jon Miranda | c9e69fa | 2021-03-22 17:13:34 -0400 | [diff] [blame] | 384 | devicePaddingId = closestProfile.devicePaddingId; |
Thales Lima | ec5abba | 2023-04-05 16:33:50 +0100 | [diff] [blame] | 385 | workspaceSpecsId = closestProfile.mWorkspaceSpecsId; |
Jordan Silva | 575c3bd | 2023-07-21 12:00:43 +0100 | [diff] [blame] | 386 | workspaceSpecsTwoPanelId = closestProfile.mWorkspaceSpecsTwoPanelId; |
Thales Lima | abfe364 | 2023-05-24 18:08:53 +0100 | [diff] [blame] | 387 | allAppsSpecsId = closestProfile.mAllAppsSpecsId; |
Jordan Silva | 575c3bd | 2023-07-21 12:00:43 +0100 | [diff] [blame] | 388 | allAppsSpecsTwoPanelId = closestProfile.mAllAppsSpecsTwoPanelId; |
Jordan Silva | 637f4eb | 2023-06-13 11:21:53 +0100 | [diff] [blame] | 389 | folderSpecsId = closestProfile.mFolderSpecsId; |
Jordan Silva | 575c3bd | 2023-07-21 12:00:43 +0100 | [diff] [blame] | 390 | folderSpecsTwoPanelId = closestProfile.mFolderSpecsTwoPanelId; |
Thales Lima | f8bfb03 | 2023-07-24 15:08:05 +0100 | [diff] [blame] | 391 | hotseatSpecsId = closestProfile.mHotseatSpecsId; |
| 392 | hotseatSpecsTwoPanelId = closestProfile.mHotseatSpecsTwoPanelId; |
Jordan Silva | 999dd2a | 2023-11-17 19:31:43 +0000 | [diff] [blame] | 393 | workspaceCellSpecsId = closestProfile.mWorkspaceCellSpecsId; |
| 394 | workspaceCellSpecsTwoPanelId = closestProfile.mWorkspaceCellSpecsTwoPanelId; |
| 395 | allAppsCellSpecsId = closestProfile.mAllAppsCellSpecsId; |
| 396 | allAppsCellSpecsTwoPanelId = closestProfile.mAllAppsCellSpecsTwoPanelId; |
Jordan Silva | 2de6a27 | 2024-01-04 14:44:20 -0300 | [diff] [blame] | 397 | numAllAppsRowsForCellHeightCalculation = |
| 398 | closestProfile.mNumAllAppsRowsForCellHeightCalculation; |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 399 | this.deviceType = deviceType; |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 400 | |
Vinit Nayak | c729317 | 2022-07-18 16:41:50 -0700 | [diff] [blame] | 401 | inlineNavButtonsEndSpacing = closestProfile.inlineNavButtonsEndSpacing; |
| 402 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 403 | iconSize = displayOption.iconSizes; |
Thales Lima | 6e0005a | 2021-10-27 15:53:41 +0100 | [diff] [blame] | 404 | float maxIconSize = iconSize[0]; |
| 405 | for (int i = 1; i < iconSize.length; i++) { |
| 406 | maxIconSize = Math.max(maxIconSize, iconSize[i]); |
| 407 | } |
| 408 | iconBitmapSize = ResourceUtils.pxFromDp(maxIconSize, metrics); |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 409 | fillResIconDpi = getLauncherIconDensity(iconBitmapSize); |
| 410 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 411 | iconTextSize = displayOption.textSizes; |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 412 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 413 | minCellSize = displayOption.minCellSize; |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 414 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 415 | borderSpaces = displayOption.borderSpaces; |
Thales Lima | a08a443 | 2022-08-09 09:55:17 +0100 | [diff] [blame] | 416 | |
Thales Lima | d90faab | 2021-09-21 17:18:47 +0100 | [diff] [blame] | 417 | horizontalMargin = displayOption.horizontalMargin; |
Thales Lima | d90faab | 2021-09-21 17:18:47 +0100 | [diff] [blame] | 418 | |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 419 | numShownHotseatIcons = closestProfile.numHotseatIcons; |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 420 | numDatabaseHotseatIcons = deviceType == TYPE_MULTI_DISPLAY |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 421 | ? closestProfile.numDatabaseHotseatIcons : closestProfile.numHotseatIcons; |
Thales Lima | b8c0595 | 2022-05-23 16:58:38 +0100 | [diff] [blame] | 422 | hotseatBarBottomSpace = displayOption.hotseatBarBottomSpace; |
| 423 | hotseatQsbSpace = displayOption.hotseatQsbSpace; |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 424 | |
Thales Lima | e9273ea | 2023-01-26 12:33:52 +0000 | [diff] [blame] | 425 | allAppsStyle = closestProfile.allAppsStyle; |
| 426 | |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 427 | numAllAppsColumns = closestProfile.numAllAppsColumns; |
Jordan Silva | 2de6a27 | 2024-01-04 14:44:20 -0300 | [diff] [blame] | 428 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 429 | numDatabaseAllAppsColumns = deviceType == TYPE_MULTI_DISPLAY |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 430 | ? closestProfile.numDatabaseAllAppsColumns : closestProfile.numAllAppsColumns; |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 431 | |
Thales Lima | b7ef569 | 2022-03-10 10:32:36 +0000 | [diff] [blame] | 432 | allAppsCellSize = displayOption.allAppsCellSize; |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 433 | allAppsBorderSpaces = displayOption.allAppsBorderSpaces; |
| 434 | allAppsIconSize = displayOption.allAppsIconSizes; |
| 435 | allAppsIconTextSize = displayOption.allAppsIconTextSizes; |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 436 | |
Thales Lima | 11af7bc | 2022-08-12 15:24:54 +0100 | [diff] [blame] | 437 | inlineQsb = closestProfile.inlineQsb; |
Thales Lima | 12d0eff | 2022-03-25 17:06:11 +0000 | [diff] [blame] | 438 | |
Jon Miranda | 9c478b6 | 2023-03-23 21:38:49 -0700 | [diff] [blame] | 439 | transientTaskbarIconSize = displayOption.transientTaskbarIconSize; |
| 440 | |
Jon Miranda | 04f0510 | 2023-04-04 12:16:31 -0700 | [diff] [blame] | 441 | startAlignTaskbar = displayOption.startAlignTaskbar; |
| 442 | |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 443 | // If the partner customization apk contains any grid overrides, apply them |
| 444 | // Supported overrides: numRows, numColumns, iconSize |
Sunny Goyal | 35c7b19 | 2021-04-20 16:51:10 -0700 | [diff] [blame] | 445 | applyPartnerDeviceProfileOverrides(context, metrics); |
Sunny Goyal | c620560 | 2015-05-21 20:46:33 -0700 | [diff] [blame] | 446 | |
Pinyao Ting | 9cd63c9 | 2021-06-16 17:51:39 +0000 | [diff] [blame] | 447 | final List<DeviceProfile> localSupportedProfiles = new ArrayList<>(); |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 448 | defaultWallpaperSize = new Point(displayInfo.currentSize); |
Sunny Goyal | 65190ae | 2022-08-02 14:16:26 -0700 | [diff] [blame] | 449 | SparseArray<DotRenderer> dotRendererCache = new SparseArray<>(); |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 450 | for (WindowBounds bounds : displayInfo.supportedBounds) { |
Pinyao Ting | 9cd63c9 | 2021-06-16 17:51:39 +0000 | [diff] [blame] | 451 | localSupportedProfiles.add(new DeviceProfile.Builder(context, this, displayInfo) |
Alex Chau | ab800f7 | 2022-12-13 17:46:06 +0000 | [diff] [blame] | 452 | .setIsMultiDisplay(deviceType == TYPE_MULTI_DISPLAY) |
Alex Chau | 6ed408f | 2022-03-04 12:58:05 +0000 | [diff] [blame] | 453 | .setWindowBounds(bounds) |
Sunny Goyal | 65190ae | 2022-08-02 14:16:26 -0700 | [diff] [blame] | 454 | .setDotRendererCache(dotRendererCache) |
Alex Chau | 6ed408f | 2022-03-04 12:58:05 +0000 | [diff] [blame] | 455 | .build()); |
Sunny Goyal | c620560 | 2015-05-21 20:46:33 -0700 | [diff] [blame] | 456 | |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 457 | // Wallpaper size should be the maximum of the all possible sizes Launcher expects |
| 458 | int displayWidth = bounds.bounds.width(); |
| 459 | int displayHeight = bounds.bounds.height(); |
| 460 | defaultWallpaperSize.y = Math.max(defaultWallpaperSize.y, displayHeight); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 461 | |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 462 | // We need to ensure that there is enough extra space in the wallpaper |
| 463 | // for the intended parallax effects |
| 464 | float parallaxFactor = |
Thales Lima | 425f682 | 2022-05-10 13:44:58 -0300 | [diff] [blame] | 465 | dpiFromPx(Math.min(displayWidth, displayHeight), displayInfo.getDensityDpi()) |
| 466 | < 720 |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 467 | ? 2 |
| 468 | : wallpaperTravelToScreenWidthRatio(displayWidth, displayHeight); |
| 469 | defaultWallpaperSize.x = |
| 470 | Math.max(defaultWallpaperSize.x, Math.round(parallaxFactor * displayWidth)); |
Sunny Goyal | 6f86609 | 2016-03-17 17:04:15 -0700 | [diff] [blame] | 471 | } |
Pinyao Ting | 9cd63c9 | 2021-06-16 17:51:39 +0000 | [diff] [blame] | 472 | supportedProfiles = Collections.unmodifiableList(localSupportedProfiles); |
Sunny Goyal | 58fa4b6 | 2019-03-22 16:23:25 -0700 | [diff] [blame] | 473 | |
Thales Lima | 6a59006 | 2022-11-22 15:52:49 +0000 | [diff] [blame] | 474 | int numMinShownHotseatIconsForTablet = supportedProfiles |
| 475 | .stream() |
| 476 | .filter(deviceProfile -> deviceProfile.isTablet) |
| 477 | .mapToInt(deviceProfile -> deviceProfile.numShownHotseatIcons) |
| 478 | .min() |
| 479 | .orElse(0); |
| 480 | |
| 481 | supportedProfiles |
| 482 | .stream() |
| 483 | .filter(deviceProfile -> deviceProfile.isTablet) |
| 484 | .forEach(deviceProfile -> { |
| 485 | deviceProfile.numShownHotseatIcons = numMinShownHotseatIconsForTablet; |
| 486 | deviceProfile.recalculateHotseatWidthAndBorderSpace(); |
| 487 | }); |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 488 | } |
| 489 | |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 490 | public void addOnChangeListener(OnIDPChangeListener listener) { |
| 491 | mChangeListeners.add(listener); |
| 492 | } |
| 493 | |
Hyunyoung Song | b4d1ca4 | 2019-01-08 17:15:16 -0800 | [diff] [blame] | 494 | public void removeOnChangeListener(OnIDPChangeListener listener) { |
| 495 | mChangeListeners.remove(listener); |
| 496 | } |
| 497 | |
Hyunyoung Song | c55a350 | 2018-12-04 15:43:16 -0800 | [diff] [blame] | 498 | |
Sunny Goyal | 7d892ff | 2019-01-11 15:08:44 -0800 | [diff] [blame] | 499 | public void setCurrentGrid(Context context, String gridName) { |
Stefan Andonian | 4c9612b | 2023-02-22 00:00:03 +0000 | [diff] [blame] | 500 | LauncherPrefs.get(context).put(GRID_NAME, gridName); |
Brandon Dayauon | 51db65e | 2024-10-23 15:07:37 -0700 | [diff] [blame^] | 501 | MAIN_EXECUTOR.execute(() -> { |
| 502 | Trace.beginSection("InvariantDeviceProfile#setCurrentGrid"); |
| 503 | onConfigChanged(context.getApplicationContext()); |
| 504 | Trace.endSection(); |
| 505 | }); |
Sunny Goyal | 7d892ff | 2019-01-11 15:08:44 -0800 | [diff] [blame] | 506 | } |
| 507 | |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 508 | private Object[] toModelState() { |
sfufa@google.com | de01329 | 2021-09-21 18:22:44 -0700 | [diff] [blame] | 509 | return new Object[]{ |
Alex Chau | 9fee3fd | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 510 | numColumns, numRows, numSearchContainerColumns, numDatabaseHotseatIcons, |
| 511 | iconBitmapSize, fillResIconDpi, numDatabaseAllAppsColumns, dbFile}; |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 512 | } |
| 513 | |
Pat Manning | 24cec69 | 2023-10-13 10:36:57 +0000 | [diff] [blame] | 514 | /** Updates IDP using the provided context. Notifies listeners of change. */ |
| 515 | @VisibleForTesting |
| 516 | public void onConfigChanged(Context context) { |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 517 | Object[] oldState = toModelState(); |
| 518 | |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 519 | // Re-init grid |
Tracy Zhou | c6060e6 | 2020-04-27 13:05:34 -0700 | [diff] [blame] | 520 | String gridName = getCurrentGridName(context); |
Jon Miranda | 6f7e970 | 2019-09-16 14:44:14 -0700 | [diff] [blame] | 521 | initGrid(context, gridName); |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 522 | |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 523 | boolean modelPropsChanged = !Arrays.equals(oldState, toModelState()); |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 524 | for (OnIDPChangeListener listener : mChangeListeners) { |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 525 | listener.onIdpChanged(modelPropsChanged); |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 526 | } |
| 527 | } |
| 528 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 529 | private static ArrayList<DisplayOption> getPredefinedDeviceProfiles(Context context, |
| 530 | String gridName, @DeviceType int deviceType, boolean allowDisabledGrid) { |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 531 | ArrayList<DisplayOption> profiles = new ArrayList<>(); |
Thales Lima | 1de4d55 | 2021-10-13 16:13:25 +0100 | [diff] [blame] | 532 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 533 | try (XmlResourceParser parser = context.getResources().getXml(R.xml.device_profiles)) { |
Sunny Goyal | 819e193 | 2016-07-07 16:43:58 -0700 | [diff] [blame] | 534 | final int depth = parser.getDepth(); |
| 535 | int type; |
Sunny Goyal | 819e193 | 2016-07-07 16:43:58 -0700 | [diff] [blame] | 536 | while (((type = parser.next()) != XmlPullParser.END_TAG || |
| 537 | parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) { |
Sunny Goyal | 7d892ff | 2019-01-11 15:08:44 -0800 | [diff] [blame] | 538 | if ((type == XmlPullParser.START_TAG) |
| 539 | && GridOption.TAG_NAME.equals(parser.getName())) { |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 540 | |
Sunny Goyal | 076e04b | 2023-04-03 12:38:30 -0700 | [diff] [blame] | 541 | GridOption gridOption = new GridOption(context, Xml.asAttributeSet(parser)); |
| 542 | if (gridOption.isEnabled(deviceType) || allowDisabledGrid) { |
Thales Lima | 7ec8382 | 2021-08-05 13:32:10 +0100 | [diff] [blame] | 543 | final int displayDepth = parser.getDepth(); |
| 544 | while (((type = parser.next()) != XmlPullParser.END_TAG |
| 545 | || parser.getDepth() > displayDepth) |
| 546 | && type != XmlPullParser.END_DOCUMENT) { |
| 547 | if ((type == XmlPullParser.START_TAG) && "display-option".equals( |
| 548 | parser.getName())) { |
| 549 | profiles.add(new DisplayOption(gridOption, context, |
Thales Lima | 1de4d55 | 2021-10-13 16:13:25 +0100 | [diff] [blame] | 550 | Xml.asAttributeSet(parser))); |
Thales Lima | 7ec8382 | 2021-08-05 13:32:10 +0100 | [diff] [blame] | 551 | } |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 552 | } |
| 553 | } |
Sunny Goyal | 819e193 | 2016-07-07 16:43:58 -0700 | [diff] [blame] | 554 | } |
| 555 | } |
sfufa@google.com | de01329 | 2021-09-21 18:22:44 -0700 | [diff] [blame] | 556 | } catch (IOException | XmlPullParserException e) { |
Sunny Goyal | 819e193 | 2016-07-07 16:43:58 -0700 | [diff] [blame] | 557 | throw new RuntimeException(e); |
| 558 | } |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 559 | |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 560 | ArrayList<DisplayOption> filteredProfiles = new ArrayList<>(); |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 561 | if (!TextUtils.isEmpty(gridName)) { |
| 562 | for (DisplayOption option : profiles) { |
Alex Chau | 238aaee | 2021-10-06 16:15:24 +0100 | [diff] [blame] | 563 | if (gridName.equals(option.grid.name) |
Sunny Goyal | 076e04b | 2023-04-03 12:38:30 -0700 | [diff] [blame] | 564 | && (option.grid.isEnabled(deviceType) || allowDisabledGrid)) { |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 565 | filteredProfiles.add(option); |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 566 | } |
| 567 | } |
| 568 | } |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 569 | if (filteredProfiles.isEmpty()) { |
| 570 | // No grid found, use the default options |
| 571 | for (DisplayOption option : profiles) { |
| 572 | if (option.canBeDefault) { |
| 573 | filteredProfiles.add(option); |
| 574 | } |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 575 | } |
| 576 | } |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 577 | if (filteredProfiles.isEmpty()) { |
| 578 | throw new RuntimeException("No display option with canBeDefault=true"); |
| 579 | } |
| 580 | return filteredProfiles; |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 581 | } |
| 582 | |
Thales Lima | 7ec8382 | 2021-08-05 13:32:10 +0100 | [diff] [blame] | 583 | /** |
Sebastián Franco | ad46eb7 | 2024-03-11 20:56:57 +0000 | [diff] [blame] | 584 | * Returns the GridOption associated to the given file name or null if the fileName is not |
| 585 | * supported. |
| 586 | * Ej, launcher.db -> "normal grid", launcher_4_by_4.db -> "practical grid" |
| 587 | */ |
| 588 | public GridOption getGridOptionFromFileName(Context context, String fileName) { |
| 589 | return parseAllGridOptions(context).stream() |
| 590 | .filter(gridOption -> Objects.equals(gridOption.dbFile, fileName)) |
| 591 | .findFirst() |
| 592 | .orElse(null); |
| 593 | } |
| 594 | |
| 595 | /** |
| 596 | * Returns the name of the given size on the current device or empty string if the size is not |
| 597 | * supported. Ej. 4x4 -> normal, 5x4 -> practical, etc. |
| 598 | * (Note: the name of the grid can be different for the same grid size depending of |
| 599 | * the values of the InvariantDeviceProfile) |
| 600 | * |
| 601 | */ |
| 602 | public String getGridNameFromSize(Context context, Point size) { |
| 603 | return parseAllGridOptions(context).stream() |
| 604 | .filter(gridOption -> gridOption.numColumns == size.x |
| 605 | && gridOption.numRows == size.y) |
| 606 | .map(gridOption -> gridOption.name) |
| 607 | .findFirst() |
| 608 | .orElse(""); |
| 609 | } |
| 610 | |
| 611 | /** |
| 612 | * Returns the grid option for the given gridName on the current device (Note: the gridOption |
| 613 | * be different for the same gridName depending on the values of the InvariantDeviceProfile). |
| 614 | */ |
| 615 | public GridOption getGridOptionFromName(Context context, String gridName) { |
| 616 | return parseAllGridOptions(context).stream() |
| 617 | .filter(gridOption -> Objects.equals(gridOption.name, gridName)) |
| 618 | .findFirst() |
| 619 | .orElse(null); |
| 620 | } |
| 621 | |
| 622 | /** |
Thales Lima | 7ec8382 | 2021-08-05 13:32:10 +0100 | [diff] [blame] | 623 | * @return all the grid options that can be shown on the device |
| 624 | */ |
| 625 | public List<GridOption> parseAllGridOptions(Context context) { |
Sunny Goyal | 076e04b | 2023-04-03 12:38:30 -0700 | [diff] [blame] | 626 | return parseAllDefinedGridOptions(context) |
| 627 | .stream() |
| 628 | .filter(go -> go.isEnabled(deviceType)) |
| 629 | .collect(Collectors.toList()); |
| 630 | } |
| 631 | |
| 632 | /** |
| 633 | * @return all the grid options that can be shown on the device |
| 634 | */ |
| 635 | public static List<GridOption> parseAllDefinedGridOptions(Context context) { |
Thales Lima | 7ec8382 | 2021-08-05 13:32:10 +0100 | [diff] [blame] | 636 | List<GridOption> result = new ArrayList<>(); |
Thales Lima | 1de4d55 | 2021-10-13 16:13:25 +0100 | [diff] [blame] | 637 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 638 | try (XmlResourceParser parser = context.getResources().getXml(R.xml.device_profiles)) { |
Thales Lima | 7ec8382 | 2021-08-05 13:32:10 +0100 | [diff] [blame] | 639 | final int depth = parser.getDepth(); |
| 640 | int type; |
| 641 | while (((type = parser.next()) != XmlPullParser.END_TAG |
| 642 | || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) { |
| 643 | if ((type == XmlPullParser.START_TAG) |
| 644 | && GridOption.TAG_NAME.equals(parser.getName())) { |
Sunny Goyal | 076e04b | 2023-04-03 12:38:30 -0700 | [diff] [blame] | 645 | result.add(new GridOption(context, Xml.asAttributeSet(parser))); |
Thales Lima | 7ec8382 | 2021-08-05 13:32:10 +0100 | [diff] [blame] | 646 | } |
| 647 | } |
| 648 | } catch (IOException | XmlPullParserException e) { |
| 649 | Log.e(TAG, "Error parsing device profile", e); |
| 650 | return Collections.emptyList(); |
| 651 | } |
| 652 | return result; |
| 653 | } |
| 654 | |
Sunny Goyal | 53d7ee4 | 2015-05-22 12:25:45 -0700 | [diff] [blame] | 655 | private int getLauncherIconDensity(int requiredSize) { |
| 656 | // Densities typically defined by an app. |
sfufa@google.com | de01329 | 2021-09-21 18:22:44 -0700 | [diff] [blame] | 657 | int[] densityBuckets = new int[]{ |
Sunny Goyal | 53d7ee4 | 2015-05-22 12:25:45 -0700 | [diff] [blame] | 658 | DisplayMetrics.DENSITY_LOW, |
| 659 | DisplayMetrics.DENSITY_MEDIUM, |
| 660 | DisplayMetrics.DENSITY_TV, |
| 661 | DisplayMetrics.DENSITY_HIGH, |
| 662 | DisplayMetrics.DENSITY_XHIGH, |
| 663 | DisplayMetrics.DENSITY_XXHIGH, |
| 664 | DisplayMetrics.DENSITY_XXXHIGH |
| 665 | }; |
| 666 | |
| 667 | int density = DisplayMetrics.DENSITY_XXXHIGH; |
| 668 | for (int i = densityBuckets.length - 1; i >= 0; i--) { |
| 669 | float expectedSize = ICON_SIZE_DEFINED_IN_APP_DP * densityBuckets[i] |
| 670 | / DisplayMetrics.DENSITY_DEFAULT; |
| 671 | if (expectedSize >= requiredSize) { |
| 672 | density = densityBuckets[i]; |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | return density; |
| 677 | } |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 678 | |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 679 | /** |
| 680 | * Apply any Partner customization grid overrides. |
| 681 | * |
| 682 | * Currently we support: all apps row / column count. |
| 683 | */ |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 684 | private void applyPartnerDeviceProfileOverrides(Context context, DisplayMetrics dm) { |
| 685 | Partner p = Partner.get(context.getPackageManager()); |
Sunny Goyal | 3e58eea | 2022-11-14 14:30:07 -0800 | [diff] [blame] | 686 | if (p == null) { |
| 687 | return; |
| 688 | } |
| 689 | try { |
| 690 | int numRows = p.getIntValue(RES_GRID_NUM_ROWS, -1); |
| 691 | int numColumns = p.getIntValue(RES_GRID_NUM_COLUMNS, -1); |
| 692 | float iconSizePx = p.getDimenValue(RES_GRID_ICON_SIZE_DP, -1); |
| 693 | |
| 694 | if (numRows > 0 && numColumns > 0) { |
| 695 | this.numRows = numRows; |
| 696 | this.numColumns = numColumns; |
| 697 | } |
| 698 | if (iconSizePx > 0) { |
| 699 | this.iconSize[InvariantDeviceProfile.INDEX_DEFAULT] = |
| 700 | Utilities.dpiFromPx(iconSizePx, dm.densityDpi); |
| 701 | } |
| 702 | } catch (Resources.NotFoundException ex) { |
| 703 | Log.e(TAG, "Invalid Partner grid resource!", ex); |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 704 | } |
| 705 | } |
| 706 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 707 | private static float dist(float x0, float y0, float x1, float y1) { |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 708 | return (float) Math.hypot(x1 - x0, y1 - y0); |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 709 | } |
| 710 | |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 711 | private static DisplayOption invDistWeightedInterpolate( |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 712 | Info displayInfo, ArrayList<DisplayOption> points, @DeviceType int deviceType) { |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 713 | int minWidthPx = Integer.MAX_VALUE; |
| 714 | int minHeightPx = Integer.MAX_VALUE; |
| 715 | for (WindowBounds bounds : displayInfo.supportedBounds) { |
| 716 | boolean isTablet = displayInfo.isTablet(bounds); |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 717 | if (isTablet && deviceType == TYPE_MULTI_DISPLAY) { |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 718 | // For split displays, take half width per page |
| 719 | minWidthPx = Math.min(minWidthPx, bounds.availableSize.x / 2); |
| 720 | minHeightPx = Math.min(minHeightPx, bounds.availableSize.y); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 721 | |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 722 | } else if (!isTablet && bounds.isLandscape()) { |
| 723 | // We will use transposed layout in this case |
| 724 | minWidthPx = Math.min(minWidthPx, bounds.availableSize.y); |
| 725 | minHeightPx = Math.min(minHeightPx, bounds.availableSize.x); |
| 726 | } else { |
| 727 | minWidthPx = Math.min(minWidthPx, bounds.availableSize.x); |
| 728 | minHeightPx = Math.min(minHeightPx, bounds.availableSize.y); |
| 729 | } |
| 730 | } |
| 731 | |
Thales Lima | 425f682 | 2022-05-10 13:44:58 -0300 | [diff] [blame] | 732 | float width = dpiFromPx(minWidthPx, displayInfo.getDensityDpi()); |
| 733 | float height = dpiFromPx(minHeightPx, displayInfo.getDensityDpi()); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 734 | |
| 735 | // Sort the profiles based on the closeness to the device size |
| 736 | Collections.sort(points, (a, b) -> |
| 737 | Float.compare(dist(width, height, a.minWidthDps, a.minHeightDps), |
| 738 | dist(width, height, b.minWidthDps, b.minHeightDps))); |
| 739 | |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 740 | DisplayOption closestPoint = points.get(0); |
| 741 | GridOption closestOption = closestPoint.grid; |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 742 | float weights = 0; |
| 743 | |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 744 | if (dist(width, height, closestPoint.minWidthDps, closestPoint.minHeightDps) == 0) { |
| 745 | return closestPoint; |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 746 | } |
| 747 | |
| 748 | DisplayOption out = new DisplayOption(closestOption); |
| 749 | for (int i = 0; i < points.size() && i < KNEARESTNEIGHBOR; ++i) { |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 750 | DisplayOption p = points.get(i); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 751 | float w = weight(width, height, p.minWidthDps, p.minHeightDps, WEIGHT_POWER); |
| 752 | weights += w; |
| 753 | out.add(new DisplayOption().add(p).multiply(w)); |
| 754 | } |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 755 | out.multiply(1.0f / weights); |
| 756 | |
Thales Lima | 6e0005a | 2021-10-27 15:53:41 +0100 | [diff] [blame] | 757 | // Since the bitmaps are persisted, ensure that all bitmap sizes are not larger than |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 758 | // predefined size to avoid cache invalidation |
Thales Lima | 6e0005a | 2021-10-27 15:53:41 +0100 | [diff] [blame] | 759 | for (int i = INDEX_DEFAULT; i < COUNT_SIZES; i++) { |
| 760 | out.iconSizes[i] = Math.min(out.iconSizes[i], closestPoint.iconSizes[i]); |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 761 | } |
| 762 | |
| 763 | return out; |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 764 | } |
| 765 | |
Sunny Goyal | 2783595 | 2017-01-13 12:15:53 -0800 | [diff] [blame] | 766 | public DeviceProfile getDeviceProfile(Context context) { |
Alex Chau | c09a98a | 2023-11-14 12:51:42 +0000 | [diff] [blame] | 767 | WindowManagerProxy windowManagerProxy = WindowManagerProxy.INSTANCE.get(context); |
| 768 | Rect bounds = windowManagerProxy.getCurrentBounds(context); |
| 769 | int rotation = windowManagerProxy.getRotation(context); |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 770 | |
Alex Chau | c09a98a | 2023-11-14 12:51:42 +0000 | [diff] [blame] | 771 | return getBestMatch(bounds.width(), bounds.height(), rotation); |
Sunny Goyal | 3e9a29c | 2021-09-07 15:53:09 -0400 | [diff] [blame] | 772 | } |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 773 | |
Sunny Goyal | 187b16c | 2022-03-01 16:53:23 -0800 | [diff] [blame] | 774 | /** |
| 775 | * Returns the device profile matching the provided screen configuration |
| 776 | */ |
| 777 | public DeviceProfile getBestMatch(float screenWidth, float screenHeight, int rotation) { |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 778 | DeviceProfile bestMatch = supportedProfiles.get(0); |
| 779 | float minDiff = Float.MAX_VALUE; |
| 780 | |
| 781 | for (DeviceProfile profile : supportedProfiles) { |
Sunny Goyal | 3e9a29c | 2021-09-07 15:53:09 -0400 | [diff] [blame] | 782 | float diff = Math.abs(profile.widthPx - screenWidth) |
| 783 | + Math.abs(profile.heightPx - screenHeight); |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 784 | if (diff < minDiff) { |
| 785 | minDiff = diff; |
| 786 | bestMatch = profile; |
Sunny Goyal | 187b16c | 2022-03-01 16:53:23 -0800 | [diff] [blame] | 787 | } else if (diff == minDiff && profile.rotationHint == rotation) { |
| 788 | bestMatch = profile; |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 789 | } |
| 790 | } |
| 791 | return bestMatch; |
Sunny Goyal | 2783595 | 2017-01-13 12:15:53 -0800 | [diff] [blame] | 792 | } |
| 793 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 794 | private static float weight(float x0, float y0, float x1, float y1, float pow) { |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 795 | float d = dist(x0, y0, x1, y1); |
| 796 | if (Float.compare(d, 0f) == 0) { |
| 797 | return Float.POSITIVE_INFINITY; |
| 798 | } |
| 799 | return (float) (WEIGHT_EFFICIENT / Math.pow(d, pow)); |
| 800 | } |
Sunny Goyal | 6f86609 | 2016-03-17 17:04:15 -0700 | [diff] [blame] | 801 | |
| 802 | /** |
| 803 | * As a ratio of screen height, the total distance we want the parallax effect to span |
| 804 | * horizontally |
| 805 | */ |
| 806 | private static float wallpaperTravelToScreenWidthRatio(int width, int height) { |
| 807 | float aspectRatio = width / (float) height; |
| 808 | |
| 809 | // At an aspect ratio of 16/10, the wallpaper parallax effect should span 1.5 * screen width |
| 810 | // At an aspect ratio of 10/16, the wallpaper parallax effect should span 1.2 * screen width |
| 811 | // We will use these two data points to extrapolate how much the wallpaper parallax effect |
| 812 | // to span (ie travel) at any aspect ratio: |
| 813 | |
sfufa@google.com | de01329 | 2021-09-21 18:22:44 -0700 | [diff] [blame] | 814 | final float ASPECT_RATIO_LANDSCAPE = 16 / 10f; |
| 815 | final float ASPECT_RATIO_PORTRAIT = 10 / 16f; |
Sunny Goyal | 6f86609 | 2016-03-17 17:04:15 -0700 | [diff] [blame] | 816 | final float WALLPAPER_WIDTH_TO_SCREEN_RATIO_LANDSCAPE = 1.5f; |
| 817 | final float WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT = 1.2f; |
| 818 | |
| 819 | // To find out the desired width at different aspect ratios, we use the following two |
| 820 | // formulas, where the coefficient on x is the aspect ratio (width/height): |
| 821 | // (16/10)x + y = 1.5 |
| 822 | // (10/16)x + y = 1.2 |
| 823 | // We solve for x and y and end up with a final formula: |
| 824 | final float x = |
sfufa@google.com | de01329 | 2021-09-21 18:22:44 -0700 | [diff] [blame] | 825 | (WALLPAPER_WIDTH_TO_SCREEN_RATIO_LANDSCAPE |
| 826 | - WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT) / |
Sunny Goyal | 6f86609 | 2016-03-17 17:04:15 -0700 | [diff] [blame] | 827 | (ASPECT_RATIO_LANDSCAPE - ASPECT_RATIO_PORTRAIT); |
| 828 | final float y = WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT - x * ASPECT_RATIO_PORTRAIT; |
| 829 | return x * aspectRatio + y; |
| 830 | } |
| 831 | |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 832 | public interface OnIDPChangeListener { |
| 833 | |
Sunny Goyal | b47172b | 2021-05-03 19:59:51 -0700 | [diff] [blame] | 834 | /** |
| 835 | * Called when the device provide changes |
| 836 | */ |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 837 | void onIdpChanged(boolean modelPropertiesChanged); |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 838 | } |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 839 | |
| 840 | |
Sunny Goyal | eff44f3 | 2019-01-09 17:29:49 -0800 | [diff] [blame] | 841 | public static final class GridOption { |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 842 | |
Sunny Goyal | 7d892ff | 2019-01-11 15:08:44 -0800 | [diff] [blame] | 843 | public static final String TAG_NAME = "grid-option"; |
| 844 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 845 | private static final int DEVICE_CATEGORY_PHONE = 1 << 0; |
| 846 | private static final int DEVICE_CATEGORY_TABLET = 1 << 1; |
| 847 | private static final int DEVICE_CATEGORY_MULTI_DISPLAY = 1 << 2; |
| 848 | private static final int DEVICE_CATEGORY_ALL = |
| 849 | DEVICE_CATEGORY_PHONE | DEVICE_CATEGORY_TABLET | DEVICE_CATEGORY_MULTI_DISPLAY; |
| 850 | |
Thales Lima | 11af7bc | 2022-08-12 15:24:54 +0100 | [diff] [blame] | 851 | private static final int INLINE_QSB_FOR_PORTRAIT = 1 << 0; |
| 852 | private static final int INLINE_QSB_FOR_LANDSCAPE = 1 << 1; |
| 853 | private static final int INLINE_QSB_FOR_TWO_PANEL_PORTRAIT = 1 << 2; |
| 854 | private static final int INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE = 1 << 3; |
| 855 | private static final int DONT_INLINE_QSB = 0; |
| 856 | |
Sunny Goyal | eff44f3 | 2019-01-09 17:29:49 -0800 | [diff] [blame] | 857 | public final String name; |
| 858 | public final int numRows; |
| 859 | public final int numColumns; |
Alex Chau | 9fee3fd | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 860 | public final int numSearchContainerColumns; |
Sunny Goyal | 076e04b | 2023-04-03 12:38:30 -0700 | [diff] [blame] | 861 | public final int deviceCategory; |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 862 | |
Thales Lima | 1faa4ed | 2023-12-01 16:48:19 +0000 | [diff] [blame] | 863 | private final int[] numFolderRows = new int[COUNT_SIZES]; |
| 864 | private final int[] numFolderColumns = new int[COUNT_SIZES]; |
Thales Lima | b35faed | 2022-09-05 16:30:01 -0300 | [diff] [blame] | 865 | private final @StyleRes int folderStyle; |
Thales Lima | d852d65 | 2023-01-17 14:01:13 +0000 | [diff] [blame] | 866 | private final @StyleRes int cellStyle; |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 867 | |
Thales Lima | e9273ea | 2023-01-26 12:33:52 +0000 | [diff] [blame] | 868 | private final @StyleRes int allAppsStyle; |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 869 | private final int numAllAppsColumns; |
Jordan Silva | 2de6a27 | 2024-01-04 14:44:20 -0300 | [diff] [blame] | 870 | private final int mNumAllAppsRowsForCellHeightCalculation; |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 871 | private final int numDatabaseAllAppsColumns; |
| 872 | private final int numHotseatIcons; |
Tony Wickham | b87f3cd | 2021-04-07 15:02:37 -0700 | [diff] [blame] | 873 | private final int numDatabaseHotseatIcons; |
Thales Lima | b8c0595 | 2022-05-23 16:58:38 +0100 | [diff] [blame] | 874 | |
Thales Lima | 11af7bc | 2022-08-12 15:24:54 +0100 | [diff] [blame] | 875 | private final boolean[] inlineQsb = new boolean[COUNT_SIZES]; |
| 876 | |
Thales Lima | b35faed | 2022-09-05 16:30:01 -0300 | [diff] [blame] | 877 | private @DimenRes int inlineNavButtonsEndSpacing; |
Tracy Zhou | 7df93d2 | 2020-01-27 13:44:06 -0800 | [diff] [blame] | 878 | private final String dbFile; |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 879 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 880 | private final int defaultLayoutId; |
| 881 | private final int demoModeLayoutId; |
| 882 | |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 883 | private final boolean isScalable; |
Jon Miranda | c9e69fa | 2021-03-22 17:13:34 -0400 | [diff] [blame] | 884 | private final int devicePaddingId; |
Thales Lima | ec5abba | 2023-04-05 16:33:50 +0100 | [diff] [blame] | 885 | private final int mWorkspaceSpecsId; |
Jordan Silva | 575c3bd | 2023-07-21 12:00:43 +0100 | [diff] [blame] | 886 | private final int mWorkspaceSpecsTwoPanelId; |
Thales Lima | abfe364 | 2023-05-24 18:08:53 +0100 | [diff] [blame] | 887 | private final int mAllAppsSpecsId; |
Jordan Silva | 575c3bd | 2023-07-21 12:00:43 +0100 | [diff] [blame] | 888 | private final int mAllAppsSpecsTwoPanelId; |
Jordan Silva | 637f4eb | 2023-06-13 11:21:53 +0100 | [diff] [blame] | 889 | private final int mFolderSpecsId; |
Jordan Silva | 575c3bd | 2023-07-21 12:00:43 +0100 | [diff] [blame] | 890 | private final int mFolderSpecsTwoPanelId; |
Thales Lima | f8bfb03 | 2023-07-24 15:08:05 +0100 | [diff] [blame] | 891 | private final int mHotseatSpecsId; |
| 892 | private final int mHotseatSpecsTwoPanelId; |
Jordan Silva | 999dd2a | 2023-11-17 19:31:43 +0000 | [diff] [blame] | 893 | private final int mWorkspaceCellSpecsId; |
| 894 | private final int mWorkspaceCellSpecsTwoPanelId; |
| 895 | private final int mAllAppsCellSpecsId; |
| 896 | private final int mAllAppsCellSpecsTwoPanelId; |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 897 | |
Sunny Goyal | 076e04b | 2023-04-03 12:38:30 -0700 | [diff] [blame] | 898 | public GridOption(Context context, AttributeSet attrs) { |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 899 | TypedArray a = context.obtainStyledAttributes( |
| 900 | attrs, R.styleable.GridDisplayOption); |
| 901 | name = a.getString(R.styleable.GridDisplayOption_name); |
| 902 | numRows = a.getInt(R.styleable.GridDisplayOption_numRows, 0); |
| 903 | numColumns = a.getInt(R.styleable.GridDisplayOption_numColumns, 0); |
Alex Chau | 9fee3fd | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 904 | numSearchContainerColumns = a.getInt( |
| 905 | R.styleable.GridDisplayOption_numSearchContainerColumns, numColumns); |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 906 | |
Tracy Zhou | 7df93d2 | 2020-01-27 13:44:06 -0800 | [diff] [blame] | 907 | dbFile = a.getString(R.styleable.GridDisplayOption_dbFile); |
Alex Chau | 766cd2b | 2022-07-06 17:15:21 +0100 | [diff] [blame] | 908 | defaultLayoutId = a.getResourceId( |
| 909 | R.styleable.GridDisplayOption_defaultLayoutId, 0); |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 910 | demoModeLayoutId = a.getResourceId( |
| 911 | R.styleable.GridDisplayOption_demoModeLayoutId, defaultLayoutId); |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 912 | |
Thales Lima | e9273ea | 2023-01-26 12:33:52 +0000 | [diff] [blame] | 913 | allAppsStyle = a.getResourceId(R.styleable.GridDisplayOption_allAppsStyle, |
| 914 | R.style.AllAppsStyleDefault); |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 915 | numAllAppsColumns = a.getInt( |
| 916 | R.styleable.GridDisplayOption_numAllAppsColumns, numColumns); |
| 917 | numDatabaseAllAppsColumns = a.getInt( |
| 918 | R.styleable.GridDisplayOption_numExtendedAllAppsColumns, 2 * numAllAppsColumns); |
| 919 | |
| 920 | numHotseatIcons = a.getInt( |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 921 | R.styleable.GridDisplayOption_numHotseatIcons, numColumns); |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 922 | numDatabaseHotseatIcons = a.getInt( |
| 923 | R.styleable.GridDisplayOption_numExtendedHotseatIcons, 2 * numHotseatIcons); |
Thales Lima | b8c0595 | 2022-05-23 16:58:38 +0100 | [diff] [blame] | 924 | |
Vinit Nayak | c729317 | 2022-07-18 16:41:50 -0700 | [diff] [blame] | 925 | inlineNavButtonsEndSpacing = |
| 926 | a.getResourceId(R.styleable.GridDisplayOption_inlineNavButtonsEndSpacing, |
Thales Lima | ec5abba | 2023-04-05 16:33:50 +0100 | [diff] [blame] | 927 | R.dimen.taskbar_button_margin_default); |
Thales Lima | b35faed | 2022-09-05 16:30:01 -0300 | [diff] [blame] | 928 | |
Thales Lima | 1faa4ed | 2023-12-01 16:48:19 +0000 | [diff] [blame] | 929 | numFolderRows[INDEX_DEFAULT] = a.getInt( |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 930 | R.styleable.GridDisplayOption_numFolderRows, numRows); |
Thales Lima | 1faa4ed | 2023-12-01 16:48:19 +0000 | [diff] [blame] | 931 | numFolderColumns[INDEX_DEFAULT] = a.getInt( |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 932 | R.styleable.GridDisplayOption_numFolderColumns, numColumns); |
Jon Miranda | 6f7e970 | 2019-09-16 14:44:14 -0700 | [diff] [blame] | 933 | |
Thales Lima | 1faa4ed | 2023-12-01 16:48:19 +0000 | [diff] [blame] | 934 | if (FeatureFlags.enableResponsiveWorkspace()) { |
| 935 | numFolderRows[INDEX_LANDSCAPE] = a.getInt( |
| 936 | R.styleable.GridDisplayOption_numFolderRowsLandscape, |
| 937 | numFolderRows[INDEX_DEFAULT]); |
| 938 | numFolderColumns[INDEX_LANDSCAPE] = a.getInt( |
| 939 | R.styleable.GridDisplayOption_numFolderColumnsLandscape, |
| 940 | numFolderColumns[INDEX_DEFAULT]); |
| 941 | numFolderRows[INDEX_TWO_PANEL_PORTRAIT] = a.getInt( |
| 942 | R.styleable.GridDisplayOption_numFolderRowsTwoPanelPortrait, |
| 943 | numFolderRows[INDEX_DEFAULT]); |
| 944 | numFolderColumns[INDEX_TWO_PANEL_PORTRAIT] = a.getInt( |
| 945 | R.styleable.GridDisplayOption_numFolderColumnsTwoPanelPortrait, |
| 946 | numFolderColumns[INDEX_DEFAULT]); |
| 947 | numFolderRows[INDEX_TWO_PANEL_LANDSCAPE] = a.getInt( |
| 948 | R.styleable.GridDisplayOption_numFolderRowsTwoPanelLandscape, |
| 949 | numFolderRows[INDEX_DEFAULT]); |
| 950 | numFolderColumns[INDEX_TWO_PANEL_LANDSCAPE] = a.getInt( |
| 951 | R.styleable.GridDisplayOption_numFolderColumnsTwoPanelLandscape, |
| 952 | numFolderColumns[INDEX_DEFAULT]); |
| 953 | } else { |
| 954 | numFolderRows[INDEX_LANDSCAPE] = numFolderRows[INDEX_DEFAULT]; |
| 955 | numFolderColumns[INDEX_LANDSCAPE] = numFolderColumns[INDEX_DEFAULT]; |
| 956 | numFolderRows[INDEX_TWO_PANEL_PORTRAIT] = numFolderRows[INDEX_DEFAULT]; |
| 957 | numFolderColumns[INDEX_TWO_PANEL_PORTRAIT] = numFolderColumns[INDEX_DEFAULT]; |
| 958 | numFolderRows[INDEX_TWO_PANEL_LANDSCAPE] = numFolderRows[INDEX_DEFAULT]; |
| 959 | numFolderColumns[INDEX_TWO_PANEL_LANDSCAPE] = numFolderColumns[INDEX_DEFAULT]; |
| 960 | } |
| 961 | |
Thales Lima | b35faed | 2022-09-05 16:30:01 -0300 | [diff] [blame] | 962 | folderStyle = a.getResourceId(R.styleable.GridDisplayOption_folderStyle, |
| 963 | INVALID_RESOURCE_HANDLE); |
| 964 | |
Thales Lima | d852d65 | 2023-01-17 14:01:13 +0000 | [diff] [blame] | 965 | cellStyle = a.getResourceId(R.styleable.GridDisplayOption_cellStyle, |
| 966 | R.style.CellStyleDefault); |
| 967 | |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 968 | isScalable = a.getBoolean( |
| 969 | R.styleable.GridDisplayOption_isScalable, false); |
Jon Miranda | c9e69fa | 2021-03-22 17:13:34 -0400 | [diff] [blame] | 970 | devicePaddingId = a.getResourceId( |
Thales Lima | ae0d7ef | 2022-11-16 15:53:43 +0000 | [diff] [blame] | 971 | R.styleable.GridDisplayOption_devicePaddingId, INVALID_RESOURCE_HANDLE); |
Sunny Goyal | 076e04b | 2023-04-03 12:38:30 -0700 | [diff] [blame] | 972 | deviceCategory = a.getInt(R.styleable.GridDisplayOption_deviceCategory, |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 973 | DEVICE_CATEGORY_ALL); |
Thales Lima | 7ec8382 | 2021-08-05 13:32:10 +0100 | [diff] [blame] | 974 | |
Thales Lima | ca31b61 | 2023-09-14 14:25:26 +0100 | [diff] [blame] | 975 | if (FeatureFlags.enableResponsiveWorkspace()) { |
Thales Lima | ec5abba | 2023-04-05 16:33:50 +0100 | [diff] [blame] | 976 | mWorkspaceSpecsId = a.getResourceId( |
| 977 | R.styleable.GridDisplayOption_workspaceSpecsId, INVALID_RESOURCE_HANDLE); |
Jordan Silva | 575c3bd | 2023-07-21 12:00:43 +0100 | [diff] [blame] | 978 | mWorkspaceSpecsTwoPanelId = a.getResourceId( |
| 979 | R.styleable.GridDisplayOption_workspaceSpecsTwoPanelId, |
Jordan Silva | d29f064 | 2024-01-10 15:11:26 -0300 | [diff] [blame] | 980 | mWorkspaceSpecsId); |
Thales Lima | abfe364 | 2023-05-24 18:08:53 +0100 | [diff] [blame] | 981 | mAllAppsSpecsId = a.getResourceId( |
| 982 | R.styleable.GridDisplayOption_allAppsSpecsId, INVALID_RESOURCE_HANDLE); |
Jordan Silva | 575c3bd | 2023-07-21 12:00:43 +0100 | [diff] [blame] | 983 | mAllAppsSpecsTwoPanelId = a.getResourceId( |
| 984 | R.styleable.GridDisplayOption_allAppsSpecsTwoPanelId, |
Jordan Silva | d29f064 | 2024-01-10 15:11:26 -0300 | [diff] [blame] | 985 | mAllAppsSpecsId); |
Jordan Silva | 637f4eb | 2023-06-13 11:21:53 +0100 | [diff] [blame] | 986 | mFolderSpecsId = a.getResourceId( |
| 987 | R.styleable.GridDisplayOption_folderSpecsId, INVALID_RESOURCE_HANDLE); |
Jordan Silva | 575c3bd | 2023-07-21 12:00:43 +0100 | [diff] [blame] | 988 | mFolderSpecsTwoPanelId = a.getResourceId( |
| 989 | R.styleable.GridDisplayOption_folderSpecsTwoPanelId, |
Jordan Silva | d29f064 | 2024-01-10 15:11:26 -0300 | [diff] [blame] | 990 | mFolderSpecsId); |
Thales Lima | f8bfb03 | 2023-07-24 15:08:05 +0100 | [diff] [blame] | 991 | mHotseatSpecsId = a.getResourceId( |
| 992 | R.styleable.GridDisplayOption_hotseatSpecsId, INVALID_RESOURCE_HANDLE); |
| 993 | mHotseatSpecsTwoPanelId = a.getResourceId( |
| 994 | R.styleable.GridDisplayOption_hotseatSpecsTwoPanelId, |
Jordan Silva | d29f064 | 2024-01-10 15:11:26 -0300 | [diff] [blame] | 995 | mHotseatSpecsId); |
Jordan Silva | 999dd2a | 2023-11-17 19:31:43 +0000 | [diff] [blame] | 996 | mWorkspaceCellSpecsId = a.getResourceId( |
| 997 | R.styleable.GridDisplayOption_workspaceCellSpecsId, |
| 998 | INVALID_RESOURCE_HANDLE); |
| 999 | mWorkspaceCellSpecsTwoPanelId = a.getResourceId( |
| 1000 | R.styleable.GridDisplayOption_workspaceCellSpecsTwoPanelId, |
Jordan Silva | d29f064 | 2024-01-10 15:11:26 -0300 | [diff] [blame] | 1001 | mWorkspaceCellSpecsId); |
Jordan Silva | 999dd2a | 2023-11-17 19:31:43 +0000 | [diff] [blame] | 1002 | mAllAppsCellSpecsId = a.getResourceId( |
| 1003 | R.styleable.GridDisplayOption_allAppsCellSpecsId, |
| 1004 | INVALID_RESOURCE_HANDLE); |
| 1005 | mAllAppsCellSpecsTwoPanelId = a.getResourceId( |
| 1006 | R.styleable.GridDisplayOption_allAppsCellSpecsTwoPanelId, |
Jordan Silva | d29f064 | 2024-01-10 15:11:26 -0300 | [diff] [blame] | 1007 | mAllAppsCellSpecsId); |
Jordan Silva | 2de6a27 | 2024-01-04 14:44:20 -0300 | [diff] [blame] | 1008 | mNumAllAppsRowsForCellHeightCalculation = a.getInt( |
| 1009 | R.styleable.GridDisplayOption_numAllAppsRowsForCellHeightCalculation, |
| 1010 | numRows); |
Thales Lima | ec5abba | 2023-04-05 16:33:50 +0100 | [diff] [blame] | 1011 | } else { |
| 1012 | mWorkspaceSpecsId = INVALID_RESOURCE_HANDLE; |
Jordan Silva | 575c3bd | 2023-07-21 12:00:43 +0100 | [diff] [blame] | 1013 | mWorkspaceSpecsTwoPanelId = INVALID_RESOURCE_HANDLE; |
Thales Lima | abfe364 | 2023-05-24 18:08:53 +0100 | [diff] [blame] | 1014 | mAllAppsSpecsId = INVALID_RESOURCE_HANDLE; |
Jordan Silva | 575c3bd | 2023-07-21 12:00:43 +0100 | [diff] [blame] | 1015 | mAllAppsSpecsTwoPanelId = INVALID_RESOURCE_HANDLE; |
Jordan Silva | 637f4eb | 2023-06-13 11:21:53 +0100 | [diff] [blame] | 1016 | mFolderSpecsId = INVALID_RESOURCE_HANDLE; |
Jordan Silva | 575c3bd | 2023-07-21 12:00:43 +0100 | [diff] [blame] | 1017 | mFolderSpecsTwoPanelId = INVALID_RESOURCE_HANDLE; |
Thales Lima | f8bfb03 | 2023-07-24 15:08:05 +0100 | [diff] [blame] | 1018 | mHotseatSpecsId = INVALID_RESOURCE_HANDLE; |
| 1019 | mHotseatSpecsTwoPanelId = INVALID_RESOURCE_HANDLE; |
Jordan Silva | 999dd2a | 2023-11-17 19:31:43 +0000 | [diff] [blame] | 1020 | mWorkspaceCellSpecsId = INVALID_RESOURCE_HANDLE; |
| 1021 | mWorkspaceCellSpecsTwoPanelId = INVALID_RESOURCE_HANDLE; |
| 1022 | mAllAppsCellSpecsId = INVALID_RESOURCE_HANDLE; |
| 1023 | mAllAppsCellSpecsTwoPanelId = INVALID_RESOURCE_HANDLE; |
Jordan Silva | 2de6a27 | 2024-01-04 14:44:20 -0300 | [diff] [blame] | 1024 | mNumAllAppsRowsForCellHeightCalculation = numRows; |
Thales Lima | ec5abba | 2023-04-05 16:33:50 +0100 | [diff] [blame] | 1025 | } |
| 1026 | |
Thales Lima | 11af7bc | 2022-08-12 15:24:54 +0100 | [diff] [blame] | 1027 | int inlineForRotation = a.getInt(R.styleable.GridDisplayOption_inlineQsb, |
| 1028 | DONT_INLINE_QSB); |
| 1029 | inlineQsb[INDEX_DEFAULT] = |
| 1030 | (inlineForRotation & INLINE_QSB_FOR_PORTRAIT) == INLINE_QSB_FOR_PORTRAIT; |
| 1031 | inlineQsb[INDEX_LANDSCAPE] = |
| 1032 | (inlineForRotation & INLINE_QSB_FOR_LANDSCAPE) == INLINE_QSB_FOR_LANDSCAPE; |
| 1033 | inlineQsb[INDEX_TWO_PANEL_PORTRAIT] = |
| 1034 | (inlineForRotation & INLINE_QSB_FOR_TWO_PANEL_PORTRAIT) |
| 1035 | == INLINE_QSB_FOR_TWO_PANEL_PORTRAIT; |
| 1036 | inlineQsb[INDEX_TWO_PANEL_LANDSCAPE] = |
| 1037 | (inlineForRotation & INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE) |
| 1038 | == INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE; |
| 1039 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 1040 | a.recycle(); |
Sunny Goyal | 076e04b | 2023-04-03 12:38:30 -0700 | [diff] [blame] | 1041 | } |
| 1042 | |
| 1043 | public boolean isEnabled(@DeviceType int deviceType) { |
| 1044 | switch (deviceType) { |
| 1045 | case TYPE_PHONE: |
| 1046 | return (deviceCategory & DEVICE_CATEGORY_PHONE) == DEVICE_CATEGORY_PHONE; |
| 1047 | case TYPE_TABLET: |
| 1048 | return (deviceCategory & DEVICE_CATEGORY_TABLET) == DEVICE_CATEGORY_TABLET; |
| 1049 | case TYPE_MULTI_DISPLAY: |
| 1050 | return (deviceCategory & DEVICE_CATEGORY_MULTI_DISPLAY) |
| 1051 | == DEVICE_CATEGORY_MULTI_DISPLAY; |
| 1052 | default: |
| 1053 | return false; |
| 1054 | } |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 1055 | } |
| 1056 | } |
| 1057 | |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 1058 | @VisibleForTesting |
| 1059 | static final class DisplayOption { |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 1060 | public final GridOption grid; |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 1061 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 1062 | private final float minWidthDps; |
| 1063 | private final float minHeightDps; |
| 1064 | private final boolean canBeDefault; |
| 1065 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1066 | private final PointF[] minCellSize = new PointF[COUNT_SIZES]; |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 1067 | |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 1068 | private final PointF[] borderSpaces = new PointF[COUNT_SIZES]; |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1069 | private final float[] horizontalMargin = new float[COUNT_SIZES]; |
Thales Lima | b8c0595 | 2022-05-23 16:58:38 +0100 | [diff] [blame] | 1070 | private final float[] hotseatBarBottomSpace = new float[COUNT_SIZES]; |
| 1071 | private final float[] hotseatQsbSpace = new float[COUNT_SIZES]; |
Thales Lima | d90faab | 2021-09-21 17:18:47 +0100 | [diff] [blame] | 1072 | |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 1073 | private final float[] iconSizes = new float[COUNT_SIZES]; |
| 1074 | private final float[] textSizes = new float[COUNT_SIZES]; |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 1075 | |
Thales Lima | b7ef569 | 2022-03-10 10:32:36 +0000 | [diff] [blame] | 1076 | private final PointF[] allAppsCellSize = new PointF[COUNT_SIZES]; |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 1077 | private final float[] allAppsIconSizes = new float[COUNT_SIZES]; |
| 1078 | private final float[] allAppsIconTextSizes = new float[COUNT_SIZES]; |
| 1079 | private final PointF[] allAppsBorderSpaces = new PointF[COUNT_SIZES]; |
| 1080 | |
Jon Miranda | 9c478b6 | 2023-03-23 21:38:49 -0700 | [diff] [blame] | 1081 | private final float[] transientTaskbarIconSize = new float[COUNT_SIZES]; |
| 1082 | |
Jon Miranda | 04f0510 | 2023-04-04 12:16:31 -0700 | [diff] [blame] | 1083 | private final boolean[] startAlignTaskbar = new boolean[COUNT_SIZES]; |
| 1084 | |
Thales Lima | 1de4d55 | 2021-10-13 16:13:25 +0100 | [diff] [blame] | 1085 | DisplayOption(GridOption grid, Context context, AttributeSet attrs) { |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 1086 | this.grid = grid; |
| 1087 | |
Jon Miranda | 9c478b6 | 2023-03-23 21:38:49 -0700 | [diff] [blame] | 1088 | Resources res = context.getResources(); |
| 1089 | |
Thales Lima | 1de4d55 | 2021-10-13 16:13:25 +0100 | [diff] [blame] | 1090 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProfileDisplayOption); |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 1091 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 1092 | minWidthDps = a.getFloat(R.styleable.ProfileDisplayOption_minWidthDps, 0); |
| 1093 | minHeightDps = a.getFloat(R.styleable.ProfileDisplayOption_minHeightDps, 0); |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 1094 | |
Thales Lima | 1de4d55 | 2021-10-13 16:13:25 +0100 | [diff] [blame] | 1095 | canBeDefault = a.getBoolean(R.styleable.ProfileDisplayOption_canBeDefault, false); |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 1096 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1097 | float x; |
| 1098 | float y; |
| 1099 | |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1100 | x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidth, 0); |
| 1101 | y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeight, 0); |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1102 | minCellSize[INDEX_DEFAULT] = new PointF(x, y); |
Thales Lima | dd02734 | 2022-01-07 12:54:37 +0000 | [diff] [blame] | 1103 | |
| 1104 | x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidthLandscape, |
| 1105 | minCellSize[INDEX_DEFAULT].x); |
| 1106 | y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeightLandscape, |
| 1107 | minCellSize[INDEX_DEFAULT].y); |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1108 | minCellSize[INDEX_LANDSCAPE] = new PointF(x, y); |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1109 | |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1110 | x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidthTwoPanelPortrait, |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1111 | minCellSize[INDEX_DEFAULT].x); |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1112 | y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeightTwoPanelPortrait, |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1113 | minCellSize[INDEX_DEFAULT].y); |
| 1114 | minCellSize[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y); |
| 1115 | |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1116 | x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidthTwoPanelLandscape, |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1117 | minCellSize[INDEX_DEFAULT].x); |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1118 | y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeightTwoPanelLandscape, |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1119 | minCellSize[INDEX_DEFAULT].y); |
| 1120 | minCellSize[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y); |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 1121 | |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1122 | float borderSpace = a.getFloat(R.styleable.ProfileDisplayOption_borderSpace, 0); |
Thales Lima | 44cc3a2 | 2022-03-18 14:28:24 +0000 | [diff] [blame] | 1123 | float borderSpaceLandscape = a.getFloat( |
| 1124 | R.styleable.ProfileDisplayOption_borderSpaceLandscape, borderSpace); |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1125 | float borderSpaceTwoPanelPortrait = a.getFloat( |
| 1126 | R.styleable.ProfileDisplayOption_borderSpaceTwoPanelPortrait, borderSpace); |
| 1127 | float borderSpaceTwoPanelLandscape = a.getFloat( |
| 1128 | R.styleable.ProfileDisplayOption_borderSpaceTwoPanelLandscape, borderSpace); |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 1129 | |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1130 | x = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceHorizontal, borderSpace); |
| 1131 | y = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceVertical, borderSpace); |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 1132 | borderSpaces[INDEX_DEFAULT] = new PointF(x, y); |
Thales Lima | 44cc3a2 | 2022-03-18 14:28:24 +0000 | [diff] [blame] | 1133 | |
| 1134 | x = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceLandscapeHorizontal, |
| 1135 | borderSpaceLandscape); |
| 1136 | y = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceLandscapeVertical, |
| 1137 | borderSpaceLandscape); |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 1138 | borderSpaces[INDEX_LANDSCAPE] = new PointF(x, y); |
| 1139 | |
| 1140 | x = a.getFloat( |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1141 | R.styleable.ProfileDisplayOption_borderSpaceTwoPanelPortraitHorizontal, |
| 1142 | borderSpaceTwoPanelPortrait); |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 1143 | y = a.getFloat( |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1144 | R.styleable.ProfileDisplayOption_borderSpaceTwoPanelPortraitVertical, |
| 1145 | borderSpaceTwoPanelPortrait); |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 1146 | borderSpaces[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y); |
| 1147 | |
| 1148 | x = a.getFloat( |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1149 | R.styleable.ProfileDisplayOption_borderSpaceTwoPanelLandscapeHorizontal, |
| 1150 | borderSpaceTwoPanelLandscape); |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 1151 | y = a.getFloat( |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1152 | R.styleable.ProfileDisplayOption_borderSpaceTwoPanelLandscapeVertical, |
| 1153 | borderSpaceTwoPanelLandscape); |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 1154 | borderSpaces[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y); |
| 1155 | |
Thales Lima | b7ef569 | 2022-03-10 10:32:36 +0000 | [diff] [blame] | 1156 | x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellWidth, |
| 1157 | minCellSize[INDEX_DEFAULT].x); |
| 1158 | y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellHeight, |
| 1159 | minCellSize[INDEX_DEFAULT].y); |
| 1160 | allAppsCellSize[INDEX_DEFAULT] = new PointF(x, y); |
| 1161 | |
| 1162 | x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellWidthLandscape, |
| 1163 | allAppsCellSize[INDEX_DEFAULT].x); |
| 1164 | y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellHeightLandscape, |
| 1165 | allAppsCellSize[INDEX_DEFAULT].y); |
| 1166 | allAppsCellSize[INDEX_LANDSCAPE] = new PointF(x, y); |
| 1167 | |
| 1168 | x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellWidthTwoPanelPortrait, |
| 1169 | allAppsCellSize[INDEX_DEFAULT].x); |
| 1170 | y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellHeightTwoPanelPortrait, |
| 1171 | allAppsCellSize[INDEX_DEFAULT].y); |
| 1172 | allAppsCellSize[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y); |
| 1173 | |
| 1174 | x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellWidthTwoPanelLandscape, |
| 1175 | allAppsCellSize[INDEX_DEFAULT].x); |
| 1176 | y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellHeightTwoPanelLandscape, |
| 1177 | allAppsCellSize[INDEX_DEFAULT].y); |
| 1178 | allAppsCellSize[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y); |
| 1179 | |
Thales Lima | 080d890 | 2022-03-28 15:30:29 +0100 | [diff] [blame] | 1180 | float allAppsBorderSpace = a.getFloat( |
| 1181 | R.styleable.ProfileDisplayOption_allAppsBorderSpace, borderSpace); |
| 1182 | float allAppsBorderSpaceLandscape = a.getFloat( |
| 1183 | R.styleable.ProfileDisplayOption_allAppsBorderSpaceLandscape, |
| 1184 | allAppsBorderSpace); |
| 1185 | float allAppsBorderSpaceTwoPanelPortrait = a.getFloat( |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 1186 | R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortrait, |
Thales Lima | 080d890 | 2022-03-28 15:30:29 +0100 | [diff] [blame] | 1187 | allAppsBorderSpace); |
| 1188 | float allAppsBorderSpaceTwoPanelLandscape = a.getFloat( |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 1189 | R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelLandscape, |
Thales Lima | 080d890 | 2022-03-28 15:30:29 +0100 | [diff] [blame] | 1190 | allAppsBorderSpace); |
| 1191 | |
| 1192 | x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceHorizontal, |
| 1193 | allAppsBorderSpace); |
| 1194 | y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceVertical, |
| 1195 | allAppsBorderSpace); |
| 1196 | allAppsBorderSpaces[INDEX_DEFAULT] = new PointF(x, y); |
| 1197 | |
| 1198 | x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceLandscapeHorizontal, |
| 1199 | allAppsBorderSpaceLandscape); |
| 1200 | y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceLandscapeVertical, |
| 1201 | allAppsBorderSpaceLandscape); |
| 1202 | allAppsBorderSpaces[INDEX_LANDSCAPE] = new PointF(x, y); |
| 1203 | |
| 1204 | x = a.getFloat( |
| 1205 | R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortraitHorizontal, |
| 1206 | allAppsBorderSpaceTwoPanelPortrait); |
| 1207 | y = a.getFloat( |
| 1208 | R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortraitVertical, |
| 1209 | allAppsBorderSpaceTwoPanelPortrait); |
| 1210 | allAppsBorderSpaces[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y); |
| 1211 | |
| 1212 | x = a.getFloat( |
| 1213 | R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelLandscapeHorizontal, |
| 1214 | allAppsBorderSpaceTwoPanelLandscape); |
| 1215 | y = a.getFloat( |
| 1216 | R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelLandscapeVertical, |
| 1217 | allAppsBorderSpaceTwoPanelLandscape); |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 1218 | allAppsBorderSpaces[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y); |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 1219 | |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 1220 | iconSizes[INDEX_DEFAULT] = |
| 1221 | a.getFloat(R.styleable.ProfileDisplayOption_iconImageSize, 0); |
| 1222 | iconSizes[INDEX_LANDSCAPE] = |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1223 | a.getFloat(R.styleable.ProfileDisplayOption_iconSizeLandscape, |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 1224 | iconSizes[INDEX_DEFAULT]); |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 1225 | iconSizes[INDEX_TWO_PANEL_PORTRAIT] = |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1226 | a.getFloat(R.styleable.ProfileDisplayOption_iconSizeTwoPanelPortrait, |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 1227 | iconSizes[INDEX_DEFAULT]); |
| 1228 | iconSizes[INDEX_TWO_PANEL_LANDSCAPE] = |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1229 | a.getFloat(R.styleable.ProfileDisplayOption_iconSizeTwoPanelLandscape, |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1230 | iconSizes[INDEX_DEFAULT]); |
Jon Miranda | 6f7e970 | 2019-09-16 14:44:14 -0700 | [diff] [blame] | 1231 | |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 1232 | allAppsIconSizes[INDEX_DEFAULT] = a.getFloat( |
| 1233 | R.styleable.ProfileDisplayOption_allAppsIconSize, iconSizes[INDEX_DEFAULT]); |
Thales Lima | 1fb075d | 2022-08-10 10:47:50 +0100 | [diff] [blame] | 1234 | allAppsIconSizes[INDEX_LANDSCAPE] = a.getFloat( |
| 1235 | R.styleable.ProfileDisplayOption_allAppsIconSizeLandscape, |
Thales Lima | ed8c69b | 2022-08-17 12:21:21 -0400 | [diff] [blame] | 1236 | allAppsIconSizes[INDEX_DEFAULT]); |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 1237 | allAppsIconSizes[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat( |
| 1238 | R.styleable.ProfileDisplayOption_allAppsIconSizeTwoPanelPortrait, |
| 1239 | allAppsIconSizes[INDEX_DEFAULT]); |
| 1240 | allAppsIconSizes[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat( |
| 1241 | R.styleable.ProfileDisplayOption_allAppsIconSizeTwoPanelLandscape, |
| 1242 | allAppsIconSizes[INDEX_DEFAULT]); |
| 1243 | |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 1244 | textSizes[INDEX_DEFAULT] = |
| 1245 | a.getFloat(R.styleable.ProfileDisplayOption_iconTextSize, 0); |
| 1246 | textSizes[INDEX_LANDSCAPE] = |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1247 | a.getFloat(R.styleable.ProfileDisplayOption_iconTextSizeLandscape, |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 1248 | textSizes[INDEX_DEFAULT]); |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 1249 | textSizes[INDEX_TWO_PANEL_PORTRAIT] = |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1250 | a.getFloat(R.styleable.ProfileDisplayOption_iconTextSizeTwoPanelPortrait, |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 1251 | textSizes[INDEX_DEFAULT]); |
| 1252 | textSizes[INDEX_TWO_PANEL_LANDSCAPE] = |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1253 | a.getFloat(R.styleable.ProfileDisplayOption_iconTextSizeTwoPanelLandscape, |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1254 | textSizes[INDEX_DEFAULT]); |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 1255 | |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 1256 | allAppsIconTextSizes[INDEX_DEFAULT] = a.getFloat( |
| 1257 | R.styleable.ProfileDisplayOption_allAppsIconTextSize, textSizes[INDEX_DEFAULT]); |
| 1258 | allAppsIconTextSizes[INDEX_LANDSCAPE] = allAppsIconTextSizes[INDEX_DEFAULT]; |
| 1259 | allAppsIconTextSizes[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat( |
| 1260 | R.styleable.ProfileDisplayOption_allAppsIconTextSizeTwoPanelPortrait, |
| 1261 | allAppsIconTextSizes[INDEX_DEFAULT]); |
| 1262 | allAppsIconTextSizes[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat( |
| 1263 | R.styleable.ProfileDisplayOption_allAppsIconTextSizeTwoPanelLandscape, |
| 1264 | allAppsIconTextSizes[INDEX_DEFAULT]); |
| 1265 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1266 | horizontalMargin[INDEX_DEFAULT] = a.getFloat( |
| 1267 | R.styleable.ProfileDisplayOption_horizontalMargin, 0); |
Thales Lima | dd02734 | 2022-01-07 12:54:37 +0000 | [diff] [blame] | 1268 | horizontalMargin[INDEX_LANDSCAPE] = a.getFloat( |
| 1269 | R.styleable.ProfileDisplayOption_horizontalMarginLandscape, |
| 1270 | horizontalMargin[INDEX_DEFAULT]); |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1271 | horizontalMargin[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat( |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1272 | R.styleable.ProfileDisplayOption_horizontalMarginTwoPanelLandscape, |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1273 | horizontalMargin[INDEX_DEFAULT]); |
| 1274 | horizontalMargin[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat( |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 1275 | R.styleable.ProfileDisplayOption_horizontalMarginTwoPanelPortrait, |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1276 | horizontalMargin[INDEX_DEFAULT]); |
Thales Lima | d90faab | 2021-09-21 17:18:47 +0100 | [diff] [blame] | 1277 | |
Thales Lima | b8c0595 | 2022-05-23 16:58:38 +0100 | [diff] [blame] | 1278 | hotseatBarBottomSpace[INDEX_DEFAULT] = a.getFloat( |
| 1279 | R.styleable.ProfileDisplayOption_hotseatBarBottomSpace, |
Jon Miranda | 9c478b6 | 2023-03-23 21:38:49 -0700 | [diff] [blame] | 1280 | ResourcesCompat.getFloat(res, R.dimen.hotseat_bar_bottom_space_default)); |
Thales Lima | b8c0595 | 2022-05-23 16:58:38 +0100 | [diff] [blame] | 1281 | hotseatBarBottomSpace[INDEX_LANDSCAPE] = a.getFloat( |
| 1282 | R.styleable.ProfileDisplayOption_hotseatBarBottomSpaceLandscape, |
| 1283 | hotseatBarBottomSpace[INDEX_DEFAULT]); |
| 1284 | hotseatBarBottomSpace[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat( |
| 1285 | R.styleable.ProfileDisplayOption_hotseatBarBottomSpaceTwoPanelLandscape, |
| 1286 | hotseatBarBottomSpace[INDEX_DEFAULT]); |
| 1287 | hotseatBarBottomSpace[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat( |
| 1288 | R.styleable.ProfileDisplayOption_hotseatBarBottomSpaceTwoPanelPortrait, |
| 1289 | hotseatBarBottomSpace[INDEX_DEFAULT]); |
| 1290 | |
| 1291 | hotseatQsbSpace[INDEX_DEFAULT] = a.getFloat( |
| 1292 | R.styleable.ProfileDisplayOption_hotseatQsbSpace, |
Jon Miranda | 9c478b6 | 2023-03-23 21:38:49 -0700 | [diff] [blame] | 1293 | ResourcesCompat.getFloat(res, R.dimen.hotseat_qsb_space_default)); |
Thales Lima | b8c0595 | 2022-05-23 16:58:38 +0100 | [diff] [blame] | 1294 | hotseatQsbSpace[INDEX_LANDSCAPE] = a.getFloat( |
| 1295 | R.styleable.ProfileDisplayOption_hotseatQsbSpaceLandscape, |
| 1296 | hotseatQsbSpace[INDEX_DEFAULT]); |
| 1297 | hotseatQsbSpace[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat( |
| 1298 | R.styleable.ProfileDisplayOption_hotseatQsbSpaceTwoPanelLandscape, |
| 1299 | hotseatQsbSpace[INDEX_DEFAULT]); |
| 1300 | hotseatQsbSpace[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat( |
| 1301 | R.styleable.ProfileDisplayOption_hotseatQsbSpaceTwoPanelPortrait, |
| 1302 | hotseatQsbSpace[INDEX_DEFAULT]); |
| 1303 | |
Jon Miranda | 9c478b6 | 2023-03-23 21:38:49 -0700 | [diff] [blame] | 1304 | transientTaskbarIconSize[INDEX_DEFAULT] = a.getFloat( |
| 1305 | R.styleable.ProfileDisplayOption_transientTaskbarIconSize, |
| 1306 | ResourcesCompat.getFloat(res, R.dimen.taskbar_icon_size)); |
| 1307 | transientTaskbarIconSize[INDEX_LANDSCAPE] = a.getFloat( |
| 1308 | R.styleable.ProfileDisplayOption_transientTaskbarIconSizeLandscape, |
| 1309 | transientTaskbarIconSize[INDEX_DEFAULT]); |
| 1310 | transientTaskbarIconSize[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat( |
| 1311 | R.styleable.ProfileDisplayOption_transientTaskbarIconSizeTwoPanelLandscape, |
| 1312 | transientTaskbarIconSize[INDEX_DEFAULT]); |
| 1313 | transientTaskbarIconSize[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat( |
| 1314 | R.styleable.ProfileDisplayOption_transientTaskbarIconSizeTwoPanelPortrait, |
Jon Miranda | 4d74ad3 | 2023-03-27 16:31:11 -0700 | [diff] [blame] | 1315 | transientTaskbarIconSize[INDEX_DEFAULT]); |
Jon Miranda | 9c478b6 | 2023-03-23 21:38:49 -0700 | [diff] [blame] | 1316 | |
Jon Miranda | 04f0510 | 2023-04-04 12:16:31 -0700 | [diff] [blame] | 1317 | startAlignTaskbar[INDEX_DEFAULT] = a.getBoolean( |
| 1318 | R.styleable.ProfileDisplayOption_startAlignTaskbar, false); |
| 1319 | startAlignTaskbar[INDEX_LANDSCAPE] = a.getBoolean( |
| 1320 | R.styleable.ProfileDisplayOption_startAlignTaskbarLandscape, |
| 1321 | startAlignTaskbar[INDEX_DEFAULT]); |
| 1322 | startAlignTaskbar[INDEX_TWO_PANEL_LANDSCAPE] = a.getBoolean( |
| 1323 | R.styleable.ProfileDisplayOption_startAlignTaskbarTwoPanelLandscape, |
| 1324 | startAlignTaskbar[INDEX_LANDSCAPE]); |
| 1325 | startAlignTaskbar[INDEX_TWO_PANEL_PORTRAIT] = a.getBoolean( |
| 1326 | R.styleable.ProfileDisplayOption_startAlignTaskbarTwoPanelPortrait, |
| 1327 | startAlignTaskbar[INDEX_DEFAULT]); |
| 1328 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 1329 | a.recycle(); |
| 1330 | } |
| 1331 | |
| 1332 | DisplayOption() { |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 1333 | this(null); |
| 1334 | } |
| 1335 | |
| 1336 | DisplayOption(GridOption grid) { |
| 1337 | this.grid = grid; |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 1338 | minWidthDps = 0; |
| 1339 | minHeightDps = 0; |
| 1340 | canBeDefault = false; |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 1341 | for (int i = 0; i < COUNT_SIZES; i++) { |
| 1342 | iconSizes[i] = 0; |
| 1343 | textSizes[i] = 0; |
| 1344 | borderSpaces[i] = new PointF(); |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1345 | minCellSize[i] = new PointF(); |
Thales Lima | b7ef569 | 2022-03-10 10:32:36 +0000 | [diff] [blame] | 1346 | allAppsCellSize[i] = new PointF(); |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 1347 | allAppsIconSizes[i] = 0; |
| 1348 | allAppsIconTextSizes[i] = 0; |
| 1349 | allAppsBorderSpaces[i] = new PointF(); |
Jon Miranda | 9c478b6 | 2023-03-23 21:38:49 -0700 | [diff] [blame] | 1350 | transientTaskbarIconSize[i] = 0; |
Jon Miranda | 04f0510 | 2023-04-04 12:16:31 -0700 | [diff] [blame] | 1351 | startAlignTaskbar[i] = false; |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 1352 | } |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 1353 | } |
| 1354 | |
| 1355 | private DisplayOption multiply(float w) { |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 1356 | for (int i = 0; i < COUNT_SIZES; i++) { |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 1357 | iconSizes[i] *= w; |
| 1358 | textSizes[i] *= w; |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1359 | borderSpaces[i].x *= w; |
| 1360 | borderSpaces[i].y *= w; |
| 1361 | minCellSize[i].x *= w; |
| 1362 | minCellSize[i].y *= w; |
| 1363 | horizontalMargin[i] *= w; |
Thales Lima | b8c0595 | 2022-05-23 16:58:38 +0100 | [diff] [blame] | 1364 | hotseatBarBottomSpace[i] *= w; |
| 1365 | hotseatQsbSpace[i] *= w; |
Thales Lima | b7ef569 | 2022-03-10 10:32:36 +0000 | [diff] [blame] | 1366 | allAppsCellSize[i].x *= w; |
| 1367 | allAppsCellSize[i].y *= w; |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 1368 | allAppsIconSizes[i] *= w; |
| 1369 | allAppsIconTextSizes[i] *= w; |
| 1370 | allAppsBorderSpaces[i].x *= w; |
| 1371 | allAppsBorderSpaces[i].y *= w; |
Jon Miranda | 9c478b6 | 2023-03-23 21:38:49 -0700 | [diff] [blame] | 1372 | transientTaskbarIconSize[i] *= w; |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 1373 | } |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 1374 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 1375 | return this; |
| 1376 | } |
| 1377 | |
| 1378 | private DisplayOption add(DisplayOption p) { |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 1379 | for (int i = 0; i < COUNT_SIZES; i++) { |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 1380 | iconSizes[i] += p.iconSizes[i]; |
| 1381 | textSizes[i] += p.textSizes[i]; |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 1382 | borderSpaces[i].x += p.borderSpaces[i].x; |
| 1383 | borderSpaces[i].y += p.borderSpaces[i].y; |
| 1384 | minCellSize[i].x += p.minCellSize[i].x; |
| 1385 | minCellSize[i].y += p.minCellSize[i].y; |
| 1386 | horizontalMargin[i] += p.horizontalMargin[i]; |
Thales Lima | b8c0595 | 2022-05-23 16:58:38 +0100 | [diff] [blame] | 1387 | hotseatBarBottomSpace[i] += p.hotseatBarBottomSpace[i]; |
| 1388 | hotseatQsbSpace[i] += p.hotseatQsbSpace[i]; |
Thales Lima | b7ef569 | 2022-03-10 10:32:36 +0000 | [diff] [blame] | 1389 | allAppsCellSize[i].x += p.allAppsCellSize[i].x; |
| 1390 | allAppsCellSize[i].y += p.allAppsCellSize[i].y; |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 1391 | allAppsIconSizes[i] += p.allAppsIconSizes[i]; |
| 1392 | allAppsIconTextSizes[i] += p.allAppsIconTextSizes[i]; |
| 1393 | allAppsBorderSpaces[i].x += p.allAppsBorderSpaces[i].x; |
| 1394 | allAppsBorderSpaces[i].y += p.allAppsBorderSpaces[i].y; |
Jon Miranda | 9c478b6 | 2023-03-23 21:38:49 -0700 | [diff] [blame] | 1395 | transientTaskbarIconSize[i] += p.transientTaskbarIconSize[i]; |
Jon Miranda | 04f0510 | 2023-04-04 12:16:31 -0700 | [diff] [blame] | 1396 | startAlignTaskbar[i] |= p.startAlignTaskbar[i]; |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 1397 | } |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 1398 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 1399 | return this; |
| 1400 | } |
| 1401 | } |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 1402 | } |