blob: dfdbce9171d02a61cfbede20ac3d4fadcc81112a [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
Winson Chungf0ea4d32011-06-06 14:27:16 -070087 private Runnable mOnSizeChangedCallback;
Winson Chung785d2eb2011-04-14 16:08:02 -070088 private int mContentWidth;
Winson Chung4b576be2011-04-27 17:40:20 -070089 private int mMaxWidgetSpan, mMinWidgetSpan;
Winson Chungf0ea4d32011-06-06 14:27:16 -070090 private int mWidgetWidthGap, mWidgetHeightGap;
Winson Chung4b576be2011-04-27 17:40:20 -070091 private int mWidgetCountX, mWidgetCountY;
Winson Chung1ed747a2011-05-03 16:18:34 -070092 private final int mWidgetPreviewIconPaddedDimension;
93 private final float sWidgetPreviewIconPaddingPercentage = 0.25f;
Winson Chung785d2eb2011-04-14 16:08:02 -070094 private PagedViewCellLayout mWidgetSpacingLayout;
95
Winson Chung4b576be2011-04-27 17:40:20 -070096 // Animations
97 private final float ANIMATION_SCALE = 0.5f;
98 private final int TRANSLATE_ANIM_DURATION = 400;
99 private final int DROP_ANIM_DURATION = 200;
100
Winson Chung785d2eb2011-04-14 16:08:02 -0700101 public AppsCustomizePagedView(Context context, AttributeSet attrs) {
102 super(context, attrs);
103 mLayoutInflater = LayoutInflater.from(context);
104 mPackageManager = context.getPackageManager();
105 mContentType = ContentType.Applications;
106 mApps = new ArrayList<ApplicationInfo>();
Winson Chung1ed747a2011-05-03 16:18:34 -0700107 mWidgets = new ArrayList<Object>();
Winson Chung4dbea792011-05-05 14:21:32 -0700108 mIconCache = ((LauncherApplication) context.getApplicationContext()).getIconCache();
Winson Chung1ed747a2011-05-03 16:18:34 -0700109 mWidgetPreviewCache = new LruCache<Object, Bitmap>(sWidgetPreviewCacheSize) {
110 protected int sizeOf(Object key, Bitmap value) {
111 return value.getByteCount();
112 }
113 };
114
115 // Save the default widget preview background
116 Resources resources = context.getResources();
117 mDefaultWidgetBackground = resources.getDrawable(R.drawable.default_widget_preview);
Winson Chung785d2eb2011-04-14 16:08:02 -0700118
119 TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagedView, 0, 0);
Winson Chungf0ea4d32011-06-06 14:27:16 -0700120 // TODO-APPS_CUSTOMIZE: remove these unnecessary attrs after
Winson Chung785d2eb2011-04-14 16:08:02 -0700121 mCellCountX = a.getInt(R.styleable.PagedView_cellCountX, 6);
122 mCellCountY = a.getInt(R.styleable.PagedView_cellCountY, 4);
123 a.recycle();
Winson Chung4b576be2011-04-27 17:40:20 -0700124 a = context.obtainStyledAttributes(attrs, R.styleable.AppsCustomizePagedView, 0, 0);
Winson Chungf0ea4d32011-06-06 14:27:16 -0700125 mWidgetWidthGap =
126 a.getDimensionPixelSize(R.styleable.AppsCustomizePagedView_widgetCellWidthGap, 0);
127 mWidgetHeightGap =
128 a.getDimensionPixelSize(R.styleable.AppsCustomizePagedView_widgetCellHeightGap, 0);
Winson Chung4b576be2011-04-27 17:40:20 -0700129 mWidgetCountX = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountX, 2);
130 mWidgetCountY = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountY, 2);
131 a.recycle();
Winson Chungf0ea4d32011-06-06 14:27:16 -0700132 mWidgetSpacingLayout = new PagedViewCellLayout(getContext());
Winson Chung4b576be2011-04-27 17:40:20 -0700133
134 // The max widget span is the length N, such that NxN is the largest bounds that the widget
135 // preview can be before applying the widget scaling
136 mMinWidgetSpan = 1;
137 mMaxWidgetSpan = 3;
Winson Chung1ed747a2011-05-03 16:18:34 -0700138
139 // The padding on the non-matched dimension for the default widget preview icons
140 // (top + bottom)
141 int iconSize = resources.getDimensionPixelSize(R.dimen.app_icon_size);
142 mWidgetPreviewIconPaddedDimension =
143 (int) (iconSize * (1 + (2 * sWidgetPreviewIconPaddingPercentage)));
Winson Chung785d2eb2011-04-14 16:08:02 -0700144 }
145
146 @Override
147 protected void init() {
148 super.init();
149 mCenterPagesVertically = false;
150
151 Context context = getContext();
152 Resources r = context.getResources();
153 setDragSlopeThreshold(r.getInteger(R.integer.config_appsCustomizeDragSlopeThreshold)/100f);
154 }
155
Winson Chungf0ea4d32011-06-06 14:27:16 -0700156 @Override
157 protected void onWallpaperTap(android.view.MotionEvent ev) {
158 mLauncher.showWorkspace(true);
159 }
160
161 /**
162 * This differs from isDataReady as this is the test done if isDataReady is not set.
163 */
164 private boolean testDataReady() {
165 return !mApps.isEmpty() && !mWidgets.isEmpty();
166 }
167
168 protected void onDataReady(int width, int height) {
169 // Note that we transpose the counts in portrait so that we get a similar layout
170 boolean isLandscape = getResources().getConfiguration().orientation ==
171 Configuration.ORIENTATION_LANDSCAPE;
172 int maxCellCountX = Integer.MAX_VALUE;
173 int maxCellCountY = Integer.MAX_VALUE;
174 if (LauncherApplication.isScreenLarge()) {
175 maxCellCountX = (isLandscape ? LauncherModel.getCellCountX() :
176 LauncherModel.getCellCountY());
177 maxCellCountY = (isLandscape ? LauncherModel.getCellCountY() :
178 LauncherModel.getCellCountX());
179 }
180
181 // Now that the data is ready, we can calculate the content width, the number of cells to
182 // use for each page
183 mWidgetSpacingLayout.setGap(mPageLayoutWidthGap, mPageLayoutHeightGap);
184 mWidgetSpacingLayout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop,
185 mPageLayoutPaddingRight, mPageLayoutPaddingBottom);
186 mWidgetSpacingLayout.calculateCellCount(width, height, maxCellCountX, maxCellCountY);
187 mCellCountX = mWidgetSpacingLayout.getCellCountX();
188 mCellCountY = mWidgetSpacingLayout.getCellCountY();
189 mWidgetCountX = Math.max(1, (int) Math.round(mCellCountX / 2f));
190 mWidgetCountY = Math.max(1, (int) Math.round(mCellCountY / 3f));
191 mContentWidth = mWidgetSpacingLayout.getContentWidth();
192
193 // Notify our parent so that we can synchronize the tab bar width to this page width
194 if (mOnSizeChangedCallback != null) {
195 mOnSizeChangedCallback.run();
196 }
197
198 invalidatePageData();
199 }
200
201 @Override
202 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
203 int width = MeasureSpec.getSize(widthMeasureSpec);
204 int height = MeasureSpec.getSize(heightMeasureSpec);
205 if (!isDataReady()) {
206 if (testDataReady()) {
207 setDataIsReady();
208 setMeasuredDimension(width, height);
209 onDataReady(width, height);
210 }
211 }
212
213 super.onMeasure(widthMeasureSpec, heightMeasureSpec);
214 }
215
216 public void setOnSizeChangedCallback(Runnable r) {
217 mOnSizeChangedCallback = r;
218 }
219
Winson Chung34efdaf2011-05-24 14:19:56 -0700220 /** Removes and returns the ResolveInfo with the specified ComponentName */
221 private ResolveInfo removeResolveInfoWithComponentName(List<ResolveInfo> list,
222 ComponentName cn) {
223 Iterator<ResolveInfo> iter = list.iterator();
224 while (iter.hasNext()) {
225 ResolveInfo rinfo = iter.next();
226 ActivityInfo info = rinfo.activityInfo;
227 ComponentName c = new ComponentName(info.packageName, info.name);
228 if (c.equals(cn)) {
229 iter.remove();
230 return rinfo;
231 }
232 }
233 return null;
234 }
235
Winson Chung785d2eb2011-04-14 16:08:02 -0700236 public void onPackagesUpdated() {
Winson Chung1ed747a2011-05-03 16:18:34 -0700237 // Get the list of widgets and shortcuts
238 mWidgets.clear();
Winson Chungf0ea4d32011-06-06 14:27:16 -0700239 List<AppWidgetProviderInfo> widgets =
240 AppWidgetManager.getInstance(mLauncher).getInstalledProviders();
241 Collections.sort(widgets,
Winson Chung1ed747a2011-05-03 16:18:34 -0700242 new LauncherModel.WidgetAndShortcutNameComparator(mPackageManager));
Winson Chungf0ea4d32011-06-06 14:27:16 -0700243 Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
244 List<ResolveInfo> shortcuts = mPackageManager.queryIntentActivities(shortcutsIntent, 0);
245 Collections.sort(shortcuts,
246 new LauncherModel.WidgetAndShortcutNameComparator(mPackageManager));
247 mWidgets.addAll(widgets);
248 mWidgets.addAll(shortcuts);
Winson Chung785d2eb2011-04-14 16:08:02 -0700249
Winson Chungf0ea4d32011-06-06 14:27:16 -0700250 // The next layout pass will trigger data-ready if both widgets and apps are set, so request
251 // a layout to do this test and invalidate the page data when ready.
252 if (testDataReady()) requestLayout();
Winson Chung4b576be2011-04-27 17:40:20 -0700253 }
254
255 @Override
256 public void onClick(View v) {
257 if (v instanceof PagedViewIcon) {
258 // Animate some feedback to the click
259 final ApplicationInfo appInfo = (ApplicationInfo) v.getTag();
260 animateClickFeedback(v, new Runnable() {
261 @Override
262 public void run() {
263 mLauncher.startActivitySafely(appInfo.intent, appInfo);
264 }
265 });
266 } else if (v instanceof PagedViewWidget) {
Winson Chungd2e87b32011-06-02 10:53:07 -0700267 // Let the user know that they have to long press to add a widget
268 Toast.makeText(getContext(), R.string.long_press_widget_to_add,
269 Toast.LENGTH_SHORT).show();
Winson Chung46af2e82011-05-09 16:00:53 -0700270
Winson Chungd2e87b32011-06-02 10:53:07 -0700271 // Create a little animation to show that the widget can move
272 float offsetY = getResources().getDimensionPixelSize(R.dimen.dragViewOffsetY);
273 final ImageView p = (ImageView) v.findViewById(R.id.widget_preview);
274 AnimatorSet bounce = new AnimatorSet();
275 ValueAnimator tyuAnim = ObjectAnimator.ofFloat(p, "translationY", offsetY);
276 tyuAnim.setDuration(125);
277 ValueAnimator tydAnim = ObjectAnimator.ofFloat(p, "translationY", 0f);
278 tydAnim.setDuration(100);
279 bounce.play(tyuAnim).before(tydAnim);
280 bounce.setInterpolator(new AccelerateInterpolator());
281 bounce.start();
Winson Chung4b576be2011-04-27 17:40:20 -0700282 }
Winson Chung785d2eb2011-04-14 16:08:02 -0700283 }
284
285 /*
286 * PagedViewWithDraggableItems implementation
287 */
288 @Override
289 protected void determineDraggingStart(android.view.MotionEvent ev) {
290 // Disable dragging by pulling an app down for now.
291 }
Winson Chung4b576be2011-04-27 17:40:20 -0700292 private void beginDraggingApplication(View v) {
Winson Chung785d2eb2011-04-14 16:08:02 -0700293 // Make a copy of the ApplicationInfo
294 ApplicationInfo appInfo = new ApplicationInfo((ApplicationInfo) v.getTag());
295
Winson Chung785d2eb2011-04-14 16:08:02 -0700296 // Compose the drag image (top compound drawable, index is 1)
297 final TextView tv = (TextView) v;
298 final Drawable icon = tv.getCompoundDrawables()[1];
299 Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(),
300 Bitmap.Config.ARGB_8888);
301 Canvas c = new Canvas(b);
302 c.translate((v.getWidth() - icon.getIntrinsicWidth()) / 2, v.getPaddingTop());
303 icon.draw(c);
304
305 // Compose the visible rect of the drag image
306 Rect dragRect = null;
307 if (v instanceof TextView) {
308 int iconSize = getResources().getDimensionPixelSize(R.dimen.app_icon_size);
309 int top = v.getPaddingTop();
310 int left = (b.getWidth() - iconSize) / 2;
311 int right = left + iconSize;
312 int bottom = top + iconSize;
313 dragRect = new Rect(left, top, right, bottom);
314 }
315
316 // Start the drag
317 mLauncher.lockScreenOrientation();
318 mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1, b);
319 mDragController.startDrag(v, b, this, appInfo, DragController.DRAG_ACTION_COPY, dragRect);
320 b.recycle();
Winson Chung4b576be2011-04-27 17:40:20 -0700321 }
322 private void beginDraggingWidget(View v) {
323 // Get the widget preview as the drag representation
324 ImageView image = (ImageView) v.findViewById(R.id.widget_preview);
Winson Chung1ed747a2011-05-03 16:18:34 -0700325 PendingAddItemInfo createItemInfo = (PendingAddItemInfo) v.getTag();
Winson Chung4b576be2011-04-27 17:40:20 -0700326
327 // Compose the drag image
Winson Chung1ed747a2011-05-03 16:18:34 -0700328 Bitmap b;
Winson Chung4b576be2011-04-27 17:40:20 -0700329 Drawable preview = image.getDrawable();
330 int w = preview.getIntrinsicWidth();
331 int h = preview.getIntrinsicHeight();
Winson Chung1ed747a2011-05-03 16:18:34 -0700332 if (createItemInfo instanceof PendingAddWidgetInfo) {
333 PendingAddWidgetInfo createWidgetInfo = (PendingAddWidgetInfo) createItemInfo;
334 int[] spanXY = CellLayout.rectToCell(getResources(),
335 createWidgetInfo.minWidth, createWidgetInfo.minHeight, null);
336 createItemInfo.spanX = spanXY[0];
337 createItemInfo.spanY = spanXY[1];
338
339 b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
340 renderDrawableToBitmap(preview, b, 0, 0, w, h, 1, 1);
341 } else {
342 // Workaround for the fact that we don't keep the original ResolveInfo associated with
343 // the shortcut around. To get the icon, we just render the preview image (which has
344 // the shortcut icon) to a new drag bitmap that clips the non-icon space.
345 b = Bitmap.createBitmap(mWidgetPreviewIconPaddedDimension,
346 mWidgetPreviewIconPaddedDimension, Bitmap.Config.ARGB_8888);
347 Canvas c = new Canvas(b);
348 preview.draw(c);
349 createItemInfo.spanX = createItemInfo.spanY = 1;
350 }
Winson Chung4b576be2011-04-27 17:40:20 -0700351
352 // Start the drag
Winson Chung4b576be2011-04-27 17:40:20 -0700353 mLauncher.lockScreenOrientation();
Winson Chung1ed747a2011-05-03 16:18:34 -0700354 mLauncher.getWorkspace().onDragStartedWithItemSpans(createItemInfo.spanX,
355 createItemInfo.spanY, b);
356 mDragController.startDrag(image, b, this, createItemInfo,
Winson Chung4b576be2011-04-27 17:40:20 -0700357 DragController.DRAG_ACTION_COPY, null);
358 b.recycle();
359 }
360 @Override
361 protected boolean beginDragging(View v) {
362 if (!super.beginDragging(v)) return false;
363
Winson Chungfc79c802011-05-02 13:35:34 -0700364
Winson Chung4b576be2011-04-27 17:40:20 -0700365 if (v instanceof PagedViewIcon) {
366 beginDraggingApplication(v);
367 } else if (v instanceof PagedViewWidget) {
368 beginDraggingWidget(v);
369 }
Winson Chung785d2eb2011-04-14 16:08:02 -0700370
Winson Chungb26f3d62011-06-02 10:49:29 -0700371 // Go into spring loaded mode
372 int currentPageIndex = mLauncher.getWorkspace().getCurrentPage();
373 CellLayout currentPage = (CellLayout) mLauncher.getWorkspace().getChildAt(currentPageIndex);
374 mLauncher.enterSpringLoadedDragMode(currentPage);
Winson Chung785d2eb2011-04-14 16:08:02 -0700375 return true;
376 }
377 private void endDragging(boolean success) {
378 post(new Runnable() {
379 // Once the drag operation has fully completed, hence the post, we want to disable the
380 // deleteZone and the appInfoButton in all apps, and re-enable the instance which
381 // live in the workspace
382 public void run() {
383 // if onDestroy was called on Launcher, we might have already deleted the
384 // all apps delete zone / info button, so check if they are null
385 DeleteZone allAppsDeleteZone =
386 (DeleteZone) mLauncher.findViewById(R.id.all_apps_delete_zone);
387 ApplicationInfoDropTarget allAppsInfoButton =
388 (ApplicationInfoDropTarget) mLauncher.findViewById(R.id.all_apps_info_target);
389
390 if (allAppsDeleteZone != null) allAppsDeleteZone.setDragAndDropEnabled(false);
391 if (allAppsInfoButton != null) allAppsInfoButton.setDragAndDropEnabled(false);
392 }
393 });
Winson Chungb26f3d62011-06-02 10:49:29 -0700394 mLauncher.exitSpringLoadedDragMode();
Winson Chung785d2eb2011-04-14 16:08:02 -0700395 mLauncher.getWorkspace().onDragStopped(success);
396 mLauncher.unlockScreenOrientation();
Winson Chungb26f3d62011-06-02 10:49:29 -0700397
Winson Chung785d2eb2011-04-14 16:08:02 -0700398 }
399
400 /*
401 * DragSource implementation
402 */
403 @Override
404 public void onDragViewVisible() {}
405 @Override
Adam Cohenc0dcf592011-06-01 15:30:43 -0700406 public void onDropCompleted(View target, DragObject d, boolean success) {
Winson Chung785d2eb2011-04-14 16:08:02 -0700407 endDragging(success);
Winson Chungfc79c802011-05-02 13:35:34 -0700408
409 // Display an error message if the drag failed due to there not being enough space on the
410 // target layout we were dropping on.
411 if (!success) {
412 boolean showOutOfSpaceMessage = false;
413 if (target instanceof Workspace) {
414 int currentScreen = mLauncher.getCurrentWorkspaceScreen();
415 Workspace workspace = (Workspace) target;
416 CellLayout layout = (CellLayout) workspace.getChildAt(currentScreen);
Adam Cohenc0dcf592011-06-01 15:30:43 -0700417 ItemInfo itemInfo = (ItemInfo) d.dragInfo;
Winson Chungfc79c802011-05-02 13:35:34 -0700418 if (layout != null) {
419 layout.calculateSpans(itemInfo);
420 showOutOfSpaceMessage =
421 !layout.findCellForSpan(null, itemInfo.spanX, itemInfo.spanY);
422 }
423 }
424 // TODO-APPS_CUSTOMIZE: We need to handle this for folders as well later.
425 if (showOutOfSpaceMessage) {
426 mLauncher.showOutOfSpaceMessage();
427 }
428 }
Winson Chung785d2eb2011-04-14 16:08:02 -0700429 }
430
431 public void setContentType(ContentType type) {
432 mContentType = type;
433 setCurrentPage(0);
434 invalidatePageData();
435 }
436
437 /*
438 * Apps PagedView implementation
439 */
Winson Chung63257c12011-05-05 17:06:13 -0700440 private void setVisibilityOnChildren(ViewGroup layout, int visibility) {
441 int childCount = layout.getChildCount();
442 for (int i = 0; i < childCount; ++i) {
443 layout.getChildAt(i).setVisibility(visibility);
444 }
445 }
Winson Chung785d2eb2011-04-14 16:08:02 -0700446 private void setupPage(PagedViewCellLayout layout) {
447 layout.setCellCount(mCellCountX, mCellCountY);
448 layout.setGap(mPageLayoutWidthGap, mPageLayoutHeightGap);
449 layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop,
450 mPageLayoutPaddingRight, mPageLayoutPaddingBottom);
451
Winson Chung63257c12011-05-05 17:06:13 -0700452 // Note: We force a measure here to get around the fact that when we do layout calculations
453 // immediately after syncing, we don't have a proper width. That said, we already know the
454 // expected page width, so we can actually optimize by hiding all the TextView-based
455 // children that are expensive to measure, and let that happen naturally later.
456 setVisibilityOnChildren(layout, View.GONE);
Winson Chung785d2eb2011-04-14 16:08:02 -0700457 int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST);
458 int heightSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST);
Winson Chung63257c12011-05-05 17:06:13 -0700459 layout.setMinimumWidth(getPageContentWidth());
Winson Chung785d2eb2011-04-14 16:08:02 -0700460 layout.measure(widthSpec, heightSpec);
Winson Chung63257c12011-05-05 17:06:13 -0700461 setVisibilityOnChildren(layout, View.VISIBLE);
Winson Chung785d2eb2011-04-14 16:08:02 -0700462 }
463 public void syncAppsPages() {
464 // Ensure that we have the right number of pages
465 Context context = getContext();
466 int numPages = (int) Math.ceil((float) mApps.size() / (mCellCountX * mCellCountY));
467 for (int i = 0; i < numPages; ++i) {
468 PagedViewCellLayout layout = new PagedViewCellLayout(context);
469 setupPage(layout);
470 addView(layout);
471 }
472 }
473 public void syncAppsPageItems(int page) {
474 // ensure that we have the right number of items on the pages
475 int numPages = getPageCount();
476 int numCells = mCellCountX * mCellCountY;
477 int startIndex = page * numCells;
478 int endIndex = Math.min(startIndex + numCells, mApps.size());
479 PagedViewCellLayout layout = (PagedViewCellLayout) getChildAt(page);
480 layout.removeAllViewsOnPage();
481 for (int i = startIndex; i < endIndex; ++i) {
482 ApplicationInfo info = mApps.get(i);
483 PagedViewIcon icon = (PagedViewIcon) mLayoutInflater.inflate(
484 R.layout.apps_customize_application, layout, false);
Michael Jurkab9b8ce92011-05-05 15:05:07 -0700485 icon.applyFromApplicationInfo(
Winson Chung9f4e0fd2011-06-02 18:59:36 -0700486 info, mPageViewIconCache, true, (numPages > 1));
Winson Chung785d2eb2011-04-14 16:08:02 -0700487 icon.setOnClickListener(this);
488 icon.setOnLongClickListener(this);
489 icon.setOnTouchListener(this);
490
491 int index = i - startIndex;
492 int x = index % mCellCountX;
493 int y = index / mCellCountX;
Winson Chung6a70e9f2011-05-17 16:24:49 -0700494 layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1));
Winson Chung785d2eb2011-04-14 16:08:02 -0700495 }
Winson Chungf0ea4d32011-06-06 14:27:16 -0700496
497 // Create the hardware layers
498 layout.allowHardwareLayerCreation();
499 layout.createHardwareLayers();
Winson Chung785d2eb2011-04-14 16:08:02 -0700500 }
501 /*
502 * Widgets PagedView implementation
503 */
Winson Chung4e6a9762011-05-09 11:56:34 -0700504 private void setupPage(PagedViewGridLayout layout) {
Winson Chung785d2eb2011-04-14 16:08:02 -0700505 layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop,
506 mPageLayoutPaddingRight, mPageLayoutPaddingBottom);
Winson Chung63257c12011-05-05 17:06:13 -0700507
508 // Note: We force a measure here to get around the fact that when we do layout calculations
509 // immediately after syncing, we don't have a proper width. That said, we already know the
510 // expected page width, so we can actually optimize by hiding all the TextView-based
511 // children that are expensive to measure, and let that happen naturally later.
512 setVisibilityOnChildren(layout, View.GONE);
513 int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST);
514 int heightSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST);
Winson Chung785d2eb2011-04-14 16:08:02 -0700515 layout.setMinimumWidth(getPageContentWidth());
Winson Chung63257c12011-05-05 17:06:13 -0700516 layout.measure(widthSpec, heightSpec);
517 setVisibilityOnChildren(layout, View.VISIBLE);
Winson Chung785d2eb2011-04-14 16:08:02 -0700518 }
519 private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int x, int y, int w, int h,
520 float scaleX, float scaleY) {
521 Canvas c = new Canvas();
522 if (bitmap != null) c.setBitmap(bitmap);
523 c.save();
524 c.scale(scaleX, scaleY);
525 Rect oldBounds = d.copyBounds();
526 d.setBounds(x, y, x + w, y + h);
527 d.draw(c);
528 d.setBounds(oldBounds); // Restore the bounds
529 c.restore();
530 }
Winson Chung1ed747a2011-05-03 16:18:34 -0700531 private FastBitmapDrawable getShortcutPreview(ResolveInfo info, int cellWidth, int cellHeight) {
532 // Return the cached version if necessary
533 Bitmap cachedBitmap = mWidgetPreviewCache.get(info);
534 if (cachedBitmap != null) {
535 return new FastBitmapDrawable(cachedBitmap);
536 }
537
538 Resources resources = mLauncher.getResources();
539 int iconSize = resources.getDimensionPixelSize(R.dimen.app_icon_size);
540 // We only need to make it wide enough so as not allow the preview to be scaled
541 int expectedWidth = cellWidth;
542 int expectedHeight = mWidgetPreviewIconPaddedDimension;
Winson Chung1ed747a2011-05-03 16:18:34 -0700543
544 // Render the icon
545 Bitmap preview = Bitmap.createBitmap(expectedWidth, expectedHeight, Config.ARGB_8888);
Winson Chung4dbea792011-05-05 14:21:32 -0700546 Drawable icon = mIconCache.getFullResIcon(info, mPackageManager);
Winson Chungf0ea4d32011-06-06 14:27:16 -0700547 renderDrawableToBitmap(icon, preview, 0, 0, iconSize, iconSize, 1f, 1f);
Winson Chung1ed747a2011-05-03 16:18:34 -0700548 FastBitmapDrawable iconDrawable = new FastBitmapDrawable(preview);
549 iconDrawable.setBounds(0, 0, expectedWidth, expectedHeight);
550 mWidgetPreviewCache.put(info, preview);
551 return iconDrawable;
552 }
Winson Chung4b576be2011-04-27 17:40:20 -0700553 private FastBitmapDrawable getWidgetPreview(AppWidgetProviderInfo info, int cellHSpan,
554 int cellVSpan, int cellWidth, int cellHeight) {
Winson Chung1ed747a2011-05-03 16:18:34 -0700555 // Return the cached version if necessary
556 Bitmap cachedBitmap = mWidgetPreviewCache.get(info);
557 if (cachedBitmap != null) {
558 return new FastBitmapDrawable(cachedBitmap);
559 }
560
Winson Chung4b576be2011-04-27 17:40:20 -0700561 // Calculate the size of the drawable
562 cellHSpan = Math.max(mMinWidgetSpan, Math.min(mMaxWidgetSpan, cellHSpan));
563 cellVSpan = Math.max(mMinWidgetSpan, Math.min(mMaxWidgetSpan, cellVSpan));
564 int expectedWidth = mWidgetSpacingLayout.estimateCellWidth(cellHSpan);
565 int expectedHeight = mWidgetSpacingLayout.estimateCellHeight(cellVSpan);
566
567 // Scale down the bitmap to fit the space
568 float widgetPreviewScale = (float) cellWidth / expectedWidth;
569 expectedWidth = (int) (widgetPreviewScale * expectedWidth);
570 expectedHeight = (int) (widgetPreviewScale * expectedHeight);
571
572 // Load the preview image if possible
573 String packageName = info.provider.getPackageName();
574 Drawable drawable = null;
575 FastBitmapDrawable newDrawable = null;
576 if (info.previewImage != 0) {
577 drawable = mPackageManager.getDrawable(packageName, info.previewImage, null);
578 if (drawable == null) {
579 Log.w(LOG_TAG, "Can't load icon drawable 0x" + Integer.toHexString(info.icon)
580 + " for provider: " + info.provider);
581 } else {
582 // Scale down the preview to the dimensions we want
583 int imageWidth = drawable.getIntrinsicWidth();
584 int imageHeight = drawable.getIntrinsicHeight();
585 float aspect = (float) imageWidth / imageHeight;
586 int newWidth = imageWidth;
587 int newHeight = imageHeight;
588 if (aspect > 1f) {
589 newWidth = expectedWidth;
590 newHeight = (int) (imageHeight * ((float) expectedWidth / imageWidth));
591 } else {
592 newHeight = expectedHeight;
593 newWidth = (int) (imageWidth * ((float) expectedHeight / imageHeight));
594 }
595
596 Bitmap preview = Bitmap.createBitmap(newWidth, newHeight, Config.ARGB_8888);
597 renderDrawableToBitmap(drawable, preview, 0, 0, newWidth, newHeight, 1f, 1f);
598 newDrawable = new FastBitmapDrawable(preview);
599 newDrawable.setBounds(0, 0, newWidth, newHeight);
Winson Chung1ed747a2011-05-03 16:18:34 -0700600 mWidgetPreviewCache.put(info, preview);
Winson Chung4b576be2011-04-27 17:40:20 -0700601 }
602 }
603
604 // Generate a preview image if we couldn't load one
605 if (drawable == null) {
Winson Chung1ed747a2011-05-03 16:18:34 -0700606 Resources resources = mLauncher.getResources();
607 int iconSize = resources.getDimensionPixelSize(R.dimen.app_icon_size);
608
609 // Specify the dimensions of the bitmap
610 if (info.minWidth >= info.minHeight) {
611 expectedWidth = cellWidth;
612 expectedHeight = mWidgetPreviewIconPaddedDimension;
613 } else {
614 // Note that in vertical widgets, we might not have enough space due to the text
615 // label, so be conservative and use the width as a height bound
616 expectedWidth = mWidgetPreviewIconPaddedDimension;
617 expectedHeight = cellWidth;
618 }
Winson Chung4b576be2011-04-27 17:40:20 -0700619
620 Bitmap preview = Bitmap.createBitmap(expectedWidth, expectedHeight, Config.ARGB_8888);
Winson Chung1ed747a2011-05-03 16:18:34 -0700621 renderDrawableToBitmap(mDefaultWidgetBackground, preview, 0, 0, expectedWidth,
622 expectedHeight, 1f,1f);
Winson Chung4b576be2011-04-27 17:40:20 -0700623
624 // Draw the icon in the top left corner
625 try {
626 Drawable icon = null;
627 if (info.icon > 0) icon = mPackageManager.getDrawable(packageName, info.icon, null);
628 if (icon == null) icon = resources.getDrawable(R.drawable.ic_launcher_application);
629
Winson Chung1ed747a2011-05-03 16:18:34 -0700630 int offset = (int) (iconSize * sWidgetPreviewIconPaddingPercentage);
Winson Chung4b576be2011-04-27 17:40:20 -0700631 renderDrawableToBitmap(icon, preview, offset, offset, iconSize, iconSize, 1f, 1f);
632 } catch (Resources.NotFoundException e) {}
633
634 newDrawable = new FastBitmapDrawable(preview);
635 newDrawable.setBounds(0, 0, expectedWidth, expectedHeight);
Winson Chung1ed747a2011-05-03 16:18:34 -0700636 mWidgetPreviewCache.put(info, preview);
Winson Chung4b576be2011-04-27 17:40:20 -0700637 }
638 return newDrawable;
Winson Chung785d2eb2011-04-14 16:08:02 -0700639 }
640 public void syncWidgetPages() {
641 // Ensure that we have the right number of pages
642 Context context = getContext();
Winson Chung4b576be2011-04-27 17:40:20 -0700643 int numWidgetsPerPage = mWidgetCountX * mWidgetCountY;
644 int numPages = (int) Math.ceil(mWidgets.size() / (float) numWidgetsPerPage);
Winson Chung785d2eb2011-04-14 16:08:02 -0700645 for (int i = 0; i < numPages; ++i) {
Winson Chung4e6a9762011-05-09 11:56:34 -0700646 PagedViewGridLayout layout = new PagedViewGridLayout(context, mWidgetCountX,
647 mWidgetCountY);
Winson Chung785d2eb2011-04-14 16:08:02 -0700648 setupPage(layout);
649 addView(layout);
650 }
651 }
652 public void syncWidgetPageItems(int page) {
Winson Chung4e6a9762011-05-09 11:56:34 -0700653 PagedViewGridLayout layout = (PagedViewGridLayout) getChildAt(page);
Winson Chung4b576be2011-04-27 17:40:20 -0700654 layout.removeAllViews();
Winson Chung785d2eb2011-04-14 16:08:02 -0700655
Winson Chung4b576be2011-04-27 17:40:20 -0700656 // Calculate the dimensions of each cell we are giving to each widget
Winson Chung4b576be2011-04-27 17:40:20 -0700657 int numWidgetsPerPage = mWidgetCountX * mWidgetCountY;
Winson Chung9f4e0fd2011-06-02 18:59:36 -0700658 int numPages = (int) Math.ceil(mWidgets.size() / (float) numWidgetsPerPage);
Winson Chung4b576be2011-04-27 17:40:20 -0700659 int offset = page * numWidgetsPerPage;
660 int cellWidth = ((mWidgetSpacingLayout.getContentWidth() - mPageLayoutWidthGap
Winson Chungf0ea4d32011-06-06 14:27:16 -0700661 - ((mWidgetCountX - 1) * mWidgetWidthGap)) / mWidgetCountX);
Winson Chung4b576be2011-04-27 17:40:20 -0700662 int cellHeight = ((mWidgetSpacingLayout.getContentHeight() - mPageLayoutHeightGap
Winson Chungf0ea4d32011-06-06 14:27:16 -0700663 - ((mWidgetCountY - 1) * mWidgetHeightGap)) / mWidgetCountY);
Winson Chung4b576be2011-04-27 17:40:20 -0700664 for (int i = 0; i < Math.min(numWidgetsPerPage, mWidgets.size() - offset); ++i) {
Winson Chung1ed747a2011-05-03 16:18:34 -0700665 Object rawInfo = mWidgets.get(offset + i);
666 PendingAddItemInfo createItemInfo = null;
Winson Chung4b576be2011-04-27 17:40:20 -0700667 PagedViewWidget widget = (PagedViewWidget) mLayoutInflater.inflate(
668 R.layout.apps_customize_widget, layout, false);
Winson Chung1ed747a2011-05-03 16:18:34 -0700669 if (rawInfo instanceof AppWidgetProviderInfo) {
670 // Fill in the widget information
671 AppWidgetProviderInfo info = (AppWidgetProviderInfo) rawInfo;
672 createItemInfo = new PendingAddWidgetInfo(info, null, null);
673 final int[] cellSpans = CellLayout.rectToCell(getResources(), info.minWidth,
674 info.minHeight, null);
675 FastBitmapDrawable preview = getWidgetPreview(info, cellSpans[0], cellSpans[1],
676 cellWidth, cellHeight);
Winson Chung9f4e0fd2011-06-02 18:59:36 -0700677 widget.applyFromAppWidgetProviderInfo(info, preview, -1, cellSpans,
678 mPageViewIconCache, (numPages > 1));
Winson Chung1ed747a2011-05-03 16:18:34 -0700679 widget.setTag(createItemInfo);
680 } else if (rawInfo instanceof ResolveInfo) {
681 // Fill in the shortcuts information
682 ResolveInfo info = (ResolveInfo) rawInfo;
683 createItemInfo = new PendingAddItemInfo();
684 createItemInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
685 createItemInfo.componentName = new ComponentName(info.activityInfo.packageName,
686 info.activityInfo.name);
687 FastBitmapDrawable preview = getShortcutPreview(info, cellWidth, cellHeight);
Winson Chung9f4e0fd2011-06-02 18:59:36 -0700688 widget.applyFromResolveInfo(mPackageManager, info, preview, mPageViewIconCache,
689 (numPages > 1));
Winson Chung1ed747a2011-05-03 16:18:34 -0700690 widget.setTag(createItemInfo);
691 }
Winson Chung4b576be2011-04-27 17:40:20 -0700692 widget.setOnClickListener(this);
693 widget.setOnLongClickListener(this);
694 widget.setOnTouchListener(this);
695
696 // Layout each widget
Winson Chung4b576be2011-04-27 17:40:20 -0700697 int ix = i % mWidgetCountX;
698 int iy = i / mWidgetCountX;
Winson Chung4e6a9762011-05-09 11:56:34 -0700699 PagedViewGridLayout.LayoutParams lp = new PagedViewGridLayout.LayoutParams(cellWidth,
700 cellHeight);
Winson Chungf0ea4d32011-06-06 14:27:16 -0700701 lp.leftMargin = (ix * cellWidth) + (ix * mWidgetWidthGap);
702 lp.topMargin = (iy * cellHeight) + (iy * mWidgetHeightGap);
Winson Chung4e6a9762011-05-09 11:56:34 -0700703 layout.addView(widget, lp);
Winson Chung785d2eb2011-04-14 16:08:02 -0700704 }
Winson Chung785d2eb2011-04-14 16:08:02 -0700705 }
Winson Chung46af2e82011-05-09 16:00:53 -0700706
Winson Chung785d2eb2011-04-14 16:08:02 -0700707 @Override
708 public void syncPages() {
709 removeAllViews();
710 switch (mContentType) {
711 case Applications:
712 syncAppsPages();
713 break;
714 case Widgets:
715 syncWidgetPages();
716 break;
717 }
718 }
719 @Override
720 public void syncPageItems(int page) {
721 switch (mContentType) {
722 case Applications:
723 syncAppsPageItems(page);
724 break;
725 case Widgets:
726 syncWidgetPageItems(page);
727 break;
728 }
729 }
730
731 /**
732 * Used by the parent to get the content width to set the tab bar to
733 * @return
734 */
735 public int getPageContentWidth() {
736 return mContentWidth;
737 }
738
Winson Chungb26f3d62011-06-02 10:49:29 -0700739 @Override
740 protected void onPageBeginMoving() {
741 /* TO BE ENABLED LATER
742 setChildrenDrawnWithCacheEnabled(true);
743 for (int i = 0; i < getChildCount(); ++i) {
744 View v = getChildAt(i);
745 if (v instanceof PagedViewCellLayout) {
746 ((PagedViewCellLayout) v).setChildrenDrawingCacheEnabled(true);
747 }
748 }
749 */
750 super.onPageBeginMoving();
751 }
752
753 @Override
754 protected void onPageEndMoving() {
755 /* TO BE ENABLED LATER
756 for (int i = 0; i < getChildCount(); ++i) {
757 View v = getChildAt(i);
758 if (v instanceof PagedViewCellLayout) {
759 ((PagedViewCellLayout) v).setChildrenDrawingCacheEnabled(false);
760 }
761 }
762 setChildrenDrawnWithCacheEnabled(false);
763 */
764 super.onPageEndMoving();
765 }
766
Winson Chung785d2eb2011-04-14 16:08:02 -0700767 /*
768 * AllAppsView implementation
769 */
770 @Override
771 public void setup(Launcher launcher, DragController dragController) {
772 mLauncher = launcher;
773 mDragController = dragController;
774 }
775 @Override
776 public void zoom(float zoom, boolean animate) {
777 // TODO-APPS_CUSTOMIZE: Call back to mLauncher.zoomed()
778 }
779 @Override
780 public boolean isVisible() {
781 return (getVisibility() == VISIBLE);
782 }
783 @Override
784 public boolean isAnimating() {
785 return false;
786 }
787 @Override
788 public void setApps(ArrayList<ApplicationInfo> list) {
789 mApps = list;
790 Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
Winson Chungf0ea4d32011-06-06 14:27:16 -0700791
792 // The next layout pass will trigger data-ready if both widgets and apps are set, so request
793 // a layout to do this test and invalidate the page data when ready.
794 if (testDataReady()) requestLayout();
Winson Chung785d2eb2011-04-14 16:08:02 -0700795 }
796 private void addAppsWithoutInvalidate(ArrayList<ApplicationInfo> list) {
797 // We add it in place, in alphabetical order
798 int count = list.size();
799 for (int i = 0; i < count; ++i) {
800 ApplicationInfo info = list.get(i);
801 int index = Collections.binarySearch(mApps, info, LauncherModel.APP_NAME_COMPARATOR);
802 if (index < 0) {
803 mApps.add(-(index + 1), info);
804 }
805 }
806 }
807 @Override
808 public void addApps(ArrayList<ApplicationInfo> list) {
809 addAppsWithoutInvalidate(list);
810 invalidatePageData();
811 }
812 private int findAppByComponent(List<ApplicationInfo> list, ApplicationInfo item) {
813 ComponentName removeComponent = item.intent.getComponent();
814 int length = list.size();
815 for (int i = 0; i < length; ++i) {
816 ApplicationInfo info = list.get(i);
817 if (info.intent.getComponent().equals(removeComponent)) {
818 return i;
819 }
820 }
821 return -1;
822 }
823 private void removeAppsWithoutInvalidate(ArrayList<ApplicationInfo> list) {
824 // loop through all the apps and remove apps that have the same component
825 int length = list.size();
826 for (int i = 0; i < length; ++i) {
827 ApplicationInfo info = list.get(i);
828 int removeIndex = findAppByComponent(mApps, info);
829 if (removeIndex > -1) {
830 mApps.remove(removeIndex);
831 mPageViewIconCache.removeOutline(new PagedViewIconCache.Key(info));
832 }
833 }
834 }
835 @Override
836 public void removeApps(ArrayList<ApplicationInfo> list) {
837 removeAppsWithoutInvalidate(list);
838 invalidatePageData();
839 }
840 @Override
841 public void updateApps(ArrayList<ApplicationInfo> list) {
842 // We remove and re-add the updated applications list because it's properties may have
843 // changed (ie. the title), and this will ensure that the items will be in their proper
844 // place in the list.
845 removeAppsWithoutInvalidate(list);
846 addAppsWithoutInvalidate(list);
847 invalidatePageData();
848 }
849 @Override
850 public void reset() {
Winson Chungfc79c802011-05-02 13:35:34 -0700851 if (mContentType != ContentType.Applications) {
852 // Reset to the first page of the Apps pane
853 AppsCustomizeTabHost tabs = (AppsCustomizeTabHost)
854 mLauncher.findViewById(R.id.apps_customize_pane);
855 tabs.setCurrentTabByTag(tabs.getTabTagForContentType(ContentType.Applications));
856 } else {
857 setCurrentPage(0);
858 invalidatePageData();
859 }
Winson Chung785d2eb2011-04-14 16:08:02 -0700860 }
861 @Override
862 public void dumpState() {
863 // TODO: Dump information related to current list of Applications, Widgets, etc.
864 ApplicationInfo.dumpApplicationInfoList(LOG_TAG, "mApps", mApps);
865 dumpAppWidgetProviderInfoList(LOG_TAG, "mWidgets", mWidgets);
866 }
867 private void dumpAppWidgetProviderInfoList(String tag, String label,
Winson Chung1ed747a2011-05-03 16:18:34 -0700868 List<Object> list) {
Winson Chung785d2eb2011-04-14 16:08:02 -0700869 Log.d(tag, label + " size=" + list.size());
Winson Chung1ed747a2011-05-03 16:18:34 -0700870 for (Object i: list) {
871 if (i instanceof AppWidgetProviderInfo) {
872 AppWidgetProviderInfo info = (AppWidgetProviderInfo) i;
873 Log.d(tag, " label=\"" + info.label + "\" previewImage=" + info.previewImage
874 + " resizeMode=" + info.resizeMode + " configure=" + info.configure
875 + " initialLayout=" + info.initialLayout
876 + " minWidth=" + info.minWidth + " minHeight=" + info.minHeight);
877 } else if (i instanceof ResolveInfo) {
878 ResolveInfo info = (ResolveInfo) i;
879 Log.d(tag, " label=\"" + info.loadLabel(mPackageManager) + "\" icon="
880 + info.icon);
881 }
Winson Chung785d2eb2011-04-14 16:08:02 -0700882 }
883 }
884 @Override
885 public void surrender() {
886 // TODO: If we are in the middle of any process (ie. for holographic outlines, etc) we
887 // should stop this now.
888 }
889}