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

Commit 9ed6351a authored by Valera Trubachev's avatar Valera Trubachev
Browse files

Ring Lockscreen: add a zoom effect for secondary rings

Added a zoom effect when middle ring is dragged over secondary ring.
Also had side-effect of decreasing sensitivity of secondary rings.

Perhaps this can combined with http://review.cyanogenmod.com/#change,8294
for more visual feedback as well...

Change-Id: Ia5a0330ac9db46b09b71638cfdf5c1e3926976a6
parent 997e1773
Loading
Loading
Loading
Loading
+34 −1
Original line number Diff line number Diff line
@@ -525,6 +525,7 @@ public class RingSelector extends ViewGroup {
        private int alignCenterY;

        private boolean isHidden = false;
        private boolean isActive = false;

        public SecRing(ViewGroup parent, int ringId) {
            ring = new ImageView(parent.getContext());
@@ -563,10 +564,33 @@ public class RingSelector extends ViewGroup {
            ring.setVisibility(View.VISIBLE);
        }

        void activate() {
            if (isActive) return;
            isActive = true;

            ScaleAnimation scaleAnim = new ScaleAnimation(1.0f, 1.5f, 1.0f, 1.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            scaleAnim.setInterpolator(new DecelerateInterpolator());
            scaleAnim.setDuration(ANIM_CENTER_FADE_TIME);
            scaleAnim.setFillAfter(true);
            ring.startAnimation(scaleAnim);
        }

        void deactivate() {
            if (!isActive) return;
            isActive = false;

            ScaleAnimation scaleAnim = new ScaleAnimation(1.5f, 1.0f, 1.5f, 1.0f,
                    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            scaleAnim.setInterpolator(new DecelerateInterpolator());
            scaleAnim.setDuration(ANIM_CENTER_FADE_TIME);
            scaleAnim.setFillAfter(true);
            ring.startAnimation(scaleAnim);
        }

        void reset(boolean animate) {
            if (animate) {
                hide();
                return;
            }
            ring.setVisibility(View.INVISIBLE);
        }
@@ -854,6 +878,15 @@ public class RingSelector extends ViewGroup {
            switch (action) {
                case MotionEvent.ACTION_MOVE:
                    moveRing(x, y);
                    if (mUseMiddleRing && mCurrentRing == mMiddleRing) {
                        for (int q = 0; q < 4; q++) {
                            if (!mSecRings[q].isHidden() && mSecRings[q].contains((int) x, (int) y)) {
                                mSecRings[q].activate();
                            } else {
                                mSecRings[q].deactivate();
                            }
                        }
                    }
                    break;
                case MotionEvent.ACTION_UP:
                    int secIdx = -1;