summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorPatrick Dubroy <dubroy@google.com>2011-03-10 17:17:23 -0800
committerMichael Jurka <mikejurka@google.com>2011-03-14 10:39:11 -0700
commit96864c3c27d03b98d5a25b74b7647be064071144 (patch)
tree56ab42ed6ac64ccdeecbf327211bf7546f6843ee /src/com/android
parent5a0d66c36e69a3b4e5deb800750efe64163f0264 (diff)
downloadandroid_packages_apps_Trebuchet-96864c3c27d03b98d5a25b74b7647be064071144.tar.gz
android_packages_apps_Trebuchet-96864c3c27d03b98d5a25b74b7647be064071144.tar.bz2
android_packages_apps_Trebuchet-96864c3c27d03b98d5a25b74b7647be064071144.zip
Fix 4081795: Blue glow gone wild
Change-Id: Ib5d4a63d0eb53f498e1fd4fcf733fda22be8f894
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher2/BubbleTextView.java54
-rw-r--r--src/com/android/launcher2/CellLayout.java36
2 files changed, 53 insertions, 37 deletions
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java
index a8db330b3..f18a24197 100644
--- a/src/com/android/launcher2/BubbleTextView.java
+++ b/src/com/android/launcher2/BubbleTextView.java
@@ -126,23 +126,13 @@ public class BubbleTextView extends TextView implements VisibilityChangedBroadca
return who == mBackground || super.verifyDrawable(who);
}
- private void invalidatePressedOrFocusedBackground() {
- int padding = HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS / 2;
- View parent = (View) getParent();
- if (parent != null) {
- parent.invalidate(getLeft() - padding, getTop() - padding,
- getRight() + padding, getBottom() + padding);
- }
- invalidate();
- }
-
@Override
protected void drawableStateChanged() {
if (isPressed()) {
// In this case, we have already created the pressed outline on ACTION_DOWN,
// so we just need to do an invalidate to trigger draw
if (!mDidInvalidateForPressedState) {
- invalidatePressedOrFocusedBackground();
+ setCellLayoutPressedOrFocusedIcon();
}
} else {
// Otherwise, either clear the pressed/focused background, or create a background
@@ -161,11 +151,11 @@ public class BubbleTextView extends TextView implements VisibilityChangedBroadca
mTempCanvas, mFocusedGlowColor, mFocusedOutlineColor);
}
mStayPressed = false;
- invalidatePressedOrFocusedBackground();
+ setCellLayoutPressedOrFocusedIcon();
}
final boolean backgroundEmptyNow = mPressedOrFocusedBackground == null;
if (!backgroundEmptyBefore && backgroundEmptyNow) {
- invalidatePressedOrFocusedBackground();
+ setCellLayoutPressedOrFocusedIcon();
}
}
@@ -196,7 +186,7 @@ public class BubbleTextView extends TextView implements VisibilityChangedBroadca
destCanvas.save();
destCanvas.translate(-getScrollX() + padding / 2, -getScrollY() + padding / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
- drawImpl(destCanvas, true);
+ draw(destCanvas);
destCanvas.restore();
}
@@ -269,35 +259,25 @@ public class BubbleTextView extends TextView implements VisibilityChangedBroadca
if (!stayPressed) {
mPressedOrFocusedBackground = null;
}
- invalidatePressedOrFocusedBackground();
+ setCellLayoutPressedOrFocusedIcon();
}
- @Override
- public void draw(Canvas canvas) {
- drawImpl(canvas, false);
+ void setCellLayoutPressedOrFocusedIcon() {
+ CellLayoutChildren parent = (CellLayoutChildren) getParent();
+ CellLayout cellLayout = (CellLayout) parent.getParent();
+ cellLayout.setPressedOrFocusedIcon((mPressedOrFocusedBackground != null) ? this : null);
}
- private void drawImpl(Canvas canvas, boolean preventRecursion) {
- // If the View is focused but the focused background hasn't been created yet, create it now
- if (!preventRecursion && isFocused() && mPressedOrFocusedBackground == null) {
- mPressedOrFocusedBackground = createGlowingOutline(
- mTempCanvas, mFocusedGlowColor, mFocusedOutlineColor);
- }
+ Bitmap getPressedOrFocusedBackground() {
+ return mPressedOrFocusedBackground;
+ }
- if (mPressedOrFocusedBackground != null && (isPressed() || isFocused() || mStayPressed)) {
- // The blue glow can extend outside of our clip region, so we first temporarily expand
- // the canvas's clip region
- canvas.save(Canvas.CLIP_SAVE_FLAG);
- int padding = HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS / 2;
- canvas.clipRect(-padding + mScrollX, -padding + mScrollY,
- getWidth() + padding + mScrollX, getHeight() + padding + mScrollY,
- Region.Op.REPLACE);
- // draw blue glow
- canvas.drawBitmap(mPressedOrFocusedBackground,
- mScrollX - padding, mScrollY - padding, mTempPaint);
- canvas.restore();
- }
+ int getPressedOrFocusedBackgroundPadding() {
+ return HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS / 2;
+ }
+ @Override
+ public void draw(Canvas canvas) {
final Drawable background = mBackground;
if (background != null) {
final int scrollX = mScrollX;
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index c1c12b5ed..1111c53c7 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -113,6 +113,8 @@ public class CellLayout extends ViewGroup {
private int mDragOutlineCurrent = 0;
private final Paint mDragOutlinePaint = new Paint();
+ private BubbleTextView mPressedOrFocusedIcon;
+
private Drawable mCrosshairsDrawable = null;
private InterruptibleInOutAnimator mCrosshairsAnimator = null;
private float mCrosshairsVisibility = 0.0f;
@@ -267,6 +269,27 @@ public class CellLayout extends ViewGroup {
addView(mChildren);
}
+ private void invalidateBubbleTextView(BubbleTextView icon) {
+ final int padding = icon.getPressedOrFocusedBackgroundPadding();
+ invalidate(icon.getLeft() - padding,
+ icon.getTop() - padding,
+ icon.getRight() + padding,
+ icon.getBottom() + padding);
+ }
+
+ void setPressedOrFocusedIcon(BubbleTextView icon) {
+ // We draw the pressed or focused BubbleTextView's background in CellLayout because it
+ // requires an expanded clip rect (due to the glow's blur radius)
+ BubbleTextView oldIcon = mPressedOrFocusedIcon;
+ mPressedOrFocusedIcon = icon;
+ if (oldIcon != null) {
+ invalidateBubbleTextView(oldIcon);
+ }
+ if (mPressedOrFocusedIcon != null) {
+ invalidateBubbleTextView(mPressedOrFocusedIcon);
+ }
+ }
+
public CellLayoutChildren getChildrenLayout() {
if (getChildCount() > 0) {
return (CellLayoutChildren) getChildAt(0);
@@ -457,6 +480,19 @@ public class CellLayout extends ViewGroup {
canvas.drawBitmap(b, p.x, p.y, paint);
}
}
+
+ // We draw the pressed or focused BubbleTextView's background in CellLayout because it
+ // requires an expanded clip rect (due to the glow's blur radius)
+ if (mPressedOrFocusedIcon != null) {
+ final int padding = mPressedOrFocusedIcon.getPressedOrFocusedBackgroundPadding();
+ final Bitmap b = mPressedOrFocusedIcon.getPressedOrFocusedBackground();
+ if (b != null) {
+ canvas.drawBitmap(b,
+ mPressedOrFocusedIcon.getLeft() - padding,
+ mPressedOrFocusedIcon.getTop() - padding,
+ null);
+ }
+ }
}
@Override