Merge "Send bubble state updates to launcher & respond to launcher" into udc-dev
This commit is contained in:
@@ -1052,7 +1052,27 @@ public class BubbleController implements ConfigurationChangeListener,
|
||||
* Expands and selects the provided bubble as long as it already exists in the stack or the
|
||||
* overflow.
|
||||
*
|
||||
* This is currently only used when opening a bubble via clicking on a conversation widget.
|
||||
* This is used by external callers (launcher).
|
||||
*/
|
||||
public void expandStackAndSelectBubbleFromLauncher(String key) {
|
||||
Bubble b = mBubbleData.getAnyBubbleWithkey(key);
|
||||
if (b == null) {
|
||||
return;
|
||||
}
|
||||
if (mBubbleData.hasBubbleInStackWithKey(b.getKey())) {
|
||||
// already in the stack
|
||||
mBubbleData.setSelectedBubbleFromLauncher(b);
|
||||
mLayerView.showExpandedView(b);
|
||||
} else if (mBubbleData.hasOverflowBubbleWithKey(b.getKey())) {
|
||||
// TODO: (b/271468319) handle overflow
|
||||
} else {
|
||||
Log.w(TAG, "didn't add bubble from launcher: " + key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands and selects the provided bubble as long as it already exists in the stack or the
|
||||
* overflow. This is currently used when opening a bubble via clicking on a conversation widget.
|
||||
*/
|
||||
public void expandStackAndSelectBubble(Bubble b) {
|
||||
if (b == null) {
|
||||
@@ -1703,6 +1723,14 @@ public class BubbleController implements ConfigurationChangeListener,
|
||||
|
||||
// Update the cached state for queries from SysUI
|
||||
mImpl.mCachedState.update(update);
|
||||
|
||||
if (isShowingAsBubbleBar() && mBubbleStateListener != null) {
|
||||
BubbleBarUpdate bubbleBarUpdate = update.toBubbleBarUpdate();
|
||||
// Some updates aren't relevant to the bubble bar so check first.
|
||||
if (bubbleBarUpdate.anythingChanged()) {
|
||||
mBubbleStateListener.onBubbleStateChange(bubbleBarUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1972,17 +2000,20 @@ public class BubbleController implements ConfigurationChangeListener,
|
||||
|
||||
@Override
|
||||
public void showBubble(String key, boolean onLauncherHome) {
|
||||
// TODO
|
||||
mMainExecutor.execute(() -> {
|
||||
mBubblePositioner.setShowingInBubbleBar(onLauncherHome);
|
||||
mController.expandStackAndSelectBubbleFromLauncher(key);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBubble(String key, int reason) {
|
||||
// TODO
|
||||
// TODO (b/271466616) allow removals from launcher
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collapseBubbles() {
|
||||
// TODO
|
||||
mMainExecutor.execute(() -> mController.collapseStack());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -334,6 +334,35 @@ public class BubbleData {
|
||||
dispatchPendingChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the selected bubble and expands it, but doesn't dispatch changes
|
||||
* to {@link BubbleData.Listener}. This is used for updates coming from launcher whose views
|
||||
* will already be updated so we don't need to notify them again, but BubbleData should be
|
||||
* updated to have the correct state.
|
||||
*/
|
||||
public void setSelectedBubbleFromLauncher(BubbleViewProvider bubble) {
|
||||
if (DEBUG_BUBBLE_DATA) {
|
||||
Log.d(TAG, "setSelectedBubbleFromLauncher: " + bubble);
|
||||
}
|
||||
mExpanded = true;
|
||||
if (Objects.equals(bubble, mSelectedBubble)) {
|
||||
return;
|
||||
}
|
||||
boolean isOverflow = bubble != null && BubbleOverflow.KEY.equals(bubble.getKey());
|
||||
if (bubble != null
|
||||
&& !mBubbles.contains(bubble)
|
||||
&& !mOverflowBubbles.contains(bubble)
|
||||
&& !isOverflow) {
|
||||
Log.e(TAG, "Cannot select bubble which doesn't exist!"
|
||||
+ " (" + bubble + ") bubbles=" + mBubbles);
|
||||
return;
|
||||
}
|
||||
if (bubble != null && !isOverflow) {
|
||||
((Bubble) bubble).markAsAccessedAt(mTimeSource.currentTimeMillis());
|
||||
}
|
||||
mSelectedBubble = bubble;
|
||||
}
|
||||
|
||||
public void setSelectedBubble(BubbleViewProvider bubble) {
|
||||
if (DEBUG_BUBBLE_DATA) {
|
||||
Log.d(TAG, "setSelectedBubble: " + bubble);
|
||||
|
||||
Reference in New Issue
Block a user