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

Commit 068d1ea8 authored by Ivan Tkachenko's avatar Ivan Tkachenko Committed by Android (Google) Code Review
Browse files

Merge "Bubble bar user education" into main

parents cbaf0a7f 72597e32
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ public class BubbleBarController extends IBubblesListener.Stub {
    private static class BubbleBarViewUpdate {
        boolean expandedChanged;
        boolean expanded;
        boolean shouldShowEducation;
        String selectedBubbleKey;
        String suppressedBubbleKey;
        String unsuppressedBubbleKey;
@@ -151,6 +152,7 @@ public class BubbleBarController extends IBubblesListener.Stub {
        BubbleBarViewUpdate(BubbleBarUpdate update) {
            expandedChanged = update.expandedChanged;
            expanded = update.expanded;
            shouldShowEducation = update.shouldShowEducation;
            selectedBubbleKey = update.selectedBubbleKey;
            suppressedBubbleKey = update.suppressedBubbleKey;
            unsuppressedBubbleKey = update.unsupressedBubbleKey;
@@ -366,7 +368,9 @@ public class BubbleBarController extends IBubblesListener.Stub {
                mBubbleStashController.animateToInitialState(update.expanded);
            }
        }

        if (update.shouldShowEducation) {
            mBubbleBarViewController.prepareToShowEducation();
        }
        if (update.expandedChanged) {
            if (update.expanded != mBubbleBarViewController.isExpanded()) {
                mBubbleBarViewController.setExpandedFromSysui(update.expanded);
+24 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.launcher3.taskbar.bubbles;
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;

import android.graphics.Point;
import android.graphics.Rect;
import android.util.Log;
import android.view.MotionEvent;
@@ -75,6 +76,7 @@ public class BubbleBarViewController {
    private boolean mHiddenForSysui;
    // Whether the bar is hidden because there are no bubbles.
    private boolean mHiddenForNoBubbles;
    private boolean mShouldShowEducation;

    public BubbleBarViewController(TaskbarActivityContext activity, BubbleBarView barView) {
        mActivity = activity;
@@ -98,7 +100,7 @@ public class BubbleBarViewController {
        mBarView.getLayoutParams().height = mActivity.getDeviceProfile().taskbarHeight;
        mBubbleBarScale.updateValue(1f);
        mBubbleClickListener = v -> onBubbleClicked(v);
        mBubbleBarClickListener = v -> setExpanded(true);
        mBubbleBarClickListener = v -> onBubbleBarClicked();
        mBubbleDragController.setupBubbleBarView(mBarView);
        mBarView.setOnClickListener(mBubbleBarClickListener);
        mBarView.addOnLayoutChangeListener((view, i, i1, i2, i3, i4, i5, i6, i7) ->
@@ -121,6 +123,21 @@ public class BubbleBarViewController {
        }
    }

    private void onBubbleBarClicked() {
        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 {
            setExpanded(true);
        }
    }

    //
    // The below animators are exposed to BubbleStashController so it can manage the stashing
    // animation.
@@ -326,6 +343,12 @@ public class BubbleBarViewController {
        }
    }

    /** Marks as should show education and shows the bubble bar in a collapsed state */
    public void prepareToShowEducation() {
        mShouldShowEducation = true;
        mBubbleStashController.showBubbleBar(false /* expand the bubbles */);
    }

    /**
     * Updates the dragged bubble view in the bubble bar view, and notifies SystemUI
     * that a bubble is being dragged to dismiss.
+13 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ShortcutInfo;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
@@ -731,6 +732,18 @@ public class SystemUiProxy implements ISystemUiProxy {
        }
    }

    /**
     * Tells SysUI to show user education relative to the reference point provided.
     * @param position the bubble bar top center position in Screen coordinates.
     */
    public void showUserEducation(Point position) {
        try {
            mBubbles.showUserEducation(position.x, position.y);
        } catch (RemoteException e) {
            Log.w(TAG, "Failed call showUserEducation");
        }
    }

    //
    // Splitscreen
    //