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

Commit 458dd721 authored by Liran Binyamin's avatar Liran Binyamin
Browse files

Fix bubble expanded view width after rotation

Use a fixed width for the task view when adding it to the view hierarchy. Otherwise the width will be recalculated as part of the rotation transformation.

Demo
felix unfolded: http://recall/-/bJtug1HhvXkkeA4MQvIaiP/hBwh55vzzLzZVRFcT3RPyU
felix folded: http://recall/-/bJtug1HhvXkkeA4MQvIaiP/eeAWZM8y707R7CHH7YwQk7
tangor: http://recall/-/bJtug1HhvXkkeA4MQvIaiP/b5GXHQpPeNnUe5aYW2tsiH

Bug: 309523331
Test: Manual
      - Create bubble
      - Expand and rotate the device
      - Repeat and observe that expanded view width is always calculated correctly
Change-Id: I3dc18bc245d358541b93014a7b463c34db00ec6c
parent 06a1dce1
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -412,6 +412,23 @@ public class BubbleExpandedView extends LinearLayout {
        setLayoutDirection(LAYOUT_DIRECTION_LOCALE);
    }


    /** Updates the width of the task view if it changed. */
    void updateTaskViewContentWidth() {
        if (mTaskView != null) {
            int width = getContentWidth();
            if (mTaskView.getWidth() != width) {
                FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(width, MATCH_PARENT);
                mTaskView.setLayoutParams(lp);
            }
        }
    }

    private int getContentWidth() {
        boolean isStackOnLeft = mPositioner.isStackOnLeft(mStackView.getStackPosition());
        return mPositioner.getTaskViewContentWidth(isStackOnLeft);
    }

    /**
     * Initialize {@link BubbleController} and {@link BubbleStackView} here, this method must need
     * to be called after view inflate.
@@ -438,7 +455,12 @@ public class BubbleExpandedView extends LinearLayout {
                    mController.getTaskViewTransitions(), mController.getSyncTransactionQueue());
            mTaskView = new TaskView(mContext, mTaskViewTaskController);
            mTaskView.setListener(mController.getMainExecutor(), mTaskViewListener);
            mExpandedViewContainer.addView(mTaskView);

            // set a fixed width so it is not recalculated as part of a rotation. the width will be
            // updated manually after the rotation.
            FrameLayout.LayoutParams lp =
                    new FrameLayout.LayoutParams(getContentWidth(), MATCH_PARENT);
            mExpandedViewContainer.addView(mTaskView, lp);
            bringChildToFront(mTaskView);
        }
    }
+7 −0
Original line number Diff line number Diff line
@@ -401,6 +401,13 @@ public class BubblePositioner {
        }
    }

    /** Returns the width of the task view content. */
    public int getTaskViewContentWidth(boolean onLeft) {
        int[] paddings = getExpandedViewContainerPadding(onLeft, /* isOverflow = */ false);
        int pointerOffset = showBubblesVertically() ? getPointerSize() : 0;
        return mPositionRect.width() - paddings[0] - paddings[2] - pointerOffset;
    }

    /** Gets the y position of the expanded view if it was top-aligned. */
    public float getExpandedViewYTopAligned() {
        final int top = getAvailableRect().top;
+1 −0
Original line number Diff line number Diff line
@@ -3285,6 +3285,7 @@ public class BubbleStackView extends FrameLayout
            mExpandedViewContainer.setTranslationY(mPositioner.getExpandedViewY(mExpandedBubble,
                    mPositioner.showBubblesVertically() ? p.y : p.x));
            mExpandedViewContainer.setTranslationX(0f);
            mExpandedBubble.getExpandedView().updateTaskViewContentWidth();
            mExpandedBubble.getExpandedView().updateView(
                    mExpandedViewContainer.getLocationOnScreen());
            updatePointerPosition(false /* forIme */);