summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2012-03-02 17:14:58 -0800
committerWinson Chung <winsonc@google.com>2012-03-08 13:37:46 -0800
commiteecf02da58adef5486bf0c9ff7127ea891f457a4 (patch)
treeaa96fab5fb3528fdd838b4547922b8577112df7f
parent633f1aad55aea7afbefd8409ccfd1f693b27870b (diff)
downloadandroid_packages_apps_Trebuchet-eecf02da58adef5486bf0c9ff7127ea891f457a4.tar.gz
android_packages_apps_Trebuchet-eecf02da58adef5486bf0c9ff7127ea891f457a4.tar.bz2
android_packages_apps_Trebuchet-eecf02da58adef5486bf0c9ff7127ea891f457a4.zip
Fixing some issues/regressions related to scaled icons.
- Fixes issue with folder icons being clipped in landscape in sw720dp (Bug: 6118397) - Fixes issue with divider being in wrong orientation in sw720dp - Fixes issue with scaled icons not being drawn with filtering - Fixes issue with side pages showing under the hotseat when in landscape in phone UI - Animates the drag view on pick up and drop Change-Id: Iad26427ec63fcbc9bdb3b29a4645689ba445d5c8
-rw-r--r--res/drawable-sw720dp-land-hdpi/divider_launcher_holo.9.pngbin0 -> 199 bytes
-rw-r--r--res/drawable-sw720dp-land-mdpi/divider_launcher_holo.9.pngbin0 -> 1078 bytes
-rw-r--r--res/values-land/dimens.xml2
-rw-r--r--res/values-sw600dp-land/dimens.xml2
-rw-r--r--res/values-sw720dp/dimens.xml5
-rw-r--r--res/values/dimens.xml4
-rw-r--r--src/com/android/launcher2/BubbleTextView.java9
-rw-r--r--src/com/android/launcher2/CellLayout.java66
-rw-r--r--src/com/android/launcher2/CellLayoutChildren.java20
-rw-r--r--src/com/android/launcher2/DragLayer.java19
-rw-r--r--src/com/android/launcher2/DragView.java2
-rw-r--r--src/com/android/launcher2/FastBitmapDrawable.java2
-rw-r--r--src/com/android/launcher2/Launcher.java1
-rw-r--r--src/com/android/launcher2/PagedView.java9
-rw-r--r--src/com/android/launcher2/Workspace.java10
15 files changed, 89 insertions, 62 deletions
diff --git a/res/drawable-sw720dp-land-hdpi/divider_launcher_holo.9.png b/res/drawable-sw720dp-land-hdpi/divider_launcher_holo.9.png
new file mode 100644
index 000000000..0a1bd2a26
--- /dev/null
+++ b/res/drawable-sw720dp-land-hdpi/divider_launcher_holo.9.png
Binary files differ
diff --git a/res/drawable-sw720dp-land-mdpi/divider_launcher_holo.9.png b/res/drawable-sw720dp-land-mdpi/divider_launcher_holo.9.png
new file mode 100644
index 000000000..6d101f4ce
--- /dev/null
+++ b/res/drawable-sw720dp-land-mdpi/divider_launcher_holo.9.png
Binary files differ
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml
index b4ddc0058..5f03510f3 100644
--- a/res/values-land/dimens.xml
+++ b/res/values-land/dimens.xml
@@ -33,7 +33,7 @@
<dimen name="workspace_bottom_padding">0dp</dimen>
<!-- We really want the page spacing to be the max of either the button bar
height or the qsb bar height -->
- <dimen name="workspace_page_spacing">@dimen/button_bar_height</dimen>
+ <dimen name="workspace_page_spacing">-1dp</dimen>
<dimen name="workspace_divider_padding_left">0dp</dimen>
<dimen name="workspace_divider_padding_right">0dp</dimen>
<dimen name="workspace_divider_padding_top">12dp</dimen>
diff --git a/res/values-sw600dp-land/dimens.xml b/res/values-sw600dp-land/dimens.xml
index 882de23ce..7db0a8adb 100644
--- a/res/values-sw600dp-land/dimens.xml
+++ b/res/values-sw600dp-land/dimens.xml
@@ -21,7 +21,7 @@
<!-- Hotseat -->
<dimen name="hotseat_cell_width">75dp</dimen>
- <dimen name="hotseat_cell_height">85dp</dimen>
+ <dimen name="hotseat_cell_height">75dp</dimen>
<!-- Workspace -->
<dimen name="workspace_cell_width">96dp</dimen>
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index 0fb8d3396..62bf9a862 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -27,6 +27,9 @@
<dimen name="workspace_cell_width">96dip</dimen>
<dimen name="workspace_cell_height">96dip</dimen>
+ <dimen name="folder_cell_width">96dp</dimen>
+ <dimen name="folder_cell_height">96dp</dimen>
+
<!-- AppsCustomize -->
<integer name="apps_customize_maxCellCountX">-1</integer>
<integer name="apps_customize_maxCellCountY">-1</integer>
@@ -49,5 +52,5 @@
<!-- When dragging items on the workspace, the number of dps by which the position of
the drag view should be offset from the position of the original view. -->
<dimen name="dragViewOffsetX">0dp</dimen>
- <dimen name="dragViewOffsetY">-12dp</dimen>
+ <dimen name="dragViewOffsetY">0dp</dimen>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 4a69f4aba..45e544a7c 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -102,10 +102,10 @@
<!-- When dragging items on the workspace, the number of dps by which the position of
the drag view should be offset from the position of the original view. -->
<dimen name="dragViewOffsetX">0dp</dimen>
- <dimen name="dragViewOffsetY">-8dp</dimen>
+ <dimen name="dragViewOffsetY">0dp</dimen>
<!-- When dragging an item, how much bigger (fixed dps) the dragged view
should be. If 0, it will not be scaled at all. -->
- <dimen name="dragViewScale">8dp</dimen>
+ <dimen name="dragViewScale">12dp</dimen>
<!-- Padding applied to AppWidgets -->
<dimen name="app_widget_preview_padding_left">8dp</dimen>
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java
index 623c6ff0b..4a3a7a452 100644
--- a/src/com/android/launcher2/BubbleTextView.java
+++ b/src/com/android/launcher2/BubbleTextView.java
@@ -47,8 +47,6 @@ public class BubbleTextView extends TextView {
static final float PADDING_H = 8.0f;
static final float PADDING_V = 3.0f;
- private Paint mPaint;
- private float mBubbleColorAlpha;
private int mPrevAlpha = -1;
private final HolographicOutlineHelper mOutlineHelper = new HolographicOutlineHelper();
@@ -88,9 +86,6 @@ public class BubbleTextView extends TextView {
final Resources res = getContext().getResources();
int bubbleColor = res.getColor(R.color.bubble_dark_background);
- mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
- mPaint.setColor(bubbleColor);
- mBubbleColorAlpha = Color.alpha(bubbleColor) / 255.0f;
mFocusedOutlineColor = mFocusedGlowColor = mPressedOutlineColor = mPressedGlowColor =
res.getColor(android.R.color.holo_blue_light);
@@ -178,7 +173,8 @@ public class BubbleTextView extends TextView {
// The translate of scrollX and scrollY is necessary when drawing TextViews, because
// they set scrollX and scrollY to large values to achieve centered text
destCanvas.save();
- destCanvas.scale(getScaleX(), getScaleY(), getWidth() / 2, getHeight() / 2);
+ destCanvas.scale(getScaleX(), getScaleY(),
+ (getWidth() + padding) / 2, (getHeight() + padding) / 2);
destCanvas.translate(-getScrollX() + padding / 2, -getScrollY() + padding / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
draw(destCanvas);
@@ -328,7 +324,6 @@ public class BubbleTextView extends TextView {
protected boolean onSetAlpha(int alpha) {
if (mPrevAlpha != alpha) {
mPrevAlpha = alpha;
- mPaint.setAlpha((int) (alpha * mBubbleColorAlpha));
super.onSetAlpha(alpha);
}
return true;
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 1aaba6db9..528984a59 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -137,8 +137,8 @@ public class CellLayout extends ViewGroup {
private CellLayoutChildren mChildren;
private boolean mIsHotseat = false;
- private final int mBubbleScalePercent;
- private final int mBubbleHotseatScalePercent;
+ private float mChildScale = 1f;
+ private float mHotseatChildScale = 1f;
public CellLayout(Context context) {
this(context, null);
@@ -185,8 +185,14 @@ public class CellLayout extends ViewGroup {
mNormalBackground.setFilterBitmap(true);
mActiveGlowBackground.setFilterBitmap(true);
- mBubbleScalePercent = res.getInteger(R.integer.app_icon_scale_percent);
- mBubbleHotseatScalePercent = res.getInteger(R.integer.app_icon_hotseat_scale_percent);
+ int iconScale = res.getInteger(R.integer.app_icon_scale_percent);
+ if (iconScale >= 0) {
+ mChildScale = iconScale / 100f;
+ }
+ int hotseatIconScale = res.getInteger(R.integer.app_icon_hotseat_scale_percent);
+ if (hotseatIconScale >= 0) {
+ mHotseatChildScale = hotseatIconScale / 100f;
+ }
// Initialize the data structures used for the drag visualization.
@@ -497,25 +503,6 @@ public class CellLayout extends ViewGroup {
@Override
protected void dispatchDraw(Canvas canvas) {
- // Debug drawing for hit space
- if (false) {
- final Rect frame = mRect;
- for (int i = mChildren.getChildCount() - 1; i >= 0; i--) {
- final View child = mChildren.getChildAt(i);
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
-
- if ((child.getVisibility() == VISIBLE || child.getAnimation() != null) &&
- lp.isLockedToGrid) {
- child.getHitRect(frame);
- frame.offset(mPaddingLeft, mPaddingTop);
-
- Paint p = new Paint();
- p.setColor(Color.GREEN);
- canvas.drawRect(frame, p);
- }
- }
- }
-
super.dispatchDraw(canvas);
if (mForegroundAlpha > 0) {
mOverScrollForegroundDrawable.setBounds(mForegroundRect);
@@ -582,12 +569,16 @@ public class CellLayout extends ViewGroup {
mIsHotseat = isHotseat;
}
+ public float getChildrenScale() {
+ return mIsHotseat ? mHotseatChildScale : mChildScale;
+ }
+
public boolean addViewToCellLayout(
View child, int index, int childId, LayoutParams params, boolean markCells) {
return addViewToCellLayout(child, index, childId, params, markCells, false);
}
- private void scaleChild(BubbleTextView bubbleChild, float pivot, int scalePercent) {
+ private void scaleChild(BubbleTextView bubbleChild, float pivot, float scale) {
// If we haven't measured the child yet, do it now
// (this happens if we're being dropped from all-apps
if (bubbleChild.getLayoutParams() instanceof LayoutParams &&
@@ -597,20 +588,13 @@ public class CellLayout extends ViewGroup {
int measuredWidth = bubbleChild.getMeasuredWidth();
int measuredHeight = bubbleChild.getMeasuredHeight();
- float scale = scalePercent / 100f;
- bubbleChild.setPivotX(pivot);
- bubbleChild.setPivotY(pivot);
bubbleChild.setScaleX(scale);
bubbleChild.setScaleY(scale);
- bubbleChild.setTranslationX(measuredWidth * (1 - scale) / 2);
- bubbleChild.setTranslationY(measuredHeight * (1 - scale) / 2);
}
private void resetChild(BubbleTextView bubbleChild) {
bubbleChild.setScaleX(1f);
bubbleChild.setScaleY(1f);
- bubbleChild.setTranslationX(0f);
- bubbleChild.setTranslationY(0f);
bubbleChild.setTextColor(getResources().getColor(R.color.workspace_icon_text_color));
}
@@ -629,14 +613,14 @@ public class CellLayout extends ViewGroup {
// Start the child with 100% scale and visible text
resetChild(bubbleChild);
- if (mIsHotseat && !allApps && mBubbleHotseatScalePercent >= 0) {
+ if (mIsHotseat && !allApps && mHotseatChildScale >= 0) {
// Scale/make transparent for a hotseat
- scaleChild(bubbleChild, 0f, mBubbleHotseatScalePercent);
+ scaleChild(bubbleChild, 0f, mHotseatChildScale);
bubbleChild.setTextColor(getResources().getColor(android.R.color.transparent));
- } else if (mBubbleScalePercent >= 0) {
+ } else if (mChildScale >= 0) {
// Else possibly still scale it if we need to for smaller icons
- scaleChild(bubbleChild, 0f, mBubbleScalePercent);
+ scaleChild(bubbleChild, 0f, mChildScale);
}
}
@@ -727,7 +711,7 @@ public class CellLayout extends ViewGroup {
public void setTagToCellInfoForPoint(int touchX, int touchY) {
final CellInfo cellInfo = mCellInfo;
- final Rect frame = mRect;
+ Rect frame = mRect;
final int x = touchX + mScrollX;
final int y = touchY + mScrollY;
final int count = mChildren.getChildCount();
@@ -741,10 +725,15 @@ public class CellLayout extends ViewGroup {
lp.isLockedToGrid) {
child.getHitRect(frame);
+ float scale = child.getScaleX();
+ frame = new Rect(child.getLeft(), child.getTop(), child.getRight(),
+ child.getBottom());
// The child hit rect is relative to the CellLayoutChildren parent, so we need to
// offset that by this CellLayout's padding to test an (x,y) point that is relative
// to this view.
frame.offset(mPaddingLeft, mPaddingTop);
+ frame.inset((int) (frame.width() * (1f - scale) / 2),
+ (int) (frame.height() * (1f - scale) / 2));
if (frame.contains(x, y)) {
cellInfo.cell = child;
@@ -791,6 +780,7 @@ public class CellLayout extends ViewGroup {
if (action == MotionEvent.ACTION_DOWN) {
setTagToCellInfoForPoint((int) ev.getX(), (int) ev.getY());
}
+
return false;
}
@@ -1978,8 +1968,8 @@ out: for (int i = x; i < x + spanX - 1 && x < xCount; i++) {
leftMargin - rightMargin;
height = myCellVSpan * cellHeight + ((myCellVSpan - 1) * heightGap) -
topMargin - bottomMargin;
- x = myCellX * (cellWidth + widthGap) + leftMargin;
- y = myCellY * (cellHeight + heightGap) + topMargin;
+ x = (int) (myCellX * (cellWidth + widthGap) + leftMargin);
+ y = (int) (myCellY * (cellHeight + heightGap) + topMargin);
}
}
diff --git a/src/com/android/launcher2/CellLayoutChildren.java b/src/com/android/launcher2/CellLayoutChildren.java
index 35f5af104..4ca44ed72 100644
--- a/src/com/android/launcher2/CellLayoutChildren.java
+++ b/src/com/android/launcher2/CellLayoutChildren.java
@@ -18,10 +18,14 @@ package com.android.launcher2;
import android.app.WallpaperManager;
import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewGroup;
+import com.android.launcher2.CellLayout.LayoutParams;
+
public class CellLayoutChildren extends ViewGroup {
static final String TAG = "CellLayoutChildren";
@@ -68,6 +72,22 @@ public class CellLayoutChildren extends ViewGroup {
}
@Override
+ protected void dispatchDraw(Canvas canvas) {
+ // Debug drawing for hit space
+ if (false) {
+ Paint p = new Paint();
+ p.setColor(0x6600FF00);
+ for (int i = getChildCount() - 1; i >= 0; i--) {
+ final View child = getChildAt(i);
+ final CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
+
+ canvas.drawRect(lp.x, lp.y, lp.x + lp.width, lp.y + lp.height, p);
+ }
+ }
+ super.dispatchDraw(canvas);
+ }
+
+ @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int count = getChildCount();
for (int i = 0; i < count; i++) {
diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java
index a3b389d24..ce5c8c517 100644
--- a/src/com/android/launcher2/DragLayer.java
+++ b/src/com/android/launcher2/DragLayer.java
@@ -433,8 +433,10 @@ public class DragLayer extends FrameLayout {
public void animateViewIntoPosition(DragView dragView, final View child, int duration,
final Runnable onFinishAnimationRunnable, View anchorView) {
- ((CellLayoutChildren) child.getParent()).measureChild(child);
+ CellLayoutChildren parentChildren = (CellLayoutChildren) child.getParent();
+ CellLayout parent = (CellLayout) (CellLayout) parentChildren.getParent();
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
+ parentChildren.measureChild(child);
Rect r = new Rect();
getViewRectRelativeToSelf(dragView, r);
@@ -442,20 +444,25 @@ public class DragLayer extends FrameLayout {
int coord[] = new int[2];
coord[0] = lp.x;
coord[1] = lp.y;
+
// Since the child hasn't necessarily been laid out, we force the lp to be updated with
// the correct coordinates (above) and use these to determine the final location
float scale = getDescendantCoordRelativeToSelf((View) child.getParent(), coord);
int toX = coord[0];
int toY = coord[1];
if (child instanceof TextView) {
+ float childrenScale = parent.getChildrenScale();
TextView tv = (TextView) child;
- Drawable d = tv.getCompoundDrawables()[1];
- // Center in the y coordinate about the target's drawable
- toY += Math.round(scale * tv.getPaddingTop());
- toY -= (dragView.getHeight() - (int) Math.round(scale * d.getIntrinsicHeight())) / 2;
- // Center in the x coordinate about the target's drawable
+ // The child may be scaled (always about the center of the view) so to account for it,
+ // we have to offset the position by the scaled size. Once we do that, we can center
+ // the drag view about the scaled child view.
+ toY += Math.round(((1f - childrenScale) * child.getMeasuredHeight()) / 2 +
+ scale * childrenScale * tv.getPaddingTop());
+ toY -= dragView.getMeasuredHeight() * (1 - scale * childrenScale) / 2;
toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
+
+ scale *= childrenScale;
} else if (child instanceof FolderIcon) {
// Account for holographic blur padding on the drag view
toY -= Workspace.DRAG_BITMAP_PADDING / 2;
diff --git a/src/com/android/launcher2/DragView.java b/src/com/android/launcher2/DragView.java
index f6c16b36e..3090e8f66 100644
--- a/src/com/android/launcher2/DragView.java
+++ b/src/com/android/launcher2/DragView.java
@@ -162,7 +162,7 @@ public class DragView extends View {
// for debugging
Paint p = new Paint();
p.setStyle(Paint.Style.FILL);
- p.setColor(0xaaffffff);
+ p.setColor(0x66ffffff);
canvas.drawRect(0, 0, getWidth(), getHeight(), p);
}
diff --git a/src/com/android/launcher2/FastBitmapDrawable.java b/src/com/android/launcher2/FastBitmapDrawable.java
index 9fa62da4a..d317d3302 100644
--- a/src/com/android/launcher2/FastBitmapDrawable.java
+++ b/src/com/android/launcher2/FastBitmapDrawable.java
@@ -29,7 +29,7 @@ class FastBitmapDrawable extends Drawable {
private int mAlpha;
private int mWidth;
private int mHeight;
- private final Paint mPaint = new Paint();
+ private final Paint mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
FastBitmapDrawable(Bitmap b) {
mAlpha = 255;
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 4e0f980e1..b7d4c8bc9 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2015,6 +2015,7 @@ public final class Launcher extends Activity
}
public boolean onLongClick(View v) {
+
if (mState != State.WORKSPACE) {
return false;
}
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index e64b0c3a6..0854508e4 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -580,7 +580,14 @@ public abstract class PagedView extends ViewGroup {
// Calculate the variable page spacing if necessary
if (mPageSpacing < 0) {
- setPageSpacing(((right - left) - getChildAt(0).getMeasuredWidth()) / 2);
+ // The gap between pages in the PagedView should be equal to the gap from the page
+ // to the edge of the screen (so it is not visible in the current screen). To
+ // account for unequal padding on each side of the paged view, we take the maximum
+ // of the left/right gap and use that as the gap between each page.
+ int offset = getRelativeChildOffset(0);
+ int spacing = Math.max(offset, (right - left) - offset -
+ getChildAt(0).getMeasuredWidth());
+ setPageSpacing(spacing);
}
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index b7fdfe8bb..b8807a924 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -1902,10 +1902,14 @@ public class Workspace extends SmoothPagedView
final Bitmap b = createDragBitmap(child, new Canvas(), DRAG_BITMAP_PADDING);
final int bmpWidth = b.getWidth();
+ final int bmpHeight = b.getHeight();
mLauncher.getDragLayer().getLocationInDragLayer(child, mTempXY);
- final int dragLayerX = (int) mTempXY[0] + (child.getWidth() - bmpWidth) / 2;
- int dragLayerY = mTempXY[1] - DRAG_BITMAP_PADDING / 2;
+ int dragLayerX =
+ Math.round(mTempXY[0] - (bmpWidth - child.getScaleX() * child.getWidth()) / 2);
+ int dragLayerY =
+ Math.round(mTempXY[1] - (bmpHeight - child.getScaleY() * bmpHeight) / 2
+ - DRAG_BITMAP_PADDING / 2);
Point dragVisualizeOffset = null;
Rect dragRect = null;
@@ -1934,7 +1938,7 @@ public class Workspace extends SmoothPagedView
}
mDragController.startDrag(b, dragLayerX, dragLayerY, source, child.getTag(),
- DragController.DRAG_ACTION_MOVE, dragVisualizeOffset, dragRect, 1f);
+ DragController.DRAG_ACTION_MOVE, dragVisualizeOffset, dragRect, child.getScaleX());
b.recycle();
// Show the scrolling indicator when you pick up an item