Set iconsSizePx of Taskbar's DeviceProfile directly
- After ag/20691430, iconScale no longer scale app icons (I should rename it later, after QPR2), so we'll need to set the desired iconSize directly for Taskbar's DeviceProfile
- Extracted setting iconSizePx and testSizePx out of updateIconSize, as they are no longer affected by scaling. This allows TaskbarActivityContext to set desired iconsize and then call updateIconSize
Bug: 256976071
Test: Test Taskbar icon size in different density
Change-Id: I741c178b59e0d8ecb4c63689e68767622329379c
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index e944480..87e2ab9 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -270,14 +270,13 @@
}
private void updateIconSize(Resources resources) {
- float taskbarIconSize = resources.getDimension(DisplayController.isTransientTaskbar(this)
- ? mDeviceProfile.isTwoPanels
- ? R.dimen.transient_taskbar_two_panels_icon_size
- : R.dimen.transient_taskbar_icon_size
- : R.dimen.taskbar_icon_size);
- mDeviceProfile.updateIconSize(1, resources);
- float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx;
- mDeviceProfile.updateIconSize(iconScale, resources);
+ mDeviceProfile.iconSizePx = resources.getDimensionPixelSize(
+ DisplayController.isTransientTaskbar(this)
+ ? mDeviceProfile.isTwoPanels
+ ? R.dimen.transient_taskbar_two_panels_icon_size
+ : R.dimen.transient_taskbar_icon_size
+ : R.dimen.taskbar_icon_size);
+ mDeviceProfile.updateIconSize(1f, resources);
}
/**
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index bfde8da..7ccd195 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -817,6 +817,11 @@
* Returns the amount of extra (or unused) vertical space.
*/
private int updateAvailableDimensions(Resources res) {
+ float invIconSizeDp = inv.iconSize[mTypeIndex];
+ float invIconTextSizeSp = inv.iconTextSize[mTypeIndex];
+ iconSizePx = Math.max(1, pxFromDp(invIconSizeDp, mMetrics));
+ iconTextSizePx = pxFromSp(invIconTextSizeSp, mMetrics);
+
updateIconSize(1f, res);
updateWorkspacePadding();
@@ -873,13 +878,7 @@
// Workspace
final boolean isVerticalLayout = isVerticalBarLayout();
- float invIconSizeDp = inv.iconSize[mTypeIndex];
- float invIconTextSizeSp = inv.iconTextSize[mTypeIndex];
-
- iconSizePx = Math.max(1, pxFromDp(invIconSizeDp, mMetrics));
- iconTextSizePx = pxFromSp(invIconTextSizeSp, mMetrics);
iconDrawablePaddingPx = (int) (iconDrawablePaddingOriginalPx * iconScale);
-
cellLayoutBorderSpacePx = getCellLayoutBorderSpace(inv, scale);
if (isScalableGrid) {