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

Commit b799cc0f authored by Justin Klaassen's avatar Justin Klaassen
Browse files

resolve merge conflicts of 90ce7e99 to ub-deskclock-escargatoire

Change-Id: I4ceb29c75a0148ea3f6738b006d273b8f7e50d7f
parents f7a62509 90ce7e99
Loading
Loading
Loading
Loading
+53 −37
Original line number Diff line number Diff line
@@ -148,6 +148,8 @@ public class AlarmActivity extends AppCompatActivity
    private ValueAnimator mDismissAnimator;
    private ValueAnimator mPulseAnimator;

    private int mInitialPointerIndex = MotionEvent.INVALID_POINTER_ID;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
@@ -345,17 +347,43 @@ public class AlarmActivity extends AppCompatActivity
    }

    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {
    public boolean onTouch(View view, MotionEvent event) {
        if (mAlarmHandled) {
            LOGGER.v("onTouch ignored: %s", motionEvent);
            LOGGER.v("onTouch ignored: %s", event);
            return false;
        }

        final int action = event.getActionMasked();
        if (action == MotionEvent.ACTION_DOWN) {
            LOGGER.v("onTouch started: %s", event);

            // Track the pointer that initiated the touch sequence.
            mInitialPointerIndex = event.getPointerId(event.getActionIndex());

            // Stop the pulse, allowing the last pulse to finish.
            mPulseAnimator.setRepeatCount(0);
        } else if (action == MotionEvent.ACTION_CANCEL) {
            LOGGER.v("onTouch canceled: %s", event);

            // Clear the pointer index.
            mInitialPointerIndex = MotionEvent.INVALID_POINTER_ID;

            // Reset everything.
            resetAnimations();
        }

        final int actionIndex = event.getActionIndex();
        if (mInitialPointerIndex == MotionEvent.INVALID_POINTER_ID
                || mInitialPointerIndex != event.getPointerId(actionIndex)) {
            // Ignore any pointers other than the initial one, bail early.
            return true;
        }

        final int[] contentLocation = {0, 0};
        mContentView.getLocationOnScreen(contentLocation);

        final float x = motionEvent.getRawX() - contentLocation[0];
        final float y = motionEvent.getRawY() - contentLocation[1];
        final float x = event.getRawX() - contentLocation[0];
        final float y = event.getRawY() - contentLocation[1];

        final int alarmLeft = mAlarmButton.getLeft() + mAlarmButton.getPaddingLeft();
        final int alarmRight = mAlarmButton.getRight() - mAlarmButton.getPaddingRight();
@@ -370,16 +398,10 @@ public class AlarmActivity extends AppCompatActivity
        }
        setAnimatedFractions(snoozeFraction, dismissFraction);

        switch (motionEvent.getActionMasked()) {
            case MotionEvent.ACTION_DOWN:
                LOGGER.v("onTouch started: %s", motionEvent);

                // Stop the pulse, allowing the last pulse to finish.
                mPulseAnimator.setRepeatCount(0);
                break;
            case MotionEvent.ACTION_UP:
                LOGGER.v("onTouch ended: %s", motionEvent);
        if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP) {
            LOGGER.v("onTouch ended: %s", event);

            mInitialPointerIndex = event.INVALID_POINTER_ID;
            if (snoozeFraction == 1.0f) {
                snooze();
            } else if (dismissFraction == 1.0f) {
@@ -389,7 +411,7 @@ public class AlarmActivity extends AppCompatActivity
                    // Animate back to the initial state.
                    AnimatorUtils.reverse(mAlarmAnimator, mSnoozeAnimator, mDismissAnimator);
                } else if (mAlarmButton.getTop() <= y && y <= mAlarmButton.getBottom()) {
                        // User touched the alarm button, hint the dismiss action
                    // User touched the alarm button, hint the dismiss action.
                    hintDismiss();
                }

@@ -399,12 +421,6 @@ public class AlarmActivity extends AppCompatActivity
                    mPulseAnimator.start();
                }
            }
                break;
            case MotionEvent.ACTION_CANCEL:
                resetAnimations();
                break;
            default:
                break;
        }

        return true;