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 | |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 19 | import static com.android.launcher3.Utilities.dpiFromPx; |
Andras Kloczl | 8e57cce | 2021-02-11 23:51:19 +0100 | [diff] [blame] | 20 | import static com.android.launcher3.config.FeatureFlags.ENABLE_TWO_PANEL_HOME; |
Sunny Goyal | 35c7b19 | 2021-04-20 16:51:10 -0700 | [diff] [blame] | 21 | import static com.android.launcher3.util.DisplayController.CHANGE_DENSITY; |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 22 | import static com.android.launcher3.util.DisplayController.CHANGE_SUPPORTED_BOUNDS; |
Sunny Goyal | 9c2b960 | 2020-01-07 13:07:55 -0800 | [diff] [blame] | 23 | import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 24 | |
Sunny Goyal | c620560 | 2015-05-21 20:46:33 -0700 | [diff] [blame] | 25 | import android.annotation.TargetApi; |
Sunny Goyal | 58fa4b6 | 2019-03-22 16:23:25 -0700 | [diff] [blame] | 26 | import android.appwidget.AppWidgetHostView; |
Sunny Goyal | 58fa4b6 | 2019-03-22 16:23:25 -0700 | [diff] [blame] | 27 | import android.content.ComponentName; |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 28 | import android.content.Context; |
Sunny Goyal | 2783595 | 2017-01-13 12:15:53 -0800 | [diff] [blame] | 29 | import android.content.res.Configuration; |
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; |
Sunny Goyal | 58fa4b6 | 2019-03-22 16:23:25 -0700 | [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; |
| 41 | import android.util.TypedValue; |
Sunny Goyal | 819e193 | 2016-07-07 16:43:58 -0700 | [diff] [blame] | 42 | import android.util.Xml; |
Sunny Goyal | 9c2b960 | 2020-01-07 13:07:55 -0800 | [diff] [blame] | 43 | import android.view.Display; |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 44 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 45 | import androidx.annotation.IntDef; |
Sunny Goyal | 6fe3eec | 2019-08-15 14:53:41 -0700 | [diff] [blame] | 46 | import androidx.annotation.Nullable; |
| 47 | import androidx.annotation.VisibleForTesting; |
| 48 | |
Sunny Goyal | 68031ca | 2021-08-02 12:23:44 -0700 | [diff] [blame] | 49 | import com.android.launcher3.model.DeviceGridState; |
Alex Chau | 238aaee | 2021-10-06 16:15:24 +0100 | [diff] [blame] | 50 | import com.android.launcher3.provider.RestoreDbTask; |
Sunny Goyal | fd58da6 | 2020-08-11 12:06:49 -0700 | [diff] [blame] | 51 | import com.android.launcher3.util.DisplayController; |
| 52 | import com.android.launcher3.util.DisplayController.Info; |
Sunny Goyal | 5bc1846 | 2019-01-07 15:13:39 -0800 | [diff] [blame] | 53 | import com.android.launcher3.util.IntArray; |
Sunny Goyal | d0e360a | 2018-06-29 14:40:18 -0700 | [diff] [blame] | 54 | import com.android.launcher3.util.MainThreadInitializedObject; |
Sunny Goyal | 5bc1846 | 2019-01-07 15:13:39 -0800 | [diff] [blame] | 55 | import com.android.launcher3.util.Themes; |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 56 | import com.android.launcher3.util.WindowBounds; |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 57 | |
Sunny Goyal | 819e193 | 2016-07-07 16:43:58 -0700 | [diff] [blame] | 58 | import org.xmlpull.v1.XmlPullParser; |
| 59 | import org.xmlpull.v1.XmlPullParserException; |
| 60 | |
| 61 | import java.io.IOException; |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 62 | import java.lang.annotation.Retention; |
| 63 | import java.lang.annotation.RetentionPolicy; |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 64 | import java.util.ArrayList; |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 65 | import java.util.Arrays; |
Sunny Goyal | 6d55f66 | 2019-01-02 12:13:43 -0800 | [diff] [blame] | 66 | import java.util.Collections; |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 67 | import java.util.List; |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 68 | |
| 69 | public class InvariantDeviceProfile { |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 70 | |
Hyunyoung Song | c55a350 | 2018-12-04 15:43:16 -0800 | [diff] [blame] | 71 | public static final String TAG = "IDP"; |
Sunny Goyal | d0e360a | 2018-06-29 14:40:18 -0700 | [diff] [blame] | 72 | // We do not need any synchronization for this variable as its only written on UI thread. |
| 73 | public static final MainThreadInitializedObject<InvariantDeviceProfile> INSTANCE = |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 74 | new MainThreadInitializedObject<>(InvariantDeviceProfile::new); |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 75 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 76 | @Retention(RetentionPolicy.SOURCE) |
| 77 | @IntDef({TYPE_PHONE, TYPE_MULTI_DISPLAY, TYPE_TABLET}) |
| 78 | public @interface DeviceType{} |
| 79 | public static final int TYPE_PHONE = 0; |
| 80 | public static final int TYPE_MULTI_DISPLAY = 1; |
| 81 | public static final int TYPE_TABLET = 2; |
| 82 | |
Hyunyoung Song | c55a350 | 2018-12-04 15:43:16 -0800 | [diff] [blame] | 83 | private static final String KEY_IDP_GRID_NAME = "idp_grid_name"; |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 84 | |
Sunny Goyal | 53d7ee4 | 2015-05-22 12:25:45 -0700 | [diff] [blame] | 85 | private static final float ICON_SIZE_DEFINED_IN_APP_DP = 48; |
| 86 | |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 87 | // Constants that affects the interpolation curve between statically defined device profile |
| 88 | // buckets. |
Hyunyoung Song | c55a350 | 2018-12-04 15:43:16 -0800 | [diff] [blame] | 89 | private static final float KNEARESTNEIGHBOR = 3; |
| 90 | private static final float WEIGHT_POWER = 5; |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 91 | |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 92 | // 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] | 93 | private static final float WEIGHT_EFFICIENT = 100000f; |
| 94 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 95 | // Used for arrays to specify different sizes (e.g. border spaces, width/height) in different |
| 96 | // constraints |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 97 | static final int COUNT_SIZES = 4; |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 98 | static final int INDEX_DEFAULT = 0; |
| 99 | static final int INDEX_LANDSCAPE = 1; |
| 100 | static final int INDEX_TWO_PANEL_PORTRAIT = 2; |
| 101 | static final int INDEX_TWO_PANEL_LANDSCAPE = 3; |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 102 | |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 103 | /** |
| 104 | * Number of icons per row and column in the workspace. |
| 105 | */ |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 106 | public int numRows; |
| 107 | public int numColumns; |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 108 | |
| 109 | /** |
| 110 | * Number of icons per row and column in the folder. |
| 111 | */ |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 112 | public int numFolderRows; |
| 113 | public int numFolderColumns; |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 114 | public float[] iconSize; |
| 115 | public float[] iconTextSize; |
Sunny Goyal | fc21830 | 2015-09-17 14:59:10 -0700 | [diff] [blame] | 116 | public int iconBitmapSize; |
| 117 | public int fillResIconDpi; |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 118 | public @DeviceType int deviceType; |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 119 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 120 | public PointF[] minCellSize; |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 121 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 122 | public PointF[] borderSpaces; |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 123 | public float folderBorderSpace; |
Thales Lima | 6e7f36c | 2022-01-04 12:14:11 +0000 | [diff] [blame] | 124 | public float[] hotseatBorderSpaces; |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 125 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 126 | public float[] horizontalMargin; |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 127 | |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 128 | public float[] allAppsIconSize; |
| 129 | public float[] allAppsIconTextSize; |
| 130 | public PointF[] allAppsBorderSpaces; |
| 131 | |
Sunny Goyal | 5bc1846 | 2019-01-07 15:13:39 -0800 | [diff] [blame] | 132 | private SparseArray<TypedValue> mExtraAttrs; |
| 133 | |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 134 | /** |
| 135 | * Number of icons inside the hotseat area. |
| 136 | */ |
Tony Wickham | b87f3cd | 2021-04-07 15:02:37 -0700 | [diff] [blame] | 137 | protected int numShownHotseatIcons; |
| 138 | |
| 139 | /** |
| 140 | * Number of icons inside the hotseat area that is stored in the database. This is greater than |
| 141 | * or equal to numnShownHotseatIcons, allowing for a seamless transition between two hotseat |
| 142 | * sizes that share the same DB. |
| 143 | */ |
| 144 | public int numDatabaseHotseatIcons; |
Adam Cohen | 2782449 | 2017-09-22 17:10:55 -0700 | [diff] [blame] | 145 | |
Jon Miranda | 6f7e970 | 2019-09-16 14:44:14 -0700 | [diff] [blame] | 146 | /** |
| 147 | * Number of columns in the all apps list. |
| 148 | */ |
| 149 | public int numAllAppsColumns; |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 150 | public int numDatabaseAllAppsColumns; |
Jon Miranda | 6f7e970 | 2019-09-16 14:44:14 -0700 | [diff] [blame] | 151 | |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 152 | /** |
| 153 | * Do not query directly. see {@link DeviceProfile#isScalableGrid}. |
| 154 | */ |
| 155 | protected boolean isScalable; |
Jon Miranda | c9e69fa | 2021-03-22 17:13:34 -0400 | [diff] [blame] | 156 | public int devicePaddingId; |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 157 | |
Tracy Zhou | 7df93d2 | 2020-01-27 13:44:06 -0800 | [diff] [blame] | 158 | public String dbFile; |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 159 | public int defaultLayoutId; |
Adam Cohen | 2782449 | 2017-09-22 17:10:55 -0700 | [diff] [blame] | 160 | int demoModeLayoutId; |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 161 | |
Pinyao Ting | 9cd63c9 | 2021-06-16 17:51:39 +0000 | [diff] [blame] | 162 | /** |
| 163 | * An immutable list of supported profiles. |
| 164 | */ |
| 165 | public List<DeviceProfile> supportedProfiles = Collections.EMPTY_LIST; |
Sunny Goyal | c620560 | 2015-05-21 20:46:33 -0700 | [diff] [blame] | 166 | |
sfufa@google.com | de01329 | 2021-09-21 18:22:44 -0700 | [diff] [blame] | 167 | @Nullable |
| 168 | public DevicePaddings devicePaddings; |
Jon Miranda | 228877d | 2021-02-09 11:05:00 -0500 | [diff] [blame] | 169 | |
Sunny Goyal | 6f86609 | 2016-03-17 17:04:15 -0700 | [diff] [blame] | 170 | public Point defaultWallpaperSize; |
Sunny Goyal | 58fa4b6 | 2019-03-22 16:23:25 -0700 | [diff] [blame] | 171 | public Rect defaultWidgetPadding; |
Sunny Goyal | 6f86609 | 2016-03-17 17:04:15 -0700 | [diff] [blame] | 172 | |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 173 | private final ArrayList<OnIDPChangeListener> mChangeListeners = new ArrayList<>(); |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 174 | |
Sunny Goyal | f633ef5 | 2018-03-13 09:57:05 -0700 | [diff] [blame] | 175 | @VisibleForTesting |
sfufa@google.com | de01329 | 2021-09-21 18:22:44 -0700 | [diff] [blame] | 176 | public InvariantDeviceProfile() { |
| 177 | } |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 178 | |
Sunny Goyal | bbf0184 | 2015-10-08 07:41:15 -0700 | [diff] [blame] | 179 | @TargetApi(23) |
Sunny Goyal | d0e360a | 2018-06-29 14:40:18 -0700 | [diff] [blame] | 180 | private InvariantDeviceProfile(Context context) { |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 181 | String gridName = getCurrentGridName(context); |
| 182 | String newGridName = initGrid(context, gridName); |
| 183 | if (!newGridName.equals(gridName)) { |
| 184 | Utilities.getPrefs(context).edit().putString(KEY_IDP_GRID_NAME, newGridName).apply(); |
| 185 | } |
Sunny Goyal | 68031ca | 2021-08-02 12:23:44 -0700 | [diff] [blame] | 186 | new DeviceGridState(this).writeToPrefs(context); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 187 | |
Tracy Zhou | c8beebf | 2021-09-23 10:18:11 -0700 | [diff] [blame] | 188 | DisplayController.INSTANCE.get(context).setPriorityListener( |
Alex Chau | fd6d942 | 2021-04-22 19:10:21 +0100 | [diff] [blame] | 189 | (displayContext, info, flags) -> { |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 190 | if ((flags & (CHANGE_DENSITY | CHANGE_SUPPORTED_BOUNDS)) != 0) { |
Alex Chau | fd6d942 | 2021-04-22 19:10:21 +0100 | [diff] [blame] | 191 | onConfigChanged(displayContext); |
Sunny Goyal | 35c7b19 | 2021-04-20 16:51:10 -0700 | [diff] [blame] | 192 | } |
| 193 | }); |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 194 | } |
| 195 | |
Hyunyoung Song | e11eb47 | 2019-03-19 15:05:21 -0700 | [diff] [blame] | 196 | /** |
| 197 | * This constructor should NOT have any monitors by design. |
| 198 | */ |
Sunny Goyal | eff44f3 | 2019-01-09 17:29:49 -0800 | [diff] [blame] | 199 | public InvariantDeviceProfile(Context context, String gridName) { |
| 200 | String newName = initGrid(context, gridName); |
| 201 | if (newName == null || !newName.equals(gridName)) { |
| 202 | throw new IllegalArgumentException("Unknown grid name"); |
| 203 | } |
| 204 | } |
| 205 | |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 206 | /** |
Sunny Goyal | 9c2b960 | 2020-01-07 13:07:55 -0800 | [diff] [blame] | 207 | * This constructor should NOT have any monitors by design. |
| 208 | */ |
| 209 | public InvariantDeviceProfile(Context context, Display display) { |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 210 | // Ensure that the main device profile is initialized |
Alex Chau | fd6d942 | 2021-04-22 19:10:21 +0100 | [diff] [blame] | 211 | INSTANCE.get(context); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 212 | String gridName = getCurrentGridName(context); |
| 213 | |
| 214 | // 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] | 215 | Info defaultInfo = DisplayController.INSTANCE.get(context).getInfo(); |
| 216 | @DeviceType int defaultDeviceType = getDeviceType(defaultInfo); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 217 | DisplayOption defaultDisplayOption = invDistWeightedInterpolate( |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 218 | defaultInfo, |
| 219 | getPredefinedDeviceProfiles(context, gridName, defaultDeviceType, |
| 220 | /*allowDisabledGrid=*/false), |
| 221 | defaultDeviceType); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 222 | |
Alex Chau | 417bd72 | 2021-01-26 15:22:18 +0000 | [diff] [blame] | 223 | Info myInfo = new Info(context, display); |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 224 | @DeviceType int deviceType = getDeviceType(myInfo); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 225 | DisplayOption myDisplayOption = invDistWeightedInterpolate( |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 226 | myInfo, |
| 227 | getPredefinedDeviceProfiles(context, gridName, deviceType, |
| 228 | /*allowDisabledGrid=*/false), |
| 229 | deviceType); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 230 | |
| 231 | DisplayOption result = new DisplayOption(defaultDisplayOption.grid) |
| 232 | .add(myDisplayOption); |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 233 | result.iconSizes[INDEX_DEFAULT] = |
| 234 | defaultDisplayOption.iconSizes[INDEX_DEFAULT]; |
| 235 | for (int i = 1; i < COUNT_SIZES; i++) { |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 236 | result.iconSizes[i] = Math.min( |
| 237 | defaultDisplayOption.iconSizes[i], myDisplayOption.iconSizes[i]); |
Alex Chau | 7c43972 | 2021-03-24 11:32:44 +0000 | [diff] [blame] | 238 | } |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 239 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 240 | System.arraycopy(defaultDisplayOption.minCellSize, 0, result.minCellSize, 0, |
| 241 | COUNT_SIZES); |
| 242 | System.arraycopy(defaultDisplayOption.borderSpaces, 0, result.borderSpaces, 0, |
| 243 | COUNT_SIZES); |
Jon Miranda | 228877d | 2021-02-09 11:05:00 -0500 | [diff] [blame] | 244 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 245 | initGrid(context, myInfo, result, deviceType); |
Sunny Goyal | 9c2b960 | 2020-01-07 13:07:55 -0800 | [diff] [blame] | 246 | } |
| 247 | |
Alex Chau | 238aaee | 2021-10-06 16:15:24 +0100 | [diff] [blame] | 248 | /** |
| 249 | * Reinitialize the current grid after a restore, where some grids might now be disabled. |
| 250 | */ |
| 251 | public void reinitializeAfterRestore(Context context) { |
| 252 | String currentDbFile = dbFile; |
| 253 | String gridName = getCurrentGridName(context); |
| 254 | String newGridName = initGrid(context, gridName); |
| 255 | if (!newGridName.equals(gridName)) { |
| 256 | Log.d(TAG, "Restored grid is disabled : " + gridName |
| 257 | + ", migrating to: " + newGridName |
| 258 | + ", removing all other grid db files"); |
| 259 | for (String gridDbFile : LauncherFiles.GRID_DB_FILES) { |
| 260 | if (gridDbFile.equals(currentDbFile)) { |
| 261 | continue; |
| 262 | } |
| 263 | if (context.getDatabasePath(gridDbFile).delete()) { |
| 264 | Log.d(TAG, "Removed old grid db file: " + gridDbFile); |
| 265 | } |
| 266 | } |
| 267 | setCurrentGrid(context, gridName); |
| 268 | } |
| 269 | } |
| 270 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 271 | private static @DeviceType int getDeviceType(Info displayInfo) { |
| 272 | // Each screen has two profiles (portrait/landscape), so devices with four or more |
| 273 | // supported profiles implies two or more internal displays. |
| 274 | if (displayInfo.supportedBounds.size() >= 4 && ENABLE_TWO_PANEL_HOME.get()) { |
| 275 | return TYPE_MULTI_DISPLAY; |
| 276 | } else if (displayInfo.supportedBounds.stream().allMatch(displayInfo::isTablet)) { |
| 277 | return TYPE_TABLET; |
| 278 | } else { |
| 279 | return TYPE_PHONE; |
| 280 | } |
| 281 | } |
| 282 | |
Tracy Zhou | 42255d2 | 2020-03-13 00:38:11 -0700 | [diff] [blame] | 283 | public static String getCurrentGridName(Context context) { |
Tracy Zhou | c6060e6 | 2020-04-27 13:05:34 -0700 | [diff] [blame] | 284 | return Utilities.isGridOptionsEnabled(context) |
| 285 | ? Utilities.getPrefs(context).getString(KEY_IDP_GRID_NAME, null) : null; |
Tracy Zhou | 42255d2 | 2020-03-13 00:38:11 -0700 | [diff] [blame] | 286 | } |
| 287 | |
Sunny Goyal | eff44f3 | 2019-01-09 17:29:49 -0800 | [diff] [blame] | 288 | private String initGrid(Context context, String gridName) { |
Sunny Goyal | 35c7b19 | 2021-04-20 16:51:10 -0700 | [diff] [blame] | 289 | Info displayInfo = DisplayController.INSTANCE.get(context).getInfo(); |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 290 | @DeviceType int deviceType = getDeviceType(displayInfo); |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 291 | |
| 292 | ArrayList<DisplayOption> allOptions = |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 293 | getPredefinedDeviceProfiles(context, gridName, deviceType, |
Alex Chau | 238aaee | 2021-10-06 16:15:24 +0100 | [diff] [blame] | 294 | RestoreDbTask.isPending(context)); |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 295 | DisplayOption displayOption = |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 296 | invDistWeightedInterpolate(displayInfo, allOptions, deviceType); |
| 297 | initGrid(context, displayInfo, displayOption, deviceType); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 298 | return displayOption.grid.name; |
Sunny Goyal | 9c2b960 | 2020-01-07 13:07:55 -0800 | [diff] [blame] | 299 | } |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 300 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 301 | private void initGrid(Context context, Info displayInfo, DisplayOption displayOption, |
| 302 | @DeviceType int deviceType) { |
Sunny Goyal | 35c7b19 | 2021-04-20 16:51:10 -0700 | [diff] [blame] | 303 | DisplayMetrics metrics = context.getResources().getDisplayMetrics(); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 304 | GridOption closestProfile = displayOption.grid; |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 305 | numRows = closestProfile.numRows; |
| 306 | numColumns = closestProfile.numColumns; |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 307 | dbFile = closestProfile.dbFile; |
| 308 | defaultLayoutId = closestProfile.defaultLayoutId; |
| 309 | demoModeLayoutId = closestProfile.demoModeLayoutId; |
| 310 | numFolderRows = closestProfile.numFolderRows; |
| 311 | numFolderColumns = closestProfile.numFolderColumns; |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 312 | isScalable = closestProfile.isScalable; |
Jon Miranda | c9e69fa | 2021-03-22 17:13:34 -0400 | [diff] [blame] | 313 | devicePaddingId = closestProfile.devicePaddingId; |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 314 | this.deviceType = deviceType; |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 315 | |
| 316 | mExtraAttrs = closestProfile.extraAttrs; |
| 317 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 318 | iconSize = displayOption.iconSizes; |
Thales Lima | 6e0005a | 2021-10-27 15:53:41 +0100 | [diff] [blame] | 319 | float maxIconSize = iconSize[0]; |
| 320 | for (int i = 1; i < iconSize.length; i++) { |
| 321 | maxIconSize = Math.max(maxIconSize, iconSize[i]); |
| 322 | } |
| 323 | iconBitmapSize = ResourceUtils.pxFromDp(maxIconSize, metrics); |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 324 | fillResIconDpi = getLauncherIconDensity(iconBitmapSize); |
| 325 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 326 | iconTextSize = displayOption.textSizes; |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 327 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 328 | minCellSize = displayOption.minCellSize; |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 329 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 330 | borderSpaces = displayOption.borderSpaces; |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 331 | folderBorderSpace = displayOption.folderBorderSpace; |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 332 | |
Thales Lima | d90faab | 2021-09-21 17:18:47 +0100 | [diff] [blame] | 333 | horizontalMargin = displayOption.horizontalMargin; |
Thales Lima | d90faab | 2021-09-21 17:18:47 +0100 | [diff] [blame] | 334 | |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 335 | numShownHotseatIcons = closestProfile.numHotseatIcons; |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 336 | numDatabaseHotseatIcons = deviceType == TYPE_MULTI_DISPLAY |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 337 | ? closestProfile.numDatabaseHotseatIcons : closestProfile.numHotseatIcons; |
Thales Lima | 6e7f36c | 2022-01-04 12:14:11 +0000 | [diff] [blame] | 338 | hotseatBorderSpaces = displayOption.hotseatBorderSpaces; |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 339 | |
| 340 | numAllAppsColumns = closestProfile.numAllAppsColumns; |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 341 | numDatabaseAllAppsColumns = deviceType == TYPE_MULTI_DISPLAY |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 342 | ? closestProfile.numDatabaseAllAppsColumns : closestProfile.numAllAppsColumns; |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 343 | |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 344 | allAppsBorderSpaces = displayOption.allAppsBorderSpaces; |
| 345 | allAppsIconSize = displayOption.allAppsIconSizes; |
| 346 | allAppsIconTextSize = displayOption.allAppsIconTextSizes; |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 347 | if (!Utilities.isGridOptionsEnabled(context)) { |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 348 | allAppsIconSize = iconSize; |
| 349 | allAppsIconTextSize = iconTextSize; |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 350 | } |
| 351 | |
Jon Miranda | c9e69fa | 2021-03-22 17:13:34 -0400 | [diff] [blame] | 352 | if (devicePaddingId != 0) { |
| 353 | devicePaddings = new DevicePaddings(context, devicePaddingId); |
| 354 | } |
| 355 | |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 356 | // If the partner customization apk contains any grid overrides, apply them |
| 357 | // Supported overrides: numRows, numColumns, iconSize |
Sunny Goyal | 35c7b19 | 2021-04-20 16:51:10 -0700 | [diff] [blame] | 358 | applyPartnerDeviceProfileOverrides(context, metrics); |
Sunny Goyal | c620560 | 2015-05-21 20:46:33 -0700 | [diff] [blame] | 359 | |
Pinyao Ting | 9cd63c9 | 2021-06-16 17:51:39 +0000 | [diff] [blame] | 360 | final List<DeviceProfile> localSupportedProfiles = new ArrayList<>(); |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 361 | defaultWallpaperSize = new Point(displayInfo.currentSize); |
| 362 | for (WindowBounds bounds : displayInfo.supportedBounds) { |
Pinyao Ting | 9cd63c9 | 2021-06-16 17:51:39 +0000 | [diff] [blame] | 363 | localSupportedProfiles.add(new DeviceProfile.Builder(context, this, displayInfo) |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 364 | .setUseTwoPanels(deviceType == TYPE_MULTI_DISPLAY) |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 365 | .setWindowBounds(bounds).build()); |
Sunny Goyal | c620560 | 2015-05-21 20:46:33 -0700 | [diff] [blame] | 366 | |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 367 | // Wallpaper size should be the maximum of the all possible sizes Launcher expects |
| 368 | int displayWidth = bounds.bounds.width(); |
| 369 | int displayHeight = bounds.bounds.height(); |
| 370 | defaultWallpaperSize.y = Math.max(defaultWallpaperSize.y, displayHeight); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 371 | |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 372 | // We need to ensure that there is enough extra space in the wallpaper |
| 373 | // for the intended parallax effects |
| 374 | float parallaxFactor = |
| 375 | dpiFromPx(Math.min(displayWidth, displayHeight), displayInfo.densityDpi) < 720 |
| 376 | ? 2 |
| 377 | : wallpaperTravelToScreenWidthRatio(displayWidth, displayHeight); |
| 378 | defaultWallpaperSize.x = |
| 379 | Math.max(defaultWallpaperSize.x, Math.round(parallaxFactor * displayWidth)); |
Sunny Goyal | 6f86609 | 2016-03-17 17:04:15 -0700 | [diff] [blame] | 380 | } |
Pinyao Ting | 9cd63c9 | 2021-06-16 17:51:39 +0000 | [diff] [blame] | 381 | supportedProfiles = Collections.unmodifiableList(localSupportedProfiles); |
Sunny Goyal | 58fa4b6 | 2019-03-22 16:23:25 -0700 | [diff] [blame] | 382 | |
| 383 | ComponentName cn = new ComponentName(context.getPackageName(), getClass().getName()); |
| 384 | defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null); |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 385 | } |
| 386 | |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 387 | public void addOnChangeListener(OnIDPChangeListener listener) { |
| 388 | mChangeListeners.add(listener); |
| 389 | } |
| 390 | |
Hyunyoung Song | b4d1ca4 | 2019-01-08 17:15:16 -0800 | [diff] [blame] | 391 | public void removeOnChangeListener(OnIDPChangeListener listener) { |
| 392 | mChangeListeners.remove(listener); |
| 393 | } |
| 394 | |
Hyunyoung Song | c55a350 | 2018-12-04 15:43:16 -0800 | [diff] [blame] | 395 | |
Sunny Goyal | 7d892ff | 2019-01-11 15:08:44 -0800 | [diff] [blame] | 396 | public void setCurrentGrid(Context context, String gridName) { |
| 397 | Context appContext = context.getApplicationContext(); |
| 398 | Utilities.getPrefs(appContext).edit().putString(KEY_IDP_GRID_NAME, gridName).apply(); |
Sunny Goyal | 6fe3eec | 2019-08-15 14:53:41 -0700 | [diff] [blame] | 399 | MAIN_EXECUTOR.execute(() -> onConfigChanged(appContext)); |
Sunny Goyal | 7d892ff | 2019-01-11 15:08:44 -0800 | [diff] [blame] | 400 | } |
| 401 | |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 402 | private Object[] toModelState() { |
sfufa@google.com | de01329 | 2021-09-21 18:22:44 -0700 | [diff] [blame] | 403 | return new Object[]{ |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 404 | numColumns, numRows, numDatabaseHotseatIcons, iconBitmapSize, fillResIconDpi, |
| 405 | numDatabaseAllAppsColumns, dbFile}; |
| 406 | } |
| 407 | |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 408 | private void onConfigChanged(Context context) { |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 409 | Object[] oldState = toModelState(); |
| 410 | |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 411 | // Re-init grid |
Tracy Zhou | c6060e6 | 2020-04-27 13:05:34 -0700 | [diff] [blame] | 412 | String gridName = getCurrentGridName(context); |
Jon Miranda | 6f7e970 | 2019-09-16 14:44:14 -0700 | [diff] [blame] | 413 | initGrid(context, gridName); |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 414 | |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 415 | boolean modelPropsChanged = !Arrays.equals(oldState, toModelState()); |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 416 | for (OnIDPChangeListener listener : mChangeListeners) { |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 417 | listener.onIdpChanged(modelPropsChanged); |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 418 | } |
| 419 | } |
| 420 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 421 | private static ArrayList<DisplayOption> getPredefinedDeviceProfiles(Context context, |
| 422 | String gridName, @DeviceType int deviceType, boolean allowDisabledGrid) { |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 423 | ArrayList<DisplayOption> profiles = new ArrayList<>(); |
Thales Lima | 1de4d55 | 2021-10-13 16:13:25 +0100 | [diff] [blame] | 424 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 425 | try (XmlResourceParser parser = context.getResources().getXml(R.xml.device_profiles)) { |
Sunny Goyal | 819e193 | 2016-07-07 16:43:58 -0700 | [diff] [blame] | 426 | final int depth = parser.getDepth(); |
| 427 | int type; |
Sunny Goyal | 819e193 | 2016-07-07 16:43:58 -0700 | [diff] [blame] | 428 | while (((type = parser.next()) != XmlPullParser.END_TAG || |
| 429 | parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) { |
Sunny Goyal | 7d892ff | 2019-01-11 15:08:44 -0800 | [diff] [blame] | 430 | if ((type == XmlPullParser.START_TAG) |
| 431 | && GridOption.TAG_NAME.equals(parser.getName())) { |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 432 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 433 | GridOption gridOption = new GridOption(context, Xml.asAttributeSet(parser), |
| 434 | deviceType); |
Alex Chau | 238aaee | 2021-10-06 16:15:24 +0100 | [diff] [blame] | 435 | if (gridOption.isEnabled || allowDisabledGrid) { |
Thales Lima | 7ec8382 | 2021-08-05 13:32:10 +0100 | [diff] [blame] | 436 | final int displayDepth = parser.getDepth(); |
| 437 | while (((type = parser.next()) != XmlPullParser.END_TAG |
| 438 | || parser.getDepth() > displayDepth) |
| 439 | && type != XmlPullParser.END_DOCUMENT) { |
| 440 | if ((type == XmlPullParser.START_TAG) && "display-option".equals( |
| 441 | parser.getName())) { |
| 442 | profiles.add(new DisplayOption(gridOption, context, |
Thales Lima | 1de4d55 | 2021-10-13 16:13:25 +0100 | [diff] [blame] | 443 | Xml.asAttributeSet(parser))); |
Thales Lima | 7ec8382 | 2021-08-05 13:32:10 +0100 | [diff] [blame] | 444 | } |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 445 | } |
| 446 | } |
Sunny Goyal | 819e193 | 2016-07-07 16:43:58 -0700 | [diff] [blame] | 447 | } |
| 448 | } |
sfufa@google.com | de01329 | 2021-09-21 18:22:44 -0700 | [diff] [blame] | 449 | } catch (IOException | XmlPullParserException e) { |
Sunny Goyal | 819e193 | 2016-07-07 16:43:58 -0700 | [diff] [blame] | 450 | throw new RuntimeException(e); |
| 451 | } |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 452 | |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 453 | ArrayList<DisplayOption> filteredProfiles = new ArrayList<>(); |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 454 | if (!TextUtils.isEmpty(gridName)) { |
| 455 | for (DisplayOption option : profiles) { |
Alex Chau | 238aaee | 2021-10-06 16:15:24 +0100 | [diff] [blame] | 456 | if (gridName.equals(option.grid.name) |
| 457 | && (option.grid.isEnabled || allowDisabledGrid)) { |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 458 | filteredProfiles.add(option); |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 459 | } |
| 460 | } |
| 461 | } |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 462 | if (filteredProfiles.isEmpty()) { |
| 463 | // No grid found, use the default options |
| 464 | for (DisplayOption option : profiles) { |
| 465 | if (option.canBeDefault) { |
| 466 | filteredProfiles.add(option); |
| 467 | } |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 468 | } |
| 469 | } |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 470 | if (filteredProfiles.isEmpty()) { |
| 471 | throw new RuntimeException("No display option with canBeDefault=true"); |
| 472 | } |
| 473 | return filteredProfiles; |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 474 | } |
| 475 | |
Thales Lima | 7ec8382 | 2021-08-05 13:32:10 +0100 | [diff] [blame] | 476 | /** |
| 477 | * @return all the grid options that can be shown on the device |
| 478 | */ |
| 479 | public List<GridOption> parseAllGridOptions(Context context) { |
| 480 | List<GridOption> result = new ArrayList<>(); |
Thales Lima | 1de4d55 | 2021-10-13 16:13:25 +0100 | [diff] [blame] | 481 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 482 | try (XmlResourceParser parser = context.getResources().getXml(R.xml.device_profiles)) { |
Thales Lima | 7ec8382 | 2021-08-05 13:32:10 +0100 | [diff] [blame] | 483 | final int depth = parser.getDepth(); |
| 484 | int type; |
| 485 | while (((type = parser.next()) != XmlPullParser.END_TAG |
| 486 | || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) { |
| 487 | if ((type == XmlPullParser.START_TAG) |
| 488 | && GridOption.TAG_NAME.equals(parser.getName())) { |
| 489 | GridOption option = |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 490 | new GridOption(context, Xml.asAttributeSet(parser), deviceType); |
Thales Lima | 7ec8382 | 2021-08-05 13:32:10 +0100 | [diff] [blame] | 491 | if (option.isEnabled) { |
| 492 | result.add(option); |
| 493 | } |
| 494 | } |
| 495 | } |
| 496 | } catch (IOException | XmlPullParserException e) { |
| 497 | Log.e(TAG, "Error parsing device profile", e); |
| 498 | return Collections.emptyList(); |
| 499 | } |
| 500 | return result; |
| 501 | } |
| 502 | |
Sunny Goyal | 53d7ee4 | 2015-05-22 12:25:45 -0700 | [diff] [blame] | 503 | private int getLauncherIconDensity(int requiredSize) { |
| 504 | // Densities typically defined by an app. |
sfufa@google.com | de01329 | 2021-09-21 18:22:44 -0700 | [diff] [blame] | 505 | int[] densityBuckets = new int[]{ |
Sunny Goyal | 53d7ee4 | 2015-05-22 12:25:45 -0700 | [diff] [blame] | 506 | DisplayMetrics.DENSITY_LOW, |
| 507 | DisplayMetrics.DENSITY_MEDIUM, |
| 508 | DisplayMetrics.DENSITY_TV, |
| 509 | DisplayMetrics.DENSITY_HIGH, |
| 510 | DisplayMetrics.DENSITY_XHIGH, |
| 511 | DisplayMetrics.DENSITY_XXHIGH, |
| 512 | DisplayMetrics.DENSITY_XXXHIGH |
| 513 | }; |
| 514 | |
| 515 | int density = DisplayMetrics.DENSITY_XXXHIGH; |
| 516 | for (int i = densityBuckets.length - 1; i >= 0; i--) { |
| 517 | float expectedSize = ICON_SIZE_DEFINED_IN_APP_DP * densityBuckets[i] |
| 518 | / DisplayMetrics.DENSITY_DEFAULT; |
| 519 | if (expectedSize >= requiredSize) { |
| 520 | density = densityBuckets[i]; |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | return density; |
| 525 | } |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 526 | |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 527 | /** |
| 528 | * Apply any Partner customization grid overrides. |
| 529 | * |
| 530 | * Currently we support: all apps row / column count. |
| 531 | */ |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 532 | private void applyPartnerDeviceProfileOverrides(Context context, DisplayMetrics dm) { |
| 533 | Partner p = Partner.get(context.getPackageManager()); |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 534 | if (p != null) { |
| 535 | p.applyInvariantDeviceProfileOverrides(this, dm); |
| 536 | } |
| 537 | } |
| 538 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 539 | private static float dist(float x0, float y0, float x1, float y1) { |
Hyunyoung Song | 35c3c7f | 2015-05-28 15:33:40 -0700 | [diff] [blame] | 540 | return (float) Math.hypot(x1 - x0, y1 - y0); |
Adam Cohen | 2e6da15 | 2015-05-06 11:42:25 -0700 | [diff] [blame] | 541 | } |
| 542 | |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 543 | private static DisplayOption invDistWeightedInterpolate( |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 544 | Info displayInfo, ArrayList<DisplayOption> points, @DeviceType int deviceType) { |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 545 | int minWidthPx = Integer.MAX_VALUE; |
| 546 | int minHeightPx = Integer.MAX_VALUE; |
| 547 | for (WindowBounds bounds : displayInfo.supportedBounds) { |
| 548 | boolean isTablet = displayInfo.isTablet(bounds); |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 549 | if (isTablet && deviceType == TYPE_MULTI_DISPLAY) { |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 550 | // For split displays, take half width per page |
| 551 | minWidthPx = Math.min(minWidthPx, bounds.availableSize.x / 2); |
| 552 | minHeightPx = Math.min(minHeightPx, bounds.availableSize.y); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 553 | |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 554 | } else if (!isTablet && bounds.isLandscape()) { |
| 555 | // We will use transposed layout in this case |
| 556 | minWidthPx = Math.min(minWidthPx, bounds.availableSize.y); |
| 557 | minHeightPx = Math.min(minHeightPx, bounds.availableSize.x); |
| 558 | } else { |
| 559 | minWidthPx = Math.min(minWidthPx, bounds.availableSize.x); |
| 560 | minHeightPx = Math.min(minHeightPx, bounds.availableSize.y); |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | float width = dpiFromPx(minWidthPx, displayInfo.densityDpi); |
| 565 | float height = dpiFromPx(minHeightPx, displayInfo.densityDpi); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 566 | |
| 567 | // Sort the profiles based on the closeness to the device size |
| 568 | Collections.sort(points, (a, b) -> |
| 569 | Float.compare(dist(width, height, a.minWidthDps, a.minHeightDps), |
| 570 | dist(width, height, b.minWidthDps, b.minHeightDps))); |
| 571 | |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 572 | DisplayOption closestPoint = points.get(0); |
| 573 | GridOption closestOption = closestPoint.grid; |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 574 | float weights = 0; |
| 575 | |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 576 | if (dist(width, height, closestPoint.minWidthDps, closestPoint.minHeightDps) == 0) { |
| 577 | return closestPoint; |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | DisplayOption out = new DisplayOption(closestOption); |
| 581 | for (int i = 0; i < points.size() && i < KNEARESTNEIGHBOR; ++i) { |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 582 | DisplayOption p = points.get(i); |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 583 | float w = weight(width, height, p.minWidthDps, p.minHeightDps, WEIGHT_POWER); |
| 584 | weights += w; |
| 585 | out.add(new DisplayOption().add(p).multiply(w)); |
| 586 | } |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 587 | out.multiply(1.0f / weights); |
| 588 | |
Thales Lima | 6e0005a | 2021-10-27 15:53:41 +0100 | [diff] [blame] | 589 | // 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] | 590 | // predefined size to avoid cache invalidation |
Thales Lima | 6e0005a | 2021-10-27 15:53:41 +0100 | [diff] [blame] | 591 | for (int i = INDEX_DEFAULT; i < COUNT_SIZES; i++) { |
| 592 | out.iconSizes[i] = Math.min(out.iconSizes[i], closestPoint.iconSizes[i]); |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | return out; |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 596 | } |
| 597 | |
Sunny Goyal | 2783595 | 2017-01-13 12:15:53 -0800 | [diff] [blame] | 598 | public DeviceProfile getDeviceProfile(Context context) { |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 599 | Resources res = context.getResources(); |
| 600 | Configuration config = context.getResources().getConfiguration(); |
| 601 | |
Sunny Goyal | 3e9a29c | 2021-09-07 15:53:09 -0400 | [diff] [blame] | 602 | float screenWidth = config.screenWidthDp * res.getDisplayMetrics().density; |
| 603 | float screenHeight = config.screenHeightDp * res.getDisplayMetrics().density; |
| 604 | return getBestMatch(screenWidth, screenHeight); |
| 605 | } |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 606 | |
Sunny Goyal | 3e9a29c | 2021-09-07 15:53:09 -0400 | [diff] [blame] | 607 | public DeviceProfile getBestMatch(float screenWidth, float screenHeight) { |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 608 | DeviceProfile bestMatch = supportedProfiles.get(0); |
| 609 | float minDiff = Float.MAX_VALUE; |
| 610 | |
| 611 | for (DeviceProfile profile : supportedProfiles) { |
Sunny Goyal | 3e9a29c | 2021-09-07 15:53:09 -0400 | [diff] [blame] | 612 | float diff = Math.abs(profile.widthPx - screenWidth) |
| 613 | + Math.abs(profile.heightPx - screenHeight); |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 614 | if (diff < minDiff) { |
| 615 | minDiff = diff; |
| 616 | bestMatch = profile; |
| 617 | } |
| 618 | } |
| 619 | return bestMatch; |
Sunny Goyal | 2783595 | 2017-01-13 12:15:53 -0800 | [diff] [blame] | 620 | } |
| 621 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 622 | 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] | 623 | float d = dist(x0, y0, x1, y1); |
| 624 | if (Float.compare(d, 0f) == 0) { |
| 625 | return Float.POSITIVE_INFINITY; |
| 626 | } |
| 627 | return (float) (WEIGHT_EFFICIENT / Math.pow(d, pow)); |
| 628 | } |
Sunny Goyal | 6f86609 | 2016-03-17 17:04:15 -0700 | [diff] [blame] | 629 | |
| 630 | /** |
| 631 | * As a ratio of screen height, the total distance we want the parallax effect to span |
| 632 | * horizontally |
| 633 | */ |
| 634 | private static float wallpaperTravelToScreenWidthRatio(int width, int height) { |
| 635 | float aspectRatio = width / (float) height; |
| 636 | |
| 637 | // At an aspect ratio of 16/10, the wallpaper parallax effect should span 1.5 * screen width |
| 638 | // At an aspect ratio of 10/16, the wallpaper parallax effect should span 1.2 * screen width |
| 639 | // We will use these two data points to extrapolate how much the wallpaper parallax effect |
| 640 | // to span (ie travel) at any aspect ratio: |
| 641 | |
sfufa@google.com | de01329 | 2021-09-21 18:22:44 -0700 | [diff] [blame] | 642 | final float ASPECT_RATIO_LANDSCAPE = 16 / 10f; |
| 643 | final float ASPECT_RATIO_PORTRAIT = 10 / 16f; |
Sunny Goyal | 6f86609 | 2016-03-17 17:04:15 -0700 | [diff] [blame] | 644 | final float WALLPAPER_WIDTH_TO_SCREEN_RATIO_LANDSCAPE = 1.5f; |
| 645 | final float WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT = 1.2f; |
| 646 | |
| 647 | // To find out the desired width at different aspect ratios, we use the following two |
| 648 | // formulas, where the coefficient on x is the aspect ratio (width/height): |
| 649 | // (16/10)x + y = 1.5 |
| 650 | // (10/16)x + y = 1.2 |
| 651 | // We solve for x and y and end up with a final formula: |
| 652 | final float x = |
sfufa@google.com | de01329 | 2021-09-21 18:22:44 -0700 | [diff] [blame] | 653 | (WALLPAPER_WIDTH_TO_SCREEN_RATIO_LANDSCAPE |
| 654 | - WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT) / |
Sunny Goyal | 6f86609 | 2016-03-17 17:04:15 -0700 | [diff] [blame] | 655 | (ASPECT_RATIO_LANDSCAPE - ASPECT_RATIO_PORTRAIT); |
| 656 | final float y = WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT - x * ASPECT_RATIO_PORTRAIT; |
| 657 | return x * aspectRatio + y; |
| 658 | } |
| 659 | |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 660 | public interface OnIDPChangeListener { |
| 661 | |
Sunny Goyal | b47172b | 2021-05-03 19:59:51 -0700 | [diff] [blame] | 662 | /** |
| 663 | * Called when the device provide changes |
| 664 | */ |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 665 | void onIdpChanged(boolean modelPropertiesChanged); |
Sunny Goyal | 87dc48b | 2018-10-12 11:42:33 -0700 | [diff] [blame] | 666 | } |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 667 | |
| 668 | |
Sunny Goyal | eff44f3 | 2019-01-09 17:29:49 -0800 | [diff] [blame] | 669 | public static final class GridOption { |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 670 | |
Sunny Goyal | 7d892ff | 2019-01-11 15:08:44 -0800 | [diff] [blame] | 671 | public static final String TAG_NAME = "grid-option"; |
| 672 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 673 | private static final int DEVICE_CATEGORY_PHONE = 1 << 0; |
| 674 | private static final int DEVICE_CATEGORY_TABLET = 1 << 1; |
| 675 | private static final int DEVICE_CATEGORY_MULTI_DISPLAY = 1 << 2; |
| 676 | private static final int DEVICE_CATEGORY_ALL = |
| 677 | DEVICE_CATEGORY_PHONE | DEVICE_CATEGORY_TABLET | DEVICE_CATEGORY_MULTI_DISPLAY; |
| 678 | |
Sunny Goyal | eff44f3 | 2019-01-09 17:29:49 -0800 | [diff] [blame] | 679 | public final String name; |
| 680 | public final int numRows; |
| 681 | public final int numColumns; |
Thales Lima | 7ec8382 | 2021-08-05 13:32:10 +0100 | [diff] [blame] | 682 | public final boolean isEnabled; |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 683 | |
| 684 | private final int numFolderRows; |
| 685 | private final int numFolderColumns; |
| 686 | |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 687 | private final int numAllAppsColumns; |
| 688 | private final int numDatabaseAllAppsColumns; |
| 689 | private final int numHotseatIcons; |
Tony Wickham | b87f3cd | 2021-04-07 15:02:37 -0700 | [diff] [blame] | 690 | private final int numDatabaseHotseatIcons; |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 691 | |
Tracy Zhou | 7df93d2 | 2020-01-27 13:44:06 -0800 | [diff] [blame] | 692 | private final String dbFile; |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 693 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 694 | private final int defaultLayoutId; |
| 695 | private final int demoModeLayoutId; |
| 696 | |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 697 | private final boolean isScalable; |
Jon Miranda | c9e69fa | 2021-03-22 17:13:34 -0400 | [diff] [blame] | 698 | private final int devicePaddingId; |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 699 | |
Sunny Goyal | 5bc1846 | 2019-01-07 15:13:39 -0800 | [diff] [blame] | 700 | private final SparseArray<TypedValue> extraAttrs; |
| 701 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 702 | public GridOption(Context context, AttributeSet attrs, @DeviceType int deviceType) { |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 703 | TypedArray a = context.obtainStyledAttributes( |
| 704 | attrs, R.styleable.GridDisplayOption); |
| 705 | name = a.getString(R.styleable.GridDisplayOption_name); |
| 706 | numRows = a.getInt(R.styleable.GridDisplayOption_numRows, 0); |
| 707 | numColumns = a.getInt(R.styleable.GridDisplayOption_numColumns, 0); |
| 708 | |
Tracy Zhou | 7df93d2 | 2020-01-27 13:44:06 -0800 | [diff] [blame] | 709 | dbFile = a.getString(R.styleable.GridDisplayOption_dbFile); |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 710 | defaultLayoutId = a.getResourceId(deviceType == TYPE_MULTI_DISPLAY && a.hasValue( |
Alex Chau | 1e44846 | 2021-08-13 21:48:35 +0100 | [diff] [blame] | 711 | R.styleable.GridDisplayOption_defaultSplitDisplayLayoutId) |
| 712 | ? R.styleable.GridDisplayOption_defaultSplitDisplayLayoutId |
| 713 | : R.styleable.GridDisplayOption_defaultLayoutId, 0); |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 714 | demoModeLayoutId = a.getResourceId( |
| 715 | R.styleable.GridDisplayOption_demoModeLayoutId, defaultLayoutId); |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 716 | |
| 717 | numAllAppsColumns = a.getInt( |
| 718 | R.styleable.GridDisplayOption_numAllAppsColumns, numColumns); |
| 719 | numDatabaseAllAppsColumns = a.getInt( |
| 720 | R.styleable.GridDisplayOption_numExtendedAllAppsColumns, 2 * numAllAppsColumns); |
| 721 | |
| 722 | numHotseatIcons = a.getInt( |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 723 | R.styleable.GridDisplayOption_numHotseatIcons, numColumns); |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 724 | numDatabaseHotseatIcons = a.getInt( |
| 725 | R.styleable.GridDisplayOption_numExtendedHotseatIcons, 2 * numHotseatIcons); |
| 726 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 727 | numFolderRows = a.getInt( |
| 728 | R.styleable.GridDisplayOption_numFolderRows, numRows); |
| 729 | numFolderColumns = a.getInt( |
| 730 | R.styleable.GridDisplayOption_numFolderColumns, numColumns); |
Jon Miranda | 6f7e970 | 2019-09-16 14:44:14 -0700 | [diff] [blame] | 731 | |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 732 | isScalable = a.getBoolean( |
| 733 | R.styleable.GridDisplayOption_isScalable, false); |
Jon Miranda | c9e69fa | 2021-03-22 17:13:34 -0400 | [diff] [blame] | 734 | devicePaddingId = a.getResourceId( |
| 735 | R.styleable.GridDisplayOption_devicePaddingId, 0); |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 736 | |
Alex Chau | 1c883d8 | 2021-12-01 18:43:10 +0000 | [diff] [blame] | 737 | int deviceCategory = a.getInt(R.styleable.GridDisplayOption_deviceCategory, |
| 738 | DEVICE_CATEGORY_ALL); |
| 739 | isEnabled = (deviceType == TYPE_PHONE |
| 740 | && ((deviceCategory & DEVICE_CATEGORY_PHONE) == DEVICE_CATEGORY_PHONE)) |
| 741 | || (deviceType == TYPE_TABLET |
| 742 | && ((deviceCategory & DEVICE_CATEGORY_TABLET) == DEVICE_CATEGORY_TABLET)) |
| 743 | || (deviceType == TYPE_MULTI_DISPLAY |
| 744 | && ((deviceCategory & DEVICE_CATEGORY_MULTI_DISPLAY) |
| 745 | == DEVICE_CATEGORY_MULTI_DISPLAY)); |
Thales Lima | 7ec8382 | 2021-08-05 13:32:10 +0100 | [diff] [blame] | 746 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 747 | a.recycle(); |
Sunny Goyal | 5bc1846 | 2019-01-07 15:13:39 -0800 | [diff] [blame] | 748 | extraAttrs = Themes.createValueMap(context, attrs, |
| 749 | IntArray.wrap(R.styleable.GridDisplayOption)); |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 750 | } |
| 751 | } |
| 752 | |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 753 | @VisibleForTesting |
| 754 | static final class DisplayOption { |
| 755 | |
| 756 | public final GridOption grid; |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 757 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 758 | private final float minWidthDps; |
| 759 | private final float minHeightDps; |
| 760 | private final boolean canBeDefault; |
| 761 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 762 | private final PointF[] minCellSize = new PointF[COUNT_SIZES]; |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 763 | |
| 764 | private float folderBorderSpace; |
| 765 | private final PointF[] borderSpaces = new PointF[COUNT_SIZES]; |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 766 | private final float[] horizontalMargin = new float[COUNT_SIZES]; |
Thales Lima | 6e7f36c | 2022-01-04 12:14:11 +0000 | [diff] [blame] | 767 | private final float[] hotseatBorderSpaces = new float[COUNT_SIZES]; |
Thales Lima | d90faab | 2021-09-21 17:18:47 +0100 | [diff] [blame] | 768 | |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 769 | private final float[] iconSizes = new float[COUNT_SIZES]; |
| 770 | private final float[] textSizes = new float[COUNT_SIZES]; |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 771 | |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 772 | private final float[] allAppsIconSizes = new float[COUNT_SIZES]; |
| 773 | private final float[] allAppsIconTextSizes = new float[COUNT_SIZES]; |
| 774 | private final PointF[] allAppsBorderSpaces = new PointF[COUNT_SIZES]; |
| 775 | |
Thales Lima | 1de4d55 | 2021-10-13 16:13:25 +0100 | [diff] [blame] | 776 | DisplayOption(GridOption grid, Context context, AttributeSet attrs) { |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 777 | this.grid = grid; |
| 778 | |
Thales Lima | 1de4d55 | 2021-10-13 16:13:25 +0100 | [diff] [blame] | 779 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProfileDisplayOption); |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 780 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 781 | minWidthDps = a.getFloat(R.styleable.ProfileDisplayOption_minWidthDps, 0); |
| 782 | minHeightDps = a.getFloat(R.styleable.ProfileDisplayOption_minHeightDps, 0); |
Sunny Goyal | 19ff728 | 2021-04-22 10:12:54 -0700 | [diff] [blame] | 783 | |
Thales Lima | 1de4d55 | 2021-10-13 16:13:25 +0100 | [diff] [blame] | 784 | canBeDefault = a.getBoolean(R.styleable.ProfileDisplayOption_canBeDefault, false); |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 785 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 786 | float x; |
| 787 | float y; |
| 788 | |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 789 | x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidth, 0); |
| 790 | y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeight, 0); |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 791 | minCellSize[INDEX_DEFAULT] = new PointF(x, y); |
| 792 | minCellSize[INDEX_LANDSCAPE] = new PointF(x, y); |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 793 | |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 794 | x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidthTwoPanelPortrait, |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 795 | minCellSize[INDEX_DEFAULT].x); |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 796 | y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeightTwoPanelPortrait, |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 797 | minCellSize[INDEX_DEFAULT].y); |
| 798 | minCellSize[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y); |
| 799 | |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 800 | x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidthTwoPanelLandscape, |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 801 | minCellSize[INDEX_DEFAULT].x); |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 802 | y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeightTwoPanelLandscape, |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 803 | minCellSize[INDEX_DEFAULT].y); |
| 804 | minCellSize[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y); |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 805 | |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 806 | float borderSpace = a.getFloat(R.styleable.ProfileDisplayOption_borderSpace, 0); |
| 807 | float borderSpaceTwoPanelPortrait = a.getFloat( |
| 808 | R.styleable.ProfileDisplayOption_borderSpaceTwoPanelPortrait, borderSpace); |
| 809 | float borderSpaceTwoPanelLandscape = a.getFloat( |
| 810 | R.styleable.ProfileDisplayOption_borderSpaceTwoPanelLandscape, borderSpace); |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 811 | |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 812 | x = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceHorizontal, borderSpace); |
| 813 | y = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceVertical, borderSpace); |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 814 | borderSpaces[INDEX_DEFAULT] = new PointF(x, y); |
| 815 | borderSpaces[INDEX_LANDSCAPE] = new PointF(x, y); |
| 816 | |
| 817 | x = a.getFloat( |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 818 | R.styleable.ProfileDisplayOption_borderSpaceTwoPanelPortraitHorizontal, |
| 819 | borderSpaceTwoPanelPortrait); |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 820 | y = a.getFloat( |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 821 | R.styleable.ProfileDisplayOption_borderSpaceTwoPanelPortraitVertical, |
| 822 | borderSpaceTwoPanelPortrait); |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 823 | borderSpaces[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y); |
| 824 | |
| 825 | x = a.getFloat( |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 826 | R.styleable.ProfileDisplayOption_borderSpaceTwoPanelLandscapeHorizontal, |
| 827 | borderSpaceTwoPanelLandscape); |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 828 | y = a.getFloat( |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 829 | R.styleable.ProfileDisplayOption_borderSpaceTwoPanelLandscapeVertical, |
| 830 | borderSpaceTwoPanelLandscape); |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 831 | borderSpaces[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y); |
| 832 | |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 833 | folderBorderSpace = borderSpace; |
| 834 | |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 835 | x = y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpace, |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 836 | borderSpace); |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 837 | allAppsBorderSpaces[INDEX_DEFAULT] = new PointF(x, y); |
| 838 | allAppsBorderSpaces[INDEX_LANDSCAPE] = new PointF(x, y); |
| 839 | x = y = a.getFloat( |
| 840 | R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortrait, |
| 841 | allAppsBorderSpaces[INDEX_DEFAULT].x); |
| 842 | allAppsBorderSpaces[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y); |
| 843 | x = y = a.getFloat( |
| 844 | R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelLandscape, |
| 845 | allAppsBorderSpaces[INDEX_DEFAULT].x); |
| 846 | allAppsBorderSpaces[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y); |
Jon Miranda | e126d72 | 2021-02-25 10:45:20 -0500 | [diff] [blame] | 847 | |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 848 | iconSizes[INDEX_DEFAULT] = |
| 849 | a.getFloat(R.styleable.ProfileDisplayOption_iconImageSize, 0); |
| 850 | iconSizes[INDEX_LANDSCAPE] = |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 851 | a.getFloat(R.styleable.ProfileDisplayOption_iconSizeLandscape, |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 852 | iconSizes[INDEX_DEFAULT]); |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 853 | iconSizes[INDEX_TWO_PANEL_PORTRAIT] = |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 854 | a.getFloat(R.styleable.ProfileDisplayOption_iconSizeTwoPanelPortrait, |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 855 | iconSizes[INDEX_DEFAULT]); |
| 856 | iconSizes[INDEX_TWO_PANEL_LANDSCAPE] = |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 857 | a.getFloat(R.styleable.ProfileDisplayOption_iconSizeTwoPanelLandscape, |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 858 | iconSizes[INDEX_DEFAULT]); |
Jon Miranda | 6f7e970 | 2019-09-16 14:44:14 -0700 | [diff] [blame] | 859 | |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 860 | allAppsIconSizes[INDEX_DEFAULT] = a.getFloat( |
| 861 | R.styleable.ProfileDisplayOption_allAppsIconSize, iconSizes[INDEX_DEFAULT]); |
| 862 | allAppsIconSizes[INDEX_LANDSCAPE] = allAppsIconSizes[INDEX_DEFAULT]; |
| 863 | allAppsIconSizes[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat( |
| 864 | R.styleable.ProfileDisplayOption_allAppsIconSizeTwoPanelPortrait, |
| 865 | allAppsIconSizes[INDEX_DEFAULT]); |
| 866 | allAppsIconSizes[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat( |
| 867 | R.styleable.ProfileDisplayOption_allAppsIconSizeTwoPanelLandscape, |
| 868 | allAppsIconSizes[INDEX_DEFAULT]); |
| 869 | |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 870 | textSizes[INDEX_DEFAULT] = |
| 871 | a.getFloat(R.styleable.ProfileDisplayOption_iconTextSize, 0); |
| 872 | textSizes[INDEX_LANDSCAPE] = |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 873 | a.getFloat(R.styleable.ProfileDisplayOption_iconTextSizeLandscape, |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 874 | textSizes[INDEX_DEFAULT]); |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 875 | textSizes[INDEX_TWO_PANEL_PORTRAIT] = |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 876 | a.getFloat(R.styleable.ProfileDisplayOption_iconTextSizeTwoPanelPortrait, |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 877 | textSizes[INDEX_DEFAULT]); |
| 878 | textSizes[INDEX_TWO_PANEL_LANDSCAPE] = |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 879 | a.getFloat(R.styleable.ProfileDisplayOption_iconTextSizeTwoPanelLandscape, |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 880 | textSizes[INDEX_DEFAULT]); |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 881 | |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 882 | allAppsIconTextSizes[INDEX_DEFAULT] = a.getFloat( |
| 883 | R.styleable.ProfileDisplayOption_allAppsIconTextSize, textSizes[INDEX_DEFAULT]); |
| 884 | allAppsIconTextSizes[INDEX_LANDSCAPE] = allAppsIconTextSizes[INDEX_DEFAULT]; |
| 885 | allAppsIconTextSizes[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat( |
| 886 | R.styleable.ProfileDisplayOption_allAppsIconTextSizeTwoPanelPortrait, |
| 887 | allAppsIconTextSizes[INDEX_DEFAULT]); |
| 888 | allAppsIconTextSizes[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat( |
| 889 | R.styleable.ProfileDisplayOption_allAppsIconTextSizeTwoPanelLandscape, |
| 890 | allAppsIconTextSizes[INDEX_DEFAULT]); |
| 891 | |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 892 | horizontalMargin[INDEX_DEFAULT] = a.getFloat( |
| 893 | R.styleable.ProfileDisplayOption_horizontalMargin, 0); |
| 894 | horizontalMargin[INDEX_LANDSCAPE] = horizontalMargin[INDEX_DEFAULT]; |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 895 | horizontalMargin[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat( |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 896 | R.styleable.ProfileDisplayOption_horizontalMarginTwoPanelLandscape, |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 897 | horizontalMargin[INDEX_DEFAULT]); |
| 898 | horizontalMargin[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat( |
Thales Lima | 85c942f | 2021-12-31 13:04:20 +0000 | [diff] [blame] | 899 | R.styleable.ProfileDisplayOption_horizontalMarginTwoPanelPortrait, |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 900 | horizontalMargin[INDEX_DEFAULT]); |
Thales Lima | d90faab | 2021-09-21 17:18:47 +0100 | [diff] [blame] | 901 | |
Thales Lima | 6e7f36c | 2022-01-04 12:14:11 +0000 | [diff] [blame] | 902 | hotseatBorderSpaces[INDEX_DEFAULT] = a.getFloat( |
| 903 | R.styleable.ProfileDisplayOption_hotseatBorderSpace, borderSpace); |
| 904 | hotseatBorderSpaces[INDEX_LANDSCAPE] = hotseatBorderSpaces[INDEX_DEFAULT]; |
Thales Lima | 6e7f36c | 2022-01-04 12:14:11 +0000 | [diff] [blame] | 905 | hotseatBorderSpaces[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat( |
| 906 | R.styleable.ProfileDisplayOption_hotseatBorderSpaceTwoPanelLandscape, |
| 907 | hotseatBorderSpaces[INDEX_DEFAULT]); |
| 908 | hotseatBorderSpaces[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat( |
| 909 | R.styleable.ProfileDisplayOption_hotseatBorderSpaceTwoPanelPortrait, |
| 910 | hotseatBorderSpaces[INDEX_DEFAULT]); |
| 911 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 912 | a.recycle(); |
| 913 | } |
| 914 | |
| 915 | DisplayOption() { |
Sunny Goyal | 0e7a338 | 2020-04-13 17:15:05 -0700 | [diff] [blame] | 916 | this(null); |
| 917 | } |
| 918 | |
| 919 | DisplayOption(GridOption grid) { |
| 920 | this.grid = grid; |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 921 | minWidthDps = 0; |
| 922 | minHeightDps = 0; |
| 923 | canBeDefault = false; |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 924 | for (int i = 0; i < COUNT_SIZES; i++) { |
| 925 | iconSizes[i] = 0; |
| 926 | textSizes[i] = 0; |
| 927 | borderSpaces[i] = new PointF(); |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 928 | minCellSize[i] = new PointF(); |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 929 | allAppsIconSizes[i] = 0; |
| 930 | allAppsIconTextSizes[i] = 0; |
| 931 | allAppsBorderSpaces[i] = new PointF(); |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 932 | } |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 933 | } |
| 934 | |
| 935 | private DisplayOption multiply(float w) { |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 936 | for (int i = 0; i < COUNT_SIZES; i++) { |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 937 | iconSizes[i] *= w; |
| 938 | textSizes[i] *= w; |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 939 | borderSpaces[i].x *= w; |
| 940 | borderSpaces[i].y *= w; |
| 941 | minCellSize[i].x *= w; |
| 942 | minCellSize[i].y *= w; |
| 943 | horizontalMargin[i] *= w; |
Thales Lima | 6e7f36c | 2022-01-04 12:14:11 +0000 | [diff] [blame] | 944 | hotseatBorderSpaces[i] *= w; |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 945 | allAppsIconSizes[i] *= w; |
| 946 | allAppsIconTextSizes[i] *= w; |
| 947 | allAppsBorderSpaces[i].x *= w; |
| 948 | allAppsBorderSpaces[i].y *= w; |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 949 | } |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 950 | |
| 951 | folderBorderSpace *= w; |
| 952 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 953 | return this; |
| 954 | } |
| 955 | |
| 956 | private DisplayOption add(DisplayOption p) { |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 957 | for (int i = 0; i < COUNT_SIZES; i++) { |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 958 | iconSizes[i] += p.iconSizes[i]; |
| 959 | textSizes[i] += p.textSizes[i]; |
Thales Lima | 83bedbf | 2021-10-05 17:47:39 +0100 | [diff] [blame] | 960 | borderSpaces[i].x += p.borderSpaces[i].x; |
| 961 | borderSpaces[i].y += p.borderSpaces[i].y; |
| 962 | minCellSize[i].x += p.minCellSize[i].x; |
| 963 | minCellSize[i].y += p.minCellSize[i].y; |
| 964 | horizontalMargin[i] += p.horizontalMargin[i]; |
Thales Lima | 6e7f36c | 2022-01-04 12:14:11 +0000 | [diff] [blame] | 965 | hotseatBorderSpaces[i] += p.hotseatBorderSpaces[i]; |
Thales Lima | bb7d388 | 2021-12-22 12:56:29 +0000 | [diff] [blame] | 966 | allAppsIconSizes[i] += p.allAppsIconSizes[i]; |
| 967 | allAppsIconTextSizes[i] += p.allAppsIconTextSizes[i]; |
| 968 | allAppsBorderSpaces[i].x += p.allAppsBorderSpaces[i].x; |
| 969 | allAppsBorderSpaces[i].y += p.allAppsBorderSpaces[i].y; |
Sunny Goyal | 6e6f799 | 2021-08-24 16:23:29 -0700 | [diff] [blame] | 970 | } |
Thales Lima | 78d00ad | 2021-09-30 11:29:06 +0100 | [diff] [blame] | 971 | |
| 972 | folderBorderSpace += p.folderBorderSpace; |
| 973 | |
Sunny Goyal | 415f173 | 2018-11-29 10:33:47 -0800 | [diff] [blame] | 974 | return this; |
| 975 | } |
| 976 | } |
Sunny Goyal | ae190ff | 2020-04-14 00:19:01 +0000 | [diff] [blame] | 977 | } |