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

Commit 1fac1fdd authored by Daniel Sandler's avatar Daniel Sandler
Browse files

Fix a longstanding bug in the shade pulldown trajectory.

Two parts to this:

1. We were looking at the measured height of the close view
   for a lot of our computations, which---particularly with
   recent changes that dispense with the old 3-window
   implementation---is increasingly unreliable

2. We were overestimating the minY that the panel must be
   pulled down before animation starts. It was enforced
   jankiness!

Bug: 5359178
Change-Id: Ie09b62226b7b0977527348b5527478665ece1df8
parent a310af88
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@
   
        <com.android.systemui.statusbar.phone.CloseDragHandle android:id="@+id/close"
            android:layout_width="match_parent"
            android:layout_height="34dp"
            android:layout_height="@dimen/close_handle_height"
            android:layout_gravity="bottom"
            android:orientation="vertical"
            >
+2 −0
Original line number Diff line number Diff line
@@ -118,4 +118,6 @@
    <!-- Diameter of outer shape drawable shown in navbar search-->
    <dimen name="navbar_search_outerring_diameter">300dip</dimen>

    <!-- Height of the draggable handle at the bottom of the phone notification panel -->
    <dimen name="close_handle_height">34dp</dimen>
</resources>
+16 −5
Original line number Diff line number Diff line
@@ -164,6 +164,7 @@ public class PhoneStatusBar extends BaseStatusBar {

    // drag bar
    CloseDragHandle mCloseView;
    private int mCloseViewHeight;

    // all notifications
    NotificationData mNotificationData = new NotificationData();
@@ -333,6 +334,7 @@ public class PhoneStatusBar extends BaseStatusBar {

        mCloseView = (CloseDragHandle)mStatusBarWindow.findViewById(R.id.close);
        mCloseView.mService = this;
        mCloseViewHeight = res.getDimensionPixelSize(R.dimen.close_handle_height);

        mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore);

@@ -466,6 +468,10 @@ public class PhoneStatusBar extends BaseStatusBar {
        return mNaturalBarHeight;
    }

    private int getCloseViewHeight() {
        return mCloseViewHeight;
    }

    private View.OnClickListener mRecentsClickListener = new View.OnClickListener() {
        public void onClick(View v) {
            toggleRecentApps();
@@ -1259,7 +1265,7 @@ public class PhoneStatusBar extends BaseStatusBar {
    }
    
    void doRevealAnimation() {
        final int h = mCloseView.getHeight() + getStatusBarHeight();
        final int h = getCloseViewHeight() + getStatusBarHeight();
        if (mAnimatingReveal && mAnimating && mAnimY < h) {
            incrementAnim();
            if (mAnimY >= h) {
@@ -1420,9 +1426,9 @@ public class PhoneStatusBar extends BaseStatusBar {
            }
        } else if (mTracking) {
            trackMovement(event);
            final int minY = statusBarSize + mCloseView.getHeight();
            final int minY = statusBarSize + getCloseViewHeight();
            if (action == MotionEvent.ACTION_MOVE) {
                if (mAnimatingReveal && y < minY) {
                if (mAnimatingReveal && (y + mViewDelta) < minY) {
                    // nothing
                } else  {
                    mAnimatingReveal = false;
@@ -1855,6 +1861,10 @@ public class PhoneStatusBar extends BaseStatusBar {
        mTrackingPosition = -mDisplayMetrics.heightPixels;
    }

    static final float saturate(float a) {
        return a < 0f ? 0f : (a > 1f ? 1f : a);
    }

    void updateExpandedViewPos(int expandedPosition) {
        if (SPEW) {
            Slog.d(TAG, "updateExpandedViewPos before expandedPosition=" + expandedPosition
@@ -1905,8 +1915,9 @@ public class PhoneStatusBar extends BaseStatusBar {
        }
        cropView.setLayoutParams(lp);
        // woo, special effects
        final float frac = (float)panelh / disph;
        final int color = ((int)(0xB0 * Math.pow(frac, 0.5))) << 24;
        final int barh = getCloseViewHeight() + getStatusBarHeight();
        final float frac = saturate((float)(panelh - barh) / (disph - barh));
        final int color = ((int)(0xB0 * Math.sin(frac * 1.57f))) << 24;
        mStatusBarWindow.setBackgroundColor(color);

//        Slog.d(TAG, String.format("updateExpanded: pos=%d frac=%.2f col=0x%08x", pos, frac, color));