diff options
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher2/AppsCustomizePagedView.java | 22 | ||||
-rw-r--r-- | src/com/android/launcher2/CellLayout.java | 7 | ||||
-rw-r--r-- | src/com/android/launcher2/IconCache.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 9 | ||||
-rw-r--r-- | src/com/android/launcher2/Utilities.java | 114 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 22 |
6 files changed, 42 insertions, 134 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 53d154ff0..16dad1be9 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -33,6 +33,7 @@ import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.Canvas; +import android.graphics.PorterDuff; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.AsyncTask; @@ -172,6 +173,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen private Canvas mCanvas; private Drawable mDefaultWidgetBackground; private IconCache mIconCache; + private int mDragViewMultiplyColor; // Dimens private int mContentWidth; @@ -202,7 +204,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // Save the default widget preview background Resources resources = context.getResources(); mDefaultWidgetBackground = resources.getDrawable(R.drawable.default_widget_preview_holo); - mAppIconSize = getResources().getDimensionPixelSize(R.dimen.app_icon_size); + mAppIconSize = resources.getDimensionPixelSize(R.dimen.app_icon_size); + mDragViewMultiplyColor = resources.getColor(R.color.drag_view_multiply_color); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagedView, 0, 0); // TODO-APPS_CUSTOMIZE: remove these unnecessary attrs after @@ -242,9 +245,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } @Override - protected void onWallpaperTap(MotionEvent ev) { - int action = ev.getAction(); - if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) { + protected void onUnhandledTap(MotionEvent ev) { + if (LauncherApplication.isScreenLarge()) { // Dismiss AppsCustomize if we tap mLauncher.showWorkspace(true); } @@ -409,7 +411,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen createItemInfo.spanY = spanXY[1]; b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); - renderDrawableToBitmap(preview, b, 0, 0, w, h, 1, 1); + renderDrawableToBitmap(preview, b, 0, 0, w, h, 1, 1, mDragViewMultiplyColor); } else { // Workaround for the fact that we don't keep the original ResolveInfo associated with // the shortcut around. To get the icon, we just render the preview image (which has @@ -420,6 +422,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen mCanvas.save(); preview.draw(mCanvas); mCanvas.restore(); + mCanvas.drawColor(mDragViewMultiplyColor, PorterDuff.Mode.MULTIPLY); mCanvas.setBitmap(null); createItemInfo.spanX = createItemInfo.spanY = 1; } @@ -745,6 +748,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int x, int y, int w, int h, float scaleX, float scaleY) { + renderDrawableToBitmap(d, bitmap, x, y, w, h, scaleX, scaleY, 0xFFFFFFFF); + } + private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int x, int y, int w, int h, + float scaleX, float scaleY, int multiplyColor) { if (bitmap != null) { Canvas c = new Canvas(bitmap); c.scale(scaleX, scaleY); @@ -752,6 +759,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen d.setBounds(x, y, x + w, y + h); d.draw(c); d.setBounds(oldBounds); // Restore the bounds + if (multiplyColor != 0xFFFFFFFF) { + c.drawColor(mDragViewMultiplyColor, PorterDuff.Mode.MULTIPLY); + } c.setBitmap(null); } } @@ -828,7 +838,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen preview = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Config.ARGB_8888); renderDrawableToBitmap(mDefaultWidgetBackground, preview, 0, 0, expectedWidth, - expectedHeight, 1f,1f); + expectedHeight, 1f, 1f); // Draw the icon in the top left corner try { diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index d9d048788..a17e2d604 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -81,6 +81,7 @@ public class CellLayout extends ViewGroup { int[] mTempLocation = new int[2]; boolean[][] mOccupied; + private boolean mLastDownOnOccupiedCell = false; private OnTouchListener mInterceptTouchListener; @@ -752,6 +753,8 @@ public class CellLayout extends ViewGroup { } } + mLastDownOnOccupiedCell = found; + if (!found) { final int cellXY[] = mTmpXY; pointToCellExact(x, y, cellXY); @@ -1877,4 +1880,8 @@ out: for (int i = x; i < x + spanX - 1 && x < xCount; i++) { + ", x=" + cellX + ", y=" + cellY + "]"; } } + + public boolean lastDownOnOccupiedCell() { + return mLastDownOnOccupiedCell; + } } diff --git a/src/com/android/launcher2/IconCache.java b/src/com/android/launcher2/IconCache.java index 1fdafc8de..b2ebe2ac3 100644 --- a/src/com/android/launcher2/IconCache.java +++ b/src/com/android/launcher2/IconCache.java @@ -44,7 +44,6 @@ public class IconCache { private final Bitmap mDefaultIcon; private final LauncherApplication mContext; private final PackageManager mPackageManager; - private final Utilities.BubbleText mBubble; private final HashMap<ComponentName, CacheEntry> mCache = new HashMap<ComponentName, CacheEntry>(INITIAL_ICON_CACHE_CAPACITY); private int mIconDpi; @@ -52,7 +51,6 @@ public class IconCache { public IconCache(LauncherApplication context) { mContext = context; mPackageManager = context.getPackageManager(); - mBubble = new Utilities.BubbleText(context); int density = context.getResources().getDisplayMetrics().densityDpi; if (LauncherApplication.isScreenLarge()) { if (density == DisplayMetrics.DENSITY_LOW) { diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 0321e3f1c..d2d734cf3 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -131,7 +131,7 @@ public abstract class PagedView extends ViewGroup { private PageSwitchListener mPageSwitchListener; private ArrayList<Boolean> mDirtyPageContent; - private boolean mDirtyPageAlpha; + private boolean mDirtyPageAlpha = true; // choice modes protected static final int CHOICE_MODE_NONE = 0; @@ -1138,7 +1138,7 @@ public abstract class PagedView extends ViewGroup { snapToDestination(); } } else { - onWallpaperTap(ev); + onUnhandledTap(ev); } mTouchState = TOUCH_STATE_REST; mActivePointerId = INVALID_POINTER; @@ -1222,12 +1222,9 @@ public abstract class PagedView extends ViewGroup { mVelocityTracker.clear(); } } - if (mTouchState == TOUCH_STATE_REST) { - onWallpaperTap(ev); - } } - protected void onWallpaperTap(MotionEvent ev) {} + protected void onUnhandledTap(MotionEvent ev) {} @Override public void requestChildFocus(View child, View focused) { diff --git a/src/com/android/launcher2/Utilities.java b/src/com/android/launcher2/Utilities.java index b537f7acc..1175fadb9 100644 --- a/src/com/android/launcher2/Utilities.java +++ b/src/com/android/launcher2/Utilities.java @@ -265,120 +265,6 @@ final class Utilities { sDisabledPaint.setAlpha(0x88); } - static class BubbleText { - private static final int MAX_LINES = 2; - - private final TextPaint mTextPaint; - - private final RectF mBubbleRect = new RectF(); - - private final float mTextWidth; - private final int mLeading; - private final int mFirstLineY; - private final int mLineHeight; - - private final int mBitmapWidth; - private final int mBitmapHeight; - private final int mDensity; - - BubbleText(Context context) { - final Resources resources = context.getResources(); - - final DisplayMetrics metrics = resources.getDisplayMetrics(); - final float scale = metrics.density; - mDensity = metrics.densityDpi; - - final float paddingLeft = 2.0f * scale; - final float paddingRight = 2.0f * scale; - final float cellWidth = resources.getDimension(R.dimen.title_texture_width); - - RectF bubbleRect = mBubbleRect; - bubbleRect.left = 0; - bubbleRect.top = 0; - bubbleRect.right = (int) cellWidth; - - mTextWidth = cellWidth - paddingLeft - paddingRight; - - TextPaint textPaint = mTextPaint = new TextPaint(); - textPaint.setTypeface(Typeface.DEFAULT); - textPaint.setTextSize(13*scale); - textPaint.setColor(0xffffffff); - textPaint.setAntiAlias(true); - if (TEXT_BURN) { - textPaint.setShadowLayer(8, 0, 0, 0xff000000); - } - - float ascent = -textPaint.ascent(); - float descent = textPaint.descent(); - float leading = 0.0f;//(ascent+descent) * 0.1f; - mLeading = (int)(leading + 0.5f); - mFirstLineY = (int)(leading + ascent + 0.5f); - mLineHeight = (int)(leading + ascent + descent + 0.5f); - - mBitmapWidth = (int)(mBubbleRect.width() + 0.5f); - mBitmapHeight = roundToPow2((int)((MAX_LINES * mLineHeight) + leading + 0.5f)); - - mBubbleRect.offsetTo((mBitmapWidth-mBubbleRect.width())/2, 0); - - if (false) { - Log.d(TAG, "mBitmapWidth=" + mBitmapWidth + " mBitmapHeight=" - + mBitmapHeight + " w=" + ((int)(mBubbleRect.width() + 0.5f)) - + " h=" + ((int)((MAX_LINES * mLineHeight) + leading + 0.5f))); - } - } - - /** You own the bitmap after this and you must call recycle on it. */ - Bitmap createTextBitmap(String text) { - Bitmap b = Bitmap.createBitmap(mBitmapWidth, mBitmapHeight, Bitmap.Config.ALPHA_8); - b.setDensity(mDensity); - Canvas c = new Canvas(b); - - StaticLayout layout = new StaticLayout(text, mTextPaint, (int)mTextWidth, - Alignment.ALIGN_CENTER, 1, 0, true); - int lineCount = layout.getLineCount(); - if (lineCount > MAX_LINES) { - lineCount = MAX_LINES; - } - //if (!TEXT_BURN && lineCount > 0) { - //RectF bubbleRect = mBubbleRect; - //bubbleRect.bottom = height(lineCount); - //c.drawRoundRect(bubbleRect, mCornerRadius, mCornerRadius, mRectPaint); - //} - for (int i=0; i<lineCount; i++) { - //int x = (int)((mBubbleRect.width() - layout.getLineMax(i)) / 2.0f); - //int y = mFirstLineY + (i * mLineHeight); - final String lineText = text.substring(layout.getLineStart(i), layout.getLineEnd(i)); - int x = (int)(mBubbleRect.left - + ((mBubbleRect.width() - mTextPaint.measureText(lineText)) * 0.5f)); - int y = mFirstLineY + (i * mLineHeight); - c.drawText(lineText, x, y, mTextPaint); - } - - c.setBitmap(null); - return b; - } - - private int height(int lineCount) { - return (int)((lineCount * mLineHeight) + mLeading + mLeading + 0.0f); - } - - int getBubbleWidth() { - return (int)(mBubbleRect.width() + 0.5f); - } - - int getMaxBubbleHeight() { - return height(MAX_LINES); - } - - int getBitmapWidth() { - return mBitmapWidth; - } - - int getBitmapHeight() { - return mBitmapHeight; - } - } - /** Only works for positive numbers. */ static int roundToPow2(int n) { int orig = n; diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index ce3aad4fb..9856f7e16 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -17,12 +17,12 @@ package com.android.launcher2; import android.animation.Animator; +import android.animation.Animator.AnimatorListener; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.TimeInterpolator; import android.animation.ValueAnimator; -import android.animation.Animator.AnimatorListener; import android.animation.ValueAnimator.AnimatorUpdateListener; import android.app.AlertDialog; import android.app.WallpaperManager; @@ -33,15 +33,14 @@ import android.content.ClipDescription; import android.content.ComponentName; import android.content.Context; import android.content.Intent; -import android.content.pm.PackageManager; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Camera; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; +import android.graphics.PorterDuff; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Region.Op; @@ -183,6 +182,7 @@ public class Workspace extends SmoothPagedView private Bitmap mDragOutline = null; private final Rect mTempRect = new Rect(); private final int[] mTempXY = new int[2]; + private int mDragViewMultiplyColor; // Paint used to draw external drop outline private final Paint mExternalDragOutlinePaint = new Paint(); @@ -306,6 +306,7 @@ public class Workspace extends SmoothPagedView mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f; + mDragViewMultiplyColor = res.getColor(R.color.drag_view_multiply_color); // if the value is manually specified, use that instead cellCountX = a.getInt(R.styleable.Workspace_cellCountX, cellCountX); @@ -597,11 +598,20 @@ public class Workspace extends SmoothPagedView @Override public boolean onInterceptTouchEvent(MotionEvent ev) { - if (ev.getAction() == MotionEvent.ACTION_DOWN) { + switch (ev.getAction() & MotionEvent.ACTION_MASK) { + case MotionEvent.ACTION_DOWN: mXDown = ev.getX(); mYDown = ev.getY(); + break; + case MotionEvent.ACTION_POINTER_UP: + case MotionEvent.ACTION_UP: + if (mTouchState == TOUCH_STATE_REST) { + final CellLayout currentPage = (CellLayout) getChildAt(mCurrentPage); + if (!currentPage.lastDownOnOccupiedCell()) { + onWallpaperTap(ev); + } + } } - return super.onInterceptTouchEvent(ev); } @@ -1290,7 +1300,6 @@ public class Workspace extends SmoothPagedView } } - @Override protected void onWallpaperTap(MotionEvent ev) { final int[] position = mTempCell; getLocationOnScreen(position); @@ -1964,6 +1973,7 @@ public class Workspace extends SmoothPagedView canvas.setBitmap(b); drawDragView(v, canvas, padding, true); mOutlineHelper.applyOuterBlur(b, canvas, outlineColor); + canvas.drawColor(mDragViewMultiplyColor, PorterDuff.Mode.MULTIPLY); canvas.setBitmap(null); return b; |