summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2010-12-13 12:11:33 -0800
committerWinson Chung <winsonc@google.com>2010-12-14 15:32:02 -0800
commit88127038178b3bbf0eb91103a31e682cc0615074 (patch)
treeb380b586ed42782e8d9f34866dc083dec435e90b /src/com/android
parent09a19c4cfc91795a11ae0b4e75b6fc6588cffee9 (diff)
downloadandroid_packages_apps_Trebuchet-88127038178b3bbf0eb91103a31e682cc0615074.tar.gz
android_packages_apps_Trebuchet-88127038178b3bbf0eb91103a31e682cc0615074.tar.bz2
android_packages_apps_Trebuchet-88127038178b3bbf0eb91103a31e682cc0615074.zip
Various tweaks to launcher
- Removing hotdog for shadow bg protection - Adding bg protection for customization tray - Restoring holographic outlines for all apps - Small bug fixes Change-Id: I58d81bb490f78c76fcaf46122febc3c1aace854e
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher2/BubbleTextView.java74
-rw-r--r--src/com/android/launcher2/CacheableTextView.java32
-rw-r--r--src/com/android/launcher2/CellLayout.java1
-rw-r--r--src/com/android/launcher2/Launcher.java2
-rw-r--r--src/com/android/launcher2/PagedViewIcon.java11
-rw-r--r--src/com/android/launcher2/Workspace.java25
6 files changed, 89 insertions, 56 deletions
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java
index 855f261f8..995877b91 100644
--- a/src/com/android/launcher2/BubbleTextView.java
+++ b/src/com/android/launcher2/BubbleTextView.java
@@ -36,6 +36,11 @@ import com.android.launcher.R;
*/
public class BubbleTextView extends CacheableTextView {
static final float CORNER_RADIUS = 4.0f;
+ static final float SHADOW_LARGE_RADIUS = 4.0f;
+ static final float SHADOW_SMALL_RADIUS = 1.75f;
+ static final float SHADOW_Y_OFFSET = 2.0f;
+ static final int SHADOW_LARGE_COLOUR = 0xCC000000;
+ static final int SHADOW_SMALL_COLOUR = 0xBB000000;
static final float PADDING_H = 8.0f;
static final float PADDING_V = 3.0f;
@@ -83,11 +88,17 @@ public class BubbleTextView extends CacheableTextView {
mPaddingV = PADDING_V * scale;
}
- protected int getVerticalPadding() {
+ protected int getCacheTopPadding() {
return (int) PADDING_V;
}
- protected int getHorizontalPadding() {
- return (int) PADDING_H;
+ protected int getCacheBottomPadding() {
+ return (int) (PADDING_V + SHADOW_LARGE_RADIUS + SHADOW_Y_OFFSET);
+ }
+ protected int getCacheLeftPadding() {
+ return (int) (PADDING_H + SHADOW_LARGE_RADIUS);
+ }
+ protected int getCacheRightPadding() {
+ return (int) (PADDING_H + SHADOW_LARGE_RADIUS);
}
public void applyFromShortcutInfo(ShortcutInfo info, IconCache iconCache) {
@@ -126,41 +137,34 @@ public class BubbleTextView extends CacheableTextView {
@Override
public void draw(Canvas canvas) {
- final Drawable background = mBackground;
- if (background != null) {
- final int scrollX = mScrollX;
- final int scrollY = mScrollY;
-
- if (mBackgroundSizeChanged) {
- background.setBounds(0, 0, mRight - mLeft, mBottom - mTop);
- mBackgroundSizeChanged = false;
- }
-
- if ((scrollX | scrollY) == 0) {
- background.draw(canvas);
- } else {
- canvas.translate(scrollX, scrollY);
- background.draw(canvas);
- canvas.translate(-scrollX, -scrollY);
+ if (isBuildingCache()) {
+ // We enhance the shadow by drawing the shadow twice
+ this.setShadowLayer(SHADOW_LARGE_RADIUS, 0.0f, SHADOW_Y_OFFSET, SHADOW_LARGE_COLOUR);
+ super.draw(canvas);
+ this.setShadowLayer(SHADOW_SMALL_RADIUS, 0.0f, 0.0f, SHADOW_SMALL_COLOUR);
+ super.draw(canvas);
+ } else {
+ final Drawable background = mBackground;
+ if (background != null) {
+ final int scrollX = mScrollX;
+ final int scrollY = mScrollY;
+
+ if (mBackgroundSizeChanged) {
+ background.setBounds(0, 0, mRight - mLeft, mBottom - mTop);
+ mBackgroundSizeChanged = false;
+ }
+
+ if ((scrollX | scrollY) == 0) {
+ background.draw(canvas);
+ } else {
+ canvas.translate(scrollX, scrollY);
+ background.draw(canvas);
+ canvas.translate(-scrollX, -scrollY);
+ }
}
- }
- // Draw the hotdog bubble
- final Layout layout = getLayout();
- if (layout != null) {
- final int offset = getExtendedPaddingTop();
- final int paddingLeft = getPaddingLeft();
- final int paddingRight = getPaddingRight();
- final float left = layout.getLineLeft(0) + paddingLeft;
- final float right = Math.min(layout.getLineRight(0) + paddingRight,
- left + getWidth() - paddingLeft - paddingRight);
- mRect.set(left - mPaddingH, offset + (int) layout.getLineTop(0) - mPaddingV,
- right + mPaddingH, offset + (int) layout.getLineBottom(0) + mPaddingV);
-
- canvas.drawRoundRect(mRect, mCornerRadius, mCornerRadius, mPaint);
+ super.draw(canvas);
}
-
- super.draw(canvas);
}
@Override
diff --git a/src/com/android/launcher2/CacheableTextView.java b/src/com/android/launcher2/CacheableTextView.java
index 873cd4ed7..da2f302c1 100644
--- a/src/com/android/launcher2/CacheableTextView.java
+++ b/src/com/android/launcher2/CacheableTextView.java
@@ -20,8 +20,8 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.Paint;
-import android.graphics.Rect;
import android.text.Layout;
import android.util.AttributeSet;
import android.widget.TextView;
@@ -60,10 +60,16 @@ public class CacheableTextView extends TextView {
super(context, attrs, defStyle);
}
- protected int getVerticalPadding() {
+ protected int getCacheTopPadding() {
return 0;
}
- protected int getHorizontalPadding() {
+ protected int getCacheLeftPadding() {
+ return 0;
+ }
+ protected int getCacheRightPadding() {
+ return 0;
+ }
+ protected int getCacheBottomPadding() {
return 0;
}
@@ -84,21 +90,21 @@ public class CacheableTextView extends TextView {
final int top = getExtendedPaddingTop();
final float prevAlpha = getAlpha();
- int vPadding = getVerticalPadding();
- int hPadding = getHorizontalPadding();
-
- mTextCacheLeft = layout.getLineLeft(0) - hPadding;
- mTextCacheTop = top + layout.getLineTop(0) - mPaddingV - vPadding;
+ mTextCacheLeft = layout.getLineLeft(0) - getCacheLeftPadding();
+ mTextCacheTop = top + layout.getLineTop(0) - mPaddingV - getCacheTopPadding();
mRectLeft = mScrollX + getLeft();
mRectTop = 0;
mTextCacheScrollX = mScrollX;
final float textCacheRight =
- Math.min(left + layout.getLineRight(0) + mPaddingH, mScrollX + mRight - mLeft) + hPadding;
- final float textCacheBottom = top + layout.getLineBottom(0) + mPaddingV + vPadding;
+ Math.min(left + layout.getLineRight(0) + mPaddingH, mScrollX + mRight - mLeft) +
+ getCacheRightPadding();
+ final float textCacheBottom = top + layout.getLineBottom(0) + mPaddingV +
+ getCacheBottomPadding();
+ final float xCharWidth = getPaint().measureText("x");
- int width = (int) (textCacheRight - mTextCacheLeft);
+ int width = (int) (textCacheRight - mTextCacheLeft + (2 * xCharWidth));
int height = (int) (textCacheBottom - mTextCacheTop);
if (width != 0 && height != 0) {
@@ -150,6 +156,10 @@ public class CacheableTextView extends TextView {
super.draw(canvas);
}
+ protected boolean isBuildingCache() {
+ return mIsBuildingCache;
+ }
+
@Override
protected boolean onSetAlpha(int alpha) {
if (mPrevAlpha != alpha) {
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index fd0ef51d1..daaf4bece 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -139,6 +139,7 @@ public class CellLayout extends ViewGroup implements Dimmable {
// A ViewGroup usually does not draw, but CellLayout needs to draw a rectangle to show
// the user where a dragged item will land when dropped.
setWillNotDraw(false);
+ setClipChildren(false);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CellLayout, defStyle, 0);
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 0cb0e138e..455b130c1 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -294,7 +294,7 @@ public final class Launcher extends Activity
checkForLocaleChange();
setWallpaperDimension();
setContentView(R.layout.launcher);
- mHomeCustomizationDrawer = (TabHost) findViewById(com.android.internal.R.id.tabhost);
+ mHomeCustomizationDrawer = (TabHost) findViewById(R.id.customization_drawer);
if (mHomeCustomizationDrawer != null) {
mHomeCustomizationDrawer.setup();
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index 884884e31..d91daf918 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -52,7 +52,7 @@ public class PagedViewIcon extends CacheableTextView implements Checkable {
private Object mIconCacheKey;
private PagedViewIconCache mIconCache;
- private int mAlpha;
+ private int mAlpha = 255;
private int mHolographicAlpha;
private boolean mIsChecked;
@@ -64,8 +64,6 @@ public class PagedViewIcon extends CacheableTextView implements Checkable {
// Highlight colors
private int mHoloBlurColor;
private int mHoloOutlineColor;
- private int mCheckedBlurColor;
- private int mCheckedOutlineColor;
private static final HandlerThread sWorkerThread = new HandlerThread("pagedviewicon-helper");
static {
@@ -110,11 +108,8 @@ public class PagedViewIcon extends CacheableTextView implements Checkable {
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagedViewIcon, defStyle, 0);
- mAlpha = 255;
mHoloBlurColor = a.getColor(R.styleable.PagedViewIcon_blurColor, 0);
mHoloOutlineColor = a.getColor(R.styleable.PagedViewIcon_outlineColor, 0);
- mCheckedBlurColor = a.getColor(R.styleable.PagedViewIcon_checkedBlurColor, 0);
- mCheckedOutlineColor = a.getColor(R.styleable.PagedViewIcon_checkedOutlineColor, 0);
a.recycle();
if (sHolographicOutlineHelper == null) {
@@ -126,14 +121,12 @@ public class PagedViewIcon extends CacheableTextView implements Checkable {
}
private void queueHolographicOutlineCreation() {
- /* Temporarily disabling holographic outline creation.
// Generate the outline in the background
if (mHolographicOutline == null) {
Message m = sWorker.obtainMessage(MESSAGE_CREATE_HOLOGRAPHIC_OUTLINE);
m.obj = this;
sWorker.sendMessage(m);
}
- */
}
public void applyFromApplicationInfo(ApplicationInfo info, PagedViewIconCache cache,
@@ -248,7 +241,7 @@ public class PagedViewIcon extends CacheableTextView implements Checkable {
if (mCheckedAlphaAnimator != null) {
mCheckedAlphaAnimator.cancel();
}
- mCheckedAlphaAnimator = ObjectAnimator.ofFloat(this, "alpha", alpha);
+ mCheckedAlphaAnimator = ObjectAnimator.ofFloat(this, "alpha", getAlpha(), alpha);
mCheckedAlphaAnimator.setDuration(duration);
mCheckedAlphaAnimator.start();
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 705453d3a..06893e2d5 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -62,6 +62,7 @@ import android.view.DragEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
+import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;
@@ -117,6 +118,11 @@ public class Workspace extends SmoothPagedView
private float mOverScrollMaxBackgroundAlpha = 0.0f;
private int mOverScrollPageIndex = -1;
+ private View mCustomizationDrawer;
+ private View mCustomizationDrawerContent;
+ private int[] mCustomizationDrawerPos = new int[2];
+ private float[] mCustomizationDrawerTransformedPos = new float[2];
+
private final WallpaperManager mWallpaperManager;
private int mDefaultPage;
@@ -754,6 +760,21 @@ public class Workspace extends SmoothPagedView
mBackground.setBounds(mScrollX, 0, mScrollX + getMeasuredWidth(), getMeasuredHeight());
mBackground.draw(canvas);
if (mDrawCustomizeTrayBackground) {
+ // Find out where to offset the gradient for the customization tray content
+ mCustomizationDrawer.getLocationOnScreen(mCustomizationDrawerPos);
+ final Matrix m = mCustomizationDrawer.getMatrix();
+ mCustomizationDrawerTransformedPos[0] = 0.0f;
+ mCustomizationDrawerTransformedPos[1] = mCustomizationDrawerContent.getTop();
+ m.mapPoints(mCustomizationDrawerTransformedPos);
+
+ // Draw the bg gradient
+ final int offset = (int) (mCustomizationDrawerPos[1] +
+ mCustomizationDrawerTransformedPos[1]);
+ mBackground.setBounds(mScrollX, offset, mScrollX + getMeasuredWidth(),
+ offset + getMeasuredHeight());
+ mBackground.draw(canvas);
+
+ // Draw the bg glow
mCustomizeTrayBackground.setAlpha(alpha);
mCustomizeTrayBackground.setBounds(mScrollX, 0, mScrollX + getMeasuredWidth(),
getMeasuredHeight());
@@ -2216,6 +2237,10 @@ public class Workspace extends SmoothPagedView
void setLauncher(Launcher launcher) {
mLauncher = launcher;
mSpringLoadedDragControllger = new SpringLoadedDragController(mLauncher);
+
+ mCustomizationDrawer = mLauncher.findViewById(R.id.customization_drawer);
+ mCustomizationDrawerContent =
+ mCustomizationDrawer.findViewById(com.android.internal.R.id.tabcontent);
}
public void setDragController(DragController dragController) {