summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-05-07 11:00:53 -0700
committerYorke Lee <yorkelee@google.com>2014-05-07 11:04:20 -0700
commitf66cc0403faab0a31ccdb2c78e0dad5be11218f5 (patch)
treebef16cedc7fae158a9aa66ae8dca163c6ff98f0d
parent861fd2a2737051843582c4261567342016853868 (diff)
Make drag shadow work across entire layout
Move drag shadow view into main layout so that it can be drawn over all other views. Also offset it accordingly based on its parent's X/Y coordinates Bug: 14393052 Change-Id: I957469cf505d30812b539517d2aeab3f72a733ca
-rw-r--r--res/layout/dialtacts_activity.xml11
-rw-r--r--res/layout/phone_favorites_fragment.xml7
-rw-r--r--src/com/android/dialer/list/PhoneFavoriteListView.java36
-rw-r--r--src/com/android/dialer/list/SpeedDialFragment.java2
4 files changed, 32 insertions, 24 deletions
diff --git a/res/layout/dialtacts_activity.xml b/res/layout/dialtacts_activity.xml
index e4e2a238b..90b66fd76 100644
--- a/res/layout/dialtacts_activity.xml
+++ b/res/layout/dialtacts_activity.xml
@@ -102,4 +102,15 @@
android:src="@drawable/ic_dial_action_call"
android:visibility="gone" />
</FrameLayout>
+ <!-- Host container for the contact tile drag shadow -->
+ <FrameLayout
+ android:layout_height="match_parent"
+ android:layout_width="match_parent">
+ <ImageView
+ android:id="@+id/contact_tile_drag_shadow_overlay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ android:importantForAccessibility="no" />
+ </FrameLayout>
</RelativeLayout>
diff --git a/res/layout/phone_favorites_fragment.xml b/res/layout/phone_favorites_fragment.xml
index 89a9f73bc..76e5e9838 100644
--- a/res/layout/phone_favorites_fragment.xml
+++ b/res/layout/phone_favorites_fragment.xml
@@ -40,13 +40,6 @@
android:clipToPadding="false"
android:fadingEdge="none"
android:divider="@null" />
-
- <ImageView
- android:id="@+id/contact_tile_drag_shadow_overlay"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:visibility="gone"
- android:importantForAccessibility="no" />
</FrameLayout>
<include
diff --git a/src/com/android/dialer/list/PhoneFavoriteListView.java b/src/com/android/dialer/list/PhoneFavoriteListView.java
index 074cc07d6..4ecc1cd90 100644
--- a/src/com/android/dialer/list/PhoneFavoriteListView.java
+++ b/src/com/android/dialer/list/PhoneFavoriteListView.java
@@ -59,6 +59,7 @@ public class PhoneFavoriteListView extends GridView implements OnDragDropListene
private Bitmap mDragShadowBitmap;
private ImageView mDragShadowOverlay;
+ private View mDragShadowParent;
private int mAnimationDuration;
final int[] mLocationOnScreen = new int[2];
@@ -190,6 +191,7 @@ public class PhoneFavoriteListView extends GridView implements OnDragDropListene
public void setDragShadowOverlay(ImageView overlay) {
mDragShadowOverlay = overlay;
+ mDragShadowParent = (View) mDragShadowOverlay.getParent();
}
/**
@@ -230,10 +232,21 @@ public class PhoneFavoriteListView extends GridView implements OnDragDropListene
return;
}
- // Square tile is relative to the contact tile,
- // and contact tile is relative to this list view.
- mDragShadowLeft = tileView.getLeft();
- mDragShadowTop = tileView.getTop();
+ tileView.getLocationOnScreen(mLocationOnScreen);
+ mDragShadowLeft = mLocationOnScreen[0];
+ mDragShadowTop = mLocationOnScreen[1];
+
+ // x and y are the coordinates of the on-screen touch event. Using these
+ // and the on-screen location of the tileView, calculate the difference between
+ // the position of the user's finger and the position of the tileView. These will
+ // be used to offset the location of the drag shadow so that it appears that the
+ // tileView is positioned directly under the user's finger.
+ mTouchOffsetToChildLeft = x - mDragShadowLeft;
+ mTouchOffsetToChildTop = y - mDragShadowTop;
+
+ mDragShadowParent.getLocationOnScreen(mLocationOnScreen);
+ mDragShadowLeft -= mLocationOnScreen[0];
+ mDragShadowTop -= mLocationOnScreen[1];
mDragShadowOverlay.setImageBitmap(mDragShadowBitmap);
mDragShadowOverlay.setVisibility(VISIBLE);
@@ -241,19 +254,14 @@ public class PhoneFavoriteListView extends GridView implements OnDragDropListene
mDragShadowOverlay.setX(mDragShadowLeft);
mDragShadowOverlay.setY(mDragShadowTop);
-
- // x and y passed in are the coordinates of where the user has touched down,
- // calculate the offset to the top left coordinate of the dragged child. This
- // will be used for drawing the drag shadow.
- mTouchOffsetToChildLeft = x - mDragShadowLeft;
- mTouchOffsetToChildTop = y - mDragShadowTop;
}
@Override
public void onDragHovered(int x, int y, PhoneFavoriteSquareTileView tileView) {
// Update the drag shadow location.
- mDragShadowLeft = x - mTouchOffsetToChildLeft;
- mDragShadowTop = y - mTouchOffsetToChildTop;
+ mDragShadowParent.getLocationOnScreen(mLocationOnScreen);
+ mDragShadowLeft = x - mTouchOffsetToChildLeft - mLocationOnScreen[0];
+ mDragShadowTop = y - mTouchOffsetToChildTop - mLocationOnScreen[1];
// Draw the drag shadow at its last known location if the drag shadow exists.
if (mDragShadowOverlay != null) {
mDragShadowOverlay.setX(mDragShadowLeft);
@@ -263,10 +271,6 @@ public class PhoneFavoriteListView extends GridView implements OnDragDropListene
@Override
public void onDragFinished(int x, int y) {
- // Update the drag shadow location.
- mDragShadowLeft = x - mTouchOffsetToChildLeft;
- mDragShadowTop = y - mTouchOffsetToChildTop;
-
if (mDragShadowOverlay != null) {
mDragShadowOverlay.clearAnimation();
mDragShadowOverlay.animate().alpha(0.0f)
diff --git a/src/com/android/dialer/list/SpeedDialFragment.java b/src/com/android/dialer/list/SpeedDialFragment.java
index cfcea9ddb..0399bf7d5 100644
--- a/src/com/android/dialer/list/SpeedDialFragment.java
+++ b/src/com/android/dialer/list/SpeedDialFragment.java
@@ -206,7 +206,7 @@ public class SpeedDialFragment extends Fragment implements OnItemClickListener,
mListView.getDragDropController().addOnDragDropListener(mContactTileAdapter);
final ImageView dragShadowOverlay =
- (ImageView) mParentView.findViewById(R.id.contact_tile_drag_shadow_overlay);
+ (ImageView) getActivity().findViewById(R.id.contact_tile_drag_shadow_overlay);
mListView.setDragShadowOverlay(dragShadowOverlay);
mEmptyView = mParentView.findViewById(R.id.phone_no_favorites_view);