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

Commit 061a4de8 authored by Chris Wren's avatar Chris Wren Committed by Android (Google) Code Review
Browse files

Merge "resolve conflicting assumptions from the merge." into jb-mr1-dev

parents a2f7ca7d cea52074
Loading
Loading
Loading
Loading
+32 −16
Original line number Diff line number Diff line
@@ -86,6 +86,8 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
    private float mInitialTouchFocusY;
    private float mInitialTouchY;
    private float mInitialTouchSpan;
    private float mLastFocusY;
    private float mLastSpanY;
    private int mTouchSlop;
    private int mLastMotionY;
    private float mPopLimit;
@@ -207,11 +209,6 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
                float focusX = detector.getFocusX();
                float focusY = detector.getFocusY();

                // your fingers have to be somewhat close to the bounds of the view in question
                mInitialTouchFocusY = focusY;
                mInitialTouchSpan = Math.abs(detector.getCurrentSpan());
                if (DEBUG_SCALE) Slog.d(TAG, "got mInitialTouchSpan: (" + mInitialTouchSpan + ")");

                final View underFocus = findView(focusX, focusY);
                if (underFocus != null) {
                    startExpanding(underFocus, STRETCH);
@@ -222,24 +219,19 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
            @Override
            public boolean onScale(ScaleGestureDetector detector) {
                if (DEBUG_SCALE) Slog.v(TAG, "onscale() on " + mCurrView);
                updateExpansion();
                return true;
            }

            @Override
            public void onScaleEnd(ScaleGestureDetector detector) {
                if (DEBUG_SCALE) Slog.v(TAG, "onscaleend()");
                // I guess we're alone now
                if (DEBUG_SCALE) Slog.d(TAG, "scale end");
                finishExpanding(false);
                clearView();
            }
        });
    }

    private void updateExpansion() {
        if (DEBUG_SCALE) Slog.v(TAG, "updateExpansion()");
        // are we scaling or dragging?
        float span = Math.abs(mSGD.getCurrentSpan()) - mInitialTouchSpan;
        float span = mSGD.getCurrentSpan() - mInitialTouchSpan;
        span *= USE_SPAN ? 1f : 0f;
        float drag = mSGD.getFocusY() - mInitialTouchFocusY;
        drag *= USE_DRAG ? 1f : 0f;
@@ -251,6 +243,8 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
        mScaler.setHeight(newHeight);

        setGlow(calculateGlow(target, newHeight));
        mLastFocusY = mSGD.getFocusY();
        mLastSpanY = mSGD.getCurrentSpan();
    }

    private float clamp(float target) {
@@ -362,6 +356,13 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
        mSGD.onTouchEvent(ev);
        final int x = (int) mSGD.getFocusX();
        final int y = (int) mSGD.getFocusY();

        mInitialTouchFocusY = y;
        mInitialTouchSpan = mSGD.getCurrentSpan();
        mLastFocusY = mInitialTouchFocusY;
        mLastSpanY = mInitialTouchSpan;
        if (DEBUG_SCALE) Slog.d(TAG, "set initial span: " + mInitialTouchSpan);

        if (mExpanding) {
            return true;
        } else {
@@ -376,8 +377,6 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
                // detect a vertical pulling gesture with fingers somewhat separated
                if (DEBUG_SCALE) Slog.v(TAG, "got pull gesture (xspan=" + xspan + "px)");

                mInitialTouchFocusY = y;

                final View underFocus = findView(x, y);
                if (underFocus != null) {
                    startExpanding(underFocus, PULL);
@@ -424,7 +423,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        final int action = ev.getAction();
        final int action = ev.getActionMasked();
        if (DEBUG_SCALE) Slog.d(TAG, "touch: act=" + MotionEvent.actionToString(action) +
                " expanding=" + mExpanding +
                (0 != (mExpansionStyle & BLINDS) ? " (blinds)" : "") +
@@ -481,6 +480,14 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {

                break;
            }

            case MotionEvent.ACTION_POINTER_UP:
            case MotionEvent.ACTION_POINTER_DOWN:
                if (DEBUG) Slog.d(TAG, "pointer change");
                mInitialTouchY += mSGD.getFocusY() - mLastFocusY;
                mInitialTouchSpan += mSGD.getCurrentSpan() - mLastSpanY;
                break;

            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                if (DEBUG) Slog.d(TAG, "up/cancel");
@@ -492,8 +499,11 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
    }

    private void startExpanding(View v, int expandType) {
        mExpanding = true;
        mExpansionStyle = expandType;
        if (mExpanding &&  v == mCurrView) {
            return;
        }
        mExpanding = true;
        if (DEBUG) Slog.d(TAG, "scale type " + expandType + " beginning on view: " + v);
        mCallback.setUserLockedChild(v, true);
        setView(v);
@@ -515,6 +525,8 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
    private void finishExpanding(boolean force) {
        if (!mExpanding) return;

        if (DEBUG) Slog.d(TAG, "scale in finishing on view: " + mCurrView);

        float currentHeight = mScaler.getHeight();
        float targetHeight = mSmallSize;
        float h = mScaler.getHeight();
@@ -539,6 +551,10 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
        mExpanding = false;
        mExpansionStyle = NONE;

        if (DEBUG) Slog.d(TAG, "wasClosed is: " + wasClosed);
        if (DEBUG) Slog.d(TAG, "currentHeight is: " + currentHeight);
        if (DEBUG) Slog.d(TAG, "mSmallSize is: " + mSmallSize);
        if (DEBUG) Slog.d(TAG, "targetHeight is: " + targetHeight);
        if (DEBUG) Slog.d(TAG, "scale was finished on view: " + mCurrView);
    }