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

Commit f0a123f8 authored by Liran Binyamin's avatar Liran Binyamin Committed by Android (Google) Code Review
Browse files

Merge "Pass bubble flyout from wm shell to launcher" into main

parents 8c5e7897 3d5f5686
Loading
Loading
Loading
Loading
+22 −10
Original line number Diff line number Diff line
@@ -30,29 +30,32 @@ import java.util.Objects;
 */
public class BubbleInfo implements Parcelable {

    private String mKey; // Same key as the Notification
    private final String mKey; // Same key as the Notification
    private int mFlags;  // Flags from BubbleMetadata
    @Nullable
    private String mShortcutId;
    private int mUserId;
    private String mPackageName;
    private final String mShortcutId;
    private final int mUserId;
    private final String mPackageName;
    /**
     * All notification bubbles require a shortcut to be set on the notification, however, the
     * app could still specify an Icon and PendingIntent to use for the bubble. In that case
     * this icon will be populated. If the bubble is entirely shortcut based, this will be null.
     */
    @Nullable
    private Icon mIcon;
    private final Icon mIcon;
    @Nullable
    private String mTitle;
    private final String mTitle;
    @Nullable
    private String mAppName;
    private boolean mIsImportantConversation;
    private boolean mShowAppBadge;
    private final String mAppName;
    private final boolean mIsImportantConversation;
    private final boolean mShowAppBadge;
    @Nullable
    private final ParcelableFlyoutMessage mParcelableFlyoutMessage;

    public BubbleInfo(String key, int flags, @Nullable String shortcutId, @Nullable Icon icon,
            int userId, String packageName, @Nullable String title, @Nullable String appName,
            boolean isImportantConversation, boolean showAppBadge) {
            boolean isImportantConversation, boolean showAppBadge,
            @Nullable ParcelableFlyoutMessage flyoutMessage) {
        mKey = key;
        mFlags = flags;
        mShortcutId = shortcutId;
@@ -63,6 +66,7 @@ public class BubbleInfo implements Parcelable {
        mAppName = appName;
        mIsImportantConversation = isImportantConversation;
        mShowAppBadge = showAppBadge;
        mParcelableFlyoutMessage = flyoutMessage;
    }

    private BubbleInfo(Parcel source) {
@@ -76,6 +80,8 @@ public class BubbleInfo implements Parcelable {
        mAppName = source.readString();
        mIsImportantConversation = source.readBoolean();
        mShowAppBadge = source.readBoolean();
        mParcelableFlyoutMessage = source.readParcelable(
                ParcelableFlyoutMessage.class.getClassLoader(), ParcelableFlyoutMessage.class);
    }

    public String getKey() {
@@ -122,6 +128,11 @@ public class BubbleInfo implements Parcelable {
        return mShowAppBadge;
    }

    @Nullable
    public ParcelableFlyoutMessage getParcelableFlyoutMessage() {
        return mParcelableFlyoutMessage;
    }

    /**
     * Whether this bubble is currently being hidden from the stack.
     */
@@ -180,6 +191,7 @@ public class BubbleInfo implements Parcelable {
        parcel.writeString(mAppName);
        parcel.writeBoolean(mIsImportantConversation);
        parcel.writeBoolean(mShowAppBadge);
        parcel.writeParcelable(mParcelableFlyoutMessage, flags);
    }

    @NonNull
+55 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.wm.shell.shared.bubbles

import android.graphics.drawable.Icon
import android.os.Parcel
import android.os.Parcelable

/** The contents of the flyout message to be passed to launcher for rendering in the bubble bar. */
class ParcelableFlyoutMessage(
    val icon: Icon?,
    val title: String?,
    val message: String?,
) : Parcelable {

    constructor(
        parcel: Parcel
    ) : this(
        icon = parcel.readParcelable(Icon::class.java.classLoader),
        title = parcel.readString(),
        message = parcel.readString(),
    )

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeParcelable(icon, flags)
        parcel.writeString(title)
        parcel.writeString(message)
    }

    override fun describeContents() = 0

    companion object {
        @JvmField
        val CREATOR =
            object : Parcelable.Creator<ParcelableFlyoutMessage> {
                override fun createFromParcel(parcel: Parcel) = ParcelableFlyoutMessage(parcel)

                override fun newArray(size: Int) = arrayOfNulls<ParcelableFlyoutMessage>(size)
            }
    }
}
+17 −1
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import com.android.wm.shell.bubbles.bar.BubbleBarLayerView;
import com.android.wm.shell.shared.annotations.ShellBackgroundThread;
import com.android.wm.shell.shared.annotations.ShellMainThread;
import com.android.wm.shell.shared.bubbles.BubbleInfo;
import com.android.wm.shell.shared.bubbles.ParcelableFlyoutMessage;

import java.io.PrintWriter;
import java.util.List;
@@ -350,7 +351,22 @@ public class Bubble implements BubbleViewProvider {
                getTitle(),
                getAppName(),
                isImportantConversation(),
                !isAppLaunchIntent());
                !isAppLaunchIntent(),
                getParcelableFlyoutMessage());
    }

    /** Creates a parcelable flyout message to send to launcher. */
    @Nullable
    private ParcelableFlyoutMessage getParcelableFlyoutMessage() {
        if (mFlyoutMessage == null) {
            return null;
        }
        // the icon is only used in group chats
        Icon icon = mFlyoutMessage.isGroupChat ? mFlyoutMessage.senderIcon : null;
        String title =
                mFlyoutMessage.senderName == null ? null : mFlyoutMessage.senderName.toString();
        String message = mFlyoutMessage.message == null ? null : mFlyoutMessage.message.toString();
        return new ParcelableFlyoutMessage(icon, title, message);
    }

    @Override
+5 −1
Original line number Diff line number Diff line
@@ -274,7 +274,7 @@ public class BubbleViewInfoTask {
        @Nullable BubbleExpandedView expandedView;
        int dotColor;
        Path dotPath;
        @Nullable Bubble.FlyoutMessage flyoutMessage;
        Bubble.FlyoutMessage flyoutMessage;
        Bitmap bubbleBitmap;
        Bitmap badgeBitmap;

@@ -300,6 +300,10 @@ public class BubbleViewInfoTask {
                return null;
            }

            // set the flyout message but don't load the avatar because we can't pass it on the
            // binder to launcher
            info.flyoutMessage = b.getFlyoutMessage();

            return info;
        }

+5 −1
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ public class BubbleViewInfoTaskLegacy extends
        @Nullable BubbleExpandedView expandedView;
        int dotColor;
        Path dotPath;
        @Nullable Bubble.FlyoutMessage flyoutMessage;
        Bubble.FlyoutMessage flyoutMessage;
        Bitmap bubbleBitmap;
        Bitmap badgeBitmap;

@@ -221,6 +221,10 @@ public class BubbleViewInfoTaskLegacy extends
                return null;
            }

            // set the flyout message but don't load the avatar because we can't pass it on the
            // binder to launcher
            info.flyoutMessage = b.getFlyoutMessage();

            return info;
        }

Loading