From 516c6e2ebac16d7ebf47579831fa87af66c912d1 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Wed, 1 Jun 2016 14:30:50 -0700 Subject: Fix bug where a starred contact couldn't be removed Removing a starred contact was broken on NYC. The problem was that the code assumed ACTION_DRAG_STARTED had coordinates that were view relative. On NYC the coordinates were window relative. This is a cherry pick of http://cl/122480283 and http://cl/123125613 Bug: 29074238 Change-Id: Ib090c6240ed65e4333ad63b3ab4f8b4744181b13 (cherry picked from commit 198074d959385599e952656d0a1b2a306f54e56f) --- src/com/android/dialer/list/DragDropController.java | 20 ++++++++++++++++---- .../android/dialer/list/PhoneFavoriteListView.java | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'src/com') diff --git a/src/com/android/dialer/list/DragDropController.java b/src/com/android/dialer/list/DragDropController.java index 8cd1046e6..66ba513a8 100644 --- a/src/com/android/dialer/list/DragDropController.java +++ b/src/com/android/dialer/list/DragDropController.java @@ -3,6 +3,8 @@ package com.android.dialer.list; import android.util.Log; import android.view.View; +import com.android.contacts.common.compat.CompatUtils; + import java.util.ArrayList; import java.util.List; @@ -33,13 +35,23 @@ public class DragDropController { /** * @return True if the drag is started, false if the drag is cancelled for some reason. */ - boolean handleDragStarted(int x, int y) { - final PhoneFavoriteSquareTileView tileView = mDragItemContainer.getViewForLocation(x, y); + boolean handleDragStarted(View v, int x, int y) { + int screenX = x; + int screenY = y; + // The coordinates in dragEvent of DragEvent.ACTION_DRAG_STARTED before NYC is window-related. + // This is fixed in NYC. + if (CompatUtils.isNCompatible()) { + v.getLocationOnScreen(mLocationOnScreen); + screenX = x + mLocationOnScreen[0]; + screenY = y + mLocationOnScreen[1]; + } + final PhoneFavoriteSquareTileView tileView = mDragItemContainer.getViewForLocation( + screenX, screenY); if (tileView == null) { return false; } for (int i = 0; i < mOnDragDropListeners.size(); i++) { - mOnDragDropListeners.get(i).onDragStarted(x, y, tileView); + mOnDragDropListeners.get(i).onDragStarted(screenX, screenY, tileView); } return true; @@ -80,4 +92,4 @@ public class DragDropController { } } -} \ No newline at end of file +} diff --git a/src/com/android/dialer/list/PhoneFavoriteListView.java b/src/com/android/dialer/list/PhoneFavoriteListView.java index ec31bd31f..aad8ad58f 100644 --- a/src/com/android/dialer/list/PhoneFavoriteListView.java +++ b/src/com/android/dialer/list/PhoneFavoriteListView.java @@ -155,7 +155,7 @@ public class PhoneFavoriteListView extends GridView implements OnDragDropListene // on a {@link PhoneFavoriteTileView} return false; } - if (!mDragDropController.handleDragStarted(eX, eY)) { + if (!mDragDropController.handleDragStarted(this, eX, eY)) { return false; } break; -- cgit v1.2.3