diff options
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/launcher2/Folder.java | 10 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 84 | ||||
-rw-r--r-- | src/com/android/launcher2/LauncherModel.java | 11 | ||||
-rw-r--r-- | src/com/android/launcher2/Utilities.java | 30 |
4 files changed, 80 insertions, 55 deletions
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java index 641e0f7..15a0642 100644 --- a/src/com/android/launcher2/Folder.java +++ b/src/com/android/launcher2/Folder.java @@ -292,13 +292,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList return mInfo; } - void onOpen() { - // When the folder opens, we need to refresh the GridView's selection by - // forcing a layout - // TODO: find out if this is still necessary - mContent.requestLayout(); - } - void bind(FolderInfo info) { mInfo = info; ArrayList<ShortcutInfo> children = info.contents; @@ -849,7 +842,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList private void onCloseComplete() { DragLayer parent = (DragLayer) getParent(); - parent.removeView(Folder.this); + parent.removeView(this); + mDragController.removeDropTarget((DropTarget) this); clearFocus(); if (mRearrangeOnClose) { diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index c025638..bb7bdf5 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -436,6 +436,7 @@ public final class Launcher extends Activity * a configuration step, this allows the proper animations to run after other transitions. */ private boolean completeAdd(PendingAddArguments args) { + boolean result = false; switch (args.requestCode) { case REQUEST_PICK_APPLICATION: completeAddApplication(args.intent, args.container, args.screen, args.cellX, @@ -447,19 +448,24 @@ public final class Launcher extends Activity case REQUEST_CREATE_SHORTCUT: completeAddShortcut(args.intent, args.container, args.screen, args.cellX, args.cellY); - return true; + result = true; + break; case REQUEST_PICK_APPWIDGET: addAppWidgetFromPick(args.intent); break; case REQUEST_CREATE_APPWIDGET: int appWidgetId = args.intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); completeAddAppWidget(appWidgetId, args.container, args.screen); - return true; + result = true; + break; case REQUEST_PICK_WALLPAPER: // We just wanted the activity result here so we can clear mWaitingForResult break; } - return false; + // In any situation where we have a multi-step drop, we should reset the add info only after + // we complete the drop + resetAddInfo(); + return result; } @Override @@ -629,7 +635,6 @@ public final class Launcher extends Activity } State state = intToState(savedState.getInt(RUNTIME_STATE, State.WORKSPACE.ordinal())); - if (state == State.APPS_CUSTOMIZE) { showAllApps(false); } @@ -910,8 +915,9 @@ public final class Launcher extends Activity mDragLayer.clearAllResizeFrames(); updateRunning(); - // Reset AllApps to it's initial state - if (mAppsCustomizeContent != null) { + // Reset AllApps to it's initial state only if we are not in the middle of + // processing a multi-step drop + if (mAppsCustomizeContent != null && mPendingAddInfo.container == ItemInfo.NO_ID) { mAppsCustomizeContent.reset(); } } else if (Intent.ACTION_USER_PRESENT.equals(action)) { @@ -1133,6 +1139,10 @@ public final class Launcher extends Activity public void onDestroy() { super.onDestroy(); + // Remove all pending runnables + mHandler.removeMessages(ADVANCE_MSG); + mHandler.removeMessages(0); + // Stop callbacks from LauncherModel LauncherApplication app = ((LauncherApplication) getApplication()); mModel.stopLoader(); @@ -1454,25 +1464,6 @@ public final class Launcher extends Activity } } - public void closeFolder() { - Folder folder = mWorkspace.getOpenFolder(); - if (folder != null) { - closeFolder(folder); - } - } - - void closeFolder(Folder folder) { - folder.getInfo().opened = false; - - ViewGroup parent = (ViewGroup) folder.getParent().getParent(); - if (parent != null) { - FolderIcon fi = (FolderIcon) mWorkspace.getViewForTag(folder.mInfo); - shrinkAndFadeInFolderIcon(fi); - mDragController.removeDropTarget((DropTarget)folder); - } - folder.animateClosed(); - } - /** * Re-listen when widgets are reset. */ @@ -1718,11 +1709,34 @@ public final class Launcher extends Activity growAndFadeOutFolderIcon(folderIcon); info.opened = true; - mDragLayer.addView(folder); - mDragController.addDropTarget((DropTarget) folder); - + // Just verify that the folder hasn't already been added to the DragLayer. + // There was a one-off crash where the folder had a parent already. + if (folder.getParent() == null) { + mDragLayer.addView(folder); + mDragController.addDropTarget((DropTarget) folder); + } else { + Log.w(TAG, "Opening folder (" + folder + ") which already has a parent (" + + folder.getParent() + ")."); + } folder.animateOpen(); - folder.onOpen(); + } + + public void closeFolder() { + Folder folder = mWorkspace.getOpenFolder(); + if (folder != null) { + closeFolder(folder); + } + } + + void closeFolder(Folder folder) { + folder.getInfo().opened = false; + + ViewGroup parent = (ViewGroup) folder.getParent().getParent(); + if (parent != null) { + FolderIcon fi = (FolderIcon) mWorkspace.getViewForTag(folder.mInfo); + shrinkAndFadeInFolderIcon(fi); + } + folder.animateClosed(); } public boolean onLongClick(View v) { @@ -2169,7 +2183,7 @@ public final class Launcher extends Activity // Otherwise, we are not in spring loaded mode, so don't do anything. } void exitSpringLoadedDragModeDelayed(final boolean successfulDrop, boolean extendedDelay) { - mWorkspace.postDelayed(new Runnable() { + mHandler.postDelayed(new Runnable() { @Override public void run() { exitSpringLoadedDragMode(); @@ -2545,20 +2559,12 @@ public final class Launcher extends Activity } /** - * Receives notifications when applications are added/removed. + * Receives notifications when system dialogs are to be closed. */ private class CloseSystemDialogsIntentReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { closeSystemDialogs(); - String reason = intent.getStringExtra("reason"); - if (!"homekey".equals(reason)) { - boolean animate = true; - if (mPaused || "lock".equals(reason)) { - animate = false; - } - showWorkspace(animate); - } } } diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java index 63e8077..1573483 100644 --- a/src/com/android/launcher2/LauncherModel.java +++ b/src/com/android/launcher2/LauncherModel.java @@ -1511,7 +1511,7 @@ public class LauncherModel extends BroadcastReceiver { // the db if (icon == null) { if (c != null) { - icon = getIconFromCursor(c, iconIndex); + icon = getIconFromCursor(c, iconIndex, context); } } // the fallback icon @@ -1581,7 +1581,7 @@ public class LauncherModel extends BroadcastReceiver { } // the db if (icon == null) { - icon = getIconFromCursor(c, iconIndex); + icon = getIconFromCursor(c, iconIndex, context); } // the fallback icon if (icon == null) { @@ -1590,7 +1590,7 @@ public class LauncherModel extends BroadcastReceiver { } break; case LauncherSettings.Favorites.ICON_TYPE_BITMAP: - icon = getIconFromCursor(c, iconIndex); + icon = getIconFromCursor(c, iconIndex, context); if (icon == null) { icon = getFallbackIcon(); info.customIcon = false; @@ -1609,14 +1609,15 @@ public class LauncherModel extends BroadcastReceiver { return info; } - Bitmap getIconFromCursor(Cursor c, int iconIndex) { + Bitmap getIconFromCursor(Cursor c, int iconIndex, Context context) { if (false) { Log.d(TAG, "getIconFromCursor app=" + c.getString(c.getColumnIndexOrThrow(LauncherSettings.Favorites.TITLE))); } byte[] data = c.getBlob(iconIndex); try { - return BitmapFactory.decodeByteArray(data, 0, data.length); + return Utilities.createIconBitmap( + BitmapFactory.decodeByteArray(data, 0, data.length), context); } catch (Exception e) { return null; } diff --git a/src/com/android/launcher2/Utilities.java b/src/com/android/launcher2/Utilities.java index c63c822..b537f7a 100644 --- a/src/com/android/launcher2/Utilities.java +++ b/src/com/android/launcher2/Utilities.java @@ -76,8 +76,32 @@ final class Utilities { } /** - * Returns a bitmap suitable for the all apps view. The bitmap will be a power - * of two sized ARGB_8888 bitmap that can be used as a gl texture. + * Returns a bitmap suitable for the all apps view. Used to convert pre-ICS + * icon bitmaps that are stored in the database (which were 74x74 pixels at hdpi size) + * to the proper size (48dp) + */ + static Bitmap createIconBitmap(Bitmap icon, Context context) { + int textureWidth = sIconTextureWidth; + int textureHeight = sIconTextureHeight; + int sourceWidth = icon.getWidth(); + int sourceHeight = icon.getHeight(); + if (sourceWidth > textureWidth && sourceHeight > textureHeight) { + // Icon is bigger than it should be; clip it (solves the GB->ICS migration case) + return Bitmap.createBitmap(icon, + (sourceWidth - textureWidth) / 2, + (sourceHeight - textureHeight) / 2, + textureWidth, textureHeight); + } else if (sourceWidth == textureWidth && sourceHeight == textureHeight) { + // Icon is the right size, no need to change it + return icon; + } else { + // Icon is too small, render to a larger bitmap + return createIconBitmap(new BitmapDrawable(icon), context); + } + } + + /** + * Returns a bitmap suitable for the all apps view. */ static Bitmap createIconBitmap(Drawable icon, Context context) { synchronized (sCanvas) { // we share the statics :-( @@ -103,7 +127,7 @@ final class Utilities { int sourceWidth = icon.getIntrinsicWidth(); int sourceHeight = icon.getIntrinsicHeight(); - if (sourceWidth > 0 && sourceWidth > 0) { + if (sourceWidth > 0 && sourceHeight > 0) { // There are intrinsic sizes. if (width < sourceWidth || height < sourceHeight) { // It's too big, scale it down. |