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
mTempCanvas, mFocusedGlowColor, mFocusedOutlineColor);
}
mStayPressed = false;
- invalidatePressedOrFocusedBackground();
+ setCellLayoutPressedOrFocusedIcon();
}
final boolean backgroundEmptyNow = mPressedOrFocusedBackground == null;
if (!backgroundEmptyBefore && backgroundEmptyNow) {
- invalidatePressedOrFocusedBackground();
+ setCellLayoutPressedOrFocusedIcon();
}
}
destCanvas.save();
destCanvas.translate(-getScrollX() + padding / 2, -getScrollY() + padding / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
- drawImpl(destCanvas, true);
+ draw(destCanvas);
destCanvas.restore();
}
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;
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;
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);
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