diff options
author | Michael Jurka <mikejurka@google.com> | 2011-08-29 14:03:34 -0700 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2011-09-07 16:59:07 -0700 |
commit | c9d95c5897fc5ebbf53903d4ab18ad13d196f643 (patch) | |
tree | 86af38c22deec7c93b6434d2e04ec1a2e923b6dc /src | |
parent | 6c6f6f2009337ebfcc7f8fa3e5651d070ee2a9d7 (diff) | |
download | packages_apps_trebuchet-c9d95c5897fc5ebbf53903d4ab18ad13d196f643.zip packages_apps_trebuchet-c9d95c5897fc5ebbf53903d4ab18ad13d196f643.tar.gz packages_apps_trebuchet-c9d95c5897fc5ebbf53903d4ab18ad13d196f643.tar.bz2 |
Cleaning up LauncherModel
- performing all DB operations immediately if called from worker thread (a previous change that did this in updateItemInDatabase fixed an outstanding bug)
- centralizing logic to do database updates
- removing old logging code
Change-Id: Idc7bfef3921828ff7c5492b8e996c0a07e1ec508
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher2/AllAppsList.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher2/ApplicationInfo.java | 12 | ||||
-rw-r--r-- | src/com/android/launcher2/AppsCustomizePagedView.java | 7 | ||||
-rw-r--r-- | src/com/android/launcher2/FolderInfo.java | 3 | ||||
-rw-r--r-- | src/com/android/launcher2/InstallWidgetReceiver.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher2/ItemInfo.java | 11 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher2/LauncherAppWidgetInfo.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher2/LauncherModel.java | 233 | ||||
-rw-r--r-- | src/com/android/launcher2/PendingAddItemInfo.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher2/ShortcutInfo.java | 12 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 4 |
12 files changed, 137 insertions, 171 deletions
diff --git a/src/com/android/launcher2/AllAppsList.java b/src/com/android/launcher2/AllAppsList.java index 7c107a7..051b0bd 100644 --- a/src/com/android/launcher2/AllAppsList.java +++ b/src/com/android/launcher2/AllAppsList.java @@ -91,7 +91,7 @@ class AllAppsList { if (matches.size() > 0) { for (ResolveInfo info : matches) { - add(new ApplicationInfo(context.getPackageManager(), info, mIconCache, null, "15")); + add(new ApplicationInfo(context.getPackageManager(), info, mIconCache, null)); } } } @@ -142,7 +142,7 @@ class AllAppsList { info.activityInfo.applicationInfo.packageName, info.activityInfo.name); if (applicationInfo == null) { - add(new ApplicationInfo(context.getPackageManager(), info, mIconCache, null, "16")); + add(new ApplicationInfo(context.getPackageManager(), info, mIconCache, null)); } else { mIconCache.remove(applicationInfo.componentName); mIconCache.getTitleAndIcon(applicationInfo, info, null); diff --git a/src/com/android/launcher2/ApplicationInfo.java b/src/com/android/launcher2/ApplicationInfo.java index bbca664..1fc1d1f 100644 --- a/src/com/android/launcher2/ApplicationInfo.java +++ b/src/com/android/launcher2/ApplicationInfo.java @@ -60,8 +60,7 @@ class ApplicationInfo extends ItemInfo { int flags = 0; - ApplicationInfo(String whereCreated) { - super(whereCreated); + ApplicationInfo() { itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT; } @@ -69,8 +68,7 @@ class ApplicationInfo extends ItemInfo { * Must not hold the Context. */ public ApplicationInfo(PackageManager pm, ResolveInfo info, IconCache iconCache, - HashMap<Object, CharSequence> labelCache, String whereCreated) { - super(whereCreated); + HashMap<Object, CharSequence> labelCache) { final String packageName = info.activityInfo.applicationInfo.packageName; this.componentName = new ComponentName(packageName, info.activityInfo.name); @@ -95,8 +93,8 @@ class ApplicationInfo extends ItemInfo { iconCache.getTitleAndIcon(this, info, labelCache); } - public ApplicationInfo(ApplicationInfo info, String whereCreated) { - super(info, whereCreated); + public ApplicationInfo(ApplicationInfo info) { + super(info); componentName = info.componentName; title = info.title.toString(); intent = new Intent(info.intent); @@ -135,6 +133,6 @@ class ApplicationInfo extends ItemInfo { } public ShortcutInfo makeShortcut() { - return new ShortcutInfo(this, "18"); + return new ShortcutInfo(this); } } diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index d3e0963..878cc27 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -1014,8 +1014,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen if (rawInfo instanceof AppWidgetProviderInfo) { // Fill in the widget information AppWidgetProviderInfo info = (AppWidgetProviderInfo) rawInfo; - createItemInfo = new PendingAddWidgetInfo(info, null, null, "13"); - int[] cellSpans = mLauncher.getSpanForWidget(info, null); + createItemInfo = new PendingAddWidgetInfo(info, null, null); + int[] cellSpans = CellLayout.rectToCell(getResources(), + info.minWidth, info.minHeight, null); FastBitmapDrawable preview = new FastBitmapDrawable(data.generatedImages.get(i)); widget.applyFromAppWidgetProviderInfo(info, preview, -1, cellSpans, mHolographicOutlineHelper); @@ -1023,7 +1024,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } else if (rawInfo instanceof ResolveInfo) { // Fill in the shortcuts information ResolveInfo info = (ResolveInfo) rawInfo; - createItemInfo = new PendingAddItemInfo("14"); + createItemInfo = new PendingAddItemInfo(); createItemInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT; createItemInfo.componentName = new ComponentName(info.activityInfo.packageName, info.activityInfo.name); diff --git a/src/com/android/launcher2/FolderInfo.java b/src/com/android/launcher2/FolderInfo.java index 0f8b9e0..3ae31d2 100644 --- a/src/com/android/launcher2/FolderInfo.java +++ b/src/com/android/launcher2/FolderInfo.java @@ -42,8 +42,7 @@ class FolderInfo extends ItemInfo { ArrayList<FolderListener> listeners = new ArrayList<FolderListener>(); - FolderInfo(String whereCreated) { - super(whereCreated); + FolderInfo() { itemType = LauncherSettings.Favorites.ITEM_TYPE_FOLDER; } diff --git a/src/com/android/launcher2/InstallWidgetReceiver.java b/src/com/android/launcher2/InstallWidgetReceiver.java index 1b54e90..6b3763c 100644 --- a/src/com/android/launcher2/InstallWidgetReceiver.java +++ b/src/com/android/launcher2/InstallWidgetReceiver.java @@ -187,7 +187,7 @@ public class InstallWidgetReceiver { final AppWidgetProviderInfo widgetInfo = mActivities.get(which).widgetInfo; final PendingAddWidgetInfo createInfo = new PendingAddWidgetInfo(widgetInfo, mMimeType, - mClipData, "4"); + mClipData); mLauncher.addAppWidgetFromDrop(createInfo, LauncherSettings.Favorites.CONTAINER_DESKTOP, mTargetLayoutScreen, null, mTargetLayoutPos); } diff --git a/src/com/android/launcher2/ItemInfo.java b/src/com/android/launcher2/ItemInfo.java index 5c05f16..8d46624 100644 --- a/src/com/android/launcher2/ItemInfo.java +++ b/src/com/android/launcher2/ItemInfo.java @@ -86,16 +86,10 @@ class ItemInfo { */ int[] dropPos = null; - /* - * A tag to know where this item was created - */ - String whereCreated; - - ItemInfo(String whereCreated) { - this.whereCreated = whereCreated; + ItemInfo() { } - ItemInfo(ItemInfo info, String whereCreated) { + ItemInfo(ItemInfo info) { id = info.id; cellX = info.cellX; cellY = info.cellY; @@ -104,7 +98,6 @@ class ItemInfo { screen = info.screen; itemType = info.itemType; container = info.container; - this.whereCreated = whereCreated; } /** diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 8bbf902..6ff46f8 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -177,7 +177,7 @@ public final class Launcher extends Activity private AppWidgetManager mAppWidgetManager; private LauncherAppWidgetHost mAppWidgetHost; - private ItemInfo mPendingAddInfo = new ItemInfo("1"); + private ItemInfo mPendingAddInfo = new ItemInfo(); private int[] mTmpAddItemCellCoordinates = new int[2]; private FolderInfo mFolderInfo; @@ -946,7 +946,7 @@ public final class Launcher extends Activity } // Build Launcher-specific widget info and save to database - LauncherAppWidgetInfo launcherInfo = new LauncherAppWidgetInfo(appWidgetId, "2"); + LauncherAppWidgetInfo launcherInfo = new LauncherAppWidgetInfo(appWidgetId); launcherInfo.spanX = spanXY[0]; launcherInfo.spanY = spanXY[1]; @@ -1490,7 +1490,7 @@ public final class Launcher extends Activity FolderIcon addFolder(CellLayout layout, long container, final int screen, int cellX, int cellY) { - final FolderInfo folderInfo = new FolderInfo("3"); + final FolderInfo folderInfo = new FolderInfo(); folderInfo.title = getText(R.string.folder_name); // Update the model diff --git a/src/com/android/launcher2/LauncherAppWidgetInfo.java b/src/com/android/launcher2/LauncherAppWidgetInfo.java index 69eae17..844abb5 100644 --- a/src/com/android/launcher2/LauncherAppWidgetInfo.java +++ b/src/com/android/launcher2/LauncherAppWidgetInfo.java @@ -51,8 +51,7 @@ class LauncherAppWidgetInfo extends ItemInfo { /** * Constructor for use with AppWidgets that haven't been instantiated yet. */ - LauncherAppWidgetInfo(ComponentName providerName, String whereCreated) { - super(whereCreated); + LauncherAppWidgetInfo(ComponentName providerName) { itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET; this.providerName = providerName; @@ -62,8 +61,7 @@ class LauncherAppWidgetInfo extends ItemInfo { spanY = -1; } - LauncherAppWidgetInfo(int appWidgetId, String whereCreated) { - super(whereCreated); + LauncherAppWidgetInfo(int appWidgetId) { itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET; this.appWidgetId = appWidgetId; } diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java index e0b04da..1c5dc6c 100644 --- a/src/com/android/launcher2/LauncherModel.java +++ b/src/com/android/launcher2/LauncherModel.java @@ -171,7 +171,7 @@ public class LauncherModel extends BroadcastReceiver { // by making a copy of workspace items first. final ArrayList<ItemInfo> workspaceItems = new ArrayList<ItemInfo>(sWorkspaceItems); mHandler.post(new Runnable() { - @Override + @Override public void run() { for (ItemInfo item : workspaceItems) { item.unbind(); @@ -197,6 +197,46 @@ public class LauncherModel extends BroadcastReceiver { } } + static void updateItemInDatabaseHelper(Context context, final ContentValues values, + final ItemInfo item, final String callingFunction) { + final long itemId = item.id; + final Uri uri = LauncherSettings.Favorites.getContentUri(itemId, false); + final ContentResolver cr = context.getContentResolver(); + + Runnable r = new Runnable() { + public void run() { + cr.update(uri, values, null, null); + + ItemInfo modelItem = sItemsIdMap.get(itemId); + if (item != modelItem) { + // the modelItem needs to match up perfectly with item if our model is to be + // consistent with the database-- for now, just require modelItem == item + String msg = "item: " + ((item != null) ? item.toString() : "null") + + "modelItem: " + ((modelItem != null) ? modelItem.toString() : "null") + + "Error: ItemInfo passed to " + callingFunction + " doesn't match original"; + throw new RuntimeException(msg); + } + + // Items are added/removed from the corresponding FolderInfo elsewhere, such + // as in Workspace.onDrop. Here, we just add/remove them from the list of items + // that are on the desktop, as appropriate + if (modelItem.container == LauncherSettings.Favorites.CONTAINER_DESKTOP || + modelItem.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { + if (!sWorkspaceItems.contains(modelItem)) { + sWorkspaceItems.add(modelItem); + } + } else { + sWorkspaceItems.remove(modelItem); + } + } + }; + + if (sWorkerThread.getThreadId() == Process.myTid()) { + r.run(); + } else { + sWorker.post(r); + } + } /** * Move an item in the DB to a new <container, screen, cellX, cellY> */ @@ -205,6 +245,7 @@ public class LauncherModel extends BroadcastReceiver { item.container = container; item.cellX = cellX; item.cellY = cellY; + // We store hotseat items in canonical form which is this orientation invariant position // in the hotseat if (context instanceof Launcher && screen < 0 && @@ -214,43 +255,13 @@ public class LauncherModel extends BroadcastReceiver { item.screen = screen; } - final Uri uri = LauncherSettings.Favorites.getContentUri(item.id, false); final ContentValues values = new ContentValues(); - final ContentResolver cr = context.getContentResolver(); - values.put(LauncherSettings.Favorites.CONTAINER, item.container); values.put(LauncherSettings.Favorites.CELLX, item.cellX); values.put(LauncherSettings.Favorites.CELLY, item.cellY); values.put(LauncherSettings.Favorites.SCREEN, item.screen); - sWorker.post(new Runnable() { - public void run() { - cr.update(uri, values, null, null); - ItemInfo modelItem = sItemsIdMap.get(item.id); - if (item != modelItem) { - // the modelItem needs to match up perfectly with item if our model is to be - // consistent with the database-- for now, just require modelItem == item - String msg = "item: " + ((item != null) ? item.toString() : "null") + - " modelItem: " + ((modelItem != null) ? modelItem.toString() : "null") + - " creation tag of item: " + ((item != null) ? item.whereCreated : "null") + - " creation tag of modelItem: " + ((modelItem != null) ? modelItem.whereCreated : "null") + - " Error: ItemInfo passed to moveItemInDatabase doesn't match original"; - throw new RuntimeException(msg); - } - - // Items are added/removed from the corresponding FolderInfo elsewhere, such - // as in Workspace.onDrop. Here, we just add/remove them from the list of items - // that are on the desktop, as appropriate - if (modelItem.container == LauncherSettings.Favorites.CONTAINER_DESKTOP || - modelItem.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { - if (!sWorkspaceItems.contains(modelItem)) { - sWorkspaceItems.add(modelItem); - } - } else { - sWorkspaceItems.remove(modelItem); - } - } - }); + updateItemInDatabaseHelper(context, values, item, "moveItemInDatabase"); } /** @@ -263,32 +274,24 @@ public class LauncherModel extends BroadcastReceiver { item.cellX = cellX; item.cellY = cellY; - final Uri uri = LauncherSettings.Favorites.getContentUri(item.id, false); final ContentValues values = new ContentValues(); - final ContentResolver cr = context.getContentResolver(); - values.put(LauncherSettings.Favorites.CONTAINER, item.container); values.put(LauncherSettings.Favorites.SPANX, spanX); values.put(LauncherSettings.Favorites.SPANY, spanY); values.put(LauncherSettings.Favorites.CELLX, cellX); values.put(LauncherSettings.Favorites.CELLY, cellY); + updateItemInDatabaseHelper(context, values, item, "resizeItemInDatabase"); + } - sWorker.post(new Runnable() { - public void run() { - cr.update(uri, values, null, null); - ItemInfo modelItem = sItemsIdMap.get(item.id); - if (item != modelItem) { - // the modelItem needs to match up perfectly with item if our model is to be - // consistent with the database-- for now, just require modelItem == item - String msg = "item: " + ((item != null) ? item.toString() : "null") + - " modelItem: " + ((modelItem != null) ? modelItem.toString() : "null") + - " creation tag of item: " + ((item != null) ? item.whereCreated : "null") + - " creation tag of modelItem: " + ((modelItem != null) ? modelItem.whereCreated : "null") + - " Error: ItemInfo passed to resizeItemInDatabase doesn't match original"; - throw new RuntimeException(msg); - } - } - }); + + /** + * Update an item to the database in a specified container. + */ + static void updateItemInDatabase(Context context, final ItemInfo item) { + final ContentValues values = new ContentValues(); + item.onAddToDatabase(values); + item.updateValuesWithCoordinates(values, item.cellX, item.cellY); + updateItemInDatabaseHelper(context, values, item, "updateItemInDatabase"); } /** @@ -331,7 +334,7 @@ public class LauncherModel extends BroadcastReceiver { try { while (c.moveToNext()) { - ItemInfo item = new ItemInfo("17"); + ItemInfo item = new ItemInfo(); item.cellX = c.getInt(cellXIndex); item.cellY = c.getInt(cellYIndex); item.spanX = c.getInt(spanXIndex); @@ -420,7 +423,7 @@ public class LauncherModel extends BroadcastReceiver { values.put(LauncherSettings.Favorites._ID, item.id); item.updateValuesWithCoordinates(values, item.cellX, item.cellY); - sWorker.post(new Runnable() { + Runnable r = new Runnable() { public void run() { cr.insert(notify ? LauncherSettings.Favorites.CONTENT_URI : LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, values); @@ -447,7 +450,13 @@ public class LauncherModel extends BroadcastReceiver { break; } } - }); + }; + + if (sWorkerThread.getThreadId() == Process.myTid()) { + r.run(); + } else { + sWorker.post(r); + } } /** @@ -477,30 +486,31 @@ public class LauncherModel extends BroadcastReceiver { } /** - * Update an item to the database in a specified container. + * Removes the specified item from the database + * @param context + * @param item */ - static void updateItemInDatabase(Context context, final ItemInfo item) { - final ContentValues values = new ContentValues(); + static void deleteItemFromDatabase(Context context, final ItemInfo item) { final ContentResolver cr = context.getContentResolver(); - - item.onAddToDatabase(values); - item.updateValuesWithCoordinates(values, item.cellX, item.cellY); - + final Uri uriToDelete = LauncherSettings.Favorites.getContentUri(item.id, false); Runnable r = new Runnable() { public void run() { - cr.update(LauncherSettings.Favorites.getContentUri(item.id, false), - values, null, null); - final ItemInfo modelItem = sItemsIdMap.get(item.id); - if (item != modelItem) { - // the modelItem needs to match up perfectly with item if our model is to be - // consistent with the database-- for now, just require modelItem == item - String msg = "item: " + ((item != null) ? item.toString() : "null") + - " modelItem: " + ((modelItem != null) ? modelItem.toString() : "null") + - " creation tag of item: " + ((item != null) ? item.whereCreated : "null") + - " creation tag of modelItem: " + ((modelItem != null) ? modelItem.whereCreated : "null") + - " Error: ItemInfo passed to updateItemInDatabase doesn't match original"; - throw new RuntimeException(msg); + cr.delete(uriToDelete, null, null); + switch (item.itemType) { + case LauncherSettings.Favorites.ITEM_TYPE_FOLDER: + sFolders.remove(item.id); + sWorkspaceItems.remove(item); + break; + case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION: + case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT: + sWorkspaceItems.remove(item); + break; + case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET: + sAppWidgets.remove((LauncherAppWidgetInfo) item); + break; } + sItemsIdMap.remove(item.id); + sDbIconCache.remove(item); } }; if (sWorkerThread.getThreadId() == Process.myTid()) { @@ -511,57 +521,32 @@ public class LauncherModel extends BroadcastReceiver { } /** - * Removes the specified item from the database - * @param context - * @param item - */ - static void deleteItemFromDatabase(Context context, final ItemInfo item) { - final ContentResolver cr = context.getContentResolver(); - final Uri uriToDelete = LauncherSettings.Favorites.getContentUri(item.id, false); - sWorker.post(new Runnable() { - public void run() { - cr.delete(uriToDelete, null, null); - switch (item.itemType) { - case LauncherSettings.Favorites.ITEM_TYPE_FOLDER: - sFolders.remove(item.id); - sWorkspaceItems.remove(item); - break; - case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION: - case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT: - sWorkspaceItems.remove(item); - break; - case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET: - sAppWidgets.remove((LauncherAppWidgetInfo) item); - break; - } - sItemsIdMap.remove(item.id); - sDbIconCache.remove(item); - } - }); - } - - /** * Remove the contents of the specified folder from the database */ static void deleteFolderContentsFromDatabase(Context context, final FolderInfo info) { final ContentResolver cr = context.getContentResolver(); - sWorker.post(new Runnable() { - public void run() { - cr.delete(LauncherSettings.Favorites.getContentUri(info.id, false), null, null); - sItemsIdMap.remove(info.id); - sFolders.remove(info.id); - sDbIconCache.remove(info); - sWorkspaceItems.remove(info); - - cr.delete(LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, - LauncherSettings.Favorites.CONTAINER + "=" + info.id, null); - for (ItemInfo childInfo : info.contents) { - sItemsIdMap.remove(childInfo.id); - sDbIconCache.remove(childInfo); - } + Runnable r = new Runnable() { + public void run() { + cr.delete(LauncherSettings.Favorites.getContentUri(info.id, false), null, null); + sItemsIdMap.remove(info.id); + sFolders.remove(info.id); + sDbIconCache.remove(info); + sWorkspaceItems.remove(info); + + cr.delete(LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, + LauncherSettings.Favorites.CONTAINER + "=" + info.id, null); + for (ItemInfo childInfo : info.contents) { + sItemsIdMap.remove(childInfo.id); + sDbIconCache.remove(childInfo); } - }); + } + }; + if (sWorkerThread.getThreadId() == Process.myTid()) { + r.run(); + } else { + sWorker.post(r); + } } /** @@ -1102,7 +1087,7 @@ public class LauncherModel extends BroadcastReceiver { + id + " appWidgetId=" + appWidgetId); itemsToRemove.add(id); } else { - appWidgetInfo = new LauncherAppWidgetInfo(appWidgetId, "5"); + appWidgetInfo = new LauncherAppWidgetInfo(appWidgetId); appWidgetInfo.id = id; appWidgetInfo.screen = c.getInt(screenIndex); appWidgetInfo.cellX = c.getInt(cellXIndex); @@ -1394,7 +1379,7 @@ public class LauncherModel extends BroadcastReceiver { for (int j=0; i<N && j<batchSize; j++) { // This builds the icon bitmaps. mAllAppsList.add(new ApplicationInfo(packageManager, apps.get(i), - mIconCache, mLabelCache, "6")); + mIconCache, mLabelCache)); i++; } @@ -1590,7 +1575,7 @@ public class LauncherModel extends BroadcastReceiver { public ShortcutInfo getShortcutInfo(PackageManager manager, Intent intent, Context context, Cursor c, int iconIndex, int titleIndex, HashMap<Object, CharSequence> labelCache) { Bitmap icon = null; - final ShortcutInfo info = new ShortcutInfo("7"); + final ShortcutInfo info = new ShortcutInfo(); ComponentName componentName = intent.getComponent(); if (componentName == null) { @@ -1655,7 +1640,7 @@ public class LauncherModel extends BroadcastReceiver { int titleIndex) { Bitmap icon = null; - final ShortcutInfo info = new ShortcutInfo("8"); + final ShortcutInfo info = new ShortcutInfo(); info.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT; // TODO: If there's an explicit component and we can't install that, delete it. @@ -1814,7 +1799,7 @@ public class LauncherModel extends BroadcastReceiver { } } - final ShortcutInfo info = new ShortcutInfo("9"); + final ShortcutInfo info = new ShortcutInfo(); if (icon == null) { if (fallbackIcon != null) { @@ -1882,7 +1867,7 @@ public class LauncherModel extends BroadcastReceiver { FolderInfo folderInfo = folders.get(id); if (folderInfo == null) { // No placeholder -- create a new instance - folderInfo = new FolderInfo("10"); + folderInfo = new FolderInfo(); folders.put(id, folderInfo); } return folderInfo; diff --git a/src/com/android/launcher2/PendingAddItemInfo.java b/src/com/android/launcher2/PendingAddItemInfo.java index 6ee300b..7b564e0 100644 --- a/src/com/android/launcher2/PendingAddItemInfo.java +++ b/src/com/android/launcher2/PendingAddItemInfo.java @@ -28,10 +28,6 @@ class PendingAddItemInfo extends ItemInfo { * The component that will be created. */ ComponentName componentName; - - public PendingAddItemInfo(String whereCreated) { - super(whereCreated); - } } class PendingAddWidgetInfo extends PendingAddItemInfo { @@ -43,9 +39,7 @@ class PendingAddWidgetInfo extends PendingAddItemInfo { String mimeType; Parcelable configurationData; - public PendingAddWidgetInfo( - AppWidgetProviderInfo i, String dataMimeType, Parcelable data, String whereCreated) { - super(whereCreated); + public PendingAddWidgetInfo(AppWidgetProviderInfo i, String dataMimeType, Parcelable data) { itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET; componentName = i.provider; minWidth = i.minWidth; diff --git a/src/com/android/launcher2/ShortcutInfo.java b/src/com/android/launcher2/ShortcutInfo.java index 6d4853f..c0f80ae 100644 --- a/src/com/android/launcher2/ShortcutInfo.java +++ b/src/com/android/launcher2/ShortcutInfo.java @@ -62,14 +62,12 @@ class ShortcutInfo extends ItemInfo { */ private Bitmap mIcon; - ShortcutInfo(String whereCreated) { - super(whereCreated); + ShortcutInfo() { itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT; - this.whereCreated = whereCreated; } - public ShortcutInfo(ShortcutInfo info, String whereCreated) { - super(info, whereCreated); + public ShortcutInfo(ShortcutInfo info) { + super(info); title = info.title.toString(); intent = new Intent(info.intent); if (info.iconResource != null) { @@ -82,8 +80,8 @@ class ShortcutInfo extends ItemInfo { } /** TODO: Remove this. It's only called by ApplicationInfo.makeShortcut. */ - public ShortcutInfo(ApplicationInfo info, String whereCreated) { - super(info, whereCreated); + public ShortcutInfo(ApplicationInfo info) { + super(info); title = info.title.toString(); intent = new Intent(info.intent); customIcon = false; diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 29da4bf..e8c5116 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -2309,7 +2309,7 @@ public class Workspace extends SmoothPagedView // that widget final AppWidgetProviderInfo widgetInfo = widgets.get(0).widgetInfo; final PendingAddWidgetInfo createInfo = - new PendingAddWidgetInfo(widgetInfo, mimeType, data, "11"); + new PendingAddWidgetInfo(widgetInfo, mimeType, data); mLauncher.addAppWidgetFromDrop(createInfo, LauncherSettings.Favorites.CONTAINER_DESKTOP, mCurrentPage, null, pos); } else { @@ -2825,7 +2825,7 @@ public class Workspace extends SmoothPagedView case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT: if (info.container == NO_ID && info instanceof ApplicationInfo) { // Came from all apps -- make a copy - info = new ShortcutInfo((ApplicationInfo) info, "12"); + info = new ShortcutInfo((ApplicationInfo) info); } view = mLauncher.createShortcut(R.layout.application, cellLayout, (ShortcutInfo) info); |