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

Commit 891e9e3c authored by Liran Binyamin's avatar Liran Binyamin
Browse files

Fix hotseat icon translation issue

The current behavior that adjusts hotseat icons to make room for the
bubble bar uses the index of the hotseat icon to calculate translation x.

The problem is that if icons are reordered, the index of the icon may be
different than the actual cell number it belongs to.

This change updates the logic to use the cell rather than the index.

Flag: com.android.wm.shell.enable_bubble_bar
Fixes: 345686425
Test: manual - on tablet in portrait
       - show bubble bar
       - observe hotseat icons adjust
       - drag an icon from the home screen into hotseat
       - observe icons are shown correctly
       - rotate the device to landscape and back to portrait
Change-Id: I8628892234d1b31205b93ba3089c6dbf2820ea04
parent ff83f1c4
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -97,10 +97,9 @@ public class Hotseat extends CellLayout implements Insettable {
        if (bubbleBarEnabled) {
            float adjustedBorderSpace = dp.getHotseatAdjustedBorderSpaceForBubbleBar(getContext());
            if (hasBubbles && Float.compare(adjustedBorderSpace, 0f) != 0) {
                getShortcutsAndWidgets().setTranslationProvider(child -> {
                    int index = getShortcutsAndWidgets().indexOfChild(child);
                getShortcutsAndWidgets().setTranslationProvider(cellX -> {
                    float borderSpaceDelta = adjustedBorderSpace - dp.hotseatBorderSpace;
                    return dp.iconSizePx + index * borderSpaceDelta;
                    return dp.iconSizePx + cellX * borderSpaceDelta;
                });
                if (mQsb instanceof HorizontalInsettableView) {
                    HorizontalInsettableView insettableQsb = (HorizontalInsettableView) mQsb;
@@ -147,10 +146,7 @@ public class Hotseat extends CellLayout implements Insettable {

        // update the translation provider for future layout passes of hotseat icons.
        if (isBubbleBarVisible) {
            icons.setTranslationProvider(child -> {
                int index = icons.indexOfChild(child);
                return dp.iconSizePx + index * borderSpaceDelta;
            });
            icons.setTranslationProvider(cellX -> dp.iconSizePx + cellX * borderSpaceDelta);
        } else {
            icons.setTranslationProvider(null);
        }
+2 −2
Original line number Diff line number Diff line
@@ -245,7 +245,7 @@ public class ShortcutAndWidgetContainer extends ViewGroup implements FolderIcon.
        }
        child.layout(childLeft, childTop, childLeft + lp.width, childTop + lp.height);
        if (mTranslationProvider != null) {
            final float tx = mTranslationProvider.getTranslationX(child);
            final float tx = mTranslationProvider.getTranslationX(lp.getCellX());
            if (child instanceof Reorderable) {
                ((Reorderable) child).getTranslateDelegate()
                        .getTranslationX(INDEX_BUBBLE_ADJUSTMENT_ANIM)
@@ -330,6 +330,6 @@ public class ShortcutAndWidgetContainer extends ViewGroup implements FolderIcon.

    /** Provides translation values to apply when laying out child views. */
    interface TranslationProvider {
        float getTranslationX(View child);
        float getTranslationX(int cellX);
    }
}