blob: f8e87c57f141bb700e5786de0317110ce205c72a [file] [log] [blame]
The Android Open Source Project31dd5032009-03-03 19:32:27 -08001/*
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
Daniel Sandler325dc232013-06-05 22:57:57 -040017package com.android.launcher3;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080018
Tony8f402802017-06-16 17:24:54 -070019import android.animation.Animator;
Tony Wickham1237df02017-02-24 08:59:36 -080020import android.animation.ObjectAnimator;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080021import android.content.Context;
Adam Cohen96bb7982014-07-07 11:58:56 -070022import android.content.res.ColorStateList;
Adam Cohen96bb7982014-07-07 11:58:56 -070023import android.content.res.TypedArray;
Michael Jurka67b2f6c2010-11-17 12:33:46 -080024import android.graphics.Bitmap;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080025import android.graphics.Canvas;
Tony17b7f9b2017-05-23 12:19:09 -070026import android.graphics.Color;
Winson1f064272016-07-18 17:18:02 -070027import android.graphics.Paint;
Tony Wickham1237df02017-02-24 08:59:36 -080028import android.graphics.Point;
29import android.graphics.Rect;
Michael Jurka137142e2011-01-05 20:57:04 -080030import android.graphics.Region;
Tony17b7f9b2017-05-23 12:19:09 -070031import android.graphics.drawable.ColorDrawable;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080032import android.graphics.drawable.Drawable;
Tony8f402802017-06-16 17:24:54 -070033import android.support.v4.graphics.ColorUtils;
Winson Chung656d11c2010-11-29 17:15:47 -080034import android.util.AttributeSet;
Tony Wickham1237df02017-02-24 08:59:36 -080035import android.util.Property;
Winson Chung5f8afe62013-08-12 16:19:28 -070036import android.util.TypedValue;
Sunny Goyal508da152014-08-14 10:53:27 -070037import android.view.KeyEvent;
Michael Jurka38b4f7c2010-12-14 16:46:39 -080038import android.view.MotionEvent;
Sunny Goyal317698b2015-07-29 11:45:41 -070039import android.view.View;
Jason Monk02dd7ae2014-04-15 15:23:31 -040040import android.view.ViewConfiguration;
Sunny Goyal4ffec482016-02-09 11:28:52 -080041import android.view.ViewDebug;
Sunny Goyal4b6eb262015-05-14 19:24:40 -070042import android.view.ViewParent;
Michael Jurkabdb5c532011-02-01 15:05:06 -080043import android.widget.TextView;
Sunny Goyal317698b2015-07-29 11:45:41 -070044
Sunny Goyal34b65272015-03-11 16:56:52 -070045import com.android.launcher3.IconCache.IconLoadRequest;
Sunny Goyal2d7cca12017-01-03 16:52:43 -080046import com.android.launcher3.IconCache.ItemInfoUpdateReceiver;
Tony Wickham9a8d11f2017-01-11 09:53:12 -080047import com.android.launcher3.badge.BadgeInfo;
Tony Wickham010d2552017-01-20 08:15:28 -080048import com.android.launcher3.badge.BadgeRenderer;
Jon Miranda529af302017-02-28 14:18:54 -080049import com.android.launcher3.folder.FolderIconPreviewVerifier;
Sunny Goyal55cb70b2016-11-12 09:58:29 -080050import com.android.launcher3.graphics.DrawableFactory;
Sunny Goyal10629b02016-09-01 12:50:11 -070051import com.android.launcher3.graphics.HolographicOutlineHelper;
Tony Wickham1237df02017-02-24 08:59:36 -080052import com.android.launcher3.graphics.IconPalette;
Sunny Goyal96ac68a2017-02-02 16:37:21 -080053import com.android.launcher3.graphics.PreloadIconDrawable;
Hyunyoung Song2bd3d7d2015-05-21 13:04:53 -070054import com.android.launcher3.model.PackageItemInfo;
Sunny Goyal34b65272015-03-11 16:56:52 -070055
Sunny Goyalc469aad2015-10-01 11:24:23 -070056import java.text.NumberFormat;
57
The Android Open Source Project31dd5032009-03-03 19:32:27 -080058/**
59 * TextView that draws a bubble behind the text. We cannot use a LineBackgroundSpan
60 * because we want to make the bubble taller than the text and TextView's clip is
61 * too aggressive.
62 */
Sunny Goyal2a76e3f2017-02-16 13:33:15 -080063public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver {
Sunny Goyal95abbb32014-08-04 10:53:22 -070064
Sunny Goyal8f8f3982016-07-25 17:08:38 -070065 // Dimensions in DP
66 private static final float AMBIENT_SHADOW_RADIUS = 2.5f;
67 private static final float KEY_SHADOW_RADIUS = 1f;
68 private static final float KEY_SHADOW_OFFSET = 0.5f;
Winson Chung656d11c2010-11-29 17:15:47 -080069
Sunny Goyaldfaccf62015-05-11 16:30:44 -070070 private static final int DISPLAY_WORKSPACE = 0;
71 private static final int DISPLAY_ALL_APPS = 1;
Sunny Goyalbaec6ff2016-09-14 11:26:21 -070072 private static final int DISPLAY_FOLDER = 2;
Sunny Goyaldfaccf62015-05-11 16:30:44 -070073
Sunny Goyal2a76e3f2017-02-16 13:33:15 -080074 private static final int[] STATE_PRESSED = new int[] {android.R.attr.state_pressed};
75
Sunny Goyal53d7ee42015-05-22 12:25:45 -070076 private final Launcher mLauncher;
Winson Chungb745afb2015-03-02 11:51:23 -080077 private Drawable mIcon;
Winson1f064272016-07-18 17:18:02 -070078 private final boolean mCenterVertically;
Sunny Goyal71b5c0b2015-01-08 16:59:04 -080079 private final Drawable mBackground;
Tony Wickham1bce7fd2016-04-28 17:39:03 -070080 private OnLongClickListener mOnLongClickListener;
Sunny Goyal71b5c0b2015-01-08 16:59:04 -080081 private final CheckLongPressHelper mLongPressHelper;
82 private final HolographicOutlineHelper mOutlineHelper;
Mady Melloref044dd2015-06-02 15:35:07 -070083 private final StylusEventHelper mStylusEventHelper;
Mario Bertschlera6936942017-05-31 14:48:19 -070084 private final int mAmbientShadowColor;
85 private final int mKeyShadowColor;
Sunny Goyal71b5c0b2015-01-08 16:59:04 -080086
Sunny Goyal71b5c0b2015-01-08 16:59:04 -080087 private boolean mBackgroundSizeChanged;
88
Sunny Goyal508da152014-08-14 10:53:27 -070089 private Bitmap mPressedBackground;
Michael Jurka38b4f7c2010-12-14 16:46:39 -080090
Jason Monk02dd7ae2014-04-15 15:23:31 -040091 private float mSlop;
92
Winson Chung93f98ea2015-03-10 16:28:47 -070093 private final boolean mDeferShadowGenerationOnTouch;
Sunny Goyal15872da2014-07-08 15:43:54 -070094 private final boolean mCustomShadowsEnabled;
Winson Chungb745afb2015-03-02 11:51:23 -080095 private final boolean mLayoutHorizontal;
96 private final int mIconSize;
Sunny Goyal4ffec482016-02-09 11:28:52 -080097 @ViewDebug.ExportedProperty(category = "launcher")
Winson Chungb745afb2015-03-02 11:51:23 -080098 private int mTextColor;
Tony17b7f9b2017-05-23 12:19:09 -070099 private boolean mIsIconVisible = true;
Winson Chung5f8afe62013-08-12 16:19:28 -0700100
Tony Wickham1237df02017-02-24 08:59:36 -0800101 private BadgeInfo mBadgeInfo;
102 private BadgeRenderer mBadgeRenderer;
Tony Wickham7092db02017-06-07 14:32:23 -0700103 private IconPalette mBadgePalette;
Tony Wickham1237df02017-02-24 08:59:36 -0800104 private float mBadgeScale;
105 private boolean mForceHideBadge;
106 private Point mTempSpaceForBadgeOffset = new Point();
107 private Rect mTempIconBounds = new Rect();
108
109 private static final Property<BubbleTextView, Float> BADGE_SCALE_PROPERTY
110 = new Property<BubbleTextView, Float>(Float.TYPE, "badgeScale") {
111 @Override
112 public Float get(BubbleTextView bubbleTextView) {
113 return bubbleTextView.mBadgeScale;
114 }
115
116 @Override
117 public void set(BubbleTextView bubbleTextView, Float value) {
118 bubbleTextView.mBadgeScale = value;
119 bubbleTextView.invalidate();
120 }
121 };
122
Tony8f402802017-06-16 17:24:54 -0700123 private static final Property<BubbleTextView, Integer> TEXT_ALPHA_PROPERTY
124 = new Property<BubbleTextView, Integer>(Integer.class, "textAlpha") {
125 @Override
126 public Integer get(BubbleTextView bubbleTextView) {
127 return bubbleTextView.getTextAlpha();
128 }
129
130 @Override
131 public void set(BubbleTextView bubbleTextView, Integer alpha) {
132 bubbleTextView.setTextAlpha(alpha);
133 }
134 };
135
Sunny Goyal4ffec482016-02-09 11:28:52 -0800136 @ViewDebug.ExportedProperty(category = "launcher")
Michael Jurkaddd62e92011-02-16 17:49:14 -0800137 private boolean mStayPressed;
Sunny Goyal4ffec482016-02-09 11:28:52 -0800138 @ViewDebug.ExportedProperty(category = "launcher")
Sunny Goyal508da152014-08-14 10:53:27 -0700139 private boolean mIgnorePressedStateChange;
Sunny Goyal4ffec482016-02-09 11:28:52 -0800140 @ViewDebug.ExportedProperty(category = "launcher")
Sunny Goyal69b75642015-05-15 17:00:24 -0700141 private boolean mDisableRelayout = false;
Chris Wrenaeff7ea2014-02-14 16:59:24 -0500142
Sunny Goyal34b65272015-03-11 16:56:52 -0700143 private IconLoadRequest mIconLoadRequest;
144
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800145 public BubbleTextView(Context context) {
Adam Cohen96bb7982014-07-07 11:58:56 -0700146 this(context, null, 0);
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800147 }
148
149 public BubbleTextView(Context context, AttributeSet attrs) {
Adam Cohen96bb7982014-07-07 11:58:56 -0700150 this(context, attrs, 0);
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800151 }
152
153 public BubbleTextView(Context context, AttributeSet attrs, int defStyle) {
154 super(context, attrs, defStyle);
Andrew Sappersteinabef55a2016-06-19 12:49:00 -0700155 mLauncher = Launcher.getLauncher(context);
Sunny Goyal53d7ee42015-05-22 12:25:45 -0700156 DeviceProfile grid = mLauncher.getDeviceProfile();
Adam Cohen96bb7982014-07-07 11:58:56 -0700157
Adam Cohen96bb7982014-07-07 11:58:56 -0700158 TypedArray a = context.obtainStyledAttributes(attrs,
159 R.styleable.BubbleTextView, defStyle, 0);
Sunny Goyal1f3f07d2017-02-10 16:52:16 -0800160 mCustomShadowsEnabled = a.getBoolean(R.styleable.BubbleTextView_customShadows, false);
Winson Chungb745afb2015-03-02 11:51:23 -0800161 mLayoutHorizontal = a.getBoolean(R.styleable.BubbleTextView_layoutHorizontal, false);
Winson Chung93f98ea2015-03-10 16:28:47 -0700162 mDeferShadowGenerationOnTouch =
163 a.getBoolean(R.styleable.BubbleTextView_deferShadowGeneration, false);
Mario Bertschlera6936942017-05-31 14:48:19 -0700164 mAmbientShadowColor = a.getColor(R.styleable.BubbleTextView_ambientShadowColor, 0x33000000);
165 mKeyShadowColor = a.getColor(R.styleable.BubbleTextView_keyShadowColor, 0x66000000);
Sunny Goyaldfaccf62015-05-11 16:30:44 -0700166
167 int display = a.getInteger(R.styleable.BubbleTextView_iconDisplay, DISPLAY_WORKSPACE);
168 int defaultIconSize = grid.iconSizePx;
169 if (display == DISPLAY_WORKSPACE) {
Winson Chung44d0aac2015-05-11 18:02:55 -0700170 setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.iconTextSizePx);
Jon Miranda09660722017-06-14 14:20:14 -0700171 setCompoundDrawablePadding(grid.iconDrawablePaddingPx);
Sunny Goyaldfaccf62015-05-11 16:30:44 -0700172 } else if (display == DISPLAY_ALL_APPS) {
Winson1f064272016-07-18 17:18:02 -0700173 setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.allAppsIconTextSizePx);
174 setCompoundDrawablePadding(grid.allAppsIconDrawablePaddingPx);
Sunny Goyaldfaccf62015-05-11 16:30:44 -0700175 defaultIconSize = grid.allAppsIconSizePx;
Sunny Goyalbaec6ff2016-09-14 11:26:21 -0700176 } else if (display == DISPLAY_FOLDER) {
Jon Mirandabf7d8122016-11-03 15:29:29 -0700177 setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.folderChildTextSizePx);
Sunny Goyalbaec6ff2016-09-14 11:26:21 -0700178 setCompoundDrawablePadding(grid.folderChildDrawablePaddingPx);
Jon Mirandabf7d8122016-11-03 15:29:29 -0700179 defaultIconSize = grid.folderChildIconSizePx;
Sunny Goyaldfaccf62015-05-11 16:30:44 -0700180 }
Winson1f064272016-07-18 17:18:02 -0700181 mCenterVertically = a.getBoolean(R.styleable.BubbleTextView_centerVertically, false);
Sunny Goyaldfaccf62015-05-11 16:30:44 -0700182
183 mIconSize = a.getDimensionPixelSize(R.styleable.BubbleTextView_iconSizeOverride,
184 defaultIconSize);
Adam Cohen96bb7982014-07-07 11:58:56 -0700185 a.recycle();
186
Sunny Goyal15872da2014-07-08 15:43:54 -0700187 if (mCustomShadowsEnabled) {
188 // Draw the background itself as the parent is drawn twice.
189 mBackground = getBackground();
190 setBackground(null);
Sunny Goyal8f8f3982016-07-25 17:08:38 -0700191
192 // Set shadow layer as the larger shadow to that the textView does not clip the shadow.
193 float density = getResources().getDisplayMetrics().density;
Mario Bertschlera6936942017-05-31 14:48:19 -0700194 setShadowLayer(density * AMBIENT_SHADOW_RADIUS, 0, 0, mAmbientShadowColor);
Sunny Goyal15872da2014-07-08 15:43:54 -0700195 } else {
196 mBackground = null;
197 }
Winson Chungb745afb2015-03-02 11:51:23 -0800198
Sunny Goyal71b5c0b2015-01-08 16:59:04 -0800199 mLongPressHelper = new CheckLongPressHelper(this);
Mady Mellorbb835202015-07-15 16:34:34 -0700200 mStylusEventHelper = new StylusEventHelper(new SimpleOnStylusPressListener(this), this);
Sunny Goyal71b5c0b2015-01-08 16:59:04 -0800201
Sunny Goyal10629b02016-09-01 12:50:11 -0700202 mOutlineHelper = HolographicOutlineHelper.getInstance(getContext());
Sunny Goyalae502842016-06-17 08:43:56 -0700203 setAccessibilityDelegate(mLauncher.getAccessibilityDelegate());
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800204 }
205
Sunny Goyal1cd01b02016-11-09 10:43:58 -0800206 public void applyFromShortcutInfo(ShortcutInfo info) {
207 applyFromShortcutInfo(info, false);
Winson Chung5f8afe62013-08-12 16:19:28 -0700208 }
209
Sunny Goyal1cd01b02016-11-09 10:43:58 -0800210 public void applyFromShortcutInfo(ShortcutInfo info, boolean promiseStateChanged) {
211 applyIconAndLabel(info.iconBitmap, info);
Michael Jurka67b2f6c2010-11-17 12:33:46 -0800212 setTag(info);
Sunny Goyal34942622014-08-29 17:20:55 -0700213 if (promiseStateChanged || info.isPromise()) {
Tony Wickham9a8d11f2017-01-11 09:53:12 -0800214 applyPromiseState(promiseStateChanged);
Chris Wrenaeff7ea2014-02-14 16:59:24 -0500215 }
Tony Wickham010d2552017-01-20 08:15:28 -0800216
Tony Wickham1e618492017-02-02 12:57:18 -0800217 applyBadgeState(info, false /* animate */);
Michael Jurka67b2f6c2010-11-17 12:33:46 -0800218 }
219
Sunny Goyal508da152014-08-14 10:53:27 -0700220 public void applyFromApplicationInfo(AppInfo info) {
Sunny Goyalf4204382016-07-13 10:46:07 -0700221 applyIconAndLabel(info.iconBitmap, info);
222
Winson Chung888b3a12015-03-13 11:14:16 -0700223 // We don't need to check the info since it's not a ShortcutInfo
224 super.setTag(info);
Sunny Goyal34b65272015-03-11 16:56:52 -0700225
226 // Verify high res immediately
227 verifyHighRes();
Tony Wickham010d2552017-01-20 08:15:28 -0800228
Mario Bertschler08ffaae2017-03-20 11:30:27 -0700229 if (info instanceof PromiseAppInfo) {
230 PromiseAppInfo promiseAppInfo = (PromiseAppInfo) info;
231 applyProgressLevel(promiseAppInfo.level);
232 }
Tony Wickham1e618492017-02-02 12:57:18 -0800233 applyBadgeState(info, false /* animate */);
Sunny Goyal508da152014-08-14 10:53:27 -0700234 }
235
Sunny Goyal0e08f162015-05-12 11:32:39 -0700236 public void applyFromPackageItemInfo(PackageItemInfo info) {
Sunny Goyalf4204382016-07-13 10:46:07 -0700237 applyIconAndLabel(info.iconBitmap, info);
Sunny Goyal0e08f162015-05-12 11:32:39 -0700238 // We don't need to check the info since it's not a ShortcutInfo
239 super.setTag(info);
240
241 // Verify high res immediately
242 verifyHighRes();
243 }
244
Sunny Goyalf4204382016-07-13 10:46:07 -0700245 private void applyIconAndLabel(Bitmap icon, ItemInfo info) {
Sunny Goyal55cb70b2016-11-12 09:58:29 -0800246 FastBitmapDrawable iconDrawable = DrawableFactory.get(getContext()).newIcon(icon, info);
Tony Wickham6b910a22016-11-08 10:40:34 -0800247 iconDrawable.setIsDisabled(info.isDisabled());
Sunny Goyalf4204382016-07-13 10:46:07 -0700248 setIcon(iconDrawable);
249 setText(info.title);
250 if (info.contentDescription != null) {
251 setContentDescription(info.isDisabled()
252 ? getContext().getString(R.string.disabled_app_label, info.contentDescription)
253 : info.contentDescription);
254 }
255 }
256
Winson Chung7501adf2015-06-02 11:24:28 -0700257 /**
258 * Overrides the default long press timeout.
259 */
260 public void setLongPressTimeout(int longPressTimeout) {
261 mLongPressHelper.setLongPressTimeout(longPressTimeout);
262 }
Sunny Goyal0e08f162015-05-12 11:32:39 -0700263
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800264 @Override
265 protected boolean setFrame(int left, int top, int right, int bottom) {
Michael Jurka8b805b12012-04-18 14:23:14 -0700266 if (getLeft() != left || getRight() != right || getTop() != top || getBottom() != bottom) {
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800267 mBackgroundSizeChanged = true;
268 }
269 return super.setFrame(left, top, right, bottom);
270 }
271
272 @Override
273 protected boolean verifyDrawable(Drawable who) {
274 return who == mBackground || super.verifyDrawable(who);
275 }
276
277 @Override
Michael Jurka816474f2012-06-25 14:49:02 -0700278 public void setTag(Object tag) {
279 if (tag != null) {
280 LauncherModel.checkItemInfo((ItemInfo) tag);
281 }
282 super.setTag(tag);
283 }
284
285 @Override
Sunny Goyal2a76e3f2017-02-16 13:33:15 -0800286 public void refreshDrawableState() {
Sunny Goyal508da152014-08-14 10:53:27 -0700287 if (!mIgnorePressedStateChange) {
Sunny Goyal2a76e3f2017-02-16 13:33:15 -0800288 super.refreshDrawableState();
Michael Jurka38b4f7c2010-12-14 16:46:39 -0800289 }
Sunny Goyal508da152014-08-14 10:53:27 -0700290 }
Michael Jurka38b4f7c2010-12-14 16:46:39 -0800291
Sunny Goyal2a76e3f2017-02-16 13:33:15 -0800292 @Override
293 protected int[] onCreateDrawableState(int extraSpace) {
294 final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
295 if (mStayPressed) {
296 mergeDrawableStates(drawableState, STATE_PRESSED);
297 }
298 return drawableState;
299 }
300
Winson Chungb745afb2015-03-02 11:51:23 -0800301 /** Returns the icon for this view. */
302 public Drawable getIcon() {
303 return mIcon;
304 }
305
306 /** Returns whether the layout is horizontal. */
307 public boolean isLayoutHorizontal() {
308 return mLayoutHorizontal;
309 }
310
Michael Jurka38b4f7c2010-12-14 16:46:39 -0800311 @Override
Tony Wickham1bce7fd2016-04-28 17:39:03 -0700312 public void setOnLongClickListener(OnLongClickListener l) {
313 super.setOnLongClickListener(l);
314 mOnLongClickListener = l;
315 }
316
317 public OnLongClickListener getOnLongClickListener() {
318 return mOnLongClickListener;
319 }
320
321 @Override
Michael Jurka38b4f7c2010-12-14 16:46:39 -0800322 public boolean onTouchEvent(MotionEvent event) {
323 // Call the superclass onTouchEvent first, because sometimes it changes the state to
324 // isPressed() on an ACTION_UP
325 boolean result = super.onTouchEvent(event);
326
Mady Melloref044dd2015-06-02 15:35:07 -0700327 // Check for a stylus button press, if it occurs cancel any long press checks.
Mady Mellorbb835202015-07-15 16:34:34 -0700328 if (mStylusEventHelper.onMotionEvent(event)) {
Mady Melloref044dd2015-06-02 15:35:07 -0700329 mLongPressHelper.cancelLongPress();
330 result = true;
331 }
332
Michael Jurka38b4f7c2010-12-14 16:46:39 -0800333 switch (event.getAction()) {
334 case MotionEvent.ACTION_DOWN:
Sunny Goyal508da152014-08-14 10:53:27 -0700335 // So that the pressed outline is visible immediately on setStayPressed(),
Michael Jurka38b4f7c2010-12-14 16:46:39 -0800336 // we pre-create it on ACTION_DOWN (it takes a small but perceptible amount of time
337 // to create it)
Winson Chung93f98ea2015-03-10 16:28:47 -0700338 if (!mDeferShadowGenerationOnTouch && mPressedBackground == null) {
Sunny Goyal508da152014-08-14 10:53:27 -0700339 mPressedBackground = mOutlineHelper.createMediumDropShadow(this);
Michael Jurka38b4f7c2010-12-14 16:46:39 -0800340 }
Winson Chung88f33452012-02-23 15:23:44 -0800341
Mady Melloref044dd2015-06-02 15:35:07 -0700342 // If we're in a stylus button press, don't check for long press.
343 if (!mStylusEventHelper.inStylusButtonPressed()) {
344 mLongPressHelper.postCheckForLongPress();
345 }
Michael Jurka38b4f7c2010-12-14 16:46:39 -0800346 break;
347 case MotionEvent.ACTION_CANCEL:
348 case MotionEvent.ACTION_UP:
349 // If we've touched down and up on an item, and it's still not "pressed", then
350 // destroy the pressed outline
351 if (!isPressed()) {
Sunny Goyal508da152014-08-14 10:53:27 -0700352 mPressedBackground = null;
Michael Jurka38b4f7c2010-12-14 16:46:39 -0800353 }
Winson Chung88f33452012-02-23 15:23:44 -0800354
355 mLongPressHelper.cancelLongPress();
Michael Jurka38b4f7c2010-12-14 16:46:39 -0800356 break;
Jason Monk02dd7ae2014-04-15 15:23:31 -0400357 case MotionEvent.ACTION_MOVE:
358 if (!Utilities.pointInView(this, event.getX(), event.getY(), mSlop)) {
359 mLongPressHelper.cancelLongPress();
360 }
361 break;
Michael Jurka38b4f7c2010-12-14 16:46:39 -0800362 }
363 return result;
364 }
365
Michael Jurkaddd62e92011-02-16 17:49:14 -0800366 void setStayPressed(boolean stayPressed) {
367 mStayPressed = stayPressed;
368 if (!stayPressed) {
Sunny Goyal10629b02016-09-01 12:50:11 -0700369 HolographicOutlineHelper.getInstance(getContext()).recycleShadowBitmap(mPressedBackground);
Sunny Goyal508da152014-08-14 10:53:27 -0700370 mPressedBackground = null;
Winson Chung93f98ea2015-03-10 16:28:47 -0700371 } else {
372 if (mPressedBackground == null) {
373 mPressedBackground = mOutlineHelper.createMediumDropShadow(this);
374 }
Michael Jurkaddd62e92011-02-16 17:49:14 -0800375 }
Sunny Goyal508da152014-08-14 10:53:27 -0700376
377 // Only show the shadow effect when persistent pressed state is set.
Sunny Goyal4b6eb262015-05-14 19:24:40 -0700378 ViewParent parent = getParent();
379 if (parent != null && parent.getParent() instanceof BubbleTextShadowHandler) {
380 ((BubbleTextShadowHandler) parent.getParent()).setPressedIcon(
381 this, mPressedBackground);
Sunny Goyal508da152014-08-14 10:53:27 -0700382 }
383
Sunny Goyal2a76e3f2017-02-16 13:33:15 -0800384 refreshDrawableState();
Patrick Dubroy3499d8c2011-03-10 17:17:23 -0800385 }
386
Sunny Goyal508da152014-08-14 10:53:27 -0700387 void clearPressedBackground() {
388 setPressed(false);
389 setStayPressed(false);
390 }
391
392 @Override
393 public boolean onKeyDown(int keyCode, KeyEvent event) {
394 if (super.onKeyDown(keyCode, event)) {
395 // Pre-create shadow so show immediately on click.
396 if (mPressedBackground == null) {
397 mPressedBackground = mOutlineHelper.createMediumDropShadow(this);
Adam Cohen76fc0852011-06-17 13:26:23 -0700398 }
Sunny Goyal508da152014-08-14 10:53:27 -0700399 return true;
Patrick Dubroyd69e1132011-03-15 10:29:01 -0700400 }
Sunny Goyal508da152014-08-14 10:53:27 -0700401 return false;
Patrick Dubroy3499d8c2011-03-10 17:17:23 -0800402 }
403
Sunny Goyal508da152014-08-14 10:53:27 -0700404 @Override
405 public boolean onKeyUp(int keyCode, KeyEvent event) {
406 // Unlike touch events, keypress event propagate pressed state change immediately,
407 // without waiting for onClickHandler to execute. Disable pressed state changes here
408 // to avoid flickering.
409 mIgnorePressedStateChange = true;
410 boolean result = super.onKeyUp(keyCode, event);
Winson Chung1e9cbfe2011-09-30 16:52:26 -0700411
Sunny Goyal508da152014-08-14 10:53:27 -0700412 mPressedBackground = null;
413 mIgnorePressedStateChange = false;
Sunny Goyal2a76e3f2017-02-16 13:33:15 -0800414 refreshDrawableState();
Sunny Goyal508da152014-08-14 10:53:27 -0700415 return result;
Michael Jurkaddd62e92011-02-16 17:49:14 -0800416 }
Patrick Dubroya017c032011-03-09 15:58:32 -0800417
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800418 @Override
419 public void draw(Canvas canvas) {
Adam Cohen96bb7982014-07-07 11:58:56 -0700420 if (!mCustomShadowsEnabled) {
Adam Cohen477828c2013-09-20 12:05:49 -0700421 super.draw(canvas);
Tony Wickham1237df02017-02-24 08:59:36 -0800422 drawBadgeIfNecessary(canvas);
Adam Cohen477828c2013-09-20 12:05:49 -0700423 return;
424 }
425
Michael Jurkabdb5c532011-02-01 15:05:06 -0800426 final Drawable background = mBackground;
427 if (background != null) {
Michael Jurka8b805b12012-04-18 14:23:14 -0700428 final int scrollX = getScrollX();
429 final int scrollY = getScrollY();
Winson Chung88127032010-12-13 12:11:33 -0800430
Michael Jurkabdb5c532011-02-01 15:05:06 -0800431 if (mBackgroundSizeChanged) {
Michael Jurka8b805b12012-04-18 14:23:14 -0700432 background.setBounds(0, 0, getRight() - getLeft(), getBottom() - getTop());
Michael Jurkabdb5c532011-02-01 15:05:06 -0800433 mBackgroundSizeChanged = false;
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800434 }
Michael Jurkabdb5c532011-02-01 15:05:06 -0800435
436 if ((scrollX | scrollY) == 0) {
437 background.draw(canvas);
438 } else {
439 canvas.translate(scrollX, scrollY);
440 background.draw(canvas);
441 canvas.translate(-scrollX, -scrollY);
442 }
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800443 }
Andrew Flynn0dca1ec2012-02-29 13:33:22 -0800444
445 // If text is transparent, don't draw any shadow
Sunny Goyal1f3f07d2017-02-10 16:52:16 -0800446 if ((getCurrentTextColor() >> 24) == 0) {
Andrew Flynn0dca1ec2012-02-29 13:33:22 -0800447 getPaint().clearShadowLayer();
448 super.draw(canvas);
Tony Wickham1237df02017-02-24 08:59:36 -0800449 drawBadgeIfNecessary(canvas);
Andrew Flynn0dca1ec2012-02-29 13:33:22 -0800450 return;
451 }
452
Michael Jurkabdb5c532011-02-01 15:05:06 -0800453 // We enhance the shadow by drawing the shadow twice
Sunny Goyal8f8f3982016-07-25 17:08:38 -0700454 float density = getResources().getDisplayMetrics().density;
Mario Bertschlera6936942017-05-31 14:48:19 -0700455 getPaint().setShadowLayer(density * AMBIENT_SHADOW_RADIUS, 0, 0, mAmbientShadowColor);
Michael Jurkabdb5c532011-02-01 15:05:06 -0800456 super.draw(canvas);
457 canvas.save(Canvas.CLIP_SAVE_FLAG);
Michael Jurka8b805b12012-04-18 14:23:14 -0700458 canvas.clipRect(getScrollX(), getScrollY() + getExtendedPaddingTop(),
459 getScrollX() + getWidth(),
460 getScrollY() + getHeight(), Region.Op.INTERSECT);
Sunny Goyal8f8f3982016-07-25 17:08:38 -0700461 getPaint().setShadowLayer(
Mario Bertschlera6936942017-05-31 14:48:19 -0700462 density * KEY_SHADOW_RADIUS, 0.0f, density * KEY_SHADOW_OFFSET, mKeyShadowColor);
Michael Jurkabdb5c532011-02-01 15:05:06 -0800463 super.draw(canvas);
464 canvas.restore();
Tony Wickham1237df02017-02-24 08:59:36 -0800465
466 drawBadgeIfNecessary(canvas);
467 }
468
469 /**
470 * Draws the icon badge in the top right corner of the icon bounds.
471 * @param canvas The canvas to draw to.
472 */
473 private void drawBadgeIfNecessary(Canvas canvas) {
474 if (!mForceHideBadge && (hasBadge() || mBadgeScale > 0)) {
475 getIconBounds(mTempIconBounds);
476 mTempSpaceForBadgeOffset.set((getWidth() - mIconSize) / 2, getPaddingTop());
477 final int scrollX = getScrollX();
478 final int scrollY = getScrollY();
479 canvas.translate(scrollX, scrollY);
Tony Wickham7092db02017-06-07 14:32:23 -0700480 mBadgeRenderer.draw(canvas, mBadgePalette, mBadgeInfo, mTempIconBounds, mBadgeScale,
Tony Wickham1237df02017-02-24 08:59:36 -0800481 mTempSpaceForBadgeOffset);
482 canvas.translate(-scrollX, -scrollY);
483 }
484 }
485
486 public void forceHideBadge(boolean forceHideBadge) {
487 if (mForceHideBadge == forceHideBadge) {
488 return;
489 }
490 mForceHideBadge = forceHideBadge;
491
492 if (forceHideBadge) {
493 invalidate();
494 } else if (hasBadge()) {
495 ObjectAnimator.ofFloat(this, BADGE_SCALE_PROPERTY, 0, 1).start();
496 }
497 }
498
499 private boolean hasBadge() {
Tony Wickham0530e8c2017-04-26 18:13:56 -0700500 return mBadgeInfo != null;
Tony Wickham1237df02017-02-24 08:59:36 -0800501 }
502
503 public void getIconBounds(Rect outBounds) {
504 int top = getPaddingTop();
505 int left = (getWidth() - mIconSize) / 2;
506 int right = left + mIconSize;
507 int bottom = top + mIconSize;
508 outBounds.set(left, top, right, bottom);
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800509 }
Joe Onorato9c1289c2009-08-17 11:03:03 -0400510
511 @Override
512 protected void onAttachedToWindow() {
513 super.onAttachedToWindow();
Sunny Goyal95abbb32014-08-04 10:53:22 -0700514
Winson Chung656d11c2010-11-29 17:15:47 -0800515 if (mBackground != null) mBackground.setCallback(this);
Jason Monk02dd7ae2014-04-15 15:23:31 -0400516 mSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
Joe Onorato9c1289c2009-08-17 11:03:03 -0400517 }
518
519 @Override
Winson1f064272016-07-18 17:18:02 -0700520 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
521 if (mCenterVertically) {
522 Paint.FontMetrics fm = getPaint().getFontMetrics();
523 int cellHeightPx = mIconSize + getCompoundDrawablePadding() +
524 (int) Math.ceil(fm.bottom - fm.top);
525 int height = MeasureSpec.getSize(heightMeasureSpec);
526 setPadding(getPaddingLeft(), (height - cellHeightPx) / 2, getPaddingRight(),
527 getPaddingBottom());
528 }
529 super.onMeasure(widthMeasureSpec, heightMeasureSpec);
530 }
531
532 @Override
Joe Onorato9c1289c2009-08-17 11:03:03 -0400533 protected void onDetachedFromWindow() {
534 super.onDetachedFromWindow();
Winson Chung656d11c2010-11-29 17:15:47 -0800535 if (mBackground != null) mBackground.setCallback(null);
Joe Onorato9c1289c2009-08-17 11:03:03 -0400536 }
Winson Chungaffd7b42010-08-20 15:11:56 -0700537
Adam Cohen477828c2013-09-20 12:05:49 -0700538 @Override
539 public void setTextColor(int color) {
540 mTextColor = color;
541 super.setTextColor(color);
542 }
543
Adam Cohen96bb7982014-07-07 11:58:56 -0700544 @Override
545 public void setTextColor(ColorStateList colors) {
546 mTextColor = colors.getDefaultColor();
547 super.setTextColor(colors);
Adam Cohen477828c2013-09-20 12:05:49 -0700548 }
549
Winson Chung5f8afe62013-08-12 16:19:28 -0700550 public void setTextVisibility(boolean visible) {
Winson Chung5f8afe62013-08-12 16:19:28 -0700551 if (visible) {
Adam Cohen477828c2013-09-20 12:05:49 -0700552 super.setTextColor(mTextColor);
Winson Chung5f8afe62013-08-12 16:19:28 -0700553 } else {
Tony8f402802017-06-16 17:24:54 -0700554 setTextAlpha(0);
Winson Chung5f8afe62013-08-12 16:19:28 -0700555 }
Winson Chung5f8afe62013-08-12 16:19:28 -0700556 }
557
Tony8f402802017-06-16 17:24:54 -0700558 private void setTextAlpha(int alpha) {
559 super.setTextColor(ColorUtils.setAlphaComponent(mTextColor, alpha));
560 }
561
562 private int getTextAlpha() {
563 return Color.alpha(getCurrentTextColor());
564 }
565
566 /**
567 * Creates an animator to fade the text in or out.
568 * @param fadeIn Whether the text should fade in or fade out.
569 */
570 public Animator createTextAlphaAnimator(boolean fadeIn) {
571 return ObjectAnimator.ofInt(this, TEXT_ALPHA_PROPERTY, fadeIn ? Color.alpha(mTextColor) : 0);
572 }
573
Winson Chungaffd7b42010-08-20 15:11:56 -0700574 @Override
Winson Chung88f33452012-02-23 15:23:44 -0800575 public void cancelLongPress() {
576 super.cancelLongPress();
577
578 mLongPressHelper.cancelLongPress();
579 }
Chris Wrenaeff7ea2014-02-14 16:59:24 -0500580
Tony Wickham9a8d11f2017-01-11 09:53:12 -0800581 public void applyPromiseState(boolean promiseStateChanged) {
Sunny Goyale755d462014-07-22 13:48:29 -0700582 if (getTag() instanceof ShortcutInfo) {
Chris Wren40c5ed32014-06-24 18:24:23 -0400583 ShortcutInfo info = (ShortcutInfo) getTag();
Sunny Goyal34942622014-08-29 17:20:55 -0700584 final boolean isPromise = info.isPromise();
585 final int progressLevel = isPromise ?
586 ((info.hasStatusFlag(ShortcutInfo.FLAG_INSTALL_SESSION_ACTIVE) ?
587 info.getInstallProgress() : 0)) : 100;
Sunny Goyale755d462014-07-22 13:48:29 -0700588
Mario Bertschler08ffaae2017-03-20 11:30:27 -0700589 PreloadIconDrawable preloadDrawable = applyProgressLevel(progressLevel);
590 if (preloadDrawable != null && promiseStateChanged) {
591 preloadDrawable.maybePerformFinishedAnimation();
592 }
593 }
594 }
595
596 public PreloadIconDrawable applyProgressLevel(int progressLevel) {
597 if (getTag() instanceof ItemInfoWithIcon) {
598 ItemInfoWithIcon info = (ItemInfoWithIcon) getTag();
599 setContentDescription(progressLevel > 0
600 ? getContext().getString(R.string.app_downloading_title, info.title,
601 NumberFormat.getPercentInstance().format(progressLevel * 0.01))
602 : getContext().getString(R.string.app_waiting_download_title, info.title));
Sunny Goyalc469aad2015-10-01 11:24:23 -0700603
Winson Chungb745afb2015-03-02 11:51:23 -0800604 if (mIcon != null) {
Sunny Goyale755d462014-07-22 13:48:29 -0700605 final PreloadIconDrawable preloadDrawable;
Winson Chungb745afb2015-03-02 11:51:23 -0800606 if (mIcon instanceof PreloadIconDrawable) {
607 preloadDrawable = (PreloadIconDrawable) mIcon;
Mario Bertschler08ffaae2017-03-20 11:30:27 -0700608 preloadDrawable.setLevel(progressLevel);
Sunny Goyale755d462014-07-22 13:48:29 -0700609 } else {
Sunny Goyal96ac68a2017-02-02 16:37:21 -0800610 preloadDrawable = DrawableFactory.get(getContext())
611 .newPendingIcon(info.iconBitmap, getContext());
Mario Bertschler08ffaae2017-03-20 11:30:27 -0700612 preloadDrawable.setLevel(progressLevel);
Tony Wickhambfbf7f92016-05-19 11:19:39 -0700613 setIcon(preloadDrawable);
Sunny Goyale755d462014-07-22 13:48:29 -0700614 }
Mario Bertschler08ffaae2017-03-20 11:30:27 -0700615 return preloadDrawable;
Sunny Goyale755d462014-07-22 13:48:29 -0700616 }
Chris Wren40c5ed32014-06-24 18:24:23 -0400617 }
Mario Bertschler08ffaae2017-03-20 11:30:27 -0700618 return null;
Chris Wren40c5ed32014-06-24 18:24:23 -0400619 }
Sunny Goyal95abbb32014-08-04 10:53:22 -0700620
Tony Wickham1e618492017-02-02 12:57:18 -0800621 public void applyBadgeState(ItemInfo itemInfo, boolean animate) {
Tony Wickham9a8d11f2017-01-11 09:53:12 -0800622 if (mIcon instanceof FastBitmapDrawable) {
Tony Wickham1237df02017-02-24 08:59:36 -0800623 boolean wasBadged = mBadgeInfo != null;
Tony Wickham2fe09f22017-04-25 12:46:04 -0700624 mBadgeInfo = mLauncher.getPopupDataProvider().getBadgeInfoForItem(itemInfo);
625 boolean isBadged = mBadgeInfo != null;
Tony Wickham1237df02017-02-24 08:59:36 -0800626 float newBadgeScale = isBadged ? 1f : 0;
Tony Wickham2fe09f22017-04-25 12:46:04 -0700627 mBadgeRenderer = mLauncher.getDeviceProfile().mBadgeRenderer;
Tony Wickham1237df02017-02-24 08:59:36 -0800628 if (wasBadged || isBadged) {
Tony Wickham7092db02017-06-07 14:32:23 -0700629 mBadgePalette = IconPalette.getBadgePalette(getResources());
630 if (mBadgePalette == null) {
631 mBadgePalette = ((FastBitmapDrawable) mIcon).getIconPalette();
632 }
Tony Wickham1237df02017-02-24 08:59:36 -0800633 // Animate when a badge is first added or when it is removed.
634 if (animate && (wasBadged ^ isBadged) && isShown()) {
635 ObjectAnimator.ofFloat(this, BADGE_SCALE_PROPERTY, newBadgeScale).start();
636 } else {
637 mBadgeScale = newBadgeScale;
638 invalidate();
639 }
640 }
Tony Wickham9a8d11f2017-01-11 09:53:12 -0800641 }
642 }
643
Tony Wickham7092db02017-06-07 14:32:23 -0700644 public IconPalette getBadgePalette() {
645 return mBadgePalette;
646 }
647
Winson Chungb745afb2015-03-02 11:51:23 -0800648 /**
649 * Sets the icon for this view based on the layout direction.
650 */
Tony Wickham377ed3f2016-07-20 15:21:04 -0700651 private void setIcon(Drawable icon) {
Winson Chungb745afb2015-03-02 11:51:23 -0800652 mIcon = icon;
Sunny Goyal55cb70b2016-11-12 09:58:29 -0800653 mIcon.setBounds(0, 0, mIconSize, mIconSize);
Tony17b7f9b2017-05-23 12:19:09 -0700654 if (mIsIconVisible) {
655 applyCompoundDrawables(mIcon);
656 }
657 }
658
659 public void setIconVisible(boolean visible) {
660 mIsIconVisible = visible;
661 mDisableRelayout = true;
662 Drawable icon = mIcon;
663 if (!visible) {
664 icon = new ColorDrawable(Color.TRANSPARENT);
665 icon.setBounds(0, 0, mIconSize, mIconSize);
666 }
667 applyCompoundDrawables(icon);
668 mDisableRelayout = false;
Tony Wickham377ed3f2016-07-20 15:21:04 -0700669 }
670
671 protected void applyCompoundDrawables(Drawable icon) {
Winson Chungb745afb2015-03-02 11:51:23 -0800672 if (mLayoutHorizontal) {
Sunny Goyala52ecb02016-12-16 15:04:51 -0800673 setCompoundDrawablesRelative(icon, null, null, null);
Winson Chungb745afb2015-03-02 11:51:23 -0800674 } else {
Tony Wickham377ed3f2016-07-20 15:21:04 -0700675 setCompoundDrawables(null, icon, null, null);
Winson Chungb745afb2015-03-02 11:51:23 -0800676 }
Winson Chungb745afb2015-03-02 11:51:23 -0800677 }
Sunny Goyal34b65272015-03-11 16:56:52 -0700678
Sunny Goyal69b75642015-05-15 17:00:24 -0700679 @Override
680 public void requestLayout() {
681 if (!mDisableRelayout) {
682 super.requestLayout();
683 }
684 }
685
Sunny Goyal34b65272015-03-11 16:56:52 -0700686 /**
687 * Applies the item info if it is same as what the view is pointing to currently.
688 */
Sunny Goyal2d7cca12017-01-03 16:52:43 -0800689 @Override
690 public void reapplyItemInfo(ItemInfoWithIcon info) {
Sunny Goyal34b65272015-03-11 16:56:52 -0700691 if (getTag() == info) {
692 mIconLoadRequest = null;
Sunny Goyal69b75642015-05-15 17:00:24 -0700693 mDisableRelayout = true;
Winsonc0880492015-08-21 11:16:27 -0700694
Sunny Goyal34b65272015-03-11 16:56:52 -0700695 if (info instanceof AppInfo) {
696 applyFromApplicationInfo((AppInfo) info);
697 } else if (info instanceof ShortcutInfo) {
Sunny Goyal1cd01b02016-11-09 10:43:58 -0800698 applyFromShortcutInfo((ShortcutInfo) info);
Jon Miranda529af302017-02-28 14:18:54 -0800699 FolderIconPreviewVerifier verifier =
700 new FolderIconPreviewVerifier(mLauncher.getDeviceProfile().inv);
701 if (verifier.isItemInPreview(info.rank) && (info.container >= 0)) {
Sunny Goyal317698b2015-07-29 11:45:41 -0700702 View folderIcon =
703 mLauncher.getWorkspace().getHomescreenIconByItemId(info.container);
704 if (folderIcon != null) {
705 folderIcon.invalidate();
706 }
707 }
Sunny Goyal0e08f162015-05-12 11:32:39 -0700708 } else if (info instanceof PackageItemInfo) {
709 applyFromPackageItemInfo((PackageItemInfo) info);
Sunny Goyal34b65272015-03-11 16:56:52 -0700710 }
Winsonc0880492015-08-21 11:16:27 -0700711
Sunny Goyal69b75642015-05-15 17:00:24 -0700712 mDisableRelayout = false;
Sunny Goyal34b65272015-03-11 16:56:52 -0700713 }
714 }
715
716 /**
717 * Verifies that the current icon is high-res otherwise posts a request to load the icon.
718 */
719 public void verifyHighRes() {
720 if (mIconLoadRequest != null) {
721 mIconLoadRequest.cancel();
722 mIconLoadRequest = null;
723 }
Sunny Goyal2d7cca12017-01-03 16:52:43 -0800724 if (getTag() instanceof ItemInfoWithIcon) {
725 ItemInfoWithIcon info = (ItemInfoWithIcon) getTag();
Sunny Goyal0e08f162015-05-12 11:32:39 -0700726 if (info.usingLowResIcon) {
Sunny Goyal87f784c2017-01-11 10:48:34 -0800727 mIconLoadRequest = LauncherAppState.getInstance(getContext()).getIconCache()
Sunny Goyal0e08f162015-05-12 11:32:39 -0700728 .updateIconInBackground(BubbleTextView.this, info);
729 }
Sunny Goyal34b65272015-03-11 16:56:52 -0700730 }
731 }
Sunny Goyal4b6eb262015-05-14 19:24:40 -0700732
Jon Miranda47170112017-03-03 14:57:14 -0800733 public int getIconSize() {
734 return mIconSize;
735 }
736
Sunny Goyal3ffa64d2016-07-25 13:54:32 -0700737 /**
Sunny Goyal4b6eb262015-05-14 19:24:40 -0700738 * Interface to be implemented by the grand parent to allow click shadow effect.
739 */
Winsonc0880492015-08-21 11:16:27 -0700740 public interface BubbleTextShadowHandler {
Sunny Goyal4b6eb262015-05-14 19:24:40 -0700741 void setPressedIcon(BubbleTextView icon, Bitmap background);
742 }
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800743}