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

Commit 0c3c3d9d authored by Mady Mellor's avatar Mady Mellor
Browse files

Separate the notion of "note bubble" and "app bubble"

There is some very specific behavior associated with notes bubbles so
we need a separate method to check for this. This CL does this by
specifying a unique key for notes bubbles & setting a flag on the bubble.

Updates uses of getting the key / note bubble creation to the new methods.

Notes bubbles & apps bubbles have some shared behavior so a notes bubble
is still considered an app bubble.

Flag: EXEMPT trivial refactor
Test: atest SystemUITests
Test: atest BubbleControllerTest (in other CL)
Bug: 390496034
Change-Id: I4d921f5a048eec520fe2eb5d39928a8934c9e024
parent 2c50fbd4
Loading
Loading
Loading
Loading
+43 −2
Original line number Diff line number Diff line
@@ -72,12 +72,18 @@ import java.util.concurrent.Executor;
public class Bubble implements BubbleViewProvider {
    private static final String TAG = "Bubble";

    /** A string suffix used in app bubbles' {@link #mKey}. */
    /** A string prefix used in app bubbles' {@link #mKey}. */
    public static final String KEY_APP_BUBBLE = "key_app_bubble";

    /** A string prefix used in note bubbles' {@link #mKey}. */
    public static final String KEY_NOTE_BUBBLE = "key_note_bubble";

    /** Whether the bubble is an app bubble. */
    private final boolean mIsAppBubble;

    /** Whether the bubble is a notetaking bubble. */
    private final boolean mIsNoteBubble;

    private final String mKey;
    @Nullable
    private final String mGroupKey;
@@ -245,6 +251,7 @@ public class Bubble implements BubbleViewProvider {
        mTaskId = taskId;
        mBubbleMetadataFlagListener = listener;
        mIsAppBubble = false;
        mIsNoteBubble = false;
    }

