Merge "Store the flyout in BubbleBarBubble" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
9c3c7cc3e2
@@ -17,10 +17,11 @@ package com.android.launcher3.taskbar.bubbles
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Path
|
||||
import com.android.launcher3.taskbar.bubbles.flyout.BubbleBarFlyoutMessage
|
||||
import com.android.wm.shell.shared.bubbles.BubbleInfo
|
||||
|
||||
/** An entity in the bubble bar. */
|
||||
sealed class BubbleBarItem(open var key: String, open var view: BubbleView)
|
||||
sealed class BubbleBarItem(open val key: String, open var view: BubbleView)
|
||||
|
||||
/** Contains state info about a bubble in the bubble bar as well as presentation information. */
|
||||
data class BubbleBarBubble(
|
||||
@@ -30,7 +31,8 @@ data class BubbleBarBubble(
|
||||
var icon: Bitmap,
|
||||
var dotColor: Int,
|
||||
var dotPath: Path,
|
||||
var appName: String
|
||||
var appName: String,
|
||||
var flyoutMessage: BubbleBarFlyoutMessage?,
|
||||
) : BubbleBarItem(info.key, view)
|
||||
|
||||
/** Represents the overflow bubble in the bubble bar. */
|
||||
|
||||
@@ -22,6 +22,7 @@ import static android.content.pm.LauncherApps.ShortcutQuery.FLAG_MATCH_DYNAMIC;
|
||||
import static android.content.pm.LauncherApps.ShortcutQuery.FLAG_MATCH_PINNED_BY_ANY_LAUNCHER;
|
||||
|
||||
import static com.android.launcher3.icons.FastBitmapDrawable.WHITE_SCRIM_ALPHA;
|
||||
import static com.android.wm.shell.shared.bubbles.FlyoutDrawableLoader.loadFlyoutDrawable;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
@@ -49,7 +50,9 @@ import com.android.launcher3.R;
|
||||
import com.android.launcher3.icons.BitmapInfo;
|
||||
import com.android.launcher3.icons.BubbleIconFactory;
|
||||
import com.android.launcher3.shortcuts.ShortcutRequest;
|
||||
import com.android.launcher3.taskbar.bubbles.flyout.BubbleBarFlyoutMessage;
|
||||
import com.android.wm.shell.shared.bubbles.BubbleInfo;
|
||||
import com.android.wm.shell.shared.bubbles.ParcelableFlyoutMessage;
|
||||
|
||||
/**
|
||||
* Loads the necessary info to populate / present a bubble (name, icon, shortcut).
|
||||
@@ -157,13 +160,16 @@ public class BubbleCreator {
|
||||
dotColor = ColorUtils.blendARGB(badgeBitmapInfo.color,
|
||||
Color.WHITE, WHITE_SCRIM_ALPHA / 255f);
|
||||
|
||||
final BubbleBarFlyoutMessage flyoutMessage =
|
||||
getFlyoutMessage(info.getParcelableFlyoutMessage());
|
||||
|
||||
if (existingBubble == null) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
BubbleView bubbleView = (BubbleView) inflater.inflate(
|
||||
R.layout.bubblebar_item_view, barView, false /* attachToRoot */);
|
||||
|
||||
BubbleBarBubble bubble = new BubbleBarBubble(info, bubbleView,
|
||||
badgeBitmap, bubbleBitmap, dotColor, dotPath, appName);
|
||||
badgeBitmap, bubbleBitmap, dotColor, dotPath, appName, flyoutMessage);
|
||||
bubbleView.setBubble(bubble);
|
||||
return bubble;
|
||||
} else {
|
||||
@@ -174,10 +180,25 @@ public class BubbleCreator {
|
||||
existingBubble.setDotColor(dotColor);
|
||||
existingBubble.setDotPath(dotPath);
|
||||
existingBubble.setAppName(appName);
|
||||
existingBubble.setFlyoutMessage(flyoutMessage);
|
||||
return existingBubble;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private BubbleBarFlyoutMessage getFlyoutMessage(
|
||||
@Nullable ParcelableFlyoutMessage parcelableFlyoutMessage) {
|
||||
if (parcelableFlyoutMessage == null) {
|
||||
return null;
|
||||
}
|
||||
String title = parcelableFlyoutMessage.getTitle();
|
||||
String message = parcelableFlyoutMessage.getMessage();
|
||||
return new BubbleBarFlyoutMessage(
|
||||
loadFlyoutDrawable(parcelableFlyoutMessage.getIcon(), mContext),
|
||||
title == null ? "" : title,
|
||||
message == null ? "" : message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the overflow view shown in the bubble bar.
|
||||
*
|
||||
|
||||
+10
-1
@@ -73,7 +73,16 @@ object FakeBubbleViewFactory {
|
||||
context.resources.getString(com.android.internal.R.string.config_icon_mask)
|
||||
)
|
||||
val bubble =
|
||||
BubbleBarBubble(bubbleInfo, bubbleView, badge, icon, dotColor, dotPath, "test app")
|
||||
BubbleBarBubble(
|
||||
bubbleInfo,
|
||||
bubbleView,
|
||||
badge,
|
||||
icon,
|
||||
dotColor,
|
||||
dotPath,
|
||||
"test app",
|
||||
null,
|
||||
)
|
||||
bubbleView.setBubble(bubble)
|
||||
return bubbleView
|
||||
}
|
||||
|
||||
+10
-1
@@ -80,7 +80,16 @@ class BubbleViewTest {
|
||||
)
|
||||
bubbleView = inflater.inflate(R.layout.bubblebar_item_view, null, false) as BubbleView
|
||||
bubble =
|
||||
BubbleBarBubble(bubbleInfo, bubbleView, bitmap, bitmap, Color.WHITE, Path(), "")
|
||||
BubbleBarBubble(
|
||||
bubbleInfo,
|
||||
bubbleView,
|
||||
bitmap,
|
||||
bitmap,
|
||||
Color.WHITE,
|
||||
Path(),
|
||||
"",
|
||||
null,
|
||||
)
|
||||
bubbleView.setBubble(bubble)
|
||||
}
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync()
|
||||
|
||||
+10
-1
@@ -886,7 +886,16 @@ class BubbleBarViewAnimatorTest {
|
||||
bubbleView =
|
||||
inflater.inflate(R.layout.bubblebar_item_view, bubbleBarView, false) as BubbleView
|
||||
bubble =
|
||||
BubbleBarBubble(bubbleInfo, bubbleView, bitmap, bitmap, Color.WHITE, Path(), "")
|
||||
BubbleBarBubble(
|
||||
bubbleInfo,
|
||||
bubbleView,
|
||||
bitmap,
|
||||
bitmap,
|
||||
Color.WHITE,
|
||||
Path(),
|
||||
"",
|
||||
null,
|
||||
)
|
||||
bubbleView.setBubble(bubble)
|
||||
bubbleBarView.addView(bubbleView)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user