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