    private Bubble(
@@ -252,6 +259,7 @@ public class Bubble implements BubbleViewProvider {
            UserHandle user,
            @Nullable Icon icon,
            boolean isAppBubble,
            boolean isNoteBubble,
            String key,
            @ShellMainThread Executor mainExecutor,
            @ShellBackgroundThread Executor bgExecutor) {
@@ -261,6 +269,7 @@ public class Bubble implements BubbleViewProvider {
        mUser = user;
        mIcon = icon;
        mIsAppBubble = isAppBubble;
        mIsNoteBubble = isNoteBubble;
        mKey = key;
        mShowBubbleUpdateDot = false;
        mMainExecutor = mainExecutor;
@@ -279,6 +288,7 @@ public class Bubble implements BubbleViewProvider {
        mUser = info.getUserHandle();
        mIcon = info.getIcon();
        mIsAppBubble = false;
        mIsNoteBubble = false;
        mKey = getBubbleKeyForShortcut(info);
        mShowBubbleUpdateDot = false;
        mMainExecutor = mainExecutor;
@@ -303,6 +313,7 @@ public class Bubble implements BubbleViewProvider {
        mUser = user;
        mIcon = icon;
        mIsAppBubble = true;
        mIsNoteBubble = false;
        mKey = key;
        mShowBubbleUpdateDot = false;
        mMainExecutor = mainExecutor;
@@ -313,6 +324,17 @@ public class Bubble implements BubbleViewProvider {
        mPackageName = task.baseActivity.getPackageName();
    }

    /** Creates a notetaking bubble. */
    public static Bubble createNotesBubble(Intent intent, UserHandle user, @Nullable Icon icon,
            @ShellMainThread Executor mainExecutor, @ShellBackgroundThread Executor bgExecutor) {
        return new Bubble(intent,
                user,
                icon,
                /* isAppBubble= */ true,
                /* isNoteBubble= */ true,
                /* key= */ getNoteBubbleKeyForApp(intent.getPackage(), user),
                mainExecutor, bgExecutor);
    }

    /** Creates an app bubble. */
    public static Bubble createAppBubble(Intent intent, UserHandle user, @Nullable Icon icon,
@@ -321,6 +343,7 @@ public class Bubble implements BubbleViewProvider {
                user,
                icon,
                /* isAppBubble= */ true,
                /* isNoteBubble= */ false,
                /* key= */ getAppBubbleKeyForApp(intent.getPackage(), user),
                mainExecutor, bgExecutor);
    }
@@ -352,6 +375,16 @@ public class Bubble implements BubbleViewProvider {
        return KEY_APP_BUBBLE + ":" + user.getIdentifier()  + ":" + packageName;
    }

    /**
     * Returns the key for a note bubble from an app with package name, {@code packageName} on an
     * Android user, {@code user}.
     */
    public static String getNoteBubbleKeyForApp(String packageName, UserHandle user) {
        Objects.requireNonNull(packageName);
        Objects.requireNonNull(user);
        return KEY_NOTE_BUBBLE + ":" + user.getIdentifier()  + ":" + packageName;
    }

    /**
     * Returns the key for a shortcut bubble using {@code packageName}, {@code user}, and the
     * {@code shortcutInfo} id.
@@ -375,6 +408,7 @@ public class Bubble implements BubbleViewProvider {
            final Bubbles.PendingIntentCanceledListener intentCancelListener,
            @ShellMainThread Executor mainExecutor, @ShellBackgroundThread Executor bgExecutor) {
        mIsAppBubble = false;
        mIsNoteBubble = false;
        mKey = entry.getKey();
        mGroupKey = entry.getGroupKey();
        mLocusId = entry.getLocusId();
@@ -1122,12 +1156,19 @@ public class Bubble implements BubbleViewProvider {
    }

    /**
     * Returns whether this bubble is from an app versus a notification.
     * Returns whether this bubble is from an app (as well as notetaking) versus a notification.
     */
    public boolean isAppBubble() {
        return mIsAppBubble;
    }

    /**
     * Returns whether this bubble is specific from the notetaking API.
     */
    public boolean isNoteBubble() {
        return mIsNoteBubble;
    }

    /** Creates open app settings intent */
    public Intent getSettingsIntent(final Context context) {
        final Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_BUBBLE_SETTINGS);
+4 −3
Original line number Diff line number Diff line
@@ -1590,7 +1590,7 @@ public class BubbleController implements ConfigurationChangeListener,
            return;
        }

        String appBubbleKey = Bubble.getAppBubbleKeyForApp(intent.getPackage(), user);
        String appBubbleKey = Bubble.getNoteBubbleKeyForApp(intent.getPackage(), user);
        PackageManager packageManager = getPackageManagerForUser(mContext, user.getIdentifier());
        if (!isResizableActivity(intent, packageManager, appBubbleKey)) return; // logs errors

@@ -1628,8 +1628,9 @@ public class BubbleController implements ConfigurationChangeListener,
                // Update the bubble entry in the overflow with the latest intent.
                b.setAppBubbleIntent(intent);
            } else {
                // App bubble does not exist, lets add and expand it
                b = Bubble.createAppBubble(intent, user, icon, mMainExecutor, mBackgroundExecutor);
                // Notes bubble does not exist, lets add and expand it
                b = Bubble.createNotesBubble(intent, user, icon, mMainExecutor,
                        mBackgroundExecutor);
            }
            ProtoLog.d(WM_SHELL_BUBBLES, "inflateAndAdd %s", appBubbleKey);
            b.setShouldAutoExpand(true);
+1 −1
Original line number Diff line number Diff line
@@ -285,7 +285,7 @@ public class BubbleExpandedView extends LinearLayout {
            // The taskId is saved to use for removeTask, preventing appearance in recent tasks.
            mTaskId = taskId;

            if (mBubble != null && mBubble.isAppBubble()) {
            if (mBubble != null && mBubble.isNoteBubble()) {
                // Let the controller know sooner what the taskId is.
                mManager.setAppBubbleTaskId(mBubble.getKey(), mTaskId);
            }
+4 −5
Original line number Diff line number Diff line
@@ -1975,12 +1975,11 @@ public class BubbleStackView extends FrameLayout
            return;
        }

        if (firstBubble && bubble.isAppBubble() && !mPositioner.hasUserModifiedDefaultPosition()) {
            // TODO (b/294284894): update language around "app bubble" here
            // If it's an app bubble and we don't have a previous resting position, update the
            // controllers to use the default position for the app bubble (it'd be different from
        if (firstBubble && bubble.isNoteBubble() && !mPositioner.hasUserModifiedDefaultPosition()) {
            // If it's an note bubble and we don't have a previous resting position, update the
            // controllers to use the default position for the note bubble (it'd be different from
            // the position initialized with the controllers originally).
            PointF startPosition =  mPositioner.getDefaultStartPosition(true /* isAppBubble */);
            PointF startPosition =  mPositioner.getDefaultStartPosition(true /* isNoteBubble */);
            mStackOnLeftOrWillBe = mPositioner.isStackOnLeft(startPosition);
            mStackAnimationController.setStackPosition(startPosition);
            mExpandedAnimationController.setCollapsePoint(startPosition);
+1 −1
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ public class BubbleTaskViewHelper {
            // The taskId is saved to use for removeTask, preventing appearance in recent tasks.
            mTaskId = taskId;

            if (mBubble != null && mBubble.isAppBubble()) {
            if (mBubble != null && mBubble.isNoteBubble()) {
                // Let the controller know sooner what the taskId is.
                mExpandedViewManager.setAppBubbleTaskId(mBubble.getKey(), mTaskId);
            }
Loading