Merge changes from topic 'am-ad7d3769-753e-4ddd-97fb-2d13b2d07948' into ub-launcher3-master
* changes:
Factor in CellLayout padding in cell size calculation. am: 8632d9dd1e am: d39707b662
Factor in CellLayout padding in cell size calculation. am: 8632d9dd1e
Factor in CellLayout padding in cell size calculation.
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 0d7e4fa..f781a3d 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1401,7 +1401,7 @@
@Override
protected boolean shouldFlingForVelocity(int velocityX) {
// When the overlay is moving, the fling or settle transition is controlled by the overlay.
- return Float.compare(mOverlayTranslation, 0) == 0 &&
+ return Float.compare(Math.abs(mOverlayTranslation), 0) == 0 &&
super.shouldFlingForVelocity(velocityX);
}
diff --git a/src/com/android/launcher3/folder/PreviewItemManager.java b/src/com/android/launcher3/folder/PreviewItemManager.java
index 7a05f67..bb23207 100644
--- a/src/com/android/launcher3/folder/PreviewItemManager.java
+++ b/src/com/android/launcher3/folder/PreviewItemManager.java
@@ -61,7 +61,7 @@
static final int INITIAL_ITEM_ANIMATION_DURATION = 350;
private static final int FINAL_ITEM_ANIMATION_DURATION = 200;
- private static final int SLIDE_IN_FIRST_PAGE_ANIMATION_DURATION_DELAY = 200;
+ private static final int SLIDE_IN_FIRST_PAGE_ANIMATION_DURATION_DELAY = 100;
private static final int SLIDE_IN_FIRST_PAGE_ANIMATION_DURATION = 300;
private static final int ITEM_SLIDE_IN_OUT_DISTANCE_PX = 200;
diff --git a/src/com/android/launcher3/touch/SwipeDetector.java b/src/com/android/launcher3/touch/SwipeDetector.java
index b470654..ec5493b 100644
--- a/src/com/android/launcher3/touch/SwipeDetector.java
+++ b/src/com/android/launcher3/touch/SwipeDetector.java
@@ -1,5 +1,6 @@
package com.android.launcher3.touch;
+import static android.view.MotionEvent.INVALID_POINTER_ID;
import android.content.Context;
import android.util.Log;
import android.view.MotionEvent;
@@ -24,6 +25,8 @@
private static final float ANIMATION_DURATION = 1200;
private static final float FAST_FLING_PX_MS = 10;
+ protected int mActivePointerId = INVALID_POINTER_ID;
+
/**
* The minimum release velocity in pixels per millisecond that triggers fling..
*/
@@ -97,7 +100,8 @@
private long mCurrentMillis;
private float mVelocity;
- private float mLastDisplacement;
+ private float mLastDisplacementX;
+ private float mLastDisplacementY;
private float mDisplacementY;
private float mDisplacementX;
@@ -149,11 +153,13 @@
}
public boolean onTouchEvent(MotionEvent ev) {
- switch (ev.getAction()) {
+ switch (ev.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
mDownX = ev.getX();
mDownY = ev.getY();
- mLastDisplacement = 0;
+ mActivePointerId = ev.getPointerId(0);
+ mLastDisplacementX = 0;
+ mLastDisplacementY = 0;
mDisplacementY = 0;
mVelocity = 0;
@@ -161,9 +167,26 @@
setState(ScrollState.DRAGGING);
}
break;
+ //case MotionEvent.ACTION_POINTER_DOWN:
+ case MotionEvent.ACTION_POINTER_UP:
+ int ptrIdx = (ev.getActionIndex() & MotionEvent.ACTION_POINTER_INDEX_MASK) >>
+ MotionEvent.ACTION_POINTER_INDEX_SHIFT;
+ int ptrId = ev.getPointerId(ptrIdx);
+ if (ptrId == mActivePointerId) {
+ final int newPointerIdx = ptrIdx == 0 ? 1 : 0;
+ mDownX = ev.getX(newPointerIdx) - mLastDisplacementX;
+ mDownY = ev.getY(newPointerIdx) - mLastDisplacementY;
+ mActivePointerId = ev.getPointerId(newPointerIdx);
+ }
+ break;
case MotionEvent.ACTION_MOVE:
- mDisplacementX = ev.getX() - mDownX;
- mDisplacementY = ev.getY() - mDownY;
+ int pointerIndex = ev.findPointerIndex(mActivePointerId);
+ if (pointerIndex == INVALID_POINTER_ID) {
+ break;
+ }
+ mDisplacementX = ev.getX(pointerIndex) - mDownX;
+ mDisplacementY = ev.getY(pointerIndex) - mDownY;
+
computeVelocity(ev);
// handle state and listener calls.
@@ -186,8 +209,12 @@
break;
}
// Do house keeping.
- mLastDisplacement = mDisplacementY;
- mLastY = ev.getY();
+ mLastDisplacementX = mDisplacementX;
+ mLastDisplacementY = mDisplacementY;
+ int pointerIndex = ev.findPointerIndex(mActivePointerId);
+ if (pointerIndex != INVALID_POINTER_ID) {
+ mLastY = ev.getY(pointerIndex);
+ }
return true;
}
@@ -215,7 +242,7 @@
}
private boolean reportDragging() {
- float delta = mDisplacementY - mLastDisplacement;
+ float delta = mDisplacementY - mLastDisplacementY;
if (delta != 0) {
if (DBG) {
Log.d(TAG, String.format("onDrag disp=%.1f, velocity=%.1f",