Merge "Import translations. DO NOT MERGE"
diff --git a/src/com/android/dialer/list/PhoneFavoriteDragAndDropListeners.java b/src/com/android/dialer/list/PhoneFavoriteDragAndDropListeners.java
index 89f39ce..ac089c7 100644
--- a/src/com/android/dialer/list/PhoneFavoriteDragAndDropListeners.java
+++ b/src/com/android/dialer/list/PhoneFavoriteDragAndDropListeners.java
@@ -17,7 +17,6 @@
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 @@
@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 @@
}
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 58ebcff..992cb1f 100644
--- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
+++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
@@ -276,13 +276,16 @@
@Override
public int getCount() {
- if (mContactEntries == null) {
+ if (mContactEntries == null || mContactEntries.isEmpty()) {
return 0;
}
int total = mContactEntries.size();
-
- return total - (mMaxTiledRows * (mColumnCount - 1));
+ // The number of contacts that don't show up as tiles
+ final int nonTiledRows = Math.max(0, total - getMaxContactsInTiles());
+ // The number of tiled rows
+ final int tiledRows = getRowCount(total - nonTiledRows);
+ return nonTiledRows + tiledRows;
}
public int getMaxTiledRows() {
@@ -521,6 +524,14 @@
}
/**
+ * 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.
*