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

Commit 16a604fe authored by Liran Binyamin's avatar Liran Binyamin
Browse files

Show the bubble bar edu view

We now show the bubble bar edu view after a request from shell
to show it was received, and as soon as the user performs a touch
gesture on the bubble bar or flyout that causes the bar to be
expanded.

The click listener on the bubble bar is removed with this change
because the input consumer already handles taps. Removing the
listener avoids processing the tap twice which causes the edu view
to not be displayed. Removing the click listener solves the issue
but ideally we should move the edu view to launcher since that
would allow us to manage its state easily.

Flag: com.android.wm.shell.enable_bubble_bar
Fixes: 374842575
Test: atest PersistentBubbleStashControllerTest
Test: atest BubbleBarSwipeControllerTest
Test: atest TransientBubbleStashControllerTest
Test: manual
       - force show the bar edu view
       - send a bubble
       - tap the bubble bar to expand
       - observe bubble bar edu is visible
       - repeat with swiping on the bar and tapping the flyout
       - launch an app
       - swipe up to show the taskbar
       - observe edu view not visible
       - send a bubble with auto expand
       - observe bubble bar expanded and edu view not visible
Change-Id: I98ec44e6edf6c69d6d47b5709140796c2ecab23e
parent 0b0452ed
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -1634,15 +1634,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
        mControllers.taskbarEduTooltipController.hide();
    }

    /**
     * Called when we want to open bubblebar when user performs swipes up gesture.
     */
    public void onSwipeToOpenBubblebar() {
        mControllers.bubbleControllers.ifPresent(controllers -> {
            controllers.bubbleStashController.showBubbleBar(/* expandBubbles= */ true);
        });
    }

    /** Returns {@code true} if Taskbar All Apps is open. */
    public boolean isTaskbarAllAppsOpen() {
        return mControllers.taskbarAllAppsController.isOpen();
+2 −2
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ class BubbleBarSwipeController {
        when {
            canUnstash() && swipeState.passedUnstash -> {
                swipeState.currentState = COLLAPSED
                bubbleStashController.showBubbleBar(expandBubbles = false)
                bubbleStashController.showBubbleBar(expandBubbles = false, bubbleBarGesture = true)
            }
            canStash() && !swipeState.passedUnstash -> {
                swipeState.currentState = STASHED
@@ -103,7 +103,7 @@ class BubbleBarSwipeController {
    /** Finish tracking swipe gesture. Animate views back to resting state */
    fun finish() {
        if (swipeState.passedUnstash && swipeState.startState in setOf(STASHED, COLLAPSED)) {
            bubbleStashController.showBubbleBar(expandBubbles = true)
            bubbleStashController.showBubbleBar(expandBubbles = true, bubbleBarGesture = true)
        }
        if (animatedSwipeTranslation.value == 0f) {
            reset()
+4 −5
Original line number Diff line number Diff line
@@ -381,6 +381,7 @@ public class BubbleBarView extends FrameLayout {
        super.onInitializeAccessibilityNodeInfoInternal(info);
        // Always show only expand action as the menu is only for collapsed bubble bar
        info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_EXPAND);
        info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_CLICK);
        info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.id.action_dismiss_all,
                getResources().getString(R.string.bubble_bar_action_dismiss_all)));
        if (mBubbleBarLocation.isOnLeft(isLayoutRtl())) {
@@ -395,10 +396,8 @@ public class BubbleBarView extends FrameLayout {
    @Override
    public boolean performAccessibilityActionInternal(int action,
            @androidx.annotation.Nullable Bundle arguments) {
        if (super.performAccessibilityActionInternal(action, arguments)) {
            return true;
        }
        if (action == AccessibilityNodeInfo.ACTION_EXPAND) {
        if (action == AccessibilityNodeInfo.ACTION_EXPAND
                || action == AccessibilityNodeInfo.ACTION_CLICK) {
            mController.expandBubbleBar();
            return true;
        }
@@ -416,7 +415,7 @@ public class BubbleBarView extends FrameLayout {
                    BubbleBarLocation.UpdateSource.A11Y_ACTION_BAR);
            return true;
        }
        return false;
        return super.performAccessibilityActionInternal(action, arguments);
    }

    @SuppressLint("RtlHardcoded")
+37 −26
Original line number Diff line number Diff line
@@ -95,7 +95,6 @@ public class BubbleBarViewController {
    private TaskbarInsetsController mTaskbarInsetsController;
    private TaskbarViewPropertiesProvider mTaskbarViewPropertiesProvider;
    private View.OnClickListener mBubbleClickListener;
    private View.OnClickListener mBubbleBarClickListener;
    private BubbleView.Controller mBubbleViewController;
    private BubbleBarOverflow mOverflowBubble;

@@ -178,13 +177,11 @@ public class BubbleBarViewController {
                dp -> onBubbleBarConfigurationChanged(/* animate= */ true));
        mBubbleBarScaleY.updateValue(1f);
        mBubbleClickListener = v -> onBubbleClicked((BubbleView) v);
        mBubbleBarClickListener = v -> expandBubbleBar();
        mBubbleDragController.setupBubbleBarView(mBarView);
        mOverflowBubble = bubbleControllers.bubbleCreator.createOverflow(mBarView);
        if (!Flags.enableOptionalBubbleOverflow()) {
            showOverflow(true);
        }
        mBarView.setOnClickListener(mBubbleBarClickListener);
        mBarView.addOnLayoutChangeListener(
                (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
                    mTaskbarInsetsController.onTaskbarOrBubblebarWindowHeightOrInsetsChanged();
@@ -211,7 +208,8 @@ public class BubbleBarViewController {

            @Override
            public void expandBubbleBar() {
                BubbleBarViewController.this.expandBubbleBar();
                BubbleBarViewController.this.setExpanded(
                        /* isExpanded= */ true, /* maybeShowEdu*/ true);
            }

            @Override
@@ -332,7 +330,7 @@ public class BubbleBarViewController {
            @Override
            public void flyoutClicked() {
                interruptAnimationForTouch();
                expandBubbleBar();
                setExpanded(/* isExpanded= */ true, /* maybeShowEdu*/ true);
            }
        };
    }
@@ -360,25 +358,6 @@ public class BubbleBarViewController {
        mBubbleStashController.onNewBubbleAnimationInterrupted(false, mBarView.getTranslationY());
    }

    private void expandBubbleBar() {
        if (mShouldShowEducation) {
            mShouldShowEducation = false;
            // Get the bubble bar bounds on screen
            Rect bounds = new Rect();
            mBarView.getBoundsOnScreen(bounds);
            // Calculate user education reference position in Screen coordinates
            Point position = new Point(bounds.centerX(), bounds.top);
            // Show user education relative to the reference point
            mSystemUiProxy.showUserEducation(position);
        } else {
            // ensure that the bubble bar has the correct translation. we may have just interrupted
            // the animation by touching the bubble bar.
            mBubbleBarTranslationY.animateToValue(mBubbleStashController.getBubbleBarTranslationY())
                    .start();
            setExpanded(true);
        }
    }

    private void collapseBubbleBar() {
        setExpanded(false);
        mBubbleStashController.stashBubbleBar();
@@ -391,6 +370,22 @@ public class BubbleBarViewController {
        }
    }

    /** Shows the education view if it was previously requested. */
    private boolean maybeShowEduView() {
        if (mShouldShowEducation) {
            mShouldShowEducation = false;
            // Get the bubble bar bounds on screen
            Rect bounds = new Rect();
            mBarView.getBoundsOnScreen(bounds);
            // Calculate user education reference position in Screen coordinates
            Point position = new Point(bounds.centerX(), bounds.top);
            // Show user education relative to the reference point
            mSystemUiProxy.showUserEducation(position);
            return true;
        }
        return false;
    }

    /** Notifies that the IME became visible. */
    public void onImeVisible() {
        if (isAnimatingNewBubble()) {
@@ -946,13 +941,25 @@ public class BubbleBarViewController {
        mBarView.setSelectedBubble(newlySelected.getView());
    }

    /** @see #setExpanded(boolean, boolean) */
    public void setExpanded(boolean isExpanded) {
        setExpanded(isExpanded, /* maybeShowEdu= */ false);
    }

    /**
     * Sets whether the bubble bar should be expanded (not unstashed, but have the contents
     * within it expanded). This method notifies SystemUI that the bubble bar is expanded and
     * showing a selected bubble. This method should ONLY be called from UI events originating
     * from Launcher.
     *
     * @param isExpanded whether the bar should be expanded
     * @param maybeShowEdu whether we should show the edu view before expanding
     */
    public void setExpanded(boolean isExpanded) {
    public void setExpanded(boolean isExpanded, boolean maybeShowEdu) {
        // if we're trying to expand try showing the edu view instead
        if (maybeShowEdu && isExpanded && !mBarView.isExpanded() && maybeShowEduView()) {
            return;
        }
        if (!mBubbleBarPinning.isAnimating() && isExpanded != mBarView.isExpanded()) {
            mBarView.setExpanded(isExpanded);
            adjustTaskbarAndHotseatToBubbleBarState(isExpanded);
@@ -1012,7 +1019,11 @@ public class BubbleBarViewController {
        }
    }

    /** Marks as should show education. */
    /**
     * Stores a request to show the education view for later processing when appropriate.
     *
     * @see #maybeShowEduView()
     */
    public void prepareToShowEducation() {
        mShouldShowEducation = true;
    }
+11 −1
Original line number Diff line number Diff line
@@ -131,7 +131,17 @@ interface BubbleStashController {
    fun stashBubbleBar()

    /** Shows the bubble bar, and expands bubbles depending on [expandBubbles]. */
    fun showBubbleBar(expandBubbles: Boolean)
    fun showBubbleBar(expandBubbles: Boolean) {
        showBubbleBar(expandBubbles = expandBubbles, bubbleBarGesture = false)
    }

    /**
     * Shows the bubble bar, and expands bubbles depending on [expandBubbles].
     *
     * Set [bubbleBarGesture] to true if this request originates from a touch gesture on the bubble
     * bar.
     */
    fun showBubbleBar(expandBubbles: Boolean, bubbleBarGesture: Boolean)

    // TODO(b/354218264): Move to BubbleBarViewAnimator
    /**
Loading