Merge "Fixes issue where notification jumps when user is dragging and its updated" into oc-dr1-dev am: 58b0e698fc

am: d2b1b0daa0

Change-Id: I145f1019fb9fad081edea71e8ca14606352e2d2f
This commit is contained in:
Mady Mellor
2017-07-20 18:46:56 +00:00
committed by android-build-merger
2 changed files with 22 additions and 10 deletions

View File

@@ -100,6 +100,7 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
private boolean mShouldShowMenu; private boolean mShouldShowMenu;
private NotificationSwipeActionHelper mSwipeHelper; private NotificationSwipeActionHelper mSwipeHelper;
private boolean mIsUserTouching;
public NotificationMenuRow(Context context) { public NotificationMenuRow(Context context) {
mContext = context; mContext = context;
@@ -202,8 +203,11 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
} else { } else {
mIconsPlaced = false; mIconsPlaced = false;
setMenuLocation(); setMenuLocation();
// If the # of items showing changed we need to update the snap position if (!mIsUserTouching) {
showMenu(mParent, mOnLeft ? getSpaceForMenu() : -getSpaceForMenu(), 0 /* velocity */); // If the # of items showing changed we need to update the snap position
showMenu(mParent, mOnLeft ? getSpaceForMenu() : -getSpaceForMenu(),
0 /* velocity */);
}
} }
} }
@@ -233,6 +237,7 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
mHandler.removeCallbacks(mCheckForDrag); mHandler.removeCallbacks(mCheckForDrag);
mCheckForDrag = null; mCheckForDrag = null;
mPrevX = ev.getRawX(); mPrevX = ev.getRawX();
mIsUserTouching = true;
break; break;
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
@@ -265,7 +270,12 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
mIsUserTouching = false;
return handleUpEvent(ev, view, velocity); return handleUpEvent(ev, view, velocity);
case MotionEvent.ACTION_CANCEL:
mIsUserTouching = false;
cancelDrag();
return false;
} }
return false; return false;
} }
@@ -354,23 +364,24 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
} }
private void snapBack(View animView, float velocity) { private void snapBack(View animView, float velocity) {
if (mFadeAnimator != null) { cancelDrag();
mFadeAnimator.cancel();
}
mHandler.removeCallbacks(mCheckForDrag);
mMenuSnappedTo = false; mMenuSnappedTo = false;
mSnapping = true; mSnapping = true;
mSwipeHelper.snap(animView, 0 /* leftTarget */, velocity); mSwipeHelper.snap(animView, 0 /* leftTarget */, velocity);
} }
private void dismiss(View animView, float velocity) { private void dismiss(View animView, float velocity) {
cancelDrag();
mMenuSnappedTo = false;
mDismissing = true;
mSwipeHelper.dismiss(animView, velocity);
}
private void cancelDrag() {
if (mFadeAnimator != null) { if (mFadeAnimator != null) {
mFadeAnimator.cancel(); mFadeAnimator.cancel();
} }
mHandler.removeCallbacks(mCheckForDrag); mHandler.removeCallbacks(mCheckForDrag);
mMenuSnappedTo = false;
mDismissing = true;
mSwipeHelper.dismiss(animView, velocity);
} }
/** /**

View File

@@ -4344,10 +4344,10 @@ public class NotificationStackScrollLayout extends ViewGroup
@Override @Override
public void onDownUpdate(View currView, MotionEvent ev) { public void onDownUpdate(View currView, MotionEvent ev) {
mTranslatingParentView = currView; mTranslatingParentView = currView;
mCurrMenuRow = null;
if (mCurrMenuRow != null) { if (mCurrMenuRow != null) {
mCurrMenuRow.onTouchEvent(currView, ev, 0 /* velocity */); mCurrMenuRow.onTouchEvent(currView, ev, 0 /* velocity */);
} }
mCurrMenuRow = null;
mHandler.removeCallbacks(mFalsingCheck); mHandler.removeCallbacks(mFalsingCheck);
// Slide back any notifications that might be showing a menu // Slide back any notifications that might be showing a menu
@@ -4358,6 +4358,7 @@ public class NotificationStackScrollLayout extends ViewGroup
mCurrMenuRow = row.createMenu(); mCurrMenuRow = row.createMenu();
mCurrMenuRow.setSwipeActionHelper(NotificationSwipeHelper.this); mCurrMenuRow.setSwipeActionHelper(NotificationSwipeHelper.this);
mCurrMenuRow.setMenuClickListener(NotificationStackScrollLayout.this); mCurrMenuRow.setMenuClickListener(NotificationStackScrollLayout.this);
mCurrMenuRow.onTouchEvent(currView, ev, 0 /* velocity */);
} }
} }