Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 608c18bd authored by Selim Cinek's avatar Selim Cinek Committed by Android (Google) Code Review
Browse files

Merge "Fixed some issues when expanding from the launcher" into qt-r1-dev

parents fed8ece4 08bd435a
Loading
Loading
Loading
Loading
+40 −2
Original line number Original line Diff line number Diff line
@@ -40,6 +40,7 @@ import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Region;
import android.os.PowerManager;
import android.os.PowerManager;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Log;
import android.util.MathUtils;
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 CAP_HEIGHT = 1456;
    private static final int FONT_HEIGHT = 2163;
    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 = "panel_open";
    static final String COUNTER_PANEL_OPEN_QS = "panel_open_qs";
    static final String COUNTER_PANEL_OPEN_QS = "panel_open_qs";
    private static final String COUNTER_PANEL_OPEN_PEEK = "panel_open_peek";
    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 boolean mHeadsUpPinnedMode;
    private float mKeyguardHeadsUpShowingAmount = 0.0f;
    private float mKeyguardHeadsUpShowingAmount = 0.0f;
    private boolean mShowingKeyguardHeadsUp;
    private boolean mShowingKeyguardHeadsUp;
    private boolean mAllowExpandForSmallExpansion;
    private Runnable mExpandAfterLayoutRunnable;


    @Inject
    @Inject
    public NotificationPanelView(@Named(VIEW_CONTEXT) Context context, AttributeSet attrs,
    public NotificationPanelView(@Named(VIEW_CONTEXT) Context context, AttributeSet attrs,
@@ -671,6 +680,10 @@ public class NotificationPanelView extends PanelView implements
        }
        }
        updateMaxHeadsUpTranslation();
        updateMaxHeadsUpTranslation();
        updateGestureExclusionRect();
        updateGestureExclusionRect();
        if (mExpandAfterLayoutRunnable != null) {
            mExpandAfterLayoutRunnable.run();
            mExpandAfterLayoutRunnable = null;
        }
    }
    }


    private void updateGestureExclusionRect() {
    private void updateGestureExclusionRect() {
@@ -1069,6 +1082,8 @@ public class NotificationPanelView extends PanelView implements
            mDownY = event.getY();
            mDownY = event.getY();
            mCollapsedOnDown = isFullyCollapsed();
            mCollapsedOnDown = isFullyCollapsed();
            mListenForHeadsUp = mCollapsedOnDown && mHeadsUpManager.hasPinnedHeadsUp();
            mListenForHeadsUp = mCollapsedOnDown && mHeadsUpManager.hasPinnedHeadsUp();
            mAllowExpandForSmallExpansion = mExpectingSynthesizedDown;
            mTouchSlopExceededBeforeDown = mExpectingSynthesizedDown;
            if (mExpectingSynthesizedDown) {
            if (mExpectingSynthesizedDown) {
                mLastEventSynthesizedDown = true;
                mLastEventSynthesizedDown = true;
            } else {
            } else {
@@ -1126,6 +1141,20 @@ public class NotificationPanelView extends PanelView implements
                / (mQsMaxExpansionHeight - mQsMinExpansionHeight));
                / (mQsMaxExpansionHeight - mQsMinExpansionHeight));
    }
    }


    @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
    @Override
    protected float getOpeningHeight() {
    protected float getOpeningHeight() {
        return mNotificationStackScroller.getOpeningHeight();
        return mNotificationStackScroller.getOpeningHeight();
@@ -1299,10 +1328,19 @@ public class NotificationPanelView extends PanelView implements
     *
     *
     * @param velocity unit is in px / millis
     * @param velocity unit is in px / millis
     */
     */
    public void stopWaitingForOpenPanelGesture(float velocity) {
    public void stopWaitingForOpenPanelGesture(final float velocity) {
        if (mExpectingSynthesizedDown) {
        if (mExpectingSynthesizedDown) {
            mExpectingSynthesizedDown = false;
            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);
            onTrackingStopped(false);
        }
        }
    }
    }
+16 −7
Original line number Original line Diff line number Diff line
@@ -62,7 +62,8 @@ public abstract class PanelView extends FrameLayout {
    private static final int INITIAL_OPENING_PEEK_DURATION = 200;
    private static final int INITIAL_OPENING_PEEK_DURATION = 200;
    private static final int PEEK_ANIMATION_DURATION = 360;
    private static final int PEEK_ANIMATION_DURATION = 360;
    private static final int NO_FIXED_DURATION = -1;
    private static final int NO_FIXED_DURATION = -1;
    private long mDownTime;
    protected long mDownTime;
    protected boolean mTouchSlopExceededBeforeDown;
    private float mMinExpandHeight;
    private float mMinExpandHeight;
    private LockscreenGestureLogger mLockscreenGestureLogger = new LockscreenGestureLogger();
    private LockscreenGestureLogger mLockscreenGestureLogger = new LockscreenGestureLogger();
    private boolean mPanelUpdateWhenAnimatorEnds;
    private boolean mPanelUpdateWhenAnimatorEnds;
@@ -323,7 +324,7 @@ public abstract class PanelView extends FrameLayout {
                if (!mGestureWaitForTouchSlop || (mHeightAnimator != null && !mHintAnimationRunning)
                if (!mGestureWaitForTouchSlop || (mHeightAnimator != null && !mHintAnimationRunning)
                        || mPeekAnimator != null) {
                        || mPeekAnimator != null) {
                    mTouchSlopExceeded = (mHeightAnimator != null && !mHintAnimationRunning)
                    mTouchSlopExceeded = (mHeightAnimator != null && !mHintAnimationRunning)
                            || mPeekAnimator != null;
                            || mPeekAnimator != null || mTouchSlopExceededBeforeDown;
                    cancelHeightAnimator();
                    cancelHeightAnimator();
                    cancelPeek();
                    cancelPeek();
                    onTrackingStarted();
                    onTrackingStarted();
@@ -409,9 +410,7 @@ public abstract class PanelView extends FrameLayout {
        runPeekAnimation(INITIAL_OPENING_PEEK_DURATION, getOpeningHeight(),
        runPeekAnimation(INITIAL_OPENING_PEEK_DURATION, getOpeningHeight(),
                false /* collapseWhenFinished */);
                false /* collapseWhenFinished */);
        notifyBarPanelExpansionChanged();
        notifyBarPanelExpansionChanged();
        if (mVibrateOnOpening) {
        maybeVibrateOnOpening();
            mVibratorHelper.vibrate(VibrationEffect.EFFECT_TICK);
        }


        //TODO: keyguard opens QS a different way; log that too?
        //TODO: keyguard opens QS a different way; log that too?


@@ -426,6 +425,12 @@ public abstract class PanelView extends FrameLayout {
                rot);
                rot);
    }
    }


    protected void maybeVibrateOnOpening() {
        if (mVibrateOnOpening) {
            mVibratorHelper.vibrate(VibrationEffect.EFFECT_TICK);
        }
    }

    protected abstract float getOpeningHeight();
    protected abstract float getOpeningHeight();


    /**
    /**
@@ -577,7 +582,7 @@ public abstract class PanelView extends FrameLayout {
                mInitialTouchY = y;
                mInitialTouchY = y;
                mInitialTouchX = x;
                mInitialTouchX = x;
                mTouchStartedInEmptyArea = !isInContentBounds(x, y);
                mTouchStartedInEmptyArea = !isInContentBounds(x, y);
                mTouchSlopExceeded = false;
                mTouchSlopExceeded = mTouchSlopExceededBeforeDown;
                mJustPeeked = false;
                mJustPeeked = false;
                mMotionAborted = false;
                mMotionAborted = false;
                mPanelClosedOnDown = isFullyCollapsed();
                mPanelClosedOnDown = isFullyCollapsed();
@@ -680,12 +685,16 @@ public abstract class PanelView extends FrameLayout {
            return true;
            return true;
        }
        }
        if (Math.abs(vectorVel) < mFlingAnimationUtils.getMinVelocityPxPerSecond()) {
        if (Math.abs(vectorVel) < mFlingAnimationUtils.getMinVelocityPxPerSecond()) {
            return getExpandedFraction() > 0.5f;
            return shouldExpandWhenNotFlinging();
        } else {
        } else {
            return vel > 0;
            return vel > 0;
        }
        }
    }
    }


    protected boolean shouldExpandWhenNotFlinging() {
        return getExpandedFraction() > 0.5f;
    }

    /**
    /**
     * @param x the final x-coordinate when the finger was lifted
     * @param x the final x-coordinate when the finger was lifted
     * @param y the final y-coordinate when the finger was lifted
     * @param y the final y-coordinate when the finger was lifted