Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a68164d8 authored by Alex Chau's avatar Alex Chau
Browse files

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
parent 3ad5eef4
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -270,14 +270,13 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
    }

    private void updateIconSize(Resources resources) {
        float taskbarIconSize = resources.getDimension(DisplayController.isTransientTaskbar(this)
        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(1, resources);
        float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx;
        mDeviceProfile.updateIconSize(iconScale, resources);
        mDeviceProfile.updateIconSize(1f, resources);
    }

    /**
+5 −6
Original line number Diff line number Diff line
@@ -817,6 +817,11 @@ public class DeviceProfile {
     * 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 @@ public class DeviceProfile {

        // 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) {