diff --git a/libs/WindowManager/Shell/res/layout/bubble_manage_button.xml b/libs/WindowManager/Shell/res/layout/bubble_manage_button.xml index 7658fca588221..0cf6d73162d24 100644 --- a/libs/WindowManager/Shell/res/layout/bubble_manage_button.xml +++ b/libs/WindowManager/Shell/res/layout/bubble_manage_button.xml @@ -17,7 +17,7 @@ - diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml index 7da31aa7d03a0..757e83a25319e 100644 --- a/libs/WindowManager/Shell/res/values/dimen.xml +++ b/libs/WindowManager/Shell/res/values/dimen.xml @@ -184,14 +184,8 @@ 40dp 20dp 4dp - - - 160dp - - 65dp - - 72dp + + 400dp 48dp diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java index e7764ea1a21e6..95b80df7fcbd2 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java @@ -636,10 +636,16 @@ public class BubbleController { } } - /** For the overflow to be focusable & receive key events the flags must be update. **/ - void updateWindowFlagsForOverflow(boolean showingOverflow) { + /** + * In some situations bubble's should be able to receive key events for back: + * - when the bubble overflow is showing + * - when the user education for the stack is showing. + * + * @param interceptBack whether back should be intercepted or not. + */ + void updateWindowFlagsForBackpress(boolean interceptBack) { if (mStackView != null && mAddedToWindowManager) { - mWmLayoutParams.flags = showingOverflow + mWmLayoutParams.flags = interceptBack ? 0 : WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java index 252b588ec63f9..4ac7dcf3d23a1 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java @@ -228,7 +228,7 @@ public class BubbleExpandedView extends LinearLayout { @Override public void onBackPressedOnTaskRoot(int taskId) { if (mTaskId == taskId && mStackView.isExpanded()) { - mController.collapseStack(); + mStackView.onBackPressed(); } } }; diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflowContainerView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflowContainerView.java index ede42285d9cdb..5e9d97f23c577 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflowContainerView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflowContainerView.java @@ -142,7 +142,7 @@ public class BubbleOverflowContainerView extends LinearLayout { super.onAttachedToWindow(); if (mController != null) { // For the overflow to get key events (e.g. back press) we need to adjust the flags - mController.updateWindowFlagsForOverflow(true); + mController.updateWindowFlagsForBackpress(true); } setOnKeyListener(mKeyListener); } @@ -151,7 +151,7 @@ public class BubbleOverflowContainerView extends LinearLayout { protected void onDetachedFromWindow() { super.onDetachedFromWindow(); if (mController != null) { - mController.updateWindowFlagsForOverflow(false); + mController.updateWindowFlagsForBackpress(false); } setOnKeyListener(null); } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java index df804ec174d38..6cff05542aa47 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java @@ -241,6 +241,13 @@ public class BubblePositioner { return mPositionRect; } + /** + * @return a rect of the screen size. + */ + public Rect getScreenRect() { + return mScreenRect; + } + /** * @return the relevant insets (status bar, nav bar, cutouts). If taskbar is showing, its * inset is not included here. diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java index 8f2df4ab39722..3d2505ef76999 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java @@ -110,9 +110,6 @@ public class BubbleStackView extends FrameLayout private static final int FADE_IN_DURATION = 320; - /** Percent to darken the bubbles when they're in the dismiss target. */ - private static final float DARKEN_PERCENT = 0.3f; - /** How long to wait, in milliseconds, before hiding the flyout. */ @VisibleForTesting static final int FLYOUT_HIDE_AFTER = 5000; @@ -559,7 +556,7 @@ public class BubbleStackView extends FrameLayout if (mBubbleData.isExpanded()) { if (mManageEduView != null) { - mManageEduView.hide(false /* show */); + mManageEduView.hide(); } // If we're expanded, tell the animation controller to prepare to drag this bubble, @@ -797,8 +794,6 @@ public class BubbleStackView extends FrameLayout mBubbleContainer.setClipChildren(false); addView(mBubbleContainer, new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); - updateUserEdu(); - mExpandedViewContainer = new FrameLayout(context); mExpandedViewContainer.setElevation(elevation); mExpandedViewContainer.setClipChildren(false); @@ -932,8 +927,10 @@ public class BubbleStackView extends FrameLayout setOnClickListener(view -> { if (mShowingManage) { showManageMenu(false /* show */); + } else if (mManageEduView != null && mManageEduView.getVisibility() == VISIBLE) { + mManageEduView.hide(); } else if (mStackEduView != null && mStackEduView.getVisibility() == VISIBLE) { - mStackEduView.hide(false); + mStackEduView.hide(false /* isExpanding */); } else if (mBubbleData.isExpanded()) { mBubbleData.setExpanded(false); } @@ -1132,10 +1129,10 @@ public class BubbleStackView extends FrameLayout return; } if (mManageEduView == null) { - mManageEduView = new ManageEducationView(mContext); + mManageEduView = new ManageEducationView(mContext, mPositioner); addView(mManageEduView); } - mManageEduView.show(mExpandedBubble.getExpandedView(), mTempRect); + mManageEduView.show(mExpandedBubble.getExpandedView()); } /** @@ -1163,21 +1160,27 @@ public class BubbleStackView extends FrameLayout return false; } if (mStackEduView == null) { - mStackEduView = new StackEducationView(mContext); + mStackEduView = new StackEducationView(mContext, mPositioner, mBubbleController); addView(mStackEduView); } mBubbleContainer.bringToFront(); return mStackEduView.show(mPositioner.getDefaultStartPosition()); } + // Recreates & shows the education views. Call when a theme/config change happens. private void updateUserEdu() { - maybeShowStackEdu(); - if (mManageEduView != null) { - mManageEduView.invalidate(); + if (mStackEduView != null && mStackEduView.getVisibility() == VISIBLE) { + removeView(mStackEduView); + mStackEduView = new StackEducationView(mContext, mPositioner, mBubbleController); + addView(mStackEduView); + mBubbleContainer.bringToFront(); // Stack appears on top of the stack education + mStackEduView.show(mPositioner.getDefaultStartPosition()); } - maybeShowManageEdu(); - if (mStackEduView != null) { - mStackEduView.invalidate(); + if (mManageEduView != null && mManageEduView.getVisibility() == VISIBLE) { + removeView(mManageEduView); + mManageEduView = new ManageEducationView(mContext, mPositioner); + addView(mManageEduView); + mManageEduView.show(mExpandedBubble.getExpandedView()); } } @@ -1274,6 +1277,7 @@ public class BubbleStackView extends FrameLayout setUpManageMenu(); setUpFlyout(); setUpDismissView(); + updateUserEdu(); mBubbleSize = mPositioner.getBubbleSize(); for (Bubble b : mBubbleData.getBubbles()) { if (b.getIconView() == null) { @@ -1730,6 +1734,21 @@ public class BubbleStackView extends FrameLayout notifyExpansionChanged(mExpandedBubble, mIsExpanded); } + /** + * Called when back press occurs while bubbles are expanded. + */ + public void onBackPressed() { + if (mIsExpanded) { + if (mShowingManage) { + showManageMenu(false); + } else if (mManageEduView != null && mManageEduView.getVisibility() == VISIBLE) { + mManageEduView.hide(); + } else { + setExpanded(false); + } + } + } + void setBubbleVisibility(Bubble b, boolean visible) { if (b.getIconView() != null) { b.getIconView().setVisibility(visible ? VISIBLE : GONE); @@ -1955,6 +1974,9 @@ public class BubbleStackView extends FrameLayout private void animateCollapse() { cancelDelayedExpandCollapseSwitchAnimations(); + if (mManageEduView != null && mManageEduView.getVisibility() == VISIBLE) { + mManageEduView.hide(); + } // Hide the menu if it's visible. showManageMenu(false); @@ -2032,7 +2054,7 @@ public class BubbleStackView extends FrameLayout final BubbleViewProvider previouslySelected = mExpandedBubble; beforeExpandedViewAnimation(); if (mManageEduView != null) { - mManageEduView.hide(false /* fromExpansion */); + mManageEduView.hide(); } if (DEBUG_BUBBLE_STACK_VIEW) { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt index 4cc67025fff4d..eb4737ac6c632 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt @@ -18,12 +18,13 @@ package com.android.wm.shell.bubbles import android.content.Context import android.graphics.Color import android.graphics.Rect +import android.graphics.drawable.ColorDrawable import android.view.LayoutInflater import android.view.View +import android.view.ViewGroup import android.widget.Button import android.widget.LinearLayout -import android.widget.TextView -import com.android.internal.util.ContrastColorUtil +import com.android.internal.R.color.system_neutral1_900 import com.android.wm.shell.R import com.android.wm.shell.animation.Interpolators @@ -31,21 +32,22 @@ import com.android.wm.shell.animation.Interpolators * User education view to highlight the manage button that allows a user to configure the settings * for the bubble. Shown only the first time a user expands a bubble. */ -class ManageEducationView constructor(context: Context) : LinearLayout(context) { +class ManageEducationView constructor(context: Context, positioner: BubblePositioner) + : LinearLayout(context) { - private val TAG = if (BubbleDebugConfig.TAG_WITH_CLASS_NAME) "BubbleManageEducationView" + private val TAG = if (BubbleDebugConfig.TAG_WITH_CLASS_NAME) "ManageEducationView" else BubbleDebugConfig.TAG_BUBBLES private val ANIMATE_DURATION: Long = 200 - private val ANIMATE_DURATION_SHORT: Long = 40 - private val manageView by lazy { findViewById(R.id.manage_education_view) } - private val manageButton by lazy { findViewById