diff --git a/lawnchair/src/app/lawnchair/preferences2/ReloadHelper.kt b/lawnchair/src/app/lawnchair/preferences2/ReloadHelper.kt index be86d5fb9c..45df01b82b 100644 --- a/lawnchair/src/app/lawnchair/preferences2/ReloadHelper.kt +++ b/lawnchair/src/app/lawnchair/preferences2/ReloadHelper.kt @@ -44,9 +44,11 @@ class ReloadHelper(private val context: Context) { recreate() } + /** + * This doesn't work, please migrate this to being a [ThemeManager] reload, + * as of right now the behaviour is defaulted to L3 that listens on prefs changes + */ fun reloadIcons() { - // This doesn't work, please migrate this to being a ThemeManager reload, - // as of right now the behaviour is defaulted to L3 that listens on prefs changes Executors.MODEL_EXECUTOR.execute { LauncherAppState.INSTANCE.get(context).iconCache.clearMemoryCache() } diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index f3b3a1d41f..d04d959c99 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -395,6 +395,8 @@ public class DeviceProfile { workspacePageIndicatorHeight = res.getDimensionPixelSize( R.dimen.workspace_page_indicator_height); + workspacePageIndicatorHeight *= PreferenceExtensionsKt + .firstBlocking(preferenceManager2.getPageIndicatorHeightFactor()); mWorkspacePageIndicatorOverlapWorkspace = res.getDimensionPixelSize(R.dimen.workspace_page_indicator_overlap_workspace); @@ -463,15 +465,6 @@ public class DeviceProfile { setupAllAppsStyle(context); - workspacePageIndicatorHeight = res.getDimensionPixelSize( - R.dimen.workspace_page_indicator_height); - float pageIndicatorHeightFactor = PreferenceExtensionsKt - .firstBlocking(preferenceManager2.getPageIndicatorHeightFactor()); - - workspacePageIndicatorHeight *= (int) pageIndicatorHeightFactor; -// mWorkspacePageIndicatorOverlapWorkspace = res -// .getDimensionPixelSize(R.dimen.workspace_page_indicator_overlap_workspace); - if (!mIsResponsiveGrid) { TypedArray cellStyle; if (inv.cellStyle != INVALID_RESOURCE_HANDLE) { @@ -1324,7 +1317,8 @@ public class DeviceProfile { mTypeIndex, scale, iconSizePx, - mIconDrawablePaddingOriginalPx + mIconDrawablePaddingOriginalPx, + allAppsCellHeightMultiplier ); } updateAllAppsContainerWidth(); diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 8d98d180cd..145e81c43a 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -347,7 +347,7 @@ public class InvariantDeviceProfile { this.mThemeManager = ThemeManager.INSTANCE.get(context.getApplicationContext()); this.mDisplayController = DisplayController.INSTANCE.get(context.getApplicationContext()); String gridName = DeviceProfileOverrides.INSTANCE.get(context).getGridName(dbGridInfo); - initGrid(context, gridName); + initGrid(context, gridName, dbGridInfo); } private String initGrid(Context context, String gridName) { @@ -385,6 +385,32 @@ public class InvariantDeviceProfile { return displayOption.grid.name; } + private String initGrid(Context context, String gridName, DeviceProfileOverrides.DBGridInfo dbGridInfo) { + Info displayInfo = mDisplayController.getInfo(); + List allOptions = getPredefinedDeviceProfiles( + context, + gridName, + displayInfo, + (RestoreDbTask.isPending(mPrefs) && !Flags.oneGridSpecs()), + mPrefs.get(FIXED_LANDSCAPE_MODE) + ); + + List allOptionsFilteredByColCount = + filterByColumnCount(allOptions, dbGridInfo.getNumColumns()); + + DisplayOption displayOption = + invDistWeightedInterpolate(displayInfo, allOptionsFilteredByColCount.isEmpty() + ? new ArrayList<>(allOptions) + : new ArrayList<>(allOptionsFilteredByColCount), + displayInfo.getDeviceType()); + + if (!displayOption.grid.name.equals(gridName)) { + mPrefs.put(GRID_NAME, displayOption.grid.name); + } + initGrid(context, displayInfo, displayOption, dbGridInfo); + return displayOption.grid.name; + } + private List filterByColumnCount( List allOptions, int numColumns) { return allOptions.stream() @@ -415,7 +441,9 @@ public class InvariantDeviceProfile { GridOption closestProfile = displayOption.grid; numRows = dbGridInfo.getNumRows(); numColumns = dbGridInfo.getNumColumns(); - numSearchContainerColumns = closestProfile.numSearchContainerColumns; + numSearchContainerColumns = deviceType == TYPE_MULTI_DISPLAY + ? closestProfile.numSearchContainerColumns + : dbGridInfo.getNumHotseatColumns(); dbFile = dbGridInfo.getDbFile(); gridType = closestProfile.gridType; defaultLayoutId = closestProfile.defaultLayoutId; @@ -451,19 +479,6 @@ public class InvariantDeviceProfile { iconSize = displayOption.iconSizes; allAppsIconSize = displayOption.allAppsIconSizes; - float maxIconSize = iconSize[0]; - for (int i = 1; i < iconSize.length; i++) { - maxIconSize = Math.max(maxIconSize, iconSize[i]); - } - float maxAllAppsIconSize = allAppsIconSize[0]; - for (int i = 1; i < allAppsIconSize.length; i++) { - maxAllAppsIconSize = Math.max(maxAllAppsIconSize, allAppsIconSize[i]); - } - // Calculate separate bitmap sizes for workspace and all apps - iconBitmapSize = ResourceUtils.pxFromDp(maxIconSize, metrics); - allAppsIconBitmapSize = ResourceUtils.pxFromDp(maxAllAppsIconSize, metrics); - // Use the larger of the two for fillResIconDpi to ensure we have adequate resources - fillResIconDpi = getLauncherIconDensity(Math.max(iconBitmapSize, allAppsIconBitmapSize)); iconTextSize = displayOption.textSizes; @@ -508,6 +523,18 @@ public class InvariantDeviceProfile { // Lawnchair ignores partner overrides and allows the user to customize the grid themselves overrideOptions.applyUi(this); + float maxIconSize = iconSize[0]; + for (int i = 1; i < iconSize.length; i++) { + maxIconSize = Math.max(maxIconSize, iconSize[i]); + } + float maxAllAppsIconSize = allAppsIconSize[0]; + for (int i = 1; i < allAppsIconSize.length; i++) { + maxAllAppsIconSize = Math.max(maxAllAppsIconSize, allAppsIconSize[i]); + } + iconBitmapSize = ResourceUtils.pxFromDp(maxIconSize, metrics); + allAppsIconBitmapSize = ResourceUtils.pxFromDp(maxAllAppsIconSize, metrics); + fillResIconDpi = getLauncherIconDensity(Math.max(iconBitmapSize, allAppsIconBitmapSize)); + final List localSupportedProfiles = new ArrayList<>(); defaultWallpaperSize = new Point(displayInfo.currentSize); SparseArray dotRendererCache = new SparseArray<>(); @@ -575,9 +602,7 @@ public class InvariantDeviceProfile { @VisibleForTesting public void setCurrentGrid(Context context, String newGridName) { if (TextUtils.equals(mPrefs.get(GRID_NAME), newGridName)) return; - // pE-TODO(QPR1): Move off setCurrentGrid to Prefs? - // Lawnchair-TODO: Move off setCurrentGrid to Prefs? - //mPrefs.put(GRID_NAME, newGridName); + mPrefs.put(GRID_NAME, newGridName); DeviceProfileOverrides.INSTANCE.get(context).setCurrentGrid(newGridName); MAIN_EXECUTOR.execute(() -> { onConfigChanged(context.getApplicationContext()); @@ -596,7 +621,7 @@ public class InvariantDeviceProfile { Object[] oldState = toModelState(); // Re-init grid - initGrid(context, mPrefs.get(GRID_NAME)); + initGrid(context, getCurrentGridName(context)); boolean modelPropsChanged = !Arrays.equals(oldState, toModelState()); for (OnIDPChangeListener listener : mChangeListeners) { diff --git a/src/com/android/launcher3/deviceprofile/AllAppsProfile.kt b/src/com/android/launcher3/deviceprofile/AllAppsProfile.kt index b69e35d931..b4987e5574 100644 --- a/src/com/android/launcher3/deviceprofile/AllAppsProfile.kt +++ b/src/com/android/launcher3/deviceprofile/AllAppsProfile.kt @@ -71,10 +71,11 @@ data class AllAppsProfile( scale: Float, iconSizePx: Int, iconDrawablePaddingOriginalPx: Int, + cellHeightMultiplier: Float = 1f, ): AllAppsProfile { val allAppsBorderSpacePx = calculateAllAppsBorderSpacePx(inv, metric, typeIndex, scale) var allAppsCellHeightPx = - (pxFromDp(inv.allAppsCellSize[typeIndex].y, metric) + allAppsBorderSpacePx.y) + (pxFromDp(inv.allAppsCellSize[typeIndex].y, metric, cellHeightMultiplier) + allAppsBorderSpacePx.y) var allAppsIconSizePx = pxFromDp(inv.allAppsIconSize[typeIndex], metric) val allAppsIconTextSizePx = pxFromSp(inv.allAppsIconTextSize[typeIndex], metric).toFloat() @@ -133,6 +134,7 @@ data class AllAppsProfile( metric: DisplayMetrics, typeIndex: Int, scale: Float, + cellHeightMultiplier: Float = 1f, ): AllAppsProfile { val allAppsBorderSpacePx = calculateAllAppsBorderSpacePx(inv, metric, typeIndex, scale) val allAppsIconSizePx = max(1, pxFromDp(inv.allAppsIconSize[typeIndex], metric, scale)) @@ -140,13 +142,10 @@ data class AllAppsProfile( res.getDimensionPixelSize(R.dimen.all_apps_icon_drawable_padding) return AllAppsProfile( borderSpacePx = allAppsBorderSpacePx, - // AllApps cells don't have real space between cells, - // so we add the border space to the cell height cellHeightPx = - (pxFromDp(inv.allAppsCellSize.get(typeIndex).y, metric) + + (pxFromDp(inv.allAppsCellSize.get(typeIndex).y, metric, cellHeightMultiplier) + allAppsBorderSpacePx.y), iconSizePx = allAppsIconSizePx, - // We need the double conversion to keep the original behaviour iconTextSizePx = (pxFromSp(inv.allAppsIconTextSize[typeIndex], metric).toFloat() * scale) .toInt() @@ -247,6 +246,7 @@ data class AllAppsProfile( scale: Float, iconSizePx: Int, iconDrawablePaddingOriginalPx: Int, + cellHeightMultiplier: Float = 1f, ) = when { isScalableGrid -> { @@ -257,11 +257,15 @@ data class AllAppsProfile( scale = scale, iconSizePx = iconSizePx, iconDrawablePaddingOriginalPx = iconDrawablePaddingOriginalPx, + cellHeightMultiplier = cellHeightMultiplier, ) } else -> { - createAllAppsProfileNonScalable(res, inv, metric, typeIndex, scale) + createAllAppsProfileNonScalable( + res, inv, metric, typeIndex, scale, + cellHeightMultiplier = cellHeightMultiplier, + ) } } } diff --git a/src/com/android/launcher3/deviceprofile/HotseatProfile.kt b/src/com/android/launcher3/deviceprofile/HotseatProfile.kt index 8a0b62ab8e..64be78430d 100644 --- a/src/com/android/launcher3/deviceprofile/HotseatProfile.kt +++ b/src/com/android/launcher3/deviceprofile/HotseatProfile.kt @@ -16,17 +16,14 @@ package com.android.launcher3.deviceprofile -import android.content.Context import android.content.res.Resources -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.unit.dp +import android.graphics.Rect import app.lawnchair.hotseat.HotseatMode import app.lawnchair.preferences2.PreferenceManager2 import com.android.launcher3.InvariantDeviceProfile import com.android.launcher3.InvariantDeviceProfile.INDEX_DEFAULT import com.android.launcher3.R import com.android.launcher3.responsive.CalculatedHotseatSpec -import com.patrykmichalik.opto.core.firstBlocking // Remaining hotseat properties // int numShownHotseatIcons - updates multiple times @@ -100,11 +97,7 @@ data class HotseatProfile( else res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_side_padding) val hotseatQsbHeight = if (isQsbEnable) res.getDimensionPixelSize(R.dimen.qsb_widget_height) else 0 - val hotseatQsbShadowHeight = if (inv.inlineQsb[INDEX_DEFAULT] && !deviceProperties.isPhone) { - res.getDimensionPixelSize(R.dimen.taskbar_size) - } else { - res.getDimensionPixelSize(R.dimen.qsb_shadow_height) - } + val hotseatQsbShadowHeight = res.getDimensionPixelSize(R.dimen.qsb_shadow_height) val hotseatQsbVisualHeight = if (isQsbEnable) hotseatQsbHeight - 2 * hotseatQsbShadowHeight else 0