diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2021-11-29 19:18:56 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-11-29 19:18:56 +0000 |
commit | bd74e73b975cf815ae6ed51348e4d56d08333b6c (patch) | |
tree | 2e60cca7b69592487b8b6699cd104adc94935a0e | |
parent | 91ce4753069539a7033a3d1fdf04ffadec6fbe69 (diff) | |
parent | dbb136d2f57e2fc7ffa2ceea8a1ab80d11e9ca1f (diff) |
Merge "Fix user education placement" into sc-v2-dev
-rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java | 39 | ||||
-rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt | 2 |
2 files changed, 32 insertions, 9 deletions
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 4ffb68530838..b40021ec82a7 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 @@ -530,9 +530,10 @@ public class BubbleStackView extends FrameLayout // Otherwise, we either tapped the stack (which means we're collapsed // and should expand) or the currently selected bubble (we're expanded // and should collapse). - if (!maybeShowStackEdu()) { + if (!maybeShowStackEdu() && !mShowedUserEducationInTouchListenerActive) { mBubbleData.setExpanded(!mBubbleData.isExpanded()); } + mShowedUserEducationInTouchListenerActive = false; } } }; @@ -550,6 +551,14 @@ public class BubbleStackView extends FrameLayout return true; } + mShowedUserEducationInTouchListenerActive = false; + if (maybeShowStackEdu()) { + mShowedUserEducationInTouchListenerActive = true; + return true; + } else if (isStackEduShowing()) { + mStackEduView.hide(false /* fromExpansion */); + } + // If the manage menu is visible, just hide it. if (mShowingManage) { showManageMenu(false /* show */); @@ -608,7 +617,8 @@ public class BubbleStackView extends FrameLayout // If we're expanding or collapsing, ignore all touch events. if (mIsExpansionAnimating // Also ignore events if we shouldn't be draggable. - || (mPositioner.showingInTaskbar() && !mIsExpanded)) { + || (mPositioner.showingInTaskbar() && !mIsExpanded) + || mShowedUserEducationInTouchListenerActive) { return; } @@ -629,7 +639,7 @@ public class BubbleStackView extends FrameLayout mExpandedAnimationController.dragBubbleOut( v, viewInitialX + dx, viewInitialY + dy); } else { - if (mStackEduView != null) { + if (isStackEduShowing()) { mStackEduView.hide(false /* fromExpansion */); } mStackAnimationController.moveStackFromTouch( @@ -647,6 +657,10 @@ public class BubbleStackView extends FrameLayout || (mPositioner.showingInTaskbar() && !mIsExpanded)) { return; } + if (mShowedUserEducationInTouchListenerActive) { + mShowedUserEducationInTouchListenerActive = false; + return; + } // First, see if the magnetized object consumes the event - if so, the bubble was // released in the target or flung out of it, and we should ignore the event. @@ -739,6 +753,7 @@ public class BubbleStackView extends FrameLayout private ImageView mManageSettingsIcon; private TextView mManageSettingsText; private boolean mShowingManage = false; + private boolean mShowedUserEducationInTouchListenerActive = false; private PhysicsAnimator.SpringConfig mManageSpringConfig = new PhysicsAnimator.SpringConfig( SpringForce.STIFFNESS_MEDIUM, SpringForce.DAMPING_RATIO_LOW_BOUNCY); private BubblePositioner mPositioner; @@ -930,10 +945,12 @@ public class BubbleStackView extends FrameLayout showManageMenu(false /* show */); } else if (mManageEduView != null && mManageEduView.getVisibility() == VISIBLE) { mManageEduView.hide(); - } else if (mStackEduView != null && mStackEduView.getVisibility() == VISIBLE) { + } else if (isStackEduShowing()) { mStackEduView.hide(false /* isExpanding */); } else if (mBubbleData.isExpanded()) { mBubbleData.setExpanded(false); + } else { + maybeShowStackEdu(); } }); @@ -1164,7 +1181,7 @@ public class BubbleStackView extends FrameLayout * @return true if education view for collapsed stack should show and was not showing before. */ private boolean maybeShowStackEdu() { - if (!shouldShowStackEdu()) { + if (!shouldShowStackEdu() || isExpanded()) { return false; } if (mStackEduView == null) { @@ -1175,9 +1192,13 @@ public class BubbleStackView extends FrameLayout return mStackEduView.show(mPositioner.getDefaultStartPosition()); } + private boolean isStackEduShowing() { + return mStackEduView != null && mStackEduView.getVisibility() == VISIBLE; + } + // Recreates & shows the education views. Call when a theme/config change happens. private void updateUserEdu() { - if (mStackEduView != null && mStackEduView.getVisibility() == VISIBLE) { + if (isStackEduShowing()) { removeView(mStackEduView); mStackEduView = new StackEducationView(mContext, mPositioner, mBubbleController); addView(mStackEduView); @@ -1859,7 +1880,7 @@ public class BubbleStackView extends FrameLayout cancelDelayedExpandCollapseSwitchAnimations(); final boolean showVertically = mPositioner.showBubblesVertically(); mIsExpanded = true; - if (mStackEduView != null) { + if (isStackEduShowing()) { mStackEduView.hide(true /* fromExpansion */); } beforeExpandedViewAnimation(); @@ -2397,7 +2418,7 @@ public class BubbleStackView extends FrameLayout if (flyoutMessage == null || flyoutMessage.message == null || !bubble.showFlyout() - || (mStackEduView != null && mStackEduView.getVisibility() == VISIBLE) + || isStackEduShowing() || isExpanded() || mIsExpansionAnimating || mIsGestureInProgress @@ -2519,7 +2540,7 @@ public class BubbleStackView extends FrameLayout * them. */ public void getTouchableRegion(Rect outRect) { - if (mStackEduView != null && mStackEduView.getVisibility() == VISIBLE) { + if (isStackEduShowing()) { // When user education shows then capture all touches outRect.set(0, 0, getWidth(), getHeight()); return; diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt index f6a90b7a76cd..3846de73842d 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt @@ -125,6 +125,7 @@ class StackEducationView constructor( * @return true if user education was shown, false otherwise. */ fun show(stackPosition: PointF): Boolean { + isHiding = false if (visibility == VISIBLE) return false controller.updateWindowFlagsForBackpress(true /* interceptBack */) @@ -164,6 +165,7 @@ class StackEducationView constructor( */ fun hide(isExpanding: Boolean) { if (visibility != VISIBLE || isHiding) return + isHiding = true controller.updateWindowFlagsForBackpress(false /* interceptBack */) animate() |