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

Commit 64db51ae authored by Mady Mellor's avatar Mady Mellor
Browse files

Fix crash when opening overflow after dismissing stack

It changed recently such that we remove the bubble stack
view when its dismissed (previously we just made it
invisible).

This revealed that we weren't cleaning up the bubble
overflow activity view when the stack was dismissed, bc
the parent of that view would be different resulting in
a crash.

This also renamed / simplified a method.

Bug: 157567251
Bug: 155417004
Test: manual - have bubbles, visit the overflow
             - dismiss the stack
             - get new bubble, open it, visit the overflow
             => no crash

Change-Id: Ia2823e5c2cb9b2a53b2379945287588edc30c072
parent 203a17d9
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -655,7 +655,13 @@ public class BubbleController implements ConfigurationController.ConfigurationLi

        try {
            mAddedToWindowManager = false;
            if (mStackView != null) {
                mWindowManager.removeView(mStackView);
                mStackView.removeView(mBubbleScrim);
                mStackView = null;
            } else {
                Log.w(TAG, "StackView added to WindowManager, but was null when removing!");
            }
        } catch (IllegalArgumentException e) {
            // This means the stack has already been removed - it shouldn't happen, but ignore if it
            // does, since we wanted it removed anyway.
+3 −1
Original line number Diff line number Diff line
@@ -311,8 +311,10 @@ public class BubbleExpandedView extends LinearLayout {
     * if a view has been added or removed from on top of the ActivityView, such as the manage menu.
     */
    void updateObscuredTouchableRegion() {
        if (mActivityView != null) {
            mActivityView.onLocationChanged();
        }
    }

    void applyThemeAttrs() {
        final TypedArray ta = mContext.obtainStyledAttributes(
+1 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ public class BubbleOverflow implements BubbleViewProvider {
        return mOverflowBtn;
    }

    void setBtnVisible(int visible) {
    void setVisible(int visible) {
        mOverflowBtn.setVisibility(visible);
    }

+9 −15
Original line number Diff line number Diff line
@@ -1119,6 +1119,9 @@ public class BubbleStackView extends FrameLayout
        super.onDetachedFromWindow();
        getViewTreeObserver().removeOnPreDrawListener(mViewUpdater);
        getViewTreeObserver().removeOnComputeInternalInsetsListener(this);
        if (mBubbleOverflow != null && mBubbleOverflow.getExpandedView() != null) {
            mBubbleOverflow.getExpandedView().cleanUpExpandedState();
        }
    }

    @Override
@@ -1339,21 +1342,12 @@ public class BubbleStackView extends FrameLayout
        Log.d(TAG, "was asked to remove Bubble, but didn't find the view! " + bubble);
    }

    private void updateOverflowBtnVisibility() {
        if (!BubbleExperimentConfig.allowBubbleOverflow(mContext)) {
    private void updateOverflowVisibility() {
        if (!BubbleExperimentConfig.allowBubbleOverflow(mContext)
                || mBubbleOverflow == null) {
            return;
        }
        if (mIsExpanded) {
            if (DEBUG_BUBBLE_STACK_VIEW) {
                Log.d(TAG, "Show overflow button.");
            }
            mBubbleOverflow.setBtnVisible(VISIBLE);
        } else {
            if (DEBUG_BUBBLE_STACK_VIEW) {
                Log.d(TAG, "Collapsed. Hide overflow button.");
            }
            mBubbleOverflow.setBtnVisible(GONE);
        }
        mBubbleOverflow.setVisible(mIsExpanded ? VISIBLE : GONE);
    }

    // via BubbleData.Listener
@@ -1607,7 +1601,7 @@ public class BubbleStackView extends FrameLayout
            Log.d(TAG, BubbleDebugConfig.formatBubblesString(getBubblesOnScreen(),
                    mExpandedBubble));
        }
        updateOverflowBtnVisibility();
        updateOverflowVisibility();
        mBubbleContainer.cancelAllAnimations();
        mExpandedAnimationController.collapseBackToStack(
                mStackAnimationController.getStackPositionAlongNearestHorizontalEdge()
@@ -1631,7 +1625,7 @@ public class BubbleStackView extends FrameLayout
        beforeExpandedViewAnimation();

        mBubbleContainer.setActiveController(mExpandedAnimationController);
        updateOverflowBtnVisibility();
        updateOverflowVisibility();
        mExpandedAnimationController.expandFromStack(() -> {
            updatePointerPosition();
            afterExpandedViewAnimation();