blob: c27e3759d7148add5b7733be4adce79fe32e409e [file] [log] [blame]
Winson Chung785d2eb2011-04-14 16:08:02 -07001/*
2 * Copyright (C) 2011 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
17package com.android.launcher2;
18
Winson Chung55b65502011-05-26 12:03:43 -070019import android.animation.AnimatorSet;
Winson Chung4b576be2011-04-27 17:40:20 -070020import android.animation.ObjectAnimator;
Winson Chungd2e87b32011-06-02 10:53:07 -070021import android.animation.ValueAnimator;
Winson Chung785d2eb2011-04-14 16:08:02 -070022import android.appwidget.AppWidgetManager;
23import android.appwidget.AppWidgetProviderInfo;
24import android.content.ComponentName;
25import android.content.Context;
26import android.content.Intent;
Winson Chung46af2e82011-05-09 16:00:53 -070027import android.content.pm.ActivityInfo;
Winson Chung785d2eb2011-04-14 16:08:02 -070028import android.content.pm.PackageManager;
29import android.content.pm.ResolveInfo;
Winson Chungf0ea4d32011-06-06 14:27:16 -070030import android.content.res.Configuration;
Winson Chung785d2eb2011-04-14 16:08:02 -070031import android.content.res.Resources;
32import android.content.res.TypedArray;
33import android.graphics.Bitmap;
Winson Chungf0ea4d32011-06-06 14:27:16 -070034import android.graphics.Bitmap.Config;
Winson Chung785d2eb2011-04-14 16:08:02 -070035import android.graphics.Canvas;
36import android.graphics.Rect;
37import android.graphics.drawable.Drawable;
38import android.util.AttributeSet;
39import android.util.Log;
Winson Chung1ed747a2011-05-03 16:18:34 -070040import android.util.LruCache;
Winson Chung785d2eb2011-04-14 16:08:02 -070041import android.view.LayoutInflater;
42import android.view.View;
Winson Chung63257c12011-05-05 17:06:13 -070043import android.view.ViewGroup;
Winson Chung55b65502011-05-26 12:03:43 -070044import android.view.animation.AccelerateInterpolator;
Winson Chung785d2eb2011-04-14 16:08:02 -070045import android.widget.ImageView;
46import android.widget.TextView;
Winson Chung55b65502011-05-26 12:03:43 -070047import android.widget.Toast;
Winson Chung785d2eb2011-04-14 16:08:02 -070048
49import com.android.launcher.R;
Adam Cohenc0dcf592011-06-01 15:30:43 -070050import com.android.launcher2.DropTarget.DragObject;
51
52import java.util.ArrayList;
53import java.util.Collections;
54import java.util.Iterator;
55import java.util.List;
Winson Chung785d2eb2011-04-14 16:08:02 -070056
57public class AppsCustomizePagedView extends PagedViewWithDraggableItems implements
58 AllAppsView, View.OnClickListener, DragSource {
59 static final String LOG_TAG = "AppsCustomizePagedView";
60
61 /**
62 * The different content types that this paged view can show.
63 */
64 public enum ContentType {
65 Applications,
Winson Chung6a26e5b2011-05-26 14:36:06 -070066 Widgets
Winson Chung785d2eb2011-04-14 16:08:02 -070067 }
68
69 // Refs
70 private Launcher mLauncher;
71 private DragController mDragController;
72 private final LayoutInflater mLayoutInflater;
73 private final PackageManager mPackageManager;
74
75 // Content
76 private ContentType mContentType;
77 private ArrayList<ApplicationInfo> mApps;
Winson Chung1ed747a2011-05-03 16:18:34 -070078 private List<Object> mWidgets;
79
80 // Caching
81 private Drawable mDefaultWidgetBackground;
82 private final int sWidgetPreviewCacheSize = 1 * 1024 * 1024; // 1 MiB
83 private LruCache<Object, Bitmap> mWidgetPreviewCache;
Winson Chung4dbea792011-05-05 14:21:32 -070084 private IconCache mIconCache;
Winson Chung785d2eb2011-04-14 16:08:02 -070085
86 // Dimens
87 private int mContentWidth;
Winson Chung4b576be2011-04-27 17:40:20 -070088 private int mMaxWidgetSpan, mMinWidgetSpan;
Winson Chungf0ea4d32011-06-06 14:27:16 -070089 private int mWidgetWidthGap, mWidgetHeightGap;
Winson Chung4b576be2011-04-27 17:40:20 -070090 private int mWidgetCountX, mWidgetCountY;
Winson Chung1ed747a2011-05-03 16:18:34 -070091 private final int mWidgetPreviewIconPaddedDimension;
92 private final float sWidgetPreviewIconPaddingPercentage = 0.25f;
Winson Chung785d2eb2011-04-14 16:08:02 -070093 private PagedViewCellLayout mWidgetSpacingLayout;
94
Winson Chung4b576be2011-04-27 17:40:20 -070095 // Animations
96 private final float ANIMATION_SCALE = 0.5f;
97 private final int TRANSLATE_ANIM_DURATION = 400;
98 private final int DROP_ANIM_DURATION = 200;
99
Winson Chung785d2eb2011-04-14 16:08:02 -0700100 public AppsCustomizePagedView(Context context, AttributeSet attrs) {
101 super(context, attrs);
102 mLayoutInflater = LayoutInflater.from(context);
103 mPackageManager = context.getPackageManager();
104 mContentType = ContentType.Applications;
105 mApps = new ArrayList<ApplicationInfo>();
Winson Chung1ed747a2011-05-03 16:18:34 -0700106 mWidgets = new ArrayList<Object>();
Winson Chung4dbea792011-05-05 14:21:32 -0700107 mIconCache = ((LauncherApplication) context.getApplicationContext()).getIconCache();
Winson Chung1ed747a2011-05-03 16:18:34 -0700108 mWidgetPreviewCache = new LruCache<Object, Bitmap>(sWidgetPreviewCacheSize) {
109 protected int sizeOf(Object key, Bitmap value) {
110 return value.getByteCount();
111 }
112 };
113
114 // Save the default widget preview background
115 Resources resources = context.getResources();
116 mDefaultWidgetBackground = resources.getDrawable(R.drawable.default_widget_preview);
Winson Chung785d2eb2011-04-14 16:08:02 -0700117
118 TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagedView, 0, 0);
Winson Chungf0ea4d32011-06-06 14:27:16 -0700119 // TODO-APPS_CUSTOMIZE: remove these unnecessary attrs after
Winson Chung785d2eb2011-04-14 16:08:02 -0700120 mCellCountX = a.getInt(R.styleable.PagedView_cellCountX, 6);
121 mCellCountY = a.getInt(R.styleable.PagedView_cellCountY, 4);
122 a.recycle();
Winson Chung4b576be2011-04-27 17:40:20 -0700123 a = context.obtainStyledAttributes(attrs, R.styleable.AppsCustomizePagedView, 0, 0);
Winson Chungf0ea4d32011-06-06 14:27:16 -0700124 mWidgetWidthGap =
125 a.getDimensionPixelSize(R.styleable.AppsCustomizePagedView_widgetCellWidthGap, 0);
126 mWidgetHeightGap =
127 a.getDimensionPixelSize(R.styleable.AppsCustomizePagedView_widgetCellHeightGap, 0);
Winson Chung4b576be2011-04-27 17:40:20 -0700128 mWidgetCountX = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountX, 2);
129 mWidgetCountY = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountY, 2);
130 a.recycle();
Winson Chungf0ea4d32011-06-06 14:27:16 -0700131 mWidgetSpacingLayout = new PagedViewCellLayout(getContext());
Winson Chung4b576be2011-04-27 17:40:20 -0700132
133 // The max widget span is the length N, such that NxN is the largest bounds that the widget
134 // preview can be before applying the widget scaling
135 mMinWidgetSpan = 1;
136 mMaxWidgetSpan = 3;
Winson Chung1ed747a2011-05-03 16:18:34 -0700137
138 // The padding on the non-matched dimension for the default widget preview icons
139 // (top + bottom)
140 int iconSize = resources.getDimensionPixelSize(R.dimen.app_icon_size);
141 mWidgetPreviewIconPaddedDimension =
142 (int) (iconSize * (1 + (2 * sWidgetPreviewIconPaddingPercentage)));
Winson Chung785d2eb2011-04-14 16:08:02 -0700143 }
144
145 @Override
146 protected void init() {
147 super.init();
148 mCenterPagesVertically = false;
149
150 Context context = getContext();
151 Resources r = context.getResources();
152 setDragSlopeThreshold(r.getInteger(R.integer.config_appsCustomizeDragSlopeThreshold)/100f);
153 }
154
Winson Chungf0ea4d32011-06-06 14:27:16 -0700155 @Override
156 protected void onWallpaperTap(android.view.MotionEvent ev) {
157 mLauncher.showWorkspace(true);
158 }
159
160 /**
161 * This differs from isDataReady as this is the test done if isDataReady is not set.
162 */
163 private boolean testDataReady() {
164 return !mApps.isEmpty() && !mWidgets.isEmpty();
165 }
166
167 protected void onDataReady(int width, int height) {
168 // Note that we transpose the counts in portrait so that we get a similar layout
169 boolean isLandscape = getResources().getConfiguration().orientation ==
170 Configuration.ORIENTATION_LANDSCAPE;
171 int maxCellCountX = Integer.MAX_VALUE;
172 int maxCellCountY = Integer.MAX_VALUE;
173 if (LauncherApplication.isScreenLarge()) {
174 maxCellCountX = (isLandscape ? LauncherModel.getCellCountX() :
175 LauncherModel.getCellCountY());
176 maxCellCountY = (isLandscape ? LauncherModel.getCellCountY() :
177 LauncherModel.getCellCountX());
178 }
179
180 // Now that the data is ready, we can calculate the content width, the number of cells to
181 // use for each page
182 mWidgetSpacingLayout.setGap(mPageLayoutWidthGap, mPageLayoutHeightGap);
183 mWidgetSpacingLayout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop,
184 mPageLayoutPaddingRight, mPageLayoutPaddingBottom);
185 mWidgetSpacingLayout.calculateCellCount(width, height, maxCellCountX, maxCellCountY);
186 mCellCountX = mWidgetSpacingLayout.getCellCountX();
187 mCellCountY = mWidgetSpacingLayout.getCellCountY();
188 mWidgetCountX = Math.max(1, (int) Math.round(mCellCountX / 2f));
189 mWidgetCountY = Math.max(1, (int) Math.round(mCellCountY / 3f));
190 mContentWidth = mWidgetSpacingLayout.getContentWidth();
191
Winson Chungf0ea4d32011-06-06 14:27:16 -0700192 invalidatePageData();
193 }
194
195 @Override
196 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
197 int width = MeasureSpec.getSize(widthMeasureSpec);
198 int height = MeasureSpec.getSize(heightMeasureSpec);
199 if (!isDataReady()) {
200 if (testDataReady()) {
201 setDataIsReady();
202 setMeasuredDimension(width, height);
203 onDataReady(width, height);
204 }
205 }
206
207 super.onMeasure(widthMeasureSpec, heightMeasureSpec);
208 }
209
Winson Chung34efdaf2011-05-24 14:19:56 -0700210 /** Removes and returns the ResolveInfo with the specified ComponentName */
211 private ResolveInfo removeResolveInfoWithComponentName(List<ResolveInfo> list,
212 ComponentName cn) {
213 Iterator<ResolveInfo> iter = list.iterator();
214 while (iter.hasNext()) {
215 ResolveInfo rinfo = iter.next();
216 ActivityInfo info = rinfo.activityInfo;
217 ComponentName c = new ComponentName(info.packageName, info.name);
218 if (c.equals(cn)) {
219 iter.remove();
220 return rinfo;
221 }
222 }
223 return null;
224 }
225
Winson Chung785d2eb2011-04-14 16:08:02 -0700226 public void onPackagesUpdated() {
Winson Chung1ed747a2011-05-03 16:18:34 -0700227 // Get the list of widgets and shortcuts
228 mWidgets.clear();
Winson Chungf0ea4d32011-06-06 14:27:16 -0700229 List<AppWidgetProviderInfo> widgets =
230 AppWidgetManager.getInstance(mLauncher).getInstalledProviders();
231 Collections.sort(widgets,
Winson Chung1ed747a2011-05-03 16:18:34 -0700232 new LauncherModel.WidgetAndShortcutNameComparator(mPackageManager));
Winson Chungf0ea4d32011-06-06 14:27:16 -0700233 Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
234 List<ResolveInfo> shortcuts = mPackageManager.queryIntentActivities(shortcutsIntent, 0);
235 Collections.sort(shortcuts,
236 new LauncherModel.WidgetAndShortcutNameComparator(mPackageManager));
237 mWidgets.addAll(widgets);
238 mWidgets.addAll(shortcuts);
Winson Chung785d2eb2011-04-14 16:08:02 -0700239
Winson Chungf0ea4d32011-06-06 14:27:16 -0700240 // The next layout pass will trigger data-ready if both widgets and apps are set, so request
241 // a layout to do this test and invalidate the page data when ready.
242 if (testDataReady()) requestLayout();
Winson Chung4b576be2011-04-27 17:40:20 -0700243 }
244
245 @Override
246 public void onClick(View v) {
247 if (v instanceof PagedViewIcon) {
248 // Animate some feedback to the click
249 final ApplicationInfo appInfo = (ApplicationInfo) v.getTag();
250 animateClickFeedback(v, new Runnable() {
251 @Override
252 public void run() {
253 mLauncher.startActivitySafely(appInfo.intent, appInfo);
254 }
255 });
256 } else if (v instanceof PagedViewWidget) {
Winson Chungd2e87b32011-06-02 10:53:07 -0700257 // Let the user know that they have to long press to add a widget
258 Toast.makeText(getContext(), R.string.long_press_widget_to_add,
259 Toast.LENGTH_SHORT).show();
Winson Chung46af2e82011-05-09 16:00:53 -0700260
Winson Chungd2e87b32011-06-02 10:53:07 -0700261 // Create a little animation to show that the widget can move
262 float offsetY = getResources().getDimensionPixelSize(R.dimen.dragViewOffsetY);
263 final ImageView p = (ImageView) v.findViewById(R.id.widget_preview);
264 AnimatorSet bounce = new AnimatorSet();
265 ValueAnimator tyuAnim = ObjectAnimator.ofFloat(p, "translationY", offsetY);
266 tyuAnim.setDuration(125);
267 ValueAnimator tydAnim = ObjectAnimator.ofFloat(p, "translationY", 0f);
268 tydAnim.setDuration(100);
269 bounce.play(tyuAnim).before(tydAnim);
270 bounce.setInterpolator(new AccelerateInterpolator());
271 bounce.start();
Winson Chung4b576be2011-04-27 17:40:20 -0700272 }
Winson Chung785d2eb2011-04-14 16:08:02 -0700273 }
274
275 /*
276 * PagedViewWithDraggableItems implementation
277 */
278 @Override
279 protected void determineDraggingStart(android.view.MotionEvent ev) {
280 // Disable dragging by pulling an app down for now.
281 }
Winson Chung4b576be2011-04-27 17:40:20 -0700282 private void beginDraggingApplication(View v) {
Winson Chung785d2eb2011-04-14 16:08:02 -0700283 // Make a copy of the ApplicationInfo
284 ApplicationInfo appInfo = new ApplicationInfo((ApplicationInfo) v.getTag());
285
Winson Chung785d2eb2011-04-14 16:08:02 -0700286 // Compose the drag image (top compound drawable, index is 1)
287 final TextView tv = (TextView) v;
288 final Drawable icon = tv.getCompoundDrawables()[1];
289 Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(),
290 Bitmap.Config.ARGB_8888);
291 Canvas c = new Canvas(b);
292 c.translate((v.getWidth() - icon.getIntrinsicWidth()) / 2, v.getPaddingTop());
293 icon.draw(c);
294
295 // Compose the visible rect of the drag image
296 Rect dragRect = null;
297 if (v instanceof TextView) {
298 int iconSize = getResources().getDimensionPixelSize(R.dimen.app_icon_size);
299 int top = v.getPaddingTop();
300 int left = (b.getWidth() - iconSize) / 2;
301 int right = left + iconSize;
302 int bottom = top + iconSize;
303 dragRect = new Rect(left, top, right, bottom);
304 }
305
306 // Start the drag
307 mLauncher.lockScreenOrientation();
308 mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1, b);
309 mDragController.startDrag(v, b, this, appInfo, DragController.DRAG_ACTION_COPY, dragRect);
310 b.recycle();
Winson Chung4b576be2011-04-27 17:40:20 -0700311 }
312 private void beginDraggingWidget(View v) {
313 // Get the widget preview as the drag representation
314 ImageView image = (ImageView) v.findViewById(R.id.widget_preview);
Winson Chung1ed747a2011-05-03 16:18:34 -0700315 PendingAddItemInfo createItemInfo = (PendingAddItemInfo) v.getTag();
Winson Chung4b576be2011-04-27 17:40:20 -0700316
317 // Compose the drag image
Winson Chung1ed747a2011-05-03 16:18:34 -0700318 Bitmap b;
Winson Chung4b576be2011-04-27 17:40:20 -0700319 Drawable preview = image.getDrawable();
320 int w = preview.getIntrinsicWidth();
321 int h = preview.getIntrinsicHeight();
Winson Chung1ed747a2011-05-03 16:18:34 -0700322 if (createItemInfo instanceof PendingAddWidgetInfo) {
323 PendingAddWidgetInfo createWidgetInfo = (PendingAddWidgetInfo) createItemInfo;
324 int[] spanXY = CellLayout.rectToCell(getResources(),
325 createWidgetInfo.minWidth, createWidgetInfo.minHeight, null);
326 createItemInfo.spanX = spanXY[0];
327 createItemInfo.spanY = spanXY[1];
328
329 b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
330 renderDrawableToBitmap(preview, b, 0, 0, w, h, 1, 1);
331 } else {
332 // Workaround for the fact that we don't keep the original ResolveInfo associated with
333 // the shortcut around. To get the icon, we just render the preview image (which has
334 // the shortcut icon) to a new drag bitmap that clips the non-icon space.
335 b = Bitmap.createBitmap(mWidgetPreviewIconPaddedDimension,
336 mWidgetPreviewIconPaddedDimension, Bitmap.Config.ARGB_8888);
337 Canvas c = new Canvas(b);
338 preview.draw(c);
339 createItemInfo.spanX = createItemInfo.spanY = 1;
340 }
Winson Chung4b576be2011-04-27 17:40:20 -0700341
342 // Start the drag
Winson Chung4b576be2011-04-27 17:40:20 -0700343 mLauncher.lockScreenOrientation();
Winson Chung1ed747a2011-05-03 16:18:34 -0700344 mLauncher.getWorkspace().onDragStartedWithItemSpans(createItemInfo.spanX,
345 createItemInfo.spanY, b);
346 mDragController.startDrag(image, b, this, createItemInfo,
Winson Chung4b576be2011-04-27 17:40:20 -0700347 DragController.DRAG_ACTION_COPY, null);
348 b.recycle();
349 }
350 @Override
351 protected boolean beginDragging(View v) {
352 if (!super.beginDragging(v)) return false;
353
Winson Chungfc79c802011-05-02 13:35:34 -0700354
Winson Chung4b576be2011-04-27 17:40:20 -0700355 if (v instanceof PagedViewIcon) {
356 beginDraggingApplication(v);
357 } else if (v instanceof PagedViewWidget) {
358 beginDraggingWidget(v);
359 }
Winson Chung785d2eb2011-04-14 16:08:02 -0700360
Winson Chungb26f3d62011-06-02 10:49:29 -0700361 // Go into spring loaded mode
362 int currentPageIndex = mLauncher.getWorkspace().getCurrentPage();
363 CellLayout currentPage = (CellLayout) mLauncher.getWorkspace().getChildAt(currentPageIndex);
364 mLauncher.enterSpringLoadedDragMode(currentPage);
Winson Chung785d2eb2011-04-14 16:08:02 -0700365 return true;
366 }
367 private void endDragging(boolean success) {
368 post(new Runnable() {
369 // Once the drag operation has fully completed, hence the post, we want to disable the
370 // deleteZone and the appInfoButton in all apps, and re-enable the instance which
371 // live in the workspace
372 public void run() {
373 // if onDestroy was called on Launcher, we might have already deleted the
374 // all apps delete zone / info button, so check if they are null
375 DeleteZone allAppsDeleteZone =
376 (DeleteZone) mLauncher.findViewById(R.id.all_apps_delete_zone);
377 ApplicationInfoDropTarget allAppsInfoButton =
378 (ApplicationInfoDropTarget) mLauncher.findViewById(R.id.all_apps_info_target);
379
380 if (allAppsDeleteZone != null) allAppsDeleteZone.setDragAndDropEnabled(false);
381 if (allAppsInfoButton != null) allAppsInfoButton.setDragAndDropEnabled(false);
382 }
383 });
Winson Chungb26f3d62011-06-02 10:49:29 -0700384 mLauncher.exitSpringLoadedDragMode();
Winson Chung785d2eb2011-04-14 16:08:02 -0700385 mLauncher.getWorkspace().onDragStopped(success);
386 mLauncher.unlockScreenOrientation();
Winson Chungb26f3d62011-06-02 10:49:29 -0700387
Winson Chung785d2eb2011-04-14 16:08:02 -0700388 }
389
390 /*
391 * DragSource implementation
392 */
393 @Override
394 public void onDragViewVisible() {}
395 @Override
Adam Cohenc0dcf592011-06-01 15:30:43 -0700396 public void onDropCompleted(View target, DragObject d, boolean success) {
Winson Chung785d2eb2011-04-14 16:08:02 -0700397 endDragging(success);
Winson Chungfc79c802011-05-02 13:35:34 -0700398
399 // Display an error message if the drag failed due to there not being enough space on the
400 // target layout we were dropping on.
401 if (!success) {
402 boolean showOutOfSpaceMessage = false;
403 if (target instanceof Workspace) {
404 int currentScreen = mLauncher.getCurrentWorkspaceScreen();
405 Workspace workspace = (Workspace) target;
406 CellLayout layout = (CellLayout) workspace.getChildAt(currentScreen);
Adam Cohenc0dcf592011-06-01 15:30:43 -0700407 ItemInfo itemInfo = (ItemInfo) d.dragInfo;
Winson Chungfc79c802011-05-02 13:35:34 -0700408 if (layout != null) {
409 layout.calculateSpans(itemInfo);
410 showOutOfSpaceMessage =
411 !layout.findCellForSpan(null, itemInfo.spanX, itemInfo.spanY);
412 }
413 }
414 // TODO-APPS_CUSTOMIZE: We need to handle this for folders as well later.
415 if (showOutOfSpaceMessage) {
416 mLauncher.showOutOfSpaceMessage();
417 }
418 }
Winson Chung785d2eb2011-04-14 16:08:02 -0700419 }
420
421 public void setContentType(ContentType type) {
422 mContentType = type;
423 setCurrentPage(0);
424 invalidatePageData();
425 }
426
427 /*
428 * Apps PagedView implementation
429 */
Winson Chung63257c12011-05-05 17:06:13 -0700430 private void setVisibilityOnChildren(ViewGroup layout, int visibility) {
431 int childCount = layout.getChildCount();
432 for (int i = 0; i < childCount; ++i) {
433 layout.getChildAt(i).setVisibility(visibility);
434 }
435 }
Winson Chung785d2eb2011-04-14 16:08:02 -0700436 private void setupPage(PagedViewCellLayout layout) {
437 layout.setCellCount(mCellCountX, mCellCountY);
438 layout.setGap(mPageLayoutWidthGap, mPageLayoutHeightGap);
439 layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop,
440 mPageLayoutPaddingRight, mPageLayoutPaddingBottom);
441
Winson Chung63257c12011-05-05 17:06:13 -0700442 // Note: We force a measure here to get around the fact that when we do layout calculations
443 // immediately after syncing, we don't have a proper width. That said, we already know the
444 // expected page width, so we can actually optimize by hiding all the TextView-based
445 // children that are expensive to measure, and let that happen naturally later.
446 setVisibilityOnChildren(layout, View.GONE);
Winson Chung785d2eb2011-04-14 16:08:02 -0700447 int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST);
448 int heightSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST);
Winson Chung63257c12011-05-05 17:06:13 -0700449 layout.setMinimumWidth(getPageContentWidth());
Winson Chung785d2eb2011-04-14 16:08:02 -0700450 layout.measure(widthSpec, heightSpec);
Winson Chung63257c12011-05-05 17:06:13 -0700451 setVisibilityOnChildren(layout, View.VISIBLE);
Winson Chung785d2eb2011-04-14 16:08:02 -0700452 }
453 public void syncAppsPages() {
454 // Ensure that we have the right number of pages
455 Context context = getContext();
456 int numPages = (int) Math.ceil((float) mApps.size() / (mCellCountX * mCellCountY));
457 for (int i = 0; i < numPages; ++i) {
458 PagedViewCellLayout layout = new PagedViewCellLayout(context);
459 setupPage(layout);
460 addView(layout);
461 }
462 }
463 public void syncAppsPageItems(int page) {
464 // ensure that we have the right number of items on the pages
465 int numPages = getPageCount();
466 int numCells = mCellCountX * mCellCountY;
467 int startIndex = page * numCells;
468 int endIndex = Math.min(startIndex + numCells, mApps.size());
469 PagedViewCellLayout layout = (PagedViewCellLayout) getChildAt(page);
470 layout.removeAllViewsOnPage();
471 for (int i = startIndex; i < endIndex; ++i) {
472 ApplicationInfo info = mApps.get(i);
473 PagedViewIcon icon = (PagedViewIcon) mLayoutInflater.inflate(
474 R.layout.apps_customize_application, layout, false);
Michael Jurkab9b8ce92011-05-05 15:05:07 -0700475 icon.applyFromApplicationInfo(
Winson Chung9f4e0fd2011-06-02 18:59:36 -0700476 info, mPageViewIconCache, true, (numPages > 1));
Winson Chung785d2eb2011-04-14 16:08:02 -0700477 icon.setOnClickListener(this);
478 icon.setOnLongClickListener(this);
479 icon.setOnTouchListener(this);
480
481 int index = i - startIndex;
482 int x = index % mCellCountX;
483 int y = index / mCellCountX;
Winson Chung6a70e9f2011-05-17 16:24:49 -0700484 layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1));
Winson Chung785d2eb2011-04-14 16:08:02 -0700485 }
Winson Chungf0ea4d32011-06-06 14:27:16 -0700486
487 // Create the hardware layers
488 layout.allowHardwareLayerCreation();
489 layout.createHardwareLayers();
Winson Chung785d2eb2011-04-14 16:08:02 -0700490 }
491 /*
492 * Widgets PagedView implementation
493 */
Winson Chung4e6a9762011-05-09 11:56:34 -0700494 private void setupPage(PagedViewGridLayout layout) {
Winson Chung785d2eb2011-04-14 16:08:02 -0700495 layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop,
496 mPageLayoutPaddingRight, mPageLayoutPaddingBottom);
Winson Chung63257c12011-05-05 17:06:13 -0700497
498 // Note: We force a measure here to get around the fact that when we do layout calculations
499 // immediately after syncing, we don't have a proper width. That said, we already know the
500 // expected page width, so we can actually optimize by hiding all the TextView-based
501 // children that are expensive to measure, and let that happen naturally later.
502 setVisibilityOnChildren(layout, View.GONE);
503 int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST);
504 int heightSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST);
Winson Chung785d2eb2011-04-14 16:08:02 -0700505 layout.setMinimumWidth(getPageContentWidth());
Winson Chung63257c12011-05-05 17:06:13 -0700506 layout.measure(widthSpec, heightSpec);
507 setVisibilityOnChildren(layout, View.VISIBLE);
Winson Chung785d2eb2011-04-14 16:08:02 -0700508 }
509 private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int x, int y, int w, int h,
510 float scaleX, float scaleY) {
Winson Chung201bc822011-06-20 15:41:53 -0700511 if (bitmap != null) {
512 Canvas c = new Canvas();
513 c.setBitmap(bitmap);
514 c.save();
515 c.scale(scaleX, scaleY);
516 Rect oldBounds = d.copyBounds();
517 d.setBounds(x, y, x + w, y + h);
518 d.draw(c);
519 d.setBounds(oldBounds); // Restore the bounds
520 c.restore();
521 }
Winson Chung785d2eb2011-04-14 16:08:02 -0700522 }
Winson Chung1ed747a2011-05-03 16:18:34 -0700523 private FastBitmapDrawable getShortcutPreview(ResolveInfo info, int cellWidth, int cellHeight) {
524 // Return the cached version if necessary
525 Bitmap cachedBitmap = mWidgetPreviewCache.get(info);
526 if (cachedBitmap != null) {
527 return new FastBitmapDrawable(cachedBitmap);
528 }
529
530 Resources resources = mLauncher.getResources();
531 int iconSize = resources.getDimensionPixelSize(R.dimen.app_icon_size);
532 // We only need to make it wide enough so as not allow the preview to be scaled
533 int expectedWidth = cellWidth;
534 int expectedHeight = mWidgetPreviewIconPaddedDimension;
Winson Chung1ed747a2011-05-03 16:18:34 -0700535
536 // Render the icon
537 Bitmap preview = Bitmap.createBitmap(expectedWidth, expectedHeight, Config.ARGB_8888);
Winson Chung4dbea792011-05-05 14:21:32 -0700538 Drawable icon = mIconCache.getFullResIcon(info, mPackageManager);
Winson Chungf0ea4d32011-06-06 14:27:16 -0700539 renderDrawableToBitmap(icon, preview, 0, 0, iconSize, iconSize, 1f, 1f);
Winson Chung1ed747a2011-05-03 16:18:34 -0700540 FastBitmapDrawable iconDrawable = new FastBitmapDrawable(preview);
541 iconDrawable.setBounds(0, 0, expectedWidth, expectedHeight);
542 mWidgetPreviewCache.put(info, preview);
543 return iconDrawable;
544 }
Winson Chung4b576be2011-04-27 17:40:20 -0700545 private FastBitmapDrawable getWidgetPreview(AppWidgetProviderInfo info, int cellHSpan,
546 int cellVSpan, int cellWidth, int cellHeight) {
Winson Chung1ed747a2011-05-03 16:18:34 -0700547 // Return the cached version if necessary
548 Bitmap cachedBitmap = mWidgetPreviewCache.get(info);
549 if (cachedBitmap != null) {
550 return new FastBitmapDrawable(cachedBitmap);
551 }
552
Winson Chung4b576be2011-04-27 17:40:20 -0700553 // Calculate the size of the drawable
554 cellHSpan = Math.max(mMinWidgetSpan, Math.min(mMaxWidgetSpan, cellHSpan));
555 cellVSpan = Math.max(mMinWidgetSpan, Math.min(mMaxWidgetSpan, cellVSpan));
556 int expectedWidth = mWidgetSpacingLayout.estimateCellWidth(cellHSpan);
557 int expectedHeight = mWidgetSpacingLayout.estimateCellHeight(cellVSpan);
558
559 // Scale down the bitmap to fit the space
560 float widgetPreviewScale = (float) cellWidth / expectedWidth;
561 expectedWidth = (int) (widgetPreviewScale * expectedWidth);
562 expectedHeight = (int) (widgetPreviewScale * expectedHeight);
563
564 // Load the preview image if possible
565 String packageName = info.provider.getPackageName();
566 Drawable drawable = null;
567 FastBitmapDrawable newDrawable = null;
568 if (info.previewImage != 0) {
569 drawable = mPackageManager.getDrawable(packageName, info.previewImage, null);
570 if (drawable == null) {
571 Log.w(LOG_TAG, "Can't load icon drawable 0x" + Integer.toHexString(info.icon)
572 + " for provider: " + info.provider);
573 } else {
574 // Scale down the preview to the dimensions we want
575 int imageWidth = drawable.getIntrinsicWidth();
576 int imageHeight = drawable.getIntrinsicHeight();
577 float aspect = (float) imageWidth / imageHeight;
578 int newWidth = imageWidth;
579 int newHeight = imageHeight;
580 if (aspect > 1f) {
581 newWidth = expectedWidth;
582 newHeight = (int) (imageHeight * ((float) expectedWidth / imageWidth));
583 } else {
584 newHeight = expectedHeight;
585 newWidth = (int) (imageWidth * ((float) expectedHeight / imageHeight));
586 }
587
588 Bitmap preview = Bitmap.createBitmap(newWidth, newHeight, Config.ARGB_8888);
589 renderDrawableToBitmap(drawable, preview, 0, 0, newWidth, newHeight, 1f, 1f);
590 newDrawable = new FastBitmapDrawable(preview);
591 newDrawable.setBounds(0, 0, newWidth, newHeight);
Winson Chung1ed747a2011-05-03 16:18:34 -0700592 mWidgetPreviewCache.put(info, preview);
Winson Chung4b576be2011-04-27 17:40:20 -0700593 }
594 }
595
596 // Generate a preview image if we couldn't load one
597 if (drawable == null) {
Winson Chung1ed747a2011-05-03 16:18:34 -0700598 Resources resources = mLauncher.getResources();
599 int iconSize = resources.getDimensionPixelSize(R.dimen.app_icon_size);
600
601 // Specify the dimensions of the bitmap
602 if (info.minWidth >= info.minHeight) {
603 expectedWidth = cellWidth;
604 expectedHeight = mWidgetPreviewIconPaddedDimension;
605 } else {
606 // Note that in vertical widgets, we might not have enough space due to the text
607 // label, so be conservative and use the width as a height bound
608 expectedWidth = mWidgetPreviewIconPaddedDimension;
609 expectedHeight = cellWidth;
610 }
Winson Chung4b576be2011-04-27 17:40:20 -0700611
612 Bitmap preview = Bitmap.createBitmap(expectedWidth, expectedHeight, Config.ARGB_8888);
Winson Chung1ed747a2011-05-03 16:18:34 -0700613 renderDrawableToBitmap(mDefaultWidgetBackground, preview, 0, 0, expectedWidth,
614 expectedHeight, 1f,1f);
Winson Chung4b576be2011-04-27 17:40:20 -0700615
616 // Draw the icon in the top left corner
617 try {
618 Drawable icon = null;
619 if (info.icon > 0) icon = mPackageManager.getDrawable(packageName, info.icon, null);
620 if (icon == null) icon = resources.getDrawable(R.drawable.ic_launcher_application);
621
Winson Chung1ed747a2011-05-03 16:18:34 -0700622 int offset = (int) (iconSize * sWidgetPreviewIconPaddingPercentage);
Winson Chung4b576be2011-04-27 17:40:20 -0700623 renderDrawableToBitmap(icon, preview, offset, offset, iconSize, iconSize, 1f, 1f);
624 } catch (Resources.NotFoundException e) {}
625
626 newDrawable = new FastBitmapDrawable(preview);
627 newDrawable.setBounds(0, 0, expectedWidth, expectedHeight);
Winson Chung1ed747a2011-05-03 16:18:34 -0700628 mWidgetPreviewCache.put(info, preview);
Winson Chung4b576be2011-04-27 17:40:20 -0700629 }
630 return newDrawable;
Winson Chung785d2eb2011-04-14 16:08:02 -0700631 }
632 public void syncWidgetPages() {
633 // Ensure that we have the right number of pages
634 Context context = getContext();
Winson Chung4b576be2011-04-27 17:40:20 -0700635 int numWidgetsPerPage = mWidgetCountX * mWidgetCountY;
636 int numPages = (int) Math.ceil(mWidgets.size() / (float) numWidgetsPerPage);
Winson Chung785d2eb2011-04-14 16:08:02 -0700637 for (int i = 0; i < numPages; ++i) {
Winson Chung4e6a9762011-05-09 11:56:34 -0700638 PagedViewGridLayout layout = new PagedViewGridLayout(context, mWidgetCountX,
639 mWidgetCountY);
Winson Chung785d2eb2011-04-14 16:08:02 -0700640 setupPage(layout);
641 addView(layout);
642 }
643 }
644 public void syncWidgetPageItems(int page) {
Winson Chung4e6a9762011-05-09 11:56:34 -0700645 PagedViewGridLayout layout = (PagedViewGridLayout) getChildAt(page);
Winson Chung4b576be2011-04-27 17:40:20 -0700646 layout.removeAllViews();
Winson Chung785d2eb2011-04-14 16:08:02 -0700647
Winson Chung4b576be2011-04-27 17:40:20 -0700648 // Calculate the dimensions of each cell we are giving to each widget
Winson Chung4b576be2011-04-27 17:40:20 -0700649 int numWidgetsPerPage = mWidgetCountX * mWidgetCountY;
Winson Chung9f4e0fd2011-06-02 18:59:36 -0700650 int numPages = (int) Math.ceil(mWidgets.size() / (float) numWidgetsPerPage);
Winson Chung4b576be2011-04-27 17:40:20 -0700651 int offset = page * numWidgetsPerPage;
652 int cellWidth = ((mWidgetSpacingLayout.getContentWidth() - mPageLayoutWidthGap
Winson Chungf0ea4d32011-06-06 14:27:16 -0700653 - ((mWidgetCountX - 1) * mWidgetWidthGap)) / mWidgetCountX);
Winson Chung4b576be2011-04-27 17:40:20 -0700654 int cellHeight = ((mWidgetSpacingLayout.getContentHeight() - mPageLayoutHeightGap
Winson Chungf0ea4d32011-06-06 14:27:16 -0700655 - ((mWidgetCountY - 1) * mWidgetHeightGap)) / mWidgetCountY);
Winson Chung4b576be2011-04-27 17:40:20 -0700656 for (int i = 0; i < Math.min(numWidgetsPerPage, mWidgets.size() - offset); ++i) {
Winson Chung1ed747a2011-05-03 16:18:34 -0700657 Object rawInfo = mWidgets.get(offset + i);
658 PendingAddItemInfo createItemInfo = null;
Winson Chung4b576be2011-04-27 17:40:20 -0700659 PagedViewWidget widget = (PagedViewWidget) mLayoutInflater.inflate(
660 R.layout.apps_customize_widget, layout, false);
Winson Chung1ed747a2011-05-03 16:18:34 -0700661 if (rawInfo instanceof AppWidgetProviderInfo) {
662 // Fill in the widget information
663 AppWidgetProviderInfo info = (AppWidgetProviderInfo) rawInfo;
664 createItemInfo = new PendingAddWidgetInfo(info, null, null);
665 final int[] cellSpans = CellLayout.rectToCell(getResources(), info.minWidth,
666 info.minHeight, null);
667 FastBitmapDrawable preview = getWidgetPreview(info, cellSpans[0], cellSpans[1],
668 cellWidth, cellHeight);
Winson Chung9f4e0fd2011-06-02 18:59:36 -0700669 widget.applyFromAppWidgetProviderInfo(info, preview, -1, cellSpans,
670 mPageViewIconCache, (numPages > 1));
Winson Chung1ed747a2011-05-03 16:18:34 -0700671 widget.setTag(createItemInfo);
672 } else if (rawInfo instanceof ResolveInfo) {
673 // Fill in the shortcuts information
674 ResolveInfo info = (ResolveInfo) rawInfo;
675 createItemInfo = new PendingAddItemInfo();
676 createItemInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
677 createItemInfo.componentName = new ComponentName(info.activityInfo.packageName,
678 info.activityInfo.name);
679 FastBitmapDrawable preview = getShortcutPreview(info, cellWidth, cellHeight);
Winson Chung9f4e0fd2011-06-02 18:59:36 -0700680 widget.applyFromResolveInfo(mPackageManager, info, preview, mPageViewIconCache,
681 (numPages > 1));
Winson Chung1ed747a2011-05-03 16:18:34 -0700682 widget.setTag(createItemInfo);
683 }
Winson Chung4b576be2011-04-27 17:40:20 -0700684 widget.setOnClickListener(this);
685 widget.setOnLongClickListener(this);
686 widget.setOnTouchListener(this);
687
688 // Layout each widget
Winson Chung4b576be2011-04-27 17:40:20 -0700689 int ix = i % mWidgetCountX;
690 int iy = i / mWidgetCountX;
Winson Chung4e6a9762011-05-09 11:56:34 -0700691 PagedViewGridLayout.LayoutParams lp = new PagedViewGridLayout.LayoutParams(cellWidth,
692 cellHeight);
Winson Chungf0ea4d32011-06-06 14:27:16 -0700693 lp.leftMargin = (ix * cellWidth) + (ix * mWidgetWidthGap);
694 lp.topMargin = (iy * cellHeight) + (iy * mWidgetHeightGap);
Winson Chung4e6a9762011-05-09 11:56:34 -0700695 layout.addView(widget, lp);
Winson Chung785d2eb2011-04-14 16:08:02 -0700696 }
Winson Chung785d2eb2011-04-14 16:08:02 -0700697 }
Winson Chung46af2e82011-05-09 16:00:53 -0700698
Winson Chung785d2eb2011-04-14 16:08:02 -0700699 @Override
700 public void syncPages() {
701 removeAllViews();
702 switch (mContentType) {
703 case Applications:
704 syncAppsPages();
705 break;
706 case Widgets:
707 syncWidgetPages();
708 break;
709 }
710 }
711 @Override
712 public void syncPageItems(int page) {
713 switch (mContentType) {
714 case Applications:
715 syncAppsPageItems(page);
716 break;
717 case Widgets:
718 syncWidgetPageItems(page);
719 break;
720 }
721 }
722
723 /**
724 * Used by the parent to get the content width to set the tab bar to
725 * @return
726 */
727 public int getPageContentWidth() {
728 return mContentWidth;
729 }
730
Winson Chungb26f3d62011-06-02 10:49:29 -0700731 @Override
732 protected void onPageBeginMoving() {
733 /* TO BE ENABLED LATER
734 setChildrenDrawnWithCacheEnabled(true);
735 for (int i = 0; i < getChildCount(); ++i) {
736 View v = getChildAt(i);
737 if (v instanceof PagedViewCellLayout) {
738 ((PagedViewCellLayout) v).setChildrenDrawingCacheEnabled(true);
739 }
740 }
741 */
742 super.onPageBeginMoving();
743 }
744
745 @Override
746 protected void onPageEndMoving() {
747 /* TO BE ENABLED LATER
748 for (int i = 0; i < getChildCount(); ++i) {
749 View v = getChildAt(i);
750 if (v instanceof PagedViewCellLayout) {
751 ((PagedViewCellLayout) v).setChildrenDrawingCacheEnabled(false);
752 }
753 }
754 setChildrenDrawnWithCacheEnabled(false);
755 */
756 super.onPageEndMoving();
757 }
758
Winson Chung785d2eb2011-04-14 16:08:02 -0700759 /*
760 * AllAppsView implementation
761 */
762 @Override
763 public void setup(Launcher launcher, DragController dragController) {
764 mLauncher = launcher;
765 mDragController = dragController;
766 }
767 @Override
768 public void zoom(float zoom, boolean animate) {
769 // TODO-APPS_CUSTOMIZE: Call back to mLauncher.zoomed()
770 }
771 @Override
772 public boolean isVisible() {
773 return (getVisibility() == VISIBLE);
774 }
775 @Override
776 public boolean isAnimating() {
777 return false;
778 }
779 @Override
780 public void setApps(ArrayList<ApplicationInfo> list) {
781 mApps = list;
782 Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
Winson Chungf0ea4d32011-06-06 14:27:16 -0700783
784 // The next layout pass will trigger data-ready if both widgets and apps are set, so request
785 // a layout to do this test and invalidate the page data when ready.
786 if (testDataReady()) requestLayout();
Winson Chung785d2eb2011-04-14 16:08:02 -0700787 }
788 private void addAppsWithoutInvalidate(ArrayList<ApplicationInfo> list) {
789 // We add it in place, in alphabetical order
790 int count = list.size();
791 for (int i = 0; i < count; ++i) {
792 ApplicationInfo info = list.get(i);
793 int index = Collections.binarySearch(mApps, info, LauncherModel.APP_NAME_COMPARATOR);
794 if (index < 0) {
795 mApps.add(-(index + 1), info);
796 }
797 }
798 }
799 @Override
800 public void addApps(ArrayList<ApplicationInfo> list) {
801 addAppsWithoutInvalidate(list);
802 invalidatePageData();
803 }
804 private int findAppByComponent(List<ApplicationInfo> list, ApplicationInfo item) {
805 ComponentName removeComponent = item.intent.getComponent();
806 int length = list.size();
807 for (int i = 0; i < length; ++i) {
808 ApplicationInfo info = list.get(i);
809 if (info.intent.getComponent().equals(removeComponent)) {
810 return i;
811 }
812 }
813 return -1;
814 }
815 private void removeAppsWithoutInvalidate(ArrayList<ApplicationInfo> list) {
816 // loop through all the apps and remove apps that have the same component
817 int length = list.size();
818 for (int i = 0; i < length; ++i) {
819 ApplicationInfo info = list.get(i);
820 int removeIndex = findAppByComponent(mApps, info);
821 if (removeIndex > -1) {
822 mApps.remove(removeIndex);
823 mPageViewIconCache.removeOutline(new PagedViewIconCache.Key(info));
824 }
825 }
826 }
827 @Override
828 public void removeApps(ArrayList<ApplicationInfo> list) {
829 removeAppsWithoutInvalidate(list);
830 invalidatePageData();
831 }
832 @Override
833 public void updateApps(ArrayList<ApplicationInfo> list) {
834 // We remove and re-add the updated applications list because it's properties may have
835 // changed (ie. the title), and this will ensure that the items will be in their proper
836 // place in the list.
837 removeAppsWithoutInvalidate(list);
838 addAppsWithoutInvalidate(list);
839 invalidatePageData();
840 }
841 @Override
842 public void reset() {
Winson Chungfc79c802011-05-02 13:35:34 -0700843 if (mContentType != ContentType.Applications) {
844 // Reset to the first page of the Apps pane
845 AppsCustomizeTabHost tabs = (AppsCustomizeTabHost)
846 mLauncher.findViewById(R.id.apps_customize_pane);
847 tabs.setCurrentTabByTag(tabs.getTabTagForContentType(ContentType.Applications));
848 } else {
849 setCurrentPage(0);
850 invalidatePageData();
851 }
Winson Chung785d2eb2011-04-14 16:08:02 -0700852 }
853 @Override
854 public void dumpState() {
855 // TODO: Dump information related to current list of Applications, Widgets, etc.
856 ApplicationInfo.dumpApplicationInfoList(LOG_TAG, "mApps", mApps);
857 dumpAppWidgetProviderInfoList(LOG_TAG, "mWidgets", mWidgets);
858 }
859 private void dumpAppWidgetProviderInfoList(String tag, String label,
Winson Chung1ed747a2011-05-03 16:18:34 -0700860 List<Object> list) {
Winson Chung785d2eb2011-04-14 16:08:02 -0700861 Log.d(tag, label + " size=" + list.size());
Winson Chung1ed747a2011-05-03 16:18:34 -0700862 for (Object i: list) {
863 if (i instanceof AppWidgetProviderInfo) {
864 AppWidgetProviderInfo info = (AppWidgetProviderInfo) i;
865 Log.d(tag, " label=\"" + info.label + "\" previewImage=" + info.previewImage
866 + " resizeMode=" + info.resizeMode + " configure=" + info.configure
867 + " initialLayout=" + info.initialLayout
868 + " minWidth=" + info.minWidth + " minHeight=" + info.minHeight);
869 } else if (i instanceof ResolveInfo) {
870 ResolveInfo info = (ResolveInfo) i;
871 Log.d(tag, " label=\"" + info.loadLabel(mPackageManager) + "\" icon="
872 + info.icon);
873 }
Winson Chung785d2eb2011-04-14 16:08:02 -0700874 }
875 }
876 @Override
877 public void surrender() {
878 // TODO: If we are in the middle of any process (ie. for holographic outlines, etc) we
879 // should stop this now.
880 }
Winson Chung007c6982011-06-14 13:27:53 -0700881
882 @Override
883 protected int getPageWidthForScrollingIndicator() {
884 return getPageContentWidth();
885 }
Winson Chung785d2eb2011-04-14 16:08:02 -0700886}