summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-02-13 12:57:53 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-02-13 12:57:53 -0800
commit98baae654dc6e69eecb5ffab2f86c5ab217a762c (patch)
treec949cee572fe7424493e7b54247ce8462813f361 /src/com/android
parent15a8880cb1b9010ce4503c10c1666568d49415b1 (diff)
downloadandroid_packages_apps_Trebuchet-98baae654dc6e69eecb5ffab2f86c5ab217a762c.tar.gz
android_packages_apps_Trebuchet-98baae654dc6e69eecb5ffab2f86c5ab217a762c.tar.bz2
android_packages_apps_Trebuchet-98baae654dc6e69eecb5ffab2f86c5ab217a762c.zip
auto import from //branches/cupcake/...@131421
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher/CellLayout.java21
-rw-r--r--src/com/android/launcher/Launcher.java115
-rw-r--r--src/com/android/launcher/LauncherGadgetHost.java105
-rw-r--r--src/com/android/launcher/LauncherGadgetHostView.java101
-rw-r--r--src/com/android/launcher/LauncherModel.java31
-rw-r--r--src/com/android/launcher/LiveFolderAdapter.java11
-rw-r--r--src/com/android/launcher/WallpaperChooser.java4
-rw-r--r--src/com/android/launcher/Widget.java30
-rw-r--r--src/com/android/launcher/Workspace.java14
9 files changed, 184 insertions, 248 deletions
diff --git a/src/com/android/launcher/CellLayout.java b/src/com/android/launcher/CellLayout.java
index 3e5a74ac6..ff8bff420 100644
--- a/src/com/android/launcher/CellLayout.java
+++ b/src/com/android/launcher/CellLayout.java
@@ -357,16 +357,10 @@ public class CellLayout extends ViewGroup {
}
cellInfo.valid = cellInfo.vacantCells.size() > 0;
- if (cellInfo.valid) {
- int[] xy = new int[2];
- if (cellInfo.findCellForSpan(xy, 1, 1)) {
- cellInfo.cellX = xy[0];
- cellInfo.cellY = xy[1];
- cellInfo.spanY = 1;
- cellInfo.spanX = 1;
- }
- }
+ // Assume the caller will perform their own cell searching, otherwise we
+ // risk causing an unnecessary rebuild after findCellForSpan()
+
return cellInfo;
}
@@ -665,9 +659,9 @@ public class CellLayout extends ViewGroup {
*
* @param width Width in pixels
* @param height Height in pixels
- * @param cellInfo {@link CellInfo} to fill with calculated span parameters
+ * @param Horizontal and vertical spans required
*/
- public void rectToCell(int width, int height, CellInfo cellInfo) {
+ public int[] rectToCell(int width, int height) {
// Always assume we're working with the smallest span to make sure we
// reserve enough space in both orientations.
int actualWidth = mCellWidth + mWidthGap;
@@ -675,8 +669,9 @@ public class CellLayout extends ViewGroup {
int smallerSize = Math.min(actualWidth, actualHeight);
// Always round up to next largest cell
- cellInfo.spanX = (width + smallerSize) / smallerSize;
- cellInfo.spanY = (height + smallerSize) / smallerSize;
+ int spanX = (width + smallerSize) / smallerSize;
+ int spanY = (height + smallerSize) / smallerSize;
+ return new int[] { spanX, spanY };
}
/**
diff --git a/src/com/android/launcher/Launcher.java b/src/com/android/launcher/Launcher.java
index 293abe808..4252daecf 100644
--- a/src/com/android/launcher/Launcher.java
+++ b/src/com/android/launcher/Launcher.java
@@ -37,7 +37,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.content.res.Configuration;
import android.database.ContentObserver;
-import android.gadget.GadgetInfo;
+import android.gadget.GadgetProviderInfo;
import android.gadget.GadgetManager;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
@@ -197,7 +197,9 @@ public final class Launcher extends Activity implements View.OnClickListener, On
mInflater = getLayoutInflater();
mGadgetManager = GadgetManager.getInstance(this);
+
mGadgetHost = new LauncherGadgetHost(this, GADGET_HOST_ID);
+ mGadgetHost.startListening();
// TODO: figure out if this is first launch and correctly clear GadgetHost database
@@ -234,18 +236,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On
Selection.setSelection(mDefaultKeySsb, 0);
}
- @Override
- protected void onStart() {
- super.onStart();
- mGadgetHost.startListening();
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- mGadgetHost.stopListening();
- }
-
private void checkForLocaleChange() {
final SharedPreferences preferences = getSharedPreferences(PREFERENCES, MODE_PRIVATE);
final Configuration configuration = getResources().getConfiguration();
@@ -315,7 +305,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On
if (resultCode == RESULT_OK && mAddItemCellInfo != null) {
switch (requestCode) {
case REQUEST_PICK_APPLICATION:
- completeAddApplication(this, data, mAddItemCellInfo);
+ completeAddApplication(this, data, mAddItemCellInfo, !mDesktopLocked);
break;
case REQUEST_PICK_SHORTCUT:
addShortcut(data);
@@ -541,8 +531,10 @@ public final class Launcher extends Activity implements View.OnClickListener, On
* @param data The intent describing the application.
* @param cellInfo The position on screen where to create the shortcut.
*/
- void completeAddApplication(Context context, Intent data, CellLayout.CellInfo cellInfo) {
+ void completeAddApplication(Context context, Intent data, CellLayout.CellInfo cellInfo,
+ boolean insertAtFirst) {
cellInfo.screen = mWorkspace.getCurrentScreen();
+ if (!findSingleSlot(cellInfo)) return;
// Find details for this application
ComponentName component = data.getComponent();
@@ -567,7 +559,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On
itemInfo.icon = activityInfo.loadIcon(packageManager);
itemInfo.container = ItemInfo.NO_ID;
- mWorkspace.addApplicationShortcut(itemInfo, mAddItemCellInfo);
+ mWorkspace.addApplicationShortcut(itemInfo, cellInfo, insertAtFirst);
}
}
@@ -580,8 +572,9 @@ public final class Launcher extends Activity implements View.OnClickListener, On
*/
private void completeAddShortcut(Intent data, CellLayout.CellInfo cellInfo,
boolean insertAtFirst) {
-
cellInfo.screen = mWorkspace.getCurrentScreen();
+ if (!findSingleSlot(cellInfo)) return;
+
final ApplicationInfo info = addShortcut(this, data, cellInfo, false);
if (!mRestoring) {
@@ -610,20 +603,20 @@ public final class Launcher extends Activity implements View.OnClickListener, On
Log.d(LOG_TAG, "dumping extras content="+extras.toString());
- GadgetInfo gadgetInfo = mGadgetManager.getGadgetInfo(gadgetId);
+ GadgetProviderInfo gadgetInfo = mGadgetManager.getGadgetInfo(gadgetId);
// Calculate the grid spans needed to fit this gadget
CellLayout layout = (CellLayout) mWorkspace.getChildAt(cellInfo.screen);
- layout.rectToCell(gadgetInfo.minWidth, gadgetInfo.minHeight, cellInfo);
-
+ int[] spans = layout.rectToCell(gadgetInfo.minWidth, gadgetInfo.minHeight);
+
// Try finding open space on Launcher screen
final int[] xy = mCellCoordinates;
- if (!findSlot(cellInfo, xy, cellInfo.spanX, cellInfo.spanY)) return;
+ if (!findSlot(cellInfo, xy, spans[0], spans[1])) return;
// Build Launcher-specific Gadget info and save to database
LauncherGadgetInfo launcherInfo = new LauncherGadgetInfo(gadgetId);
- launcherInfo.spanX = cellInfo.spanX;
- launcherInfo.spanY = cellInfo.spanY;
+ launcherInfo.spanX = spans[0];
+ launcherInfo.spanY = spans[1];
LauncherModel.addItemToDatabase(this, launcherInfo,
LauncherSettings.Favorites.CONTAINER_DESKTOP,
@@ -643,19 +636,6 @@ public final class Launcher extends Activity implements View.OnClickListener, On
} else if (sModel.isDesktopLoaded()) {
sModel.addDesktopItem(launcherInfo);
}
-
- // Request fresh update if we needed to config this gadget to
- // remove the stale UPDATE from the initial bind
- if (!extras.containsKey(SKIP_CONFIG) || true) {
- // TODO: move this down into GadgetManager to prevent abuse? (anyone
- // could force a specific gadget into the ground through flooding)
- Log.d(LOG_TAG, "requesting new gadget update because we had a config step");
- Intent intent = new Intent(GadgetManager.GADGET_UPDATE_ACTION);
- intent.putExtra(GadgetManager.EXTRA_GADGET_IDS, new int[] { gadgetId });
- intent.setComponent(gadgetInfo.provider);
- sendBroadcast(intent);
- }
-
}
public LauncherGadgetHost getGadgetHost() {
@@ -802,6 +782,8 @@ public final class Launcher extends Activity implements View.OnClickListener, On
mDestroyed = true;
super.onDestroy();
+
+ mGadgetHost.stopListening();
TextKeyListener.getInstance().release();
@@ -901,24 +883,20 @@ public final class Launcher extends Activity implements View.OnClickListener, On
}
}
- static final String SKIP_CONFIG = "skip_config";
-
void addGadget(Intent data) {
+ // TODO: catch bad gadget exception when sent
int gadgetId = data.getIntExtra(GadgetManager.EXTRA_GADGET_ID, -1);
- GadgetInfo gadget = mGadgetManager.getGadgetInfo(gadgetId);
+ GadgetProviderInfo gadget = mGadgetManager.getGadgetInfo(gadgetId);
if (gadget.configure != null) {
// Launch over to configure gadget, if needed
- Intent intent = new Intent(GadgetManager.GADGET_CONFIGURE_ACTION);
+ Intent intent = new Intent(GadgetManager.ACTION_GADGET_CONFIGURE);
intent.setComponent(gadget.configure);
intent.putExtra(GadgetManager.EXTRA_GADGET_ID, gadgetId);
startActivityForResult(intent, REQUEST_CREATE_GADGET);
} else {
// Otherwise just add it
- Log.d(LOG_TAG, "dumping extras content="+data.getExtras().toString());
- data.putExtra(SKIP_CONFIG, true);
- Log.d(LOG_TAG, "dumping extras content="+data.getExtras().toString());
onActivityResult(REQUEST_CREATE_GADGET, Activity.RESULT_OK, data);
}
}
@@ -951,28 +929,32 @@ public final class Launcher extends Activity implements View.OnClickListener, On
startActivityForResult(intent, REQUEST_CREATE_LIVE_FOLDER);
}
- void addFolder() {
+ void addFolder(boolean insertAtFirst) {
UserFolderInfo folderInfo = new UserFolderInfo();
folderInfo.title = getText(R.string.folder_name);
- int cellX = mAddItemCellInfo.cellX;
- int cellY = mAddItemCellInfo.cellY;
+
+ CellLayout.CellInfo cellInfo = mAddItemCellInfo;
+ cellInfo.screen = mWorkspace.getCurrentScreen();
+ if (!findSingleSlot(cellInfo)) return;
// Update the model
LauncherModel.addItemToDatabase(this, folderInfo, LauncherSettings.Favorites.CONTAINER_DESKTOP,
- mWorkspace.getCurrentScreen(), cellX, cellY, false);
+ mWorkspace.getCurrentScreen(), cellInfo.cellX, cellInfo.cellY, false);
sModel.addDesktopItem(folderInfo);
sModel.addFolder(folderInfo);
// Create the view
FolderIcon newFolder = FolderIcon.fromXml(R.layout.folder_icon, this,
(ViewGroup) mWorkspace.getChildAt(mWorkspace.getCurrentScreen()), folderInfo);
- mWorkspace.addInCurrentScreen(newFolder, cellX, cellY, 1, 1);
+ mWorkspace.addInCurrentScreen(newFolder,
+ cellInfo.cellX, cellInfo.cellY, 1, 1, insertAtFirst);
}
-
+
private void completeAddLiveFolder(Intent data, CellLayout.CellInfo cellInfo,
boolean insertAtFirst) {
-
cellInfo.screen = mWorkspace.getCurrentScreen();
+ if (!findSingleSlot(cellInfo)) return;
+
final LiveFolderInfo info = addLiveFolder(this, data, cellInfo, false);
if (!mRestoring) {
@@ -1031,6 +1013,16 @@ public final class Launcher extends Activity implements View.OnClickListener, On
return info;
}
+ private boolean findSingleSlot(CellLayout.CellInfo cellInfo) {
+ final int[] xy = new int[2];
+ if (findSlot(cellInfo, xy, 1, 1)) {
+ cellInfo.cellX = xy[0];
+ cellInfo.cellY = xy[1];
+ return true;
+ }
+ return false;
+ }
+
private boolean findSlot(CellLayout.CellInfo cellInfo, int[] xy, int spanX, int spanY) {
if (!cellInfo.findCellForSpan(xy, spanX, spanY)) {
boolean[] occupied = mSavedState != null ?
@@ -1184,7 +1176,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On
}
count = shortcuts.size();
-
+
final DesktopItemsBinder binder = new DesktopItemsBinder(this, shortcuts);
binder.obtainMessage(DesktopItemsBinder.MESSAGE_BIND_ITEMS, 0, count).sendToTarget();
}
@@ -1226,26 +1218,16 @@ public final class Launcher extends Activity implements View.OnClickListener, On
final LauncherGadgetInfo launcherInfo = (LauncherGadgetInfo) item;
final int gadgetId = launcherInfo.gadgetId;
- GadgetInfo gadgetInfo = mGadgetManager.getGadgetInfo(gadgetId);
+ GadgetProviderInfo gadgetInfo = mGadgetManager.getGadgetInfo(gadgetId);
launcherInfo.hostView = mGadgetHost.createView(this, gadgetId, gadgetInfo);
-
- Log.d(LOG_TAG, "about to setGadget during desktop bind");
+
+ Log.d(LOG_TAG, "about to setGadget for id="+gadgetId+", info="+gadgetInfo);
launcherInfo.hostView.setGadget(gadgetId, gadgetInfo);
launcherInfo.hostView.setTag(launcherInfo);
workspace.addInScreen(launcherInfo.hostView, item.screen, item.cellX,
item.cellY, item.spanX, item.spanY, !desktopLocked);
- // Now that we've bound the item, request an update for it
- if (gadgetInfo != null) {
- if (gadgetInfo.provider != null) {
- Intent intent = new Intent(GadgetManager.GADGET_UPDATE_ACTION);
- intent.putExtra(GadgetManager.EXTRA_GADGET_IDS, new int[] { gadgetId });
- intent.setComponent(gadgetInfo.provider);
- sendBroadcast(intent);
- }
- }
-
break;
case LauncherSettings.Favorites.ITEM_TYPE_WIDGET_SEARCH:
final int screen = workspace.getCurrentScreen();
@@ -1657,8 +1639,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On
case AddAdapter.ITEM_GADGET: {
int gadgetId = Launcher.this.mGadgetHost.allocateGadgetId();
- Intent pickIntent = new Intent(GadgetManager.GADGET_PICK_ACTION);
- pickIntent.putExtra(GadgetManager.EXTRA_HOST_ID, GADGET_HOST_ID);
+ Intent pickIntent = new Intent(GadgetManager.ACTION_GADGET_PICK);
pickIntent.putExtra(GadgetManager.EXTRA_GADGET_ID, gadgetId);
startActivityForResult(pickIntent, REQUEST_PICK_GADGET);
break;
@@ -1676,7 +1657,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On
}
case AddAdapter.ITEM_FOLDER: {
- addFolder();
+ addFolder(!mDesktopLocked);
dismissDialog(DIALOG_CREATE_SHORTCUT);
break;
}
diff --git a/src/com/android/launcher/LauncherGadgetHost.java b/src/com/android/launcher/LauncherGadgetHost.java
index 4f7e8f2f2..9bb4f0565 100644
--- a/src/com/android/launcher/LauncherGadgetHost.java
+++ b/src/com/android/launcher/LauncherGadgetHost.java
@@ -19,113 +19,20 @@ package com.android.launcher;
import android.content.Context;
import android.gadget.GadgetHost;
import android.gadget.GadgetHostView;
-import android.gadget.GadgetInfo;
-import android.graphics.Color;
-import android.view.LayoutInflater;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewConfiguration;
-import android.widget.TextView;
+import android.gadget.GadgetProviderInfo;
/**
- * Specific {@link GadgetHost} that creates our {@link LauncherGadgetHostView} which correctly
- * captures all long-press events. This ensures that users can always pick up and move gadgets.
+ * Specific {@link GadgetHost} that creates our {@link LauncherGadgetHostView}
+ * which correctly captures all long-press events. This ensures that users can
+ * always pick up and move gadgets.
*/
public class LauncherGadgetHost extends GadgetHost {
public LauncherGadgetHost(Context context, int hostId) {
super(context, hostId);
}
- protected GadgetHostView onCreateView(Context context, int gadgetId, GadgetInfo gadget) {
+ protected GadgetHostView onCreateView(Context context, int gadgetId,
+ GadgetProviderInfo gadget) {
return new LauncherGadgetHostView(context);
}
-
- /**
- * {@inheritDoc}
- */
- public class LauncherGadgetHostView extends GadgetHostView {
- static final String TAG = "LauncherGadgetHostView";
-
- private boolean mHasPerformedLongPress;
-
- private CheckForLongPress mPendingCheckForLongPress;
-
- private LayoutInflater mInflater;
-
- public LauncherGadgetHostView(Context context) {
- super(context);
-
- mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-
- // Prepare our default transition animations
- setAnimateFirstView(true);
- setInAnimation(context, android.R.anim.fade_in);
- setOutAnimation(context, android.R.anim.fade_out);
- }
-
- @Override
- protected View getErrorView() {
- return mInflater.inflate(R.layout.gadget_error, this, false);
- }
-
- public boolean onInterceptTouchEvent(MotionEvent ev) {
-
- // Consume any touch events for ourselves after longpress is triggered
- if (mHasPerformedLongPress) {
- mHasPerformedLongPress = false;
- return true;
- }
-
- // Watch for longpress events at this level to make sure
- // users can always pick up this Gadget
- switch (ev.getAction()) {
- case MotionEvent.ACTION_DOWN: {
- postCheckForLongClick();
- break;
- }
-
- case MotionEvent.ACTION_UP: {
- mHasPerformedLongPress = false;
- if (mPendingCheckForLongPress != null) {
- removeCallbacks(mPendingCheckForLongPress);
- }
- break;
- }
- }
-
- // Otherwise continue letting touch events fall through to children
- return false;
- }
-
- class CheckForLongPress implements Runnable {
- private int mOriginalWindowAttachCount;
-
- public void run() {
- if ((mParent != null) && hasWindowFocus()
- && mOriginalWindowAttachCount == getWindowAttachCount()
- && !mHasPerformedLongPress) {
- if (performLongClick()) {
- mHasPerformedLongPress = true;
- }
- }
- }
-
- public void rememberWindowAttachCount() {
- mOriginalWindowAttachCount = getWindowAttachCount();
- }
- }
-
- private void postCheckForLongClick() {
- mHasPerformedLongPress = false;
-
- if (mPendingCheckForLongPress == null) {
- mPendingCheckForLongPress = new CheckForLongPress();
- }
- mPendingCheckForLongPress.rememberWindowAttachCount();
- postDelayed(mPendingCheckForLongPress, ViewConfiguration.getLongPressTimeout());
- }
-
- }
-
}
-
diff --git a/src/com/android/launcher/LauncherGadgetHostView.java b/src/com/android/launcher/LauncherGadgetHostView.java
new file mode 100644
index 000000000..dd098aac2
--- /dev/null
+++ b/src/com/android/launcher/LauncherGadgetHostView.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher;
+
+import android.content.Context;
+import android.gadget.GadgetHostView;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewConfiguration;
+
+/**
+ * {@inheritDoc}
+ */
+public class LauncherGadgetHostView extends GadgetHostView {
+ private boolean mHasPerformedLongPress;
+
+ private CheckForLongPress mPendingCheckForLongPress;
+
+ private LayoutInflater mInflater;
+
+ public LauncherGadgetHostView(Context context) {
+ super(context);
+ mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ }
+
+ @Override
+ protected View getErrorView() {
+ return mInflater.inflate(R.layout.gadget_error, this, false);
+ }
+
+ public boolean onInterceptTouchEvent(MotionEvent ev) {
+ // Consume any touch events for ourselves after longpress is triggered
+ if (mHasPerformedLongPress) {
+ mHasPerformedLongPress = false;
+ return true;
+ }
+
+ // Watch for longpress events at this level to make sure
+ // users can always pick up this Gadget
+ switch (ev.getAction()) {
+ case MotionEvent.ACTION_DOWN: {
+ postCheckForLongClick();
+ break;
+ }
+
+ case MotionEvent.ACTION_UP: {
+ mHasPerformedLongPress = false;
+ if (mPendingCheckForLongPress != null) {
+ removeCallbacks(mPendingCheckForLongPress);
+ }
+ break;
+ }
+ }
+
+ // Otherwise continue letting touch events fall through to children
+ return false;
+ }
+
+ class CheckForLongPress implements Runnable {
+ private int mOriginalWindowAttachCount;
+
+ public void run() {
+ if ((mParent != null) && hasWindowFocus()
+ && mOriginalWindowAttachCount == getWindowAttachCount()
+ && !mHasPerformedLongPress) {
+ if (performLongClick()) {
+ mHasPerformedLongPress = true;
+ }
+ }
+ }
+
+ public void rememberWindowAttachCount() {
+ mOriginalWindowAttachCount = getWindowAttachCount();
+ }
+ }
+
+ private void postCheckForLongClick() {
+ mHasPerformedLongPress = false;
+
+ if (mPendingCheckForLongPress == null) {
+ mPendingCheckForLongPress = new CheckForLongPress();
+ }
+ mPendingCheckForLongPress.rememberWindowAttachCount();
+ postDelayed(mPendingCheckForLongPress, ViewConfiguration.getLongPressTimeout());
+ }
+}
diff --git a/src/com/android/launcher/LauncherModel.java b/src/com/android/launcher/LauncherModel.java
index 5d0179663..783eef2db 100644
--- a/src/com/android/launcher/LauncherModel.java
+++ b/src/com/android/launcher/LauncherModel.java
@@ -894,37 +894,6 @@ public class LauncherModel {
return null;
}
- static Widget getPhotoFrameInfo(Context context, int screen, int cellX, int cellY) {
- final ContentResolver cr = context.getContentResolver();
- Cursor c = cr.query(LauncherSettings.Favorites.CONTENT_URI,
- null, "screen=? and cellX=? and cellY=? and itemType=?",
- new String[] { String.valueOf(screen), String.valueOf(cellX), String.valueOf(cellY),
- String.valueOf(LauncherSettings.Favorites.ITEM_TYPE_WIDGET_PHOTO_FRAME) }, null);
-
- try {
- if (c.moveToFirst()) {
- final int idIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ID);
- final int containerIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CONTAINER);
- final int screenIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SCREEN);
- final int cellXIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLX);
- final int cellYIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLY);
-
- Widget widgetInfo = Widget.makePhotoFrame();
- widgetInfo.id = c.getLong(idIndex);
- widgetInfo.screen = c.getInt(screenIndex);
- widgetInfo.container = c.getInt(containerIndex);
- widgetInfo.cellX = c.getInt(cellXIndex);
- widgetInfo.cellY = c.getInt(cellYIndex);
-
- return widgetInfo;
- }
- } finally {
- c.close();
- }
-
- return null;
- }
-
/**
* Add an item to the database in a specified container. Sets the container, screen, cellX and
* cellY fields of the item. Also assigns an ID to the item.
diff --git a/src/com/android/launcher/LiveFolderAdapter.java b/src/com/android/launcher/LiveFolderAdapter.java
index 01db5a639..71ed85d34 100644
--- a/src/com/android/launcher/LiveFolderAdapter.java
+++ b/src/com/android/launcher/LiveFolderAdapter.java
@@ -178,10 +178,13 @@ class LiveFolderAdapter extends CursorAdapter {
}
mCustomIcons.clear();
- try {
- getCursor().close();
- } finally {
- mLauncher.stopManagingCursor(getCursor());
+ final Cursor cursor = getCursor();
+ if (cursor != null) {
+ try {
+ cursor.close();
+ } finally {
+ mLauncher.stopManagingCursor(cursor);
+ }
}
}
diff --git a/src/com/android/launcher/WallpaperChooser.java b/src/com/android/launcher/WallpaperChooser.java
index 1eb8d0cb3..c88a02a61 100644
--- a/src/com/android/launcher/WallpaperChooser.java
+++ b/src/com/android/launcher/WallpaperChooser.java
@@ -50,7 +50,6 @@ public class WallpaperChooser extends Activity implements AdapterView.OnItemSele
R.drawable.wallpaper_path_small,
R.drawable.wallpaper_sunrise_small,
R.drawable.wallpaper_mountain_small,
- R.drawable.wallpaper_ripples_small,
R.drawable.wallpaper_road_small,
R.drawable.wallpaper_jellyfish_small,
R.drawable.wallpaper_zanzibar_small,
@@ -68,7 +67,6 @@ public class WallpaperChooser extends Activity implements AdapterView.OnItemSele
R.drawable.wallpaper_path,
R.drawable.wallpaper_sunrise,
R.drawable.wallpaper_mountain,
- R.drawable.wallpaper_ripples,
R.drawable.wallpaper_road,
R.drawable.wallpaper_jellyfish,
R.drawable.wallpaper_zanzibar,
@@ -130,7 +128,7 @@ public class WallpaperChooser extends Activity implements AdapterView.OnItemSele
"drawable", packageName);
if (thumbRes != 0) {
- mThumbs.add(res);
+ mThumbs.add(thumbRes);
mImages.add(res);
}
}
diff --git a/src/com/android/launcher/Widget.java b/src/com/android/launcher/Widget.java
index 881252222..4f246cc77 100644
--- a/src/com/android/launcher/Widget.java
+++ b/src/com/android/launcher/Widget.java
@@ -20,32 +20,11 @@ import android.content.ContentValues;
import android.graphics.Bitmap;
/**
- * Represents one instance of a Launcher widget (clock, search, photo frame).
- *
+ * Represents one instance of a Launcher widget, such as search.
*/
class Widget extends ItemInfo {
-
int layoutResource;
- Bitmap photo;
- static Widget makeClock() {
- Widget w = new Widget();
- w.itemType = LauncherSettings.Favorites.ITEM_TYPE_WIDGET_CLOCK;
- w.spanX = 2;
- w.spanY = 2;
- w.layoutResource = R.layout.widget_clock;
- return w;
- }
-
- static Widget makePhotoFrame() {
- Widget w = new Widget();
- w.itemType = LauncherSettings.Favorites.ITEM_TYPE_WIDGET_PHOTO_FRAME;
- w.spanX = 2;
- w.spanY = 2;
- w.layoutResource = R.layout.widget_photo_frame;
- return w;
- }
-
static Widget makeSearch() {
Widget w = new Widget();
w.itemType = LauncherSettings.Favorites.ITEM_TYPE_WIDGET_SEARCH;
@@ -54,11 +33,4 @@ class Widget extends ItemInfo {
w.layoutResource = R.layout.widget_search;
return w;
}
-
- @Override
- void onAddToDatabase(ContentValues values) {
- super.onAddToDatabase(values);
- writeBitmap(values, photo);
- }
-
}
diff --git a/src/com/android/launcher/Workspace.java b/src/com/android/launcher/Workspace.java
index 510dad490..6d8eef5f1 100644
--- a/src/com/android/launcher/Workspace.java
+++ b/src/com/android/launcher/Workspace.java
@@ -839,11 +839,16 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
}
void addApplicationShortcut(ApplicationInfo info, CellLayout.CellInfo cellInfo) {
+ addApplicationShortcut(info, cellInfo, false);
+ }
+
+ void addApplicationShortcut(ApplicationInfo info, CellLayout.CellInfo cellInfo,
+ boolean insertAtFirst) {
final CellLayout layout = (CellLayout) getChildAt(cellInfo.screen);
final int[] result = new int[2];
layout.cellToPoint(cellInfo.cellX, cellInfo.cellY, result);
- onDropExternal(result[0], result[1], info, layout);
+ onDropExternal(result[0], result[1], info, layout, insertAtFirst);
}
public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset, Object dragInfo) {
@@ -882,6 +887,11 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
}
private void onDropExternal(int x, int y, Object dragInfo, CellLayout cellLayout) {
+ onDropExternal(x, y, dragInfo, cellLayout, false);
+ }
+
+ private void onDropExternal(int x, int y, Object dragInfo, CellLayout cellLayout,
+ boolean insertAtFirst) {
// Drag from somewhere else
ItemInfo info = (ItemInfo) dragInfo;
@@ -905,7 +915,7 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
throw new IllegalStateException("Unknown item type: " + info.itemType);
}
- cellLayout.addView(view);
+ cellLayout.addView(view, insertAtFirst ? 0 : -1);
view.setOnLongClickListener(mLongClickListener);
cellLayout.onDropChild(view, x, y);
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) view.getLayoutParams();