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

Commit 6d780499 authored by Liran Binyamin's avatar Liran Binyamin
Browse files

Fix manage click listener for promoted bubble

The manage button is created by the expanded view, but the listener
is set by stack view. Sometimes there are cases where the button
is recreated by the expanded view, which removes the existing listener.

This change now sets the click listener within the expanded view
whenever the manage button is set.

Flag: NONE
Fixes: 352481011
Test: manual
       - Have 5 bubbles in the stack
       - Create 1 more bubble so that one gets overflowed
       - Go to the overflow menu and click on the bubble to promote it
       - Click on the manage button
       - Observe the manage menu is displayed
Change-Id: Ia0d55ceb070c9bfcfa2cf9521696b35708280755
parent 6f4ee4a3
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -372,6 +372,7 @@ public class BubbleExpandedView extends LinearLayout {
        //   ==> activity view
        //   ==> manage button
        bringChildToFront(mManageButton);
        setManageClickListener();

        applyThemeAttrs();

@@ -502,6 +503,7 @@ public class BubbleExpandedView extends LinearLayout {
                R.layout.bubble_manage_button, this /* parent */, false /* attach */);
        addView(mManageButton);
        mManageButton.setVisibility(visibility);
        setManageClickListener();
        post(() -> {
            int touchAreaHeight =
                    getResources().getDimensionPixelSize(
@@ -646,9 +648,8 @@ public class BubbleExpandedView extends LinearLayout {
        }
    }

    // TODO: Could listener be passed when we pass StackView / can we avoid setting this like this
    void setManageClickListener(OnClickListener manageClickListener) {
        mManageButton.setOnClickListener(manageClickListener);
    private void setManageClickListener() {
        mManageButton.setOnClickListener(v -> mStackView.onManageBubbleClicked());
    }

    /**
+2 −16
Original line number Diff line number Diff line
@@ -1374,7 +1374,6 @@ public class BubbleStackView extends FrameLayout
        // The menu itself should respect locale direction so the icons are on the correct side.
        mManageMenu.setLayoutDirection(LAYOUT_DIRECTION_LOCALE);
        addView(mManageMenu);
        updateManageButtonListener();
    }

    /**
@@ -3375,14 +3374,6 @@ public class BubbleStackView extends FrameLayout
            mExpandedViewContainer.setAlpha(0f);
            mExpandedViewContainer.addView(bev);

            postDelayed(() -> {
                // Set the Manage button click handler from postDelayed. This appears to resolve
                // a race condition with adding the BubbleExpandedView view to the expanded view
                // container. Due to the race condition the click handler sometimes is not set up
                // correctly and is never called.
                updateManageButtonListener();
            }, 0);

            if (!mIsExpansionAnimating) {
                mIsBubbleSwitchAnimating = true;
                mSurfaceSynchronizer.syncSurfaceAndRun(() -> {
@@ -3392,13 +3383,8 @@ public class BubbleStackView extends FrameLayout
        }
    }

    private void updateManageButtonListener() {
        BubbleExpandedView bev = getExpandedView();
        if (mIsExpanded && bev != null) {
            bev.setManageClickListener((view) -> {
    void onManageBubbleClicked() {
        showManageMenu(true /* show */);
            });
        }
    }

    /**