diff options
author | Christine Chen <christinech@google.com> | 2013-08-01 12:44:40 -0700 |
---|---|---|
committer | Christine Chen <christinech@google.com> | 2013-08-01 13:53:49 -0700 |
commit | 01f15ad65dfbc72d7c8f165bda8e602ba287b434 (patch) | |
tree | 1c5e5e74a5f6b1503faa61b483a4e3e76152f109 | |
parent | ff6d2798dcd3c4b9a75537c4e69a98ba35508dc1 (diff) |
Supports drag and drop outside of a view.
Change-Id: I60c618741006916a2ce05ca0df54da2b0f95ada2
-rw-r--r-- | src/com/android/dialer/list/PhoneFavoriteDragAndDropListeners.java | 11 | ||||
-rw-r--r-- | src/com/android/dialer/list/PhoneFavoritesTileAdapter.java | 8 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/com/android/dialer/list/PhoneFavoriteDragAndDropListeners.java b/src/com/android/dialer/list/PhoneFavoriteDragAndDropListeners.java index 89f39ce0f..ac089c76f 100644 --- a/src/com/android/dialer/list/PhoneFavoriteDragAndDropListeners.java +++ b/src/com/android/dialer/list/PhoneFavoriteDragAndDropListeners.java @@ -17,7 +17,6 @@ package com.android.dialer.list; import android.content.ClipData; import android.graphics.Rect; -import android.graphics.Canvas; import android.util.Log; import android.view.DragEvent; import android.view.GestureDetector.SimpleOnGestureListener; @@ -136,6 +135,9 @@ public class PhoneFavoriteDragAndDropListeners { @Override public boolean onDrag(View v, DragEvent event) { + if (DEBUG) { + Log.v(TAG, event.toString()); + } // Handles drag events. switch (event.getAction()) { case DragEvent.ACTION_DRAG_STARTED: @@ -198,6 +200,13 @@ public class PhoneFavoriteDragAndDropListeners { } break; case DragEvent.ACTION_DRAG_ENDED: + if (mTileAdapter.getInDragging()) { + // If the drag and drop ends when the drop happens outside of any rows, + // we will end the drag here and put the item back to where it was dragged + // from before. + mTileAdapter.setInDragging(false); + mTileAdapter.dropToUnsupportedView(); + } break; case DragEvent.ACTION_DRAG_LOCATION: break; diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java index 58ebcff78..91ad110f2 100644 --- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java +++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java @@ -521,6 +521,14 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter { } /** + * Invoked when the dragged item is dropped to unsupported location. We will then move the + * contact back to where it was dragged from. + */ + public void dropToUnsupportedView() { + dropContactEntry(-1); + } + + /** * Sets an item to for pending removal. If the user does not click the undo button, the item * will be removed at the next interaction. * |