The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Joe Onorato | a590252 | 2009-07-30 13:37:37 -0700 | [diff] [blame] | 17 | package com.android.launcher2; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 18 | |
Michael Jurka | 38b4f7c | 2010-12-14 16:46:39 -0800 | [diff] [blame] | 19 | import com.android.launcher.R; |
| 20 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 21 | import android.content.Context; |
Winson Chung | 656d11c | 2010-11-29 17:15:47 -0800 | [diff] [blame] | 22 | import android.content.res.Resources; |
Michael Jurka | 67b2f6c | 2010-11-17 12:33:46 -0800 | [diff] [blame] | 23 | import android.graphics.Bitmap; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 24 | import android.graphics.Canvas; |
Winson Chung | 656d11c | 2010-11-29 17:15:47 -0800 | [diff] [blame] | 25 | import android.graphics.Color; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 26 | import android.graphics.Paint; |
Michael Jurka | 38b4f7c | 2010-12-14 16:46:39 -0800 | [diff] [blame] | 27 | import android.graphics.Rect; |
Michael Jurka | 137142e | 2011-01-05 20:57:04 -0800 | [diff] [blame] | 28 | import android.graphics.Region; |
Michael Jurka | 38b4f7c | 2010-12-14 16:46:39 -0800 | [diff] [blame] | 29 | import android.graphics.Region.Op; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 30 | import android.graphics.drawable.Drawable; |
Winson Chung | 656d11c | 2010-11-29 17:15:47 -0800 | [diff] [blame] | 31 | import android.util.AttributeSet; |
Michael Jurka | 38b4f7c | 2010-12-14 16:46:39 -0800 | [diff] [blame] | 32 | import android.view.MotionEvent; |
Michael Jurka | 99b6a5b | 2011-01-07 15:37:17 -0800 | [diff] [blame] | 33 | import android.view.View; |
Michael Jurka | bdb5c53 | 2011-02-01 15:05:06 -0800 | [diff] [blame] | 34 | import android.widget.TextView; |
Romain Guy | edcce09 | 2010-03-04 13:03:17 -0800 | [diff] [blame] | 35 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 36 | /** |
| 37 | * TextView that draws a bubble behind the text. We cannot use a LineBackgroundSpan |
| 38 | * because we want to make the bubble taller than the text and TextView's clip is |
| 39 | * too aggressive. |
| 40 | */ |
Michael Jurka | 08ee770 | 2011-08-11 16:53:35 -0700 | [diff] [blame^] | 41 | public class BubbleTextView extends TextView { |
Winson Chung | 656d11c | 2010-11-29 17:15:47 -0800 | [diff] [blame] | 42 | static final float CORNER_RADIUS = 4.0f; |
Winson Chung | 8812703 | 2010-12-13 12:11:33 -0800 | [diff] [blame] | 43 | static final float SHADOW_LARGE_RADIUS = 4.0f; |
| 44 | static final float SHADOW_SMALL_RADIUS = 1.75f; |
| 45 | static final float SHADOW_Y_OFFSET = 2.0f; |
| 46 | static final int SHADOW_LARGE_COLOUR = 0xCC000000; |
| 47 | static final int SHADOW_SMALL_COLOUR = 0xBB000000; |
Winson Chung | 656d11c | 2010-11-29 17:15:47 -0800 | [diff] [blame] | 48 | static final float PADDING_H = 8.0f; |
| 49 | static final float PADDING_V = 3.0f; |
| 50 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 51 | private Paint mPaint; |
Winson Chung | 656d11c | 2010-11-29 17:15:47 -0800 | [diff] [blame] | 52 | private float mBubbleColorAlpha; |
Winson Chung | e22a8e9 | 2010-11-12 13:40:58 -0800 | [diff] [blame] | 53 | private int mPrevAlpha = -1; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 54 | |
Michael Jurka | 38b4f7c | 2010-12-14 16:46:39 -0800 | [diff] [blame] | 55 | private final HolographicOutlineHelper mOutlineHelper = new HolographicOutlineHelper(); |
| 56 | private final Canvas mTempCanvas = new Canvas(); |
| 57 | private final Rect mTempRect = new Rect(); |
Michael Jurka | 38b4f7c | 2010-12-14 16:46:39 -0800 | [diff] [blame] | 58 | private boolean mDidInvalidateForPressedState; |
| 59 | private Bitmap mPressedOrFocusedBackground; |
| 60 | private int mFocusedOutlineColor; |
| 61 | private int mFocusedGlowColor; |
| 62 | private int mPressedOutlineColor; |
| 63 | private int mPressedGlowColor; |
| 64 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 65 | private boolean mBackgroundSizeChanged; |
| 66 | private Drawable mBackground; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 67 | |
Michael Jurka | ddd62e9 | 2011-02-16 17:49:14 -0800 | [diff] [blame] | 68 | private boolean mStayPressed; |
| 69 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 70 | public BubbleTextView(Context context) { |
| 71 | super(context); |
| 72 | init(); |
| 73 | } |
| 74 | |
| 75 | public BubbleTextView(Context context, AttributeSet attrs) { |
| 76 | super(context, attrs); |
| 77 | init(); |
| 78 | } |
| 79 | |
| 80 | public BubbleTextView(Context context, AttributeSet attrs, int defStyle) { |
| 81 | super(context, attrs, defStyle); |
| 82 | init(); |
| 83 | } |
| 84 | |
| 85 | private void init() { |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 86 | mBackground = getBackground(); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 87 | |
Winson Chung | 656d11c | 2010-11-29 17:15:47 -0800 | [diff] [blame] | 88 | final Resources res = getContext().getResources(); |
| 89 | int bubbleColor = res.getColor(R.color.bubble_dark_background); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 90 | mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); |
Winson Chung | 656d11c | 2010-11-29 17:15:47 -0800 | [diff] [blame] | 91 | mPaint.setColor(bubbleColor); |
| 92 | mBubbleColorAlpha = Color.alpha(bubbleColor) / 255.0f; |
Winson Chung | ea359c6 | 2011-08-03 17:06:35 -0700 | [diff] [blame] | 93 | mFocusedOutlineColor = res.getColor(android.R.color.holo_blue_light); |
| 94 | mFocusedGlowColor = res.getColor(android.R.color.holo_blue_light); |
| 95 | mPressedOutlineColor = res.getColor(android.R.color.holo_blue_light); |
| 96 | mPressedGlowColor = res.getColor(android.R.color.holo_blue_light); |
Michael Jurka | e7e3f6c | 2011-02-01 21:08:29 -0800 | [diff] [blame] | 97 | |
| 98 | setShadowLayer(SHADOW_LARGE_RADIUS, 0.0f, SHADOW_Y_OFFSET, SHADOW_LARGE_COLOUR); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 99 | } |
| 100 | |
Michael Jurka | 67b2f6c | 2010-11-17 12:33:46 -0800 | [diff] [blame] | 101 | public void applyFromShortcutInfo(ShortcutInfo info, IconCache iconCache) { |
| 102 | Bitmap b = info.getIcon(iconCache); |
| 103 | |
| 104 | setCompoundDrawablesWithIntrinsicBounds(null, |
| 105 | new FastBitmapDrawable(b), |
| 106 | null, null); |
| 107 | setText(info.title); |
Michael Jurka | 67b2f6c | 2010-11-17 12:33:46 -0800 | [diff] [blame] | 108 | setTag(info); |
Michael Jurka | 67b2f6c | 2010-11-17 12:33:46 -0800 | [diff] [blame] | 109 | } |
| 110 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 111 | @Override |
| 112 | protected boolean setFrame(int left, int top, int right, int bottom) { |
| 113 | if (mLeft != left || mRight != right || mTop != top || mBottom != bottom) { |
| 114 | mBackgroundSizeChanged = true; |
| 115 | } |
| 116 | return super.setFrame(left, top, right, bottom); |
| 117 | } |
| 118 | |
| 119 | @Override |
| 120 | protected boolean verifyDrawable(Drawable who) { |
| 121 | return who == mBackground || super.verifyDrawable(who); |
| 122 | } |
| 123 | |
| 124 | @Override |
| 125 | protected void drawableStateChanged() { |
Michael Jurka | 38b4f7c | 2010-12-14 16:46:39 -0800 | [diff] [blame] | 126 | if (isPressed()) { |
| 127 | // In this case, we have already created the pressed outline on ACTION_DOWN, |
| 128 | // so we just need to do an invalidate to trigger draw |
| 129 | if (!mDidInvalidateForPressedState) { |
Patrick Dubroy | 3499d8c | 2011-03-10 17:17:23 -0800 | [diff] [blame] | 130 | setCellLayoutPressedOrFocusedIcon(); |
Michael Jurka | 38b4f7c | 2010-12-14 16:46:39 -0800 | [diff] [blame] | 131 | } |
| 132 | } else { |
| 133 | // Otherwise, either clear the pressed/focused background, or create a background |
| 134 | // for the focused state |
| 135 | final boolean backgroundEmptyBefore = mPressedOrFocusedBackground == null; |
Michael Jurka | ddd62e9 | 2011-02-16 17:49:14 -0800 | [diff] [blame] | 136 | if (!mStayPressed) { |
| 137 | mPressedOrFocusedBackground = null; |
| 138 | } |
Michael Jurka | 38b4f7c | 2010-12-14 16:46:39 -0800 | [diff] [blame] | 139 | if (isFocused()) { |
Patrick Dubroy | a017c03 | 2011-03-09 15:58:32 -0800 | [diff] [blame] | 140 | if (mLayout == null) { |
| 141 | // In some cases, we get focus before we have been layed out. Set the |
| 142 | // background to null so that it will get created when the view is drawn. |
| 143 | mPressedOrFocusedBackground = null; |
| 144 | } else { |
| 145 | mPressedOrFocusedBackground = createGlowingOutline( |
| 146 | mTempCanvas, mFocusedGlowColor, mFocusedOutlineColor); |
| 147 | } |
Michael Jurka | ddd62e9 | 2011-02-16 17:49:14 -0800 | [diff] [blame] | 148 | mStayPressed = false; |
Patrick Dubroy | 3499d8c | 2011-03-10 17:17:23 -0800 | [diff] [blame] | 149 | setCellLayoutPressedOrFocusedIcon(); |
Michael Jurka | 38b4f7c | 2010-12-14 16:46:39 -0800 | [diff] [blame] | 150 | } |
| 151 | final boolean backgroundEmptyNow = mPressedOrFocusedBackground == null; |
| 152 | if (!backgroundEmptyBefore && backgroundEmptyNow) { |
Patrick Dubroy | 3499d8c | 2011-03-10 17:17:23 -0800 | [diff] [blame] | 153 | setCellLayoutPressedOrFocusedIcon(); |
Michael Jurka | 38b4f7c | 2010-12-14 16:46:39 -0800 | [diff] [blame] | 154 | } |
| 155 | } |
| 156 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 157 | Drawable d = mBackground; |
| 158 | if (d != null && d.isStateful()) { |
| 159 | d.setState(getDrawableState()); |
| 160 | } |
| 161 | super.drawableStateChanged(); |
| 162 | } |
| 163 | |
Michael Jurka | 38b4f7c | 2010-12-14 16:46:39 -0800 | [diff] [blame] | 164 | /** |
Patrick Dubroy | cd95371 | 2011-02-28 15:16:42 -0800 | [diff] [blame] | 165 | * Draw this BubbleTextView into the given Canvas. |
Michael Jurka | 38b4f7c | 2010-12-14 16:46:39 -0800 | [diff] [blame] | 166 | * |
Michael Jurka | 38b4f7c | 2010-12-14 16:46:39 -0800 | [diff] [blame] | 167 | * @param destCanvas the canvas to draw on |
| 168 | * @param padding the horizontal and vertical padding to use when drawing |
| 169 | */ |
| 170 | private void drawWithPadding(Canvas destCanvas, int padding) { |
| 171 | final Rect clipRect = mTempRect; |
| 172 | getDrawingRect(clipRect); |
| 173 | |
| 174 | // adjust the clip rect so that we don't include the text label |
| 175 | clipRect.bottom = |
| 176 | getExtendedPaddingTop() - (int) BubbleTextView.PADDING_V + getLayout().getLineTop(0); |
| 177 | |
| 178 | // Draw the View into the bitmap. |
| 179 | // The translate of scrollX and scrollY is necessary when drawing TextViews, because |
| 180 | // they set scrollX and scrollY to large values to achieve centered text |
| 181 | destCanvas.save(); |
| 182 | destCanvas.translate(-getScrollX() + padding / 2, -getScrollY() + padding / 2); |
| 183 | destCanvas.clipRect(clipRect, Op.REPLACE); |
Patrick Dubroy | 3499d8c | 2011-03-10 17:17:23 -0800 | [diff] [blame] | 184 | draw(destCanvas); |
Michael Jurka | 38b4f7c | 2010-12-14 16:46:39 -0800 | [diff] [blame] | 185 | destCanvas.restore(); |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Returns a new bitmap to be used as the object outline, e.g. to visualize the drop location. |
| 190 | * Responsibility for the bitmap is transferred to the caller. |
| 191 | */ |
| 192 | private Bitmap createGlowingOutline(Canvas canvas, int outlineColor, int glowColor) { |
| 193 | final int padding = HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS; |
| 194 | final Bitmap b = Bitmap.createBitmap( |
| 195 | getWidth() + padding, getHeight() + padding, Bitmap.Config.ARGB_8888); |
| 196 | |
| 197 | canvas.setBitmap(b); |
| 198 | drawWithPadding(canvas, padding); |
| 199 | mOutlineHelper.applyExtraThickExpensiveOutlineWithBlur(b, canvas, glowColor, outlineColor); |
Adam Cohen | aaf473c | 2011-08-03 12:02:47 -0700 | [diff] [blame] | 200 | canvas.setBitmap(null); |
Michael Jurka | 38b4f7c | 2010-12-14 16:46:39 -0800 | [diff] [blame] | 201 | |
| 202 | return b; |
| 203 | } |
| 204 | |
| 205 | @Override |
| 206 | public boolean onTouchEvent(MotionEvent event) { |
| 207 | // Call the superclass onTouchEvent first, because sometimes it changes the state to |
| 208 | // isPressed() on an ACTION_UP |
| 209 | boolean result = super.onTouchEvent(event); |
| 210 | |
| 211 | switch (event.getAction()) { |
| 212 | case MotionEvent.ACTION_DOWN: |
| 213 | // So that the pressed outline is visible immediately when isPressed() is true, |
| 214 | // we pre-create it on ACTION_DOWN (it takes a small but perceptible amount of time |
| 215 | // to create it) |
| 216 | if (mPressedOrFocusedBackground == null) { |
| 217 | mPressedOrFocusedBackground = createGlowingOutline( |
| 218 | mTempCanvas, mPressedGlowColor, mPressedOutlineColor); |
| 219 | } |
| 220 | // Invalidate so the pressed state is visible, or set a flag so we know that we |
| 221 | // have to call invalidate as soon as the state is "pressed" |
| 222 | if (isPressed()) { |
| 223 | mDidInvalidateForPressedState = true; |
| 224 | invalidate(); |
| 225 | } else { |
| 226 | mDidInvalidateForPressedState = false; |
| 227 | } |
| 228 | break; |
| 229 | case MotionEvent.ACTION_CANCEL: |
| 230 | case MotionEvent.ACTION_UP: |
| 231 | // If we've touched down and up on an item, and it's still not "pressed", then |
| 232 | // destroy the pressed outline |
| 233 | if (!isPressed()) { |
| 234 | mPressedOrFocusedBackground = null; |
| 235 | } |
| 236 | break; |
| 237 | } |
| 238 | return result; |
| 239 | } |
| 240 | |
Michael Jurka | ddd62e9 | 2011-02-16 17:49:14 -0800 | [diff] [blame] | 241 | void setStayPressed(boolean stayPressed) { |
| 242 | mStayPressed = stayPressed; |
| 243 | if (!stayPressed) { |
| 244 | mPressedOrFocusedBackground = null; |
| 245 | } |
Patrick Dubroy | 3499d8c | 2011-03-10 17:17:23 -0800 | [diff] [blame] | 246 | setCellLayoutPressedOrFocusedIcon(); |
| 247 | } |
| 248 | |
| 249 | void setCellLayoutPressedOrFocusedIcon() { |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 250 | if (getParent() instanceof CellLayoutChildren) { |
| 251 | CellLayoutChildren parent = (CellLayoutChildren) getParent(); |
| 252 | if (parent != null) { |
| 253 | CellLayout layout = (CellLayout) parent.getParent(); |
| 254 | layout.setPressedOrFocusedIcon((mPressedOrFocusedBackground != null) ? this : null); |
| 255 | } |
Patrick Dubroy | d69e113 | 2011-03-15 10:29:01 -0700 | [diff] [blame] | 256 | } |
Patrick Dubroy | 3499d8c | 2011-03-10 17:17:23 -0800 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | Bitmap getPressedOrFocusedBackground() { |
| 260 | return mPressedOrFocusedBackground; |
| 261 | } |
| 262 | |
| 263 | int getPressedOrFocusedBackgroundPadding() { |
| 264 | return HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS / 2; |
Michael Jurka | ddd62e9 | 2011-02-16 17:49:14 -0800 | [diff] [blame] | 265 | } |
Patrick Dubroy | a017c03 | 2011-03-09 15:58:32 -0800 | [diff] [blame] | 266 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 267 | @Override |
| 268 | public void draw(Canvas canvas) { |
Michael Jurka | bdb5c53 | 2011-02-01 15:05:06 -0800 | [diff] [blame] | 269 | final Drawable background = mBackground; |
| 270 | if (background != null) { |
| 271 | final int scrollX = mScrollX; |
| 272 | final int scrollY = mScrollY; |
Winson Chung | 8812703 | 2010-12-13 12:11:33 -0800 | [diff] [blame] | 273 | |
Michael Jurka | bdb5c53 | 2011-02-01 15:05:06 -0800 | [diff] [blame] | 274 | if (mBackgroundSizeChanged) { |
| 275 | background.setBounds(0, 0, mRight - mLeft, mBottom - mTop); |
| 276 | mBackgroundSizeChanged = false; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 277 | } |
Michael Jurka | bdb5c53 | 2011-02-01 15:05:06 -0800 | [diff] [blame] | 278 | |
| 279 | if ((scrollX | scrollY) == 0) { |
| 280 | background.draw(canvas); |
| 281 | } else { |
| 282 | canvas.translate(scrollX, scrollY); |
| 283 | background.draw(canvas); |
| 284 | canvas.translate(-scrollX, -scrollY); |
| 285 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 286 | } |
Michael Jurka | bdb5c53 | 2011-02-01 15:05:06 -0800 | [diff] [blame] | 287 | // We enhance the shadow by drawing the shadow twice |
Michael Jurka | e7e3f6c | 2011-02-01 21:08:29 -0800 | [diff] [blame] | 288 | getPaint().setShadowLayer(SHADOW_LARGE_RADIUS, 0.0f, SHADOW_Y_OFFSET, SHADOW_LARGE_COLOUR); |
Michael Jurka | bdb5c53 | 2011-02-01 15:05:06 -0800 | [diff] [blame] | 289 | super.draw(canvas); |
| 290 | canvas.save(Canvas.CLIP_SAVE_FLAG); |
| 291 | canvas.clipRect(mScrollX, mScrollY + getExtendedPaddingTop(), mScrollX + getWidth(), |
Winson Chung | 0969300 | 2011-02-03 23:56:47 -0800 | [diff] [blame] | 292 | mScrollY + getHeight(), Region.Op.INTERSECT); |
Michael Jurka | e7e3f6c | 2011-02-01 21:08:29 -0800 | [diff] [blame] | 293 | getPaint().setShadowLayer(SHADOW_SMALL_RADIUS, 0.0f, 0.0f, SHADOW_SMALL_COLOUR); |
Michael Jurka | bdb5c53 | 2011-02-01 15:05:06 -0800 | [diff] [blame] | 294 | super.draw(canvas); |
| 295 | canvas.restore(); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 296 | } |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 297 | |
| 298 | @Override |
| 299 | protected void onAttachedToWindow() { |
| 300 | super.onAttachedToWindow(); |
Winson Chung | 656d11c | 2010-11-29 17:15:47 -0800 | [diff] [blame] | 301 | if (mBackground != null) mBackground.setCallback(this); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | @Override |
| 305 | protected void onDetachedFromWindow() { |
| 306 | super.onDetachedFromWindow(); |
Winson Chung | 656d11c | 2010-11-29 17:15:47 -0800 | [diff] [blame] | 307 | if (mBackground != null) mBackground.setCallback(null); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 308 | } |
Winson Chung | affd7b4 | 2010-08-20 15:11:56 -0700 | [diff] [blame] | 309 | |
| 310 | @Override |
| 311 | protected boolean onSetAlpha(int alpha) { |
Winson Chung | e22a8e9 | 2010-11-12 13:40:58 -0800 | [diff] [blame] | 312 | if (mPrevAlpha != alpha) { |
| 313 | mPrevAlpha = alpha; |
Winson Chung | 656d11c | 2010-11-29 17:15:47 -0800 | [diff] [blame] | 314 | mPaint.setAlpha((int) (alpha * mBubbleColorAlpha)); |
Winson Chung | e22a8e9 | 2010-11-12 13:40:58 -0800 | [diff] [blame] | 315 | super.onSetAlpha(alpha); |
| 316 | } |
| 317 | return true; |
Winson Chung | affd7b4 | 2010-08-20 15:11:56 -0700 | [diff] [blame] | 318 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 319 | } |