Add android.home.drop even for the live wallpapers.
Change-Id: I44ad9fe573dc3d2e5d091fed01300d44b6be9473
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 6dd18d3..015f187 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -27,6 +27,7 @@
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
+import android.app.WallpaperManager;
import java.util.ArrayList;
@@ -52,14 +53,14 @@
private final CellInfo mCellInfo = new CellInfo();
int[] mCellXY = new int[2];
-
boolean[][] mOccupied;
private RectF mDragRect = new RectF();
private boolean mDirtyTag;
-
private boolean mLastDownOnOccupiedCell = false;
+
+ private final WallpaperManager mWallpaperManager;
public CellLayout(Context context) {
this(context, null);
@@ -99,6 +100,8 @@
mOccupied = new boolean[mLongAxisCells][mShortAxisCells];
}
}
+
+ mWallpaperManager = WallpaperManager.getInstance(getContext());
}
@Override
@@ -433,6 +436,14 @@
result[1] = vStartPadding + cellY * (mCellHeight + mHeightGap);
}
+ int getCellWidth() {
+ return mCellWidth;
+ }
+
+ int getCellHeight() {
+ return mCellHeight;
+ }
+
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// TODO: currently ignoring padding
@@ -528,6 +539,13 @@
int childLeft = lp.x;
int childTop = lp.y;
child.layout(childLeft, childTop, childLeft + lp.width, childTop + lp.height);
+
+ if (lp.dropped) {
+ lp.dropped = false;
+
+ mWallpaperManager.sendWallpaperCommand(getWindowToken(), "android.home.drop",
+ childLeft + lp.width / 2, childTop + lp.height / 2, 0, null);
+ }
}
}
}
@@ -616,6 +634,7 @@
lp.cellX = targetXY[0];
lp.cellY = targetXY[1];
lp.isDragging = false;
+ lp.dropped = true;
mDragRect.setEmpty();
child.requestLayout();
invalidate();
@@ -844,6 +863,8 @@
int y;
boolean regenerateId;
+
+ boolean dropped;
public LayoutParams(Context c, AttributeSet attrs) {
super(c, attrs);
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 531e10c..1574be8 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -38,11 +38,7 @@
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
-import android.graphics.drawable.TransitionDrawable;
import android.os.Bundle;
-import android.os.Looper;
-import android.os.Message;
-import android.os.MessageQueue;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -61,7 +57,6 @@
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
-import android.view.WindowManager;
import android.view.View.OnLongClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
@@ -70,10 +65,8 @@
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
-import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.LinkedList;
import java.io.DataOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -184,19 +177,14 @@
private boolean mRestoring;
private boolean mWaitingForResult;
- private boolean mLocaleChanged;
private boolean mExitingBecauseOfLaunch;
- private boolean mHomeDown;
- private boolean mBackDown;
-
private Bundle mSavedInstanceState;
private LauncherModel mModel;
- private ArrayList<ItemInfo> mDesktopItems = new ArrayList();
- private static HashMap<Long, FolderInfo> mFolders = new HashMap();
- private ArrayList<ApplicationInfo> mAllAppsList = new ArrayList();
+ private ArrayList<ItemInfo> mDesktopItems = new ArrayList<ItemInfo>();
+ private static HashMap<Long, FolderInfo> mFolders = new HashMap<Long, FolderInfo>();
public static long lastStartTime;
@@ -263,9 +251,9 @@
final int previousMnc = localeConfiguration.mnc;
final int mnc = configuration.mnc;
- mLocaleChanged = !locale.equals(previousLocale) || mcc != previousMcc || mnc != previousMnc;
+ boolean localeChanged = !locale.equals(previousLocale) || mcc != previousMcc || mnc != previousMnc;
- if (mLocaleChanged) {
+ if (localeChanged) {
localeConfiguration.locale = locale;
localeConfiguration.mcc = mcc;
localeConfiguration.mnc = mnc;
@@ -1275,22 +1263,12 @@
}
@Override
- public void onWindowFocusChanged(boolean hasFocus) {
- super.onWindowFocusChanged(hasFocus);
- if (!hasFocus) {
- mBackDown = mHomeDown = false;
- }
- }
-
- @Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_BACK:
- mBackDown = true;
return true;
case KeyEvent.KEYCODE_HOME:
- mHomeDown = true;
return true;
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
@@ -1304,10 +1282,8 @@
closeFolder();
}
}
- mBackDown = false;
return true;
case KeyEvent.KEYCODE_HOME:
- mHomeDown = false;
return true;
}
}
@@ -1881,11 +1857,6 @@
final AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
item.hostView = mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo);
- if (true) {
- Log.d(LOG_TAG, String.format("about to setAppWidget for id=%d, info=%s",
- appWidgetId, appWidgetInfo));
- }
-
item.hostView.setAppWidget(appWidgetId, appWidgetInfo);
item.hostView.setTag(item);
@@ -1945,8 +1916,7 @@
* Implementation of the method from LauncherModel.Callbacks.
*/
public void bindAllApplications(ArrayList<ApplicationInfo> apps) {
- mAllAppsList = apps;
- mAllAppsGrid.setApps(mAllAppsList);
+ mAllAppsGrid.setApps(apps);
}
/**
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index b917cdd..e103961 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -29,9 +29,7 @@
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
-import android.graphics.drawable.Drawable;
import android.net.Uri;
-import static android.util.Log.*;
import android.util.Log;
import android.os.Process;
import android.os.SystemClock;
@@ -318,18 +316,18 @@
if (mAllAppsList.added.size() > 0) {
added = mAllAppsList.added;
- mAllAppsList.added = new ArrayList();
+ mAllAppsList.added = new ArrayList<ApplicationInfo>();
}
if (mAllAppsList.removed.size() > 0) {
removed = mAllAppsList.removed;
- mAllAppsList.removed = new ArrayList();
+ mAllAppsList.removed = new ArrayList<ApplicationInfo>();
for (ApplicationInfo info: removed) {
AppInfoCache.remove(info.intent.getComponent());
}
}
if (mAllAppsList.modified.size() > 0) {
modified = mAllAppsList.modified;
- mAllAppsList.modified = new ArrayList();
+ mAllAppsList.modified = new ArrayList<ApplicationInfo>();
}
final Callbacks callbacks = mCallbacks != null ? mCallbacks.get() : null;
@@ -375,9 +373,9 @@
private int mLastAllAppsSeq = 0;
private int mAllAppsSeq = 1;
- final ArrayList<ItemInfo> mItems = new ArrayList();
- final ArrayList<LauncherAppWidgetInfo> mAppWidgets = new ArrayList();
- final HashMap<Long, FolderInfo> folders = new HashMap();
+ final ArrayList<ItemInfo> mItems = new ArrayList<ItemInfo>();
+ final ArrayList<LauncherAppWidgetInfo> mAppWidgets = new ArrayList<LauncherAppWidgetInfo>();
+ final HashMap<Long, FolderInfo> folders = new HashMap<Long, FolderInfo>();
/**
* Call this from the ui thread so the handler is initialized on the correct thread.
@@ -462,6 +460,7 @@
mWaitThread.join();
done = true;
} catch (InterruptedException ex) {
+ // Ignore
}
}
mWaitThread = null;
@@ -519,6 +518,7 @@
try {
this.wait();
} catch (InterruptedException ex) {
+ // Ignore
}
}
Log.d(TAG, "done waiting to be done with workspace");
@@ -559,7 +559,6 @@
// Setting the reference is atomic, but we can't do it inside the other critical
// sections.
mLoaderThread = null;
- return;
}
}
@@ -942,7 +941,7 @@
private void bindAllApps() {
synchronized (mLock) {
final ArrayList<ApplicationInfo> results = mAllAppsList.added;
- mAllAppsList.added = new ArrayList();
+ mAllAppsList.added = new ArrayList<ApplicationInfo>();
mHandler.post(new Runnable() {
public void run() {
final long t = SystemClock.uptimeMillis();
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 608e7b7..a0391d3 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -48,7 +48,7 @@
* A workspace is meant to be used with a fixed width only.
*/
public class Workspace extends ViewGroup implements DropTarget, DragSource, DragScroller {
- private static final String TAG = "Launcher.Workspace";
+ //private static final String TAG = "Launcher.Workspace";
private static final int INVALID_SCREEN = -1;
/**
@@ -982,7 +982,7 @@
mDragInfo.spanX, mDragInfo.spanY, cell, cellLayout, mTargetCell);
cellLayout.onDropChild(cell, mTargetCell);
- final ItemInfo info = (ItemInfo)cell.getTag();
+ final ItemInfo info = (ItemInfo) cell.getTag();
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) cell.getLayoutParams();
LauncherModel.moveItemInDatabase(mLauncher, info,
LauncherSettings.Favorites.CONTAINER_DESKTOP, index, lp.cellX, lp.cellY);