am 1f0bb3ab: Merge change I44ad9fe5 into eclair

Merge commit '1f0bb3ab418d4fddc7db436ec49ca19449d8e1bb' into eclair-mr2

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