Merge "Making bouncer switch sides on double tap only" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
211118cdb4
@@ -50,6 +50,7 @@ import android.util.AttributeSet;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.MathUtils;
|
import android.util.MathUtils;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
import android.view.GestureDetector;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
@@ -146,6 +147,7 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
|||||||
private final SpringAnimation mSpringAnimation;
|
private final SpringAnimation mSpringAnimation;
|
||||||
private final VelocityTracker mVelocityTracker = VelocityTracker.obtain();
|
private final VelocityTracker mVelocityTracker = VelocityTracker.obtain();
|
||||||
private final List<Gefingerpoken> mMotionEventListeners = new ArrayList<>();
|
private final List<Gefingerpoken> mMotionEventListeners = new ArrayList<>();
|
||||||
|
private final GestureDetector mDoubleTapDetector;
|
||||||
|
|
||||||
private float mLastTouchY = -1;
|
private float mLastTouchY = -1;
|
||||||
private int mActivePointerId = -1;
|
private int mActivePointerId = -1;
|
||||||
@@ -305,6 +307,7 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
|||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
mSpringAnimation = new SpringAnimation(this, DynamicAnimation.Y);
|
mSpringAnimation = new SpringAnimation(this, DynamicAnimation.Y);
|
||||||
mViewConfiguration = ViewConfiguration.get(context);
|
mViewConfiguration = ViewConfiguration.get(context);
|
||||||
|
mDoubleTapDetector = new GestureDetector(context, new DoubleTapListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
void onResume(SecurityMode securityMode, boolean faceAuthEnabled) {
|
void onResume(SecurityMode securityMode, boolean faceAuthEnabled) {
|
||||||
@@ -434,6 +437,7 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
final int action = event.getActionMasked();
|
final int action = event.getActionMasked();
|
||||||
|
mDoubleTapDetector.onTouchEvent(event);
|
||||||
|
|
||||||
boolean result = mMotionEventListeners.stream()
|
boolean result = mMotionEventListeners.stream()
|
||||||
.anyMatch(listener -> listener.onTouchEvent(event))
|
.anyMatch(listener -> listener.onTouchEvent(event))
|
||||||
@@ -475,15 +479,21 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
|||||||
if (mSwipeListener != null) {
|
if (mSwipeListener != null) {
|
||||||
mSwipeListener.onSwipeUp();
|
mSwipeListener.onSwipeUp();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (!mIsDragging) {
|
|
||||||
mViewMode.handleTap(event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class DoubleTapListener extends GestureDetector.SimpleOnGestureListener {
|
||||||
|
@Override
|
||||||
|
public boolean onDoubleTap(MotionEvent e) {
|
||||||
|
if (!mIsDragging) {
|
||||||
|
mViewMode.handleDoubleTap(e);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void addMotionEventListener(Gefingerpoken listener) {
|
void addMotionEventListener(Gefingerpoken listener) {
|
||||||
mMotionEventListeners.add(listener);
|
mMotionEventListeners.add(listener);
|
||||||
}
|
}
|
||||||
@@ -736,8 +746,8 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
|||||||
/** Alter the ViewFlipper position, based upon a touch outside of it */
|
/** Alter the ViewFlipper position, based upon a touch outside of it */
|
||||||
default void updatePositionByTouchX(float x) {};
|
default void updatePositionByTouchX(float x) {};
|
||||||
|
|
||||||
/** A tap on the container, outside of the ViewFlipper */
|
/** A double tap on the container, outside of the ViewFlipper */
|
||||||
default void handleTap(MotionEvent event) {};
|
default void handleDoubleTap(MotionEvent event) {};
|
||||||
|
|
||||||
/** Called when the view needs to reset or hides */
|
/** Called when the view needs to reset or hides */
|
||||||
default void reset() {};
|
default void reset() {};
|
||||||
@@ -1111,11 +1121,11 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if a tap on this view is on the other side. If so, will animate positions
|
* Determine if a double tap on this view is on the other side. If so, will animate
|
||||||
* and record the preference to always show on this side.
|
* positions and record the preference to always show on this side.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void handleTap(MotionEvent event) {
|
public void handleDoubleTap(MotionEvent event) {
|
||||||
float x = event.getX();
|
float x = event.getX();
|
||||||
boolean currentlyLeftAligned = isLeftAligned();
|
boolean currentlyLeftAligned = isLeftAligned();
|
||||||
// Did the tap hit the "other" side of the bouncer?
|
// Did the tap hit the "other" side of the bouncer?
|
||||||
|
|||||||
Reference in New Issue
Block a user