diff options
author | Winson Chung <winsonc@google.com> | 2010-12-13 12:11:33 -0800 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2010-12-14 15:32:02 -0800 |
commit | 88127038178b3bbf0eb91103a31e682cc0615074 (patch) | |
tree | b380b586ed42782e8d9f34866dc083dec435e90b | |
parent | 09a19c4cfc91795a11ae0b4e75b6fc6588cffee9 (diff) | |
download | android_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
-rw-r--r-- | res/drawable-hdpi/focused_application_background.9.png | bin | 4127 -> 4125 bytes | |||
-rw-r--r-- | res/drawable-hdpi/pressed_application_background.9.png | bin | 4075 -> 4076 bytes | |||
-rw-r--r-- | res/drawable-mdpi/focused_application_background.9.png | bin | 3614 -> 3613 bytes | |||
-rw-r--r-- | res/drawable-mdpi/pressed_application_background.9.png | bin | 3778 -> 3778 bytes | |||
-rw-r--r-- | res/layout-xlarge-land/launcher.xml | 2 | ||||
-rw-r--r-- | res/layout-xlarge-port/launcher.xml | 2 | ||||
-rw-r--r-- | res/layout-xlarge/all_apps_paged_view_application.xml | 2 | ||||
-rw-r--r-- | res/layout-xlarge/customize_paged_view_item.xml | 2 | ||||
-rw-r--r-- | res/values/attrs.xml | 4 | ||||
-rw-r--r-- | src/com/android/launcher2/BubbleTextView.java | 74 | ||||
-rw-r--r-- | src/com/android/launcher2/CacheableTextView.java | 32 | ||||
-rw-r--r-- | src/com/android/launcher2/CellLayout.java | 1 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedViewIcon.java | 11 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 25 |
15 files changed, 91 insertions, 66 deletions
diff --git a/res/drawable-hdpi/focused_application_background.9.png b/res/drawable-hdpi/focused_application_background.9.png Binary files differindex ac67b06e7..01c83c37f 100644 --- a/res/drawable-hdpi/focused_application_background.9.png +++ b/res/drawable-hdpi/focused_application_background.9.png diff --git a/res/drawable-hdpi/pressed_application_background.9.png b/res/drawable-hdpi/pressed_application_background.9.png Binary files differindex fdb064aad..c7d0bd400 100644 --- a/res/drawable-hdpi/pressed_application_background.9.png +++ b/res/drawable-hdpi/pressed_application_background.9.png diff --git a/res/drawable-mdpi/focused_application_background.9.png b/res/drawable-mdpi/focused_application_background.9.png Binary files differindex 259f122ac..341a80b47 100644 --- a/res/drawable-mdpi/focused_application_background.9.png +++ b/res/drawable-mdpi/focused_application_background.9.png diff --git a/res/drawable-mdpi/pressed_application_background.9.png b/res/drawable-mdpi/pressed_application_background.9.png Binary files differindex 754af4822..4b00eec8c 100644 --- a/res/drawable-mdpi/pressed_application_background.9.png +++ b/res/drawable-mdpi/pressed_application_background.9.png diff --git a/res/layout-xlarge-land/launcher.xml b/res/layout-xlarge-land/launcher.xml index 7b66d7c22..e421e0793 100644 --- a/res/layout-xlarge-land/launcher.xml +++ b/res/layout-xlarge-land/launcher.xml @@ -161,7 +161,7 @@ </RelativeLayout> <TabHost - android:id="@android:id/tabhost" + android:id="@+id/customization_drawer" android:layout_width="match_parent" android:layout_height="480dp" android:layout_gravity="bottom"> diff --git a/res/layout-xlarge-port/launcher.xml b/res/layout-xlarge-port/launcher.xml index c5691b8cb..d9839da76 100644 --- a/res/layout-xlarge-port/launcher.xml +++ b/res/layout-xlarge-port/launcher.xml @@ -174,7 +174,7 @@ </RelativeLayout> <TabHost - android:id="@android:id/tabhost" + android:id="@+id/customization_drawer" android:layout_width="match_parent" android:layout_height="800dp" android:layout_gravity="bottom"> diff --git a/res/layout-xlarge/all_apps_paged_view_application.xml b/res/layout-xlarge/all_apps_paged_view_application.xml index a080bcecc..e5f07bf44 100644 --- a/res/layout-xlarge/all_apps_paged_view_application.xml +++ b/res/layout-xlarge/all_apps_paged_view_application.xml @@ -20,8 +20,6 @@ launcher:blurColor="#FF6B8CF0" launcher:outlineColor="#FF8CD2FF" - launcher:checkedBlurColor="#FFBBE83C" - launcher:checkedOutlineColor="#FF8CD2FF" android:id="@+id/application_icon" android:layout_width="match_parent" diff --git a/res/layout-xlarge/customize_paged_view_item.xml b/res/layout-xlarge/customize_paged_view_item.xml index 35e06c35f..b2e5f08b3 100644 --- a/res/layout-xlarge/customize_paged_view_item.xml +++ b/res/layout-xlarge/customize_paged_view_item.xml @@ -20,8 +20,6 @@ launcher:blurColor="#FF6B8CF0" launcher:outlineColor="#FF8CD2FF" - launcher:checkedBlurColor="#FFBBE83C" - launcher:checkedOutlineColor="#FF8CD2FF" android:id="@+id/customize_icon" android:layout_width="match_parent" diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 337386916..5e6a2ab64 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -68,10 +68,6 @@ <attr name="blurColor" format="color" /> <!-- The outline color of the holographic outline --> <attr name="outlineColor" format="color" /> - <!-- The checked blur color of the holographic outline --> - <attr name="checkedBlurColor" format="color" /> - <!-- The checked outline color of the holographic outline --> - <attr name="checkedOutlineColor" format="color" /> </declare-styleable> <!-- PagedViewWidget specific attributes. These attributes are used to 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) { |