summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mady Mellor <madym@google.com> 2021-11-17 17:03:23 -0800
committer Mady Mellor <madym@google.com> 2021-11-24 17:10:34 -0800
commitdbb136d2f57e2fc7ffa2ceea8a1ab80d11e9ca1f (patch)
tree60d46fb32de2928306dc527509e07dcc3a9b900d
parent35185d54b4352ac30d587ee42b360d9c46136d10 (diff)
Fix user education placement
We were only showing the user education on click, so you could drag the bubble then click on it, then the user education would appear. However, the bubble wouldn't be in the spot we'd expect due to the initial drag so the user education would be misplaced. This change fixes the issue by showing the user education in the touchlistener onDown(*). Subsequent actions in that gesture won't do anything. A small issue is that the clickListener could be triggered in this state and then immediately hide the education, to work around this I added a flag to indicate if the education showed from the touchListener & skip hiding in that case. (*) Ideally this would occur in a proper down/up action rather than onDown but there's a lot going on in the touch handling and I think this is simplest. Test: manual - (reset device) check that tapping the bubble shows the education - (reset device) check that dragging the bubble shows the education and the bubble doesn't move on the drag - education shouldn't show more than once - bubble should be draggable after the edu goes away Bug: 200151972 Change-Id: I0bdb8d165641b5cad234b3053eb73e0575916102
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java39
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt2
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 300319a2f78f..a963557c4d62 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
@@ -529,9 +529,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;
}
}
};
@@ -549,6 +550,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 */);
@@ -607,7 +616,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;
}
@@ -628,7 +638,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(
@@ -646,6 +656,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.
@@ -738,6 +752,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;
@@ -929,10 +944,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();
}
});
@@ -1157,7 +1174,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) {
@@ -1168,9 +1185,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);
@@ -1852,7 +1873,7 @@ public class BubbleStackView extends FrameLayout
cancelDelayedExpandCollapseSwitchAnimations();
final boolean showVertically = mPositioner.showBubblesVertically();
mIsExpanded = true;
- if (mStackEduView != null) {
+ if (isStackEduShowing()) {
mStackEduView.hide(true /* fromExpansion */);
}
beforeExpandedViewAnimation();
@@ -2390,7 +2411,7 @@ public class BubbleStackView extends FrameLayout
if (flyoutMessage == null
|| flyoutMessage.message == null
|| !bubble.showFlyout()
- || (mStackEduView != null && mStackEduView.getVisibility() == VISIBLE)
+ || isStackEduShowing()
|| isExpanded()
|| mIsExpansionAnimating
|| mIsGestureInProgress
@@ -2512,7 +2533,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()