Merge change I44ad9fe5 into eclair

* changes:
  Add android.home.drop even for the live wallpapers.
This commit is contained in:
Android (Google) Code Review
2009-11-04 18:01:17 -05:00
4 changed files with 39 additions and 49 deletions
+23 -2
View File
@@ -27,6 +27,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
import android.app.WallpaperManager;
import java.util.ArrayList;
@@ -52,14 +53,14 @@ public class CellLayout extends ViewGroup {
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 @@ public class CellLayout extends ViewGroup {
mOccupied = new boolean[mLongAxisCells][mShortAxisCells];
}
}
mWallpaperManager = WallpaperManager.getInstance(getContext());
}
@Override
@@ -433,6 +436,14 @@ public class CellLayout extends ViewGroup {
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 @@ 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;
mWallpaperManager.sendWallpaperCommand(getWindowToken(), "android.home.drop",
childLeft + lp.width / 2, childTop + lp.height / 2, 0, null);
}
}
}
}
@@ -616,6 +634,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();
@@ -844,6 +863,8 @@ out: for (int i = x; i < x + spanX - 1 && x < xCount; i++) {
int y;
boolean regenerateId;
boolean dropped;
public LayoutParams(Context c, AttributeSet attrs) {
super(c, attrs);
+5 -35
View File
@@ -38,11 +38,7 @@ import android.content.res.Configuration;
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.Menu;
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.widget.Toast;
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 @@ public final class Launcher extends Activity
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 @@ public final class Launcher extends Activity
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;
@@ -1274,23 +1262,13 @@ public final class Launcher extends Activity
startActivityForResult(chooser, REQUEST_PICK_WALLPAPER);
}
@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 @@ public final class Launcher extends Activity
closeFolder();
}
}
mBackDown = false;
return true;
case KeyEvent.KEYCODE_HOME:
mHomeDown = false;
return true;
}
}
@@ -1881,11 +1857,6 @@ public final class Launcher extends Activity
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 @@ public final class Launcher extends Activity
* Implementation of the method from LauncherModel.Callbacks.
*/
public void bindAllApplications(ArrayList<ApplicationInfo> apps) {
mAllAppsList = apps;
mAllAppsGrid.setApps(mAllAppsList);
mAllAppsGrid.setApps(apps);
}
/**
+9 -10
View File
@@ -29,9 +29,7 @@ import android.content.res.Resources;
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 @@ public class LauncherModel extends BroadcastReceiver {
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 @@ public class LauncherModel extends BroadcastReceiver {
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 @@ public class LauncherModel extends BroadcastReceiver {
mWaitThread.join();
done = true;
} catch (InterruptedException ex) {
// Ignore
}
}
mWaitThread = null;
@@ -519,6 +518,7 @@ public class LauncherModel extends BroadcastReceiver {
try {
this.wait();
} catch (InterruptedException ex) {
// Ignore
}
}
Log.d(TAG, "done waiting to be done with workspace");
@@ -559,7 +559,6 @@ public class LauncherModel extends BroadcastReceiver {
// Setting the reference is atomic, but we can't do it inside the other critical
// sections.
mLoaderThread = null;
return;
}
}
@@ -942,7 +941,7 @@ public class LauncherModel extends BroadcastReceiver {
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();
+2 -2
View File
@@ -48,7 +48,7 @@ import java.util.ArrayList;
* 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 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
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);