Merge "Show last selected bubble when stack expands" into rvc-dev am: 2b40d3c462 am: b0b73c60cc

Change-Id: I01330af0e4fe3f120a4c26ce89e789d6d49643ea
This commit is contained in:
TreeHugger Robot
2020-04-13 21:46:32 +00:00
committed by Automerger Merge Worker
2 changed files with 17 additions and 3 deletions

View File

@@ -120,6 +120,7 @@ public class BubbleData {
/** Bubbles that are being loaded but haven't been added to the stack just yet. */ /** Bubbles that are being loaded but haven't been added to the stack just yet. */
private final List<Bubble> mPendingBubbles; private final List<Bubble> mPendingBubbles;
private Bubble mSelectedBubble; private Bubble mSelectedBubble;
private boolean mShowingOverflow;
private boolean mExpanded; private boolean mExpanded;
private final int mMaxBubbles; private final int mMaxBubbles;
private final int mMaxOverflowBubbles; private final int mMaxOverflowBubbles;
@@ -215,6 +216,10 @@ public class BubbleData {
dispatchPendingChanges(); dispatchPendingChanges();
} }
void setShowingOverflow(boolean showingOverflow) {
mShowingOverflow = showingOverflow;
}
private void moveOverflowBubbleToPending(Bubble b) { private void moveOverflowBubbleToPending(Bubble b) {
// Preserve new order for next repack, which sorts by last updated time. // Preserve new order for next repack, which sorts by last updated time.
b.markUpdatedAt(mTimeSource.currentTimeMillis()); b.markUpdatedAt(mTimeSource.currentTimeMillis());
@@ -513,9 +518,11 @@ public class BubbleData {
if (DEBUG_BUBBLE_DATA) { if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "setSelectedBubbleInternal: " + bubble); Log.d(TAG, "setSelectedBubbleInternal: " + bubble);
} }
if (Objects.equals(bubble, mSelectedBubble)) { if (!mShowingOverflow && Objects.equals(bubble, mSelectedBubble)) {
return; return;
} }
// Otherwise, if we are showing the overflow menu, return to the previously selected bubble.
if (bubble != null && !mBubbles.contains(bubble) && !mOverflowBubbles.contains(bubble)) { if (bubble != null && !mBubbles.contains(bubble) && !mOverflowBubbles.contains(bubble)) {
Log.e(TAG, "Cannot select bubble which doesn't exist!" Log.e(TAG, "Cannot select bubble which doesn't exist!"
+ " (" + bubble + ") bubbles=" + mBubbles); + " (" + bubble + ") bubbles=" + mBubbles);
@@ -559,6 +566,10 @@ public class BubbleData {
mStateChange.orderChanged |= repackAll(); mStateChange.orderChanged |= repackAll();
// Save the state which should be returned to when expanded (with no other changes) // Save the state which should be returned to when expanded (with no other changes)
if (mShowingOverflow) {
// Show previously selected bubble instead of overflow menu on next expansion.
setSelectedBubbleInternal(mSelectedBubble);
}
if (mBubbles.indexOf(mSelectedBubble) > 0) { if (mBubbles.indexOf(mSelectedBubble) > 0) {
// Move the selected bubble to the top while collapsed. // Move the selected bubble to the top while collapsed.
if (!mSelectedBubble.isOngoing() && mBubbles.get(0).isOngoing()) { if (!mSelectedBubble.isOngoing() && mBubbles.get(0).isOngoing()) {

View File

@@ -442,8 +442,8 @@ public class BubbleStackView extends FrameLayout {
// that means overflow was previously expanded. Set the selected bubble // that means overflow was previously expanded. Set the selected bubble
// internally without going through BubbleData (which would ignore it since it's // internally without going through BubbleData (which would ignore it since it's
// already selected). // already selected).
mBubbleData.setShowingOverflow(true);
setSelectedBubble(clickedBubble); setSelectedBubble(clickedBubble);
} }
} else { } else {
// Otherwise, we either tapped the stack (which means we're collapsed // Otherwise, we either tapped the stack (which means we're collapsed
@@ -1232,8 +1232,12 @@ public class BubbleStackView extends FrameLayout {
if (mExpandedBubble != null && mExpandedBubble.equals(bubbleToSelect)) { if (mExpandedBubble != null && mExpandedBubble.equals(bubbleToSelect)) {
return; return;
} }
if (bubbleToSelect == null || bubbleToSelect.getKey() != BubbleOverflow.KEY) {
mBubbleData.setShowingOverflow(false);
}
final BubbleViewProvider previouslySelected = mExpandedBubble; final BubbleViewProvider previouslySelected = mExpandedBubble;
mExpandedBubble = bubbleToSelect; mExpandedBubble = bubbleToSelect;
updatePointerPosition();
if (mIsExpanded) { if (mIsExpanded) {
// Make the container of the expanded view transparent before removing the expanded view // Make the container of the expanded view transparent before removing the expanded view
@@ -1243,7 +1247,6 @@ public class BubbleStackView extends FrameLayout {
mSurfaceSynchronizer.syncSurfaceAndRun(() -> { mSurfaceSynchronizer.syncSurfaceAndRun(() -> {
previouslySelected.setContentVisibility(false); previouslySelected.setContentVisibility(false);
updateExpandedBubble(); updateExpandedBubble();
updatePointerPosition();
requestUpdate(); requestUpdate();
logBubbleEvent(previouslySelected, logBubbleEvent(previouslySelected,