diff options
author | Romain Guy <romainguy@android.com> | 2010-02-12 10:22:36 +0100 |
---|---|---|
committer | Romain Guy <romainguy@android.com> | 2010-02-12 10:36:42 +0100 |
commit | a7cf2c76b6863e8db23b6783fafc6906c5c34fe1 (patch) | |
tree | fa7c20b6f0307b89fe0c218a93c0ffc9073745e5 | |
parent | 4070cffa65313d0246cb8f25e10d1c87c22e21e9 (diff) | |
download | Launcher-eclair.tar.gz |
Add support for live wallpaper tap and drop commands in Launcher.android-cts-2.1_r5android-cts-2.1_r4android-cts-2.1_r3android-cts-2.1_r2eclair
DO NOT MERGE.
-rw-r--r-- | src/com/android/launcher/CellLayout.java | 27 | ||||
-rw-r--r-- | src/com/android/launcher/Workspace.java | 13 |
2 files changed, 39 insertions, 1 deletions
diff --git a/src/com/android/launcher/CellLayout.java b/src/com/android/launcher/CellLayout.java index e53f2b3..6677bb8 100644 --- a/src/com/android/launcher/CellLayout.java +++ b/src/com/android/launcher/CellLayout.java @@ -16,6 +16,7 @@ package com.android.launcher; +import android.app.WallpaperManager; import android.content.Context; import android.content.res.TypedArray; import android.content.res.Resources; @@ -58,6 +59,9 @@ public class CellLayout extends ViewGroup { private RectF mDragRect = new RectF(); private boolean mDirtyTag; + private boolean mLastDownOnOccupiedCell = false; + + private final WallpaperManager mWallpaperManager; public CellLayout(Context context) { this(context, null); @@ -97,6 +101,8 @@ public class CellLayout extends ViewGroup { mOccupied = new boolean[mLongAxisCells][mShortAxisCells]; } } + + mWallpaperManager = WallpaperManager.getInstance(getContext()); } @Override @@ -177,6 +183,8 @@ public class CellLayout extends ViewGroup { } } + mLastDownOnOccupiedCell = found; + if (!found) { int cellXY[] = mCellXY; pointToCellExact(x, y, cellXY); @@ -523,6 +531,16 @@ public class CellLayout extends ViewGroup { int childLeft = lp.x; int childTop = lp.y; child.layout(childLeft, childTop, childLeft + lp.width, childTop + lp.height); + + if (lp.dropped) { + lp.dropped = false; + + final int[] cellXY = mCellXY; + getLocationOnScreen(cellXY); + mWallpaperManager.sendWallpaperCommand(getWindowToken(), "android.home.drop", + cellXY[0] + childLeft + lp.width / 2, + cellXY[1] + childTop + lp.height / 2, 0, null); + } } } } @@ -611,6 +629,7 @@ public class CellLayout extends ViewGroup { lp.cellX = targetXY[0]; lp.cellY = targetXY[1]; lp.isDragging = false; + lp.dropped = true; mDragRect.setEmpty(); child.requestLayout(); invalidate(); @@ -742,6 +761,10 @@ out: for (int i = x; i < x + spanX - 1 && x < xCount; i++) { } } } + + public boolean lastDownOnOccupiedCell() { + return mLastDownOnOccupiedCell; + } @Override public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) { @@ -794,8 +817,10 @@ out: for (int i = x; i < x + spanX - 1 && x < xCount; i++) { // Y coordinate of the view in the layout. @ViewDebug.ExportedProperty int y; - + boolean regenerateId; + + boolean dropped; public LayoutParams(Context c, AttributeSet attrs) { super(c, attrs); diff --git a/src/com/android/launcher/Workspace.java b/src/com/android/launcher/Workspace.java index b886e67..2e04311 100644 --- a/src/com/android/launcher/Workspace.java +++ b/src/com/android/launcher/Workspace.java @@ -646,6 +646,19 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: + + if (mTouchState != TOUCH_STATE_SCROLLING) { + final CellLayout currentScreen = (CellLayout) getChildAt(mCurrentScreen); + if (!currentScreen.lastDownOnOccupiedCell()) { + getLocationOnScreen(mTempCell); + // Send a tap to the wallpaper if the last down was on empty space + mWallpaperManager.sendWallpaperCommand(getWindowToken(), + "android.wallpaper.tap", + mTempCell[0] + (int) ev.getX(), + mTempCell[1] + (int) ev.getY(), 0, null); + } + } + // Release the drag clearChildrenCache(); mTouchState = TOUCH_STATE_REST; |