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