Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-apps-Launcher: Commit

packages/apps/Launcher


Commit MetaInfo

Révisiona7cf2c76b6863e8db23b6783fafc6906c5c34fe1 (tree)
l'heure2010-02-12 18:36:42
AuteurRomain Guy <romainguy@andr...>
CommiterRomain Guy

Message de Log

Add support for live wallpaper tap and drop commands in Launcher.

DO NOT MERGE.

Change Summary

Modification

--- a/src/com/android/launcher/CellLayout.java
+++ b/src/com/android/launcher/CellLayout.java
@@ -16,6 +16,7 @@
1616
1717 package com.android.launcher;
1818
19+import android.app.WallpaperManager;
1920 import android.content.Context;
2021 import android.content.res.TypedArray;
2122 import android.content.res.Resources;
@@ -58,6 +59,9 @@ public class CellLayout extends ViewGroup {
5859 private RectF mDragRect = new RectF();
5960
6061 private boolean mDirtyTag;
62+ private boolean mLastDownOnOccupiedCell = false;
63+
64+ private final WallpaperManager mWallpaperManager;
6165
6266 public CellLayout(Context context) {
6367 this(context, null);
@@ -97,6 +101,8 @@ public class CellLayout extends ViewGroup {
97101 mOccupied = new boolean[mLongAxisCells][mShortAxisCells];
98102 }
99103 }
104+
105+ mWallpaperManager = WallpaperManager.getInstance(getContext());
100106 }
101107
102108 @Override
@@ -177,6 +183,8 @@ public class CellLayout extends ViewGroup {
177183 }
178184 }
179185
186+ mLastDownOnOccupiedCell = found;
187+
180188 if (!found) {
181189 int cellXY[] = mCellXY;
182190 pointToCellExact(x, y, cellXY);
@@ -523,6 +531,16 @@ public class CellLayout extends ViewGroup {
523531 int childLeft = lp.x;
524532 int childTop = lp.y;
525533 child.layout(childLeft, childTop, childLeft + lp.width, childTop + lp.height);
534+
535+ if (lp.dropped) {
536+ lp.dropped = false;
537+
538+ final int[] cellXY = mCellXY;
539+ getLocationOnScreen(cellXY);
540+ mWallpaperManager.sendWallpaperCommand(getWindowToken(), "android.home.drop",
541+ cellXY[0] + childLeft + lp.width / 2,
542+ cellXY[1] + childTop + lp.height / 2, 0, null);
543+ }
526544 }
527545 }
528546 }
@@ -611,6 +629,7 @@ public class CellLayout extends ViewGroup {
611629 lp.cellX = targetXY[0];
612630 lp.cellY = targetXY[1];
613631 lp.isDragging = false;
632+ lp.dropped = true;
614633 mDragRect.setEmpty();
615634 child.requestLayout();
616635 invalidate();
@@ -742,6 +761,10 @@ out: for (int i = x; i < x + spanX - 1 && x < xCount; i++) {
742761 }
743762 }
744763 }
764+
765+ public boolean lastDownOnOccupiedCell() {
766+ return mLastDownOnOccupiedCell;
767+ }
745768
746769 @Override
747770 public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) {
@@ -794,8 +817,10 @@ out: for (int i = x; i < x + spanX - 1 && x < xCount; i++) {
794817 // Y coordinate of the view in the layout.
795818 @ViewDebug.ExportedProperty
796819 int y;
797-
820+
798821 boolean regenerateId;
822+
823+ boolean dropped;
799824
800825 public LayoutParams(Context c, AttributeSet attrs) {
801826 super(c, attrs);
--- 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
646646
647647 case MotionEvent.ACTION_CANCEL:
648648 case MotionEvent.ACTION_UP:
649+
650+ if (mTouchState != TOUCH_STATE_SCROLLING) {
651+ final CellLayout currentScreen = (CellLayout) getChildAt(mCurrentScreen);
652+ if (!currentScreen.lastDownOnOccupiedCell()) {
653+ getLocationOnScreen(mTempCell);
654+ // Send a tap to the wallpaper if the last down was on empty space
655+ mWallpaperManager.sendWallpaperCommand(getWindowToken(),
656+ "android.wallpaper.tap",
657+ mTempCell[0] + (int) ev.getX(),
658+ mTempCell[1] + (int) ev.getY(), 0, null);
659+ }
660+ }
661+
649662 // Release the drag
650663 clearChildrenCache();
651664 mTouchState = TOUCH_STATE_REST;
Afficher sur ancien navigateur de dépôt.