summaryrefslogtreecommitdiff
path: root/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-01-16 11:26:46 -0800
committerYorke Lee <yorkelee@google.com>2014-02-20 12:24:36 -0800
commit3cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1 (patch)
treee627f324ef1be14d2ac00bafe043d8f28294d575 /src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
parent28ded60d6aa23314d2cfca9ccca1e5bf731508e4 (diff)
Add drag to remove for favorites in Dialer
* Add remove view in dialtacts_activity.xml, and rearrange layout slightly so that it takes up the same position in the layout as the search view container. Contacts that are dragged to this remove view will be unstarred and unpinned. * Add drag event logic to the Remove View, so that when the user hovers a contact over it, the UI will continue to respond. Previously, only the PhoneFavoritesListView would detect touch events. * Refactor DragDropController and OnDragDropListener into separate classes. DragDropController performs the work of receiving drag/drop events from multiple views, combining them, and then firing off callbacks as appropriate to OnDragDropListeners. Each OnDragDropListener can then update their UI or internal data model as necessary in response to the callbacks. OnDragDropListener <---------------------------------------- ^ | | | DialtactsActivity ---------------> RemoveView | | | | v | | callbacks PhoneFavoriteListFragment |drag events | | | | v v | PhoneFavoriteListView ------------> DragController-------- drag events | | callbacks v PhoneFavoritesTileAdapter --> OnDragDropListener * While in here, add a content description for the clear search button Change-Id: I044ad1c5aa42c7686bde6bf5074095a4fe879bde
Diffstat (limited to 'src/com/android/dialer/list/PhoneFavoritesTileAdapter.java')
-rw-r--r--src/com/android/dialer/list/PhoneFavoritesTileAdapter.java26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
index dff68b2be..45cc5a371 100644
--- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
+++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
@@ -59,7 +59,7 @@ import java.util.PriorityQueue;
*
*/
public class PhoneFavoritesTileAdapter extends BaseAdapter implements
- SwipeHelper.OnItemGestureListener, PhoneFavoriteListView.OnDragDropListener {
+ SwipeHelper.OnItemGestureListener, OnDragDropListener {
private static final String TAG = PhoneFavoritesTileAdapter.class.getSimpleName();
private static final boolean DEBUG = false;
@@ -1204,24 +1204,38 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
}
@Override
- public void onDragStarted(int itemIndex) {
+ public void onDragStarted(int itemIndex, int x, int y, PhoneFavoriteTileView view) {
setInDragging(true);
popContactEntry(itemIndex);
}
@Override
- public void onDragHovered(int itemIndex) {
+ public void onDragHovered(int itemIndex, int x, int y) {
if (mInDragging &&
mDragEnteredEntryIndex != itemIndex &&
isIndexInBound(itemIndex) &&
- itemIndex < PIN_LIMIT) {
+ itemIndex < PIN_LIMIT &&
+ itemIndex >= 0) {
markDropArea(itemIndex);
}
}
@Override
- public void onDragFinished() {
+ public void onDragFinished(int x, int y) {
setInDragging(false);
- handleDrop();
+ // A contact has been dragged to the RemoveView in order to be unstarred, so simply wait
+ // for the new contact cursor which will cause the UI to be refreshed without the unstarred
+ // contact.
+ if (!mAwaitingRemove) {
+ handleDrop();
+ }
+ }
+
+ @Override
+ public void onDroppedOnRemove() {
+ if (mDraggedEntry != null) {
+ unstarAndUnpinContact(mDraggedEntry.lookupKey);
+ mAwaitingRemove = true;
+ }
}
}