summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Selim Cinek <cinek@google.com> 2019-07-26 11:37:14 -0700
committer Selim Cinek <cinek@google.com> 2019-07-26 12:21:42 -0700
commit08bd435a91100c674d15d5c8759c576358df6685 (patch)
tree1f81c0be0176e75b9e2731189cee966a833e369a
parent2738aa3f79041f8be9183dcc35c9e0220f6829d8 (diff)
Fixed some issues when expanding from the launcher
We didn't exceed the touchslop automatically when we got a touch from launcher which may have led us to not expand when the user flung pretty fast. Additionally could the velocity be very low if we only had very few touch events, leading to the panel also not expanding. We allow the panel to expand easier in those cases. This also fixed the vibration and the animation when the fling happens really fast. Fixes: 137707746 Test: expand from launcher like crazy and observe that it does Change-Id: Ie7d739f829a0c81352c86071f0e888ecc6c57108
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java42
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java23
2 files changed, 56 insertions, 9 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 37855ae592a5..035a5e427039 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -40,6 +40,7 @@ import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.PowerManager;
+import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.Log;
import android.util.MathUtils;
@@ -140,6 +141,12 @@ public class NotificationPanelView extends PanelView implements
private static final int CAP_HEIGHT = 1456;
private static final int FONT_HEIGHT = 2163;
+ /**
+ * Maximum time before which we will expand the panel even for slow motions when getting a
+ * touch passed over from launcher.
+ */
+ private static final int MAX_TIME_TO_OPEN_WHEN_FLINGING_FROM_LAUNCHER = 300;
+
static final String COUNTER_PANEL_OPEN = "panel_open";
static final String COUNTER_PANEL_OPEN_QS = "panel_open_qs";
private static final String COUNTER_PANEL_OPEN_PEEK = "panel_open_peek";
@@ -375,6 +382,8 @@ public class NotificationPanelView extends PanelView implements
private boolean mHeadsUpPinnedMode;
private float mKeyguardHeadsUpShowingAmount = 0.0f;
private boolean mShowingKeyguardHeadsUp;
+ private boolean mAllowExpandForSmallExpansion;
+ private Runnable mExpandAfterLayoutRunnable;
@Inject
public NotificationPanelView(@Named(VIEW_CONTEXT) Context context, AttributeSet attrs,
@@ -666,6 +675,10 @@ public class NotificationPanelView extends PanelView implements
}
updateMaxHeadsUpTranslation();
updateGestureExclusionRect();
+ if (mExpandAfterLayoutRunnable != null) {
+ mExpandAfterLayoutRunnable.run();
+ mExpandAfterLayoutRunnable = null;
+ }
}
private void updateGestureExclusionRect() {
@@ -1065,6 +1078,8 @@ public class NotificationPanelView extends PanelView implements
mDownY = event.getY();
mCollapsedOnDown = isFullyCollapsed();
mListenForHeadsUp = mCollapsedOnDown && mHeadsUpManager.hasPinnedHeadsUp();
+ mAllowExpandForSmallExpansion = mExpectingSynthesizedDown;
+ mTouchSlopExceededBeforeDown = mExpectingSynthesizedDown;
if (mExpectingSynthesizedDown) {
mLastEventSynthesizedDown = true;
} else {
@@ -1123,6 +1138,20 @@ public class NotificationPanelView extends PanelView implements
}
@Override
+ protected boolean shouldExpandWhenNotFlinging() {
+ if (super.shouldExpandWhenNotFlinging()) {
+ return true;
+ }
+ if (mAllowExpandForSmallExpansion) {
+ // When we get a touch that came over from launcher, the velocity isn't always correct
+ // Let's err on expanding if the gesture has been reasonably slow
+ long timeSinceDown = SystemClock.uptimeMillis() - mDownTime;
+ return timeSinceDown <= MAX_TIME_TO_OPEN_WHEN_FLINGING_FROM_LAUNCHER;
+ }
+ return false;
+ }
+
+ @Override
protected float getOpeningHeight() {
return mNotificationStackScroller.getOpeningHeight();
}
@@ -1294,10 +1323,19 @@ public class NotificationPanelView extends PanelView implements
*
* @param velocity unit is in px / millis
*/
- public void stopWaitingForOpenPanelGesture(float velocity) {
+ public void stopWaitingForOpenPanelGesture(final float velocity) {
if (mExpectingSynthesizedDown) {
mExpectingSynthesizedDown = false;
- fling(velocity > 1f ? 1000f * velocity : 0, true /* animate */);
+ maybeVibrateOnOpening();
+ Runnable runnable = () -> fling(velocity > 1f ? 1000f * velocity : 0,
+ true /* expand */);
+ if (mStatusBar.getStatusBarWindow().getHeight()
+ != mStatusBar.getStatusBarHeight()) {
+ // The panel is already expanded to its full size, let's expand directly
+ runnable.run();
+ } else {
+ mExpandAfterLayoutRunnable = runnable;
+ }
onTrackingStopped(false);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index a5b221bbad8c..65ecb88dd41c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -62,7 +62,8 @@ public abstract class PanelView extends FrameLayout {
private static final int INITIAL_OPENING_PEEK_DURATION = 200;
private static final int PEEK_ANIMATION_DURATION = 360;
private static final int NO_FIXED_DURATION = -1;
- private long mDownTime;
+ protected long mDownTime;
+ protected boolean mTouchSlopExceededBeforeDown;
private float mMinExpandHeight;
private LockscreenGestureLogger mLockscreenGestureLogger = new LockscreenGestureLogger();
private boolean mPanelUpdateWhenAnimatorEnds;
@@ -323,7 +324,7 @@ public abstract class PanelView extends FrameLayout {
if (!mGestureWaitForTouchSlop || (mHeightAnimator != null && !mHintAnimationRunning)
|| mPeekAnimator != null) {
mTouchSlopExceeded = (mHeightAnimator != null && !mHintAnimationRunning)
- || mPeekAnimator != null;
+ || mPeekAnimator != null || mTouchSlopExceededBeforeDown;
cancelHeightAnimator();
cancelPeek();
onTrackingStarted();
@@ -409,9 +410,7 @@ public abstract class PanelView extends FrameLayout {
runPeekAnimation(INITIAL_OPENING_PEEK_DURATION, getOpeningHeight(),
false /* collapseWhenFinished */);
notifyBarPanelExpansionChanged();
- if (mVibrateOnOpening) {
- mVibratorHelper.vibrate(VibrationEffect.EFFECT_TICK);
- }
+ maybeVibrateOnOpening();
//TODO: keyguard opens QS a different way; log that too?
@@ -426,6 +425,12 @@ public abstract class PanelView extends FrameLayout {
rot);
}
+ protected void maybeVibrateOnOpening() {
+ if (mVibrateOnOpening) {
+ mVibratorHelper.vibrate(VibrationEffect.EFFECT_TICK);
+ }
+ }
+
protected abstract float getOpeningHeight();
/**
@@ -577,7 +582,7 @@ public abstract class PanelView extends FrameLayout {
mInitialTouchY = y;
mInitialTouchX = x;
mTouchStartedInEmptyArea = !isInContentBounds(x, y);
- mTouchSlopExceeded = false;
+ mTouchSlopExceeded = mTouchSlopExceededBeforeDown;
mJustPeeked = false;
mMotionAborted = false;
mPanelClosedOnDown = isFullyCollapsed();
@@ -680,12 +685,16 @@ public abstract class PanelView extends FrameLayout {
return true;
}
if (Math.abs(vectorVel) < mFlingAnimationUtils.getMinVelocityPxPerSecond()) {
- return getExpandedFraction() > 0.5f;
+ return shouldExpandWhenNotFlinging();
} else {
return vel > 0;
}
}
+ protected boolean shouldExpandWhenNotFlinging() {
+ return getExpandedFraction() > 0.5f;
+ }
+
/**
* @param x the final x-coordinate when the finger was lifted
* @param y the final y-coordinate when the finger was lifted