diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher2/AppsCustomizePagedView.java | 10 | ||||
-rw-r--r-- | src/com/android/launcher2/BubbleTextView.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher2/CellLayout.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher2/DragLayer.java | 5 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 70 | ||||
-rw-r--r-- | src/com/android/launcher2/LauncherModel.java | 14 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 3 | ||||
-rw-r--r-- | src/com/android/launcher2/Utilities.java | 30 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 105 |
9 files changed, 114 insertions, 135 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index e5fe7bd26..53d154ff0 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -228,6 +228,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // (top + bottom) mWidgetPreviewIconPaddedDimension = (int) (mAppIconSize * (1 + (2 * sWidgetPreviewIconPaddingPercentage))); + mFadeInAdjacentScreens = LauncherApplication.isScreenLarge(); } @Override @@ -567,7 +568,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen layout.allowHardwareLayerCreation(); layout.createHardwareLayers(); - prepareGenerateHoloOutlinesTask(page, items, images); + if (mFadeInAdjacentScreens) { + prepareGenerateHoloOutlinesTask(page, items, images); + } } /** @@ -929,7 +932,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen invalidate(); forceUpdateAdjacentPagesAlpha(); - prepareGenerateHoloOutlinesTask(data.page, data.items, data.generatedImages); + + if (mFadeInAdjacentScreens) { + prepareGenerateHoloOutlinesTask(data.page, data.items, data.generatedImages); + } } private void onHolographicPageItemsLoaded(AsyncTaskPageData data) { // Invalidate early to short-circuit children invalidates diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java index bd3a4bde5..08f337e0d 100644 --- a/src/com/android/launcher2/BubbleTextView.java +++ b/src/com/android/launcher2/BubbleTextView.java @@ -93,10 +93,10 @@ public class BubbleTextView extends TextView implements VisibilityChangedBroadca mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setColor(bubbleColor); mBubbleColorAlpha = Color.alpha(bubbleColor) / 255.0f; - mFocusedOutlineColor = res.getColor(R.color.workspace_item_focused_outline_color); - mFocusedGlowColor = res.getColor(R.color.workspace_item_focused_glow_color); - mPressedOutlineColor = res.getColor(R.color.workspace_item_pressed_outline_color); - mPressedGlowColor = res.getColor(R.color.workspace_item_pressed_glow_color); + mFocusedOutlineColor = res.getColor(android.R.color.holo_blue_light); + mFocusedGlowColor = res.getColor(android.R.color.holo_blue_light); + mPressedOutlineColor = res.getColor(android.R.color.holo_blue_light); + mPressedGlowColor = res.getColor(android.R.color.holo_blue_light); setShadowLayer(SHADOW_LARGE_RADIUS, 0.0f, SHADOW_Y_OFFSET, SHADOW_LARGE_COLOUR); } diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index 0a3c96dc4..d9d048788 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -1528,8 +1528,8 @@ public class CellLayout extends ViewGroup { int smallerSize = Math.min(actualWidth, actualHeight); // Always round up to next largest cell - int spanX = (width + smallerSize) / smallerSize; - int spanY = (height + smallerSize) / smallerSize; + int spanX = (int) Math.ceil(width / (float) smallerSize); + int spanY = (int) Math.ceil(height / (float) smallerSize); if (result == null) { return new int[] { spanX, spanY }; diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java index 7fbde5471..d0d4bad6e 100644 --- a/src/com/android/launcher2/DragLayer.java +++ b/src/com/android/launcher2/DragLayer.java @@ -375,6 +375,11 @@ public class DragLayer extends FrameLayout { toY -= (dragView.getHeight() - (int) Math.round(scale * d.getIntrinsicHeight())) / 2; // Center in the x coordinate about the target's drawable toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2; + } else if (child instanceof FolderIcon) { + // Account for holographic blur padding on the drag view + toY -= HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS / 2; + // Center in the x coordinate about the target's drawable + toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2; } else { toY -= (Math.round(scale * (dragView.getHeight() - child.getMeasuredHeight()))) / 2; toX -= (Math.round(scale * (dragView.getMeasuredWidth() diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index b132870be..1af3f71d2 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)) { @@ -1195,43 +1201,6 @@ public final class Launcher extends Activity appSearchData, globalSearch); } - @Override - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - return true; - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - super.onPrepareOptionsMenu(menu); - - startWallpaper(); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case MENU_ADD: - addItems(); - return true; - case MENU_MANAGE_APPS: - manageApps(); - return true; - case MENU_WALLPAPER_SETTINGS: - startWallpaper(); - return true; - case MENU_SEARCH: - onSearchRequested(); - return true; - case MENU_NOTIFICATIONS: - showNotifications(); - return true; - } - - return super.onOptionsItemSelected(item); - } - /** * Indicates that we want global search for this activity by setting the globalSearch * argument for {@link #startSearch} to true. @@ -2214,7 +2183,12 @@ public final class Launcher extends Activity @Override public void run() { exitSpringLoadedDragMode(); + if (successfulDrop) { + // Before we show workspace, hide all apps again because + // exitSpringLoadedDragMode made it visible. This is a bit hacky; we should + // clean up our state transition functions + mAppsCustomizeTabHost.setVisibility(View.GONE); showWorkspace(true); } } @@ -2581,20 +2555,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 6658f07c2..157348312 100644 --- a/src/com/android/launcher2/LauncherModel.java +++ b/src/com/android/launcher2/LauncherModel.java @@ -382,8 +382,7 @@ public class LauncherModel extends BroadcastReceiver { final ContentResolver cr = context.getContentResolver(); item.onAddToDatabase(values); - Launcher l = (Launcher) context; - LauncherApplication app = (LauncherApplication) l.getApplication(); + LauncherApplication app = (LauncherApplication) context.getApplicationContext(); item.id = app.getLauncherProvider().generateNewId(); values.put(LauncherSettings.Favorites._ID, item.id); item.updateValuesWithCoordinates(values, item.cellX, item.cellY); @@ -1512,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 @@ -1582,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) { @@ -1591,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; @@ -1610,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/PagedView.java b/src/com/android/launcher2/PagedView.java index 48360feb1..24feb4148 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -432,6 +432,7 @@ public abstract class PagedView extends ViewGroup { int maxChildHeight = 0; final int verticalPadding = mPaddingTop + mPaddingBottom; + final int horizontalPadding = mPaddingLeft + mPaddingRight; // The children are given the same width and height as the workspace @@ -458,7 +459,7 @@ public abstract class PagedView extends ViewGroup { } final int childWidthMeasureSpec = - MeasureSpec.makeMeasureSpec(widthSize, childWidthMode); + MeasureSpec.makeMeasureSpec(widthSize - horizontalPadding, childWidthMode); final int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize - verticalPadding, childHeightMode); diff --git a/src/com/android/launcher2/Utilities.java b/src/com/android/launcher2/Utilities.java index c63c82206..b537f7acc 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. diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 26c00ad8d..ce3aad4fb 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -1000,37 +1000,7 @@ public class Workspace extends SmoothPagedView mDrawBackground = true; } - private void showBackgroundGradientForAllApps(boolean animated) { - showBackgroundGradient(animated); - } - - private void showBackgroundGradient(boolean animated) { - if (mBackground == null) return; - if (mBackgroundFadeOutAnimation != null) { - mBackgroundFadeOutAnimation.cancel(); - mBackgroundFadeOutAnimation = null; - } - if (mBackgroundFadeInAnimation != null) { - mBackgroundFadeInAnimation.cancel(); - mBackgroundFadeInAnimation = null; - } - final float finalAlpha = 1f; - if (animated) { - mBackgroundFadeInAnimation = ValueAnimator.ofFloat(getBackgroundAlpha(), finalAlpha); - mBackgroundFadeInAnimation.addUpdateListener(new AnimatorUpdateListener() { - public void onAnimationUpdate(ValueAnimator animation) { - setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue()); - } - }); - mBackgroundFadeInAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); - mBackgroundFadeInAnimation.setDuration(BACKGROUND_FADE_IN_DURATION); - mBackgroundFadeInAnimation.start(); - } else { - setBackgroundAlpha(finalAlpha); - } - } - - private void hideBackgroundGradient(float finalAlpha, boolean animated) { + private void animateBackgroundGradient(float finalAlpha, boolean animated) { if (mBackground == null) return; if (mBackgroundFadeInAnimation != null) { mBackgroundFadeInAnimation.cancel(); @@ -1040,18 +1010,21 @@ public class Workspace extends SmoothPagedView mBackgroundFadeOutAnimation.cancel(); mBackgroundFadeOutAnimation = null; } - if (animated) { - mBackgroundFadeOutAnimation = ValueAnimator.ofFloat(getBackgroundAlpha(), finalAlpha); - mBackgroundFadeOutAnimation.addUpdateListener(new AnimatorUpdateListener() { - public void onAnimationUpdate(ValueAnimator animation) { - setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue()); - } - }); - mBackgroundFadeOutAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); - mBackgroundFadeOutAnimation.setDuration(BACKGROUND_FADE_OUT_DURATION); - mBackgroundFadeOutAnimation.start(); - } else { - setBackgroundAlpha(finalAlpha); + float startAlpha = getBackgroundAlpha(); + if (finalAlpha != startAlpha) { + if (animated) { + mBackgroundFadeOutAnimation = ValueAnimator.ofFloat(startAlpha, finalAlpha); + mBackgroundFadeOutAnimation.addUpdateListener(new AnimatorUpdateListener() { + public void onAnimationUpdate(ValueAnimator animation) { + setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue()); + } + }); + mBackgroundFadeOutAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); + mBackgroundFadeOutAnimation.setDuration(BACKGROUND_FADE_OUT_DURATION); + mBackgroundFadeOutAnimation.start(); + } else { + setBackgroundAlpha(finalAlpha); + } } } @@ -1552,8 +1525,6 @@ public class Workspace extends SmoothPagedView updateWallpaperOffsetImmediately(); } setChildrenDrawnWithCacheEnabled(true); - - showBackgroundGradientForAllApps(animated); } @Override @@ -1925,8 +1896,16 @@ public class Workspace extends SmoothPagedView } } - hideBackgroundGradient(springLoaded ? getResources().getInteger( - R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f : 0f, animated); + if (springLoaded) { + // Right now we're covered by Apps Customize + // Show the background gradient immediately, so the gradient will + // be showing once AppsCustomize disappears + animateBackgroundGradient(getResources().getInteger( + R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f, false); + } else { + // Fade the background gradient away + animateBackgroundGradient(0f, true); + } } /** @@ -1970,7 +1949,7 @@ public class Workspace extends SmoothPagedView * Responsibility for the bitmap is transferred to the caller. */ public Bitmap createDragBitmap(View v, Canvas canvas, int padding) { - final int outlineColor = getResources().getColor(R.color.drag_outline_color); + final int outlineColor = getResources().getColor(android.R.color.holo_blue_light); Bitmap b; if (v instanceof TextView) { @@ -1995,7 +1974,7 @@ public class Workspace extends SmoothPagedView * Responsibility for the bitmap is transferred to the caller. */ private Bitmap createDragOutline(View v, Canvas canvas, int padding) { - final int outlineColor = getResources().getColor(R.color.drag_outline_color); + final int outlineColor = getResources().getColor(android.R.color.holo_blue_light); final Bitmap b = Bitmap.createBitmap( v.getWidth() + padding, v.getHeight() + padding, Bitmap.Config.ARGB_8888); @@ -2011,7 +1990,7 @@ public class Workspace extends SmoothPagedView * Responsibility for the bitmap is transferred to the caller. */ private Bitmap createDragOutline(Bitmap orig, Canvas canvas, int padding, int w, int h) { - final int outlineColor = getResources().getColor(R.color.drag_outline_color); + final int outlineColor = getResources().getColor(android.R.color.holo_blue_light); final Bitmap b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); canvas.setBitmap(b); @@ -2041,7 +2020,7 @@ public class Workspace extends SmoothPagedView */ private Bitmap createExternalDragOutline(Canvas canvas, int padding) { Resources r = getResources(); - final int outlineColor = r.getColor(R.color.drag_outline_color); + final int outlineColor = r.getColor(android.R.color.holo_blue_light); final int iconWidth = r.getDimensionPixelSize(R.dimen.workspace_cell_width); final int iconHeight = r.getDimensionPixelSize(R.dimen.workspace_cell_height); final int rectRadius = r.getDimensionPixelSize(R.dimen.external_drop_icon_rect_radius); @@ -2295,17 +2274,7 @@ public class Workspace extends SmoothPagedView } else if (mDragInfo != null) { final View cell = mDragInfo.cell; - boolean continueDrop = true; - if (mLauncher.isHotseatLayout(mDragTargetLayout) && d.dragInfo instanceof ItemInfo) { - ItemInfo info = (ItemInfo) d.dragInfo; - if (info.spanX > 1 || info.spanY > 1) { - continueDrop = false; - Toast.makeText(getContext(), R.string.invalid_hotseat_item, - Toast.LENGTH_SHORT).show(); - } - } - - if (continueDrop && dropTargetLayout != null) { + if (dropTargetLayout != null) { // Move internally boolean hasMovedLayouts = (getParentCellLayoutForView(cell) != dropTargetLayout); boolean hasMovedIntoHotseat = mLauncher.isHotseatLayout(dropTargetLayout); @@ -2809,6 +2778,14 @@ public class Workspace extends SmoothPagedView return res; } + private boolean isDragWidget(DragObject d) { + return (d.dragInfo instanceof LauncherAppWidgetInfo || + d.dragInfo instanceof PendingAddWidgetInfo); + } + private boolean isExternalDragWidget(DragObject d) { + return d.dragSource != this && isDragWidget(d); + } + public void onDragOver(DragObject d) { // Skip drag over events while we are dragging over side pages if (mInScrollArea) return; @@ -2825,7 +2802,7 @@ public class Workspace extends SmoothPagedView // Identify whether we have dragged over a side page if (isSmall()) { - if (mLauncher.getHotseat() != null) { + if (mLauncher.getHotseat() != null && !isExternalDragWidget(d)) { mLauncher.getHotseat().getHitRect(r); if (r.contains(d.x, d.y)) { layout = mLauncher.getHotseat().getLayout(); @@ -2862,7 +2839,7 @@ public class Workspace extends SmoothPagedView } } else { // Test to see if we are over the hotseat otherwise just use the current page - if (mLauncher.getHotseat() != null) { + if (mLauncher.getHotseat() != null && !isDragWidget(d)) { mLauncher.getHotseat().getHitRect(r); if (r.contains(d.x, d.y)) { layout = mLauncher.getHotseat().getLayout(); |