blob: cf752509e4be671b7677c7df8f2028091e7095a7 [file] [log] [blame]
Joe Onorato93839052009-08-06 20:34:32 -07001/*
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
17package com.android.launcher2;
18
Joe Onoratocb9f7982009-10-31 16:32:02 -040019import android.content.ComponentName;
Joe Onorato93839052009-08-06 20:34:32 -070020import android.content.Context;
21import android.content.res.Resources;
22import android.graphics.Bitmap;
Joe Onorato93839052009-08-06 20:34:32 -070023import android.graphics.Canvas;
Mike Cleron4a5c1e12009-11-03 10:17:05 -080024import android.graphics.PixelFormat;
Mike Cleron7d5d7462009-10-20 14:06:00 -070025import android.graphics.Rect;
Joe Onoratod769a632009-08-11 17:09:02 -070026import android.os.SystemClock;
Mike Cleron4a5c1e12009-11-03 10:17:05 -080027import android.renderscript.Allocation;
28import android.renderscript.Dimension;
29import android.renderscript.Element;
30import android.renderscript.ProgramFragment;
31import android.renderscript.ProgramStore;
32import android.renderscript.ProgramVertex;
33import android.renderscript.RSSurfaceView;
Jason Samse48eae02010-02-09 15:55:48 -080034import android.renderscript.RenderScriptGL;
Mike Cleron4a5c1e12009-11-03 10:17:05 -080035import android.renderscript.RenderScript;
36import android.renderscript.Sampler;
37import android.renderscript.Script;
38import android.renderscript.ScriptC;
39import android.renderscript.SimpleMesh;
40import android.renderscript.Type;
Joe Onorato93839052009-08-06 20:34:32 -070041import android.util.AttributeSet;
42import android.util.Log;
Joe Onoratod769a632009-08-11 17:09:02 -070043import android.view.KeyEvent;
44import android.view.MotionEvent;
Joe Onoratob39e51a2009-10-28 15:47:49 -040045import android.view.SoundEffectConstants;
Joe Onorato93839052009-08-06 20:34:32 -070046import android.view.SurfaceHolder;
Joe Onoratod769a632009-08-11 17:09:02 -070047import android.view.VelocityTracker;
Mike Cleron4a5c1e12009-11-03 10:17:05 -080048import android.view.View;
Joe Onoratod769a632009-08-11 17:09:02 -070049import android.view.ViewConfiguration;
Joe Onorato52a653f2009-11-11 14:52:11 -080050import android.view.accessibility.AccessibilityEvent;
Mike Cleron4a5c1e12009-11-03 10:17:05 -080051
52import java.util.ArrayList;
Joe Onoratobe386092009-11-17 17:32:16 -080053import java.util.Arrays;
Mike Cleron4a5c1e12009-11-03 10:17:05 -080054import java.util.Collections;
55import java.util.Comparator;
Joe Onorato93839052009-08-06 20:34:32 -070056
57
Joe Onorato6665c0f2009-09-02 15:27:24 -070058public class AllAppsView extends RSSurfaceView
Joe Onorato5162ea92009-09-03 09:39:42 -070059 implements View.OnClickListener, View.OnLongClickListener, DragSource {
Joe Onorato9c1289c2009-08-17 11:03:03 -040060 private static final String TAG = "Launcher.AllAppsView";
61
Joe Onoratofb0ca672009-09-14 17:55:46 -040062 /** Bit for mLocks for when there are icons being loaded. */
63 private static final int LOCK_ICONS_PENDING = 1;
64
Joe Onorato68ffd102009-10-15 17:59:43 -070065 private static final int TRACKING_NONE = 0;
66 private static final int TRACKING_FLING = 1;
67 private static final int TRACKING_HOME = 2;
Joe Onoratobcbeab82009-10-01 21:45:43 -070068
Joe Onoratoeb8325a2009-11-08 13:20:30 -050069 private static final int SELECTED_NONE = 0;
70 private static final int SELECTED_FOCUSED = 1;
71 private static final int SELECTED_PRESSED = 2;
72
73 private static final int SELECTION_NONE = 0;
74 private static final int SELECTION_ICONS = 1;
75 private static final int SELECTION_HOME = 2;
76
Joe Onorato6665c0f2009-09-02 15:27:24 -070077 private Launcher mLauncher;
Joe Onorato5162ea92009-09-03 09:39:42 -070078 private DragController mDragController;
Joe Onoratofb0ca672009-09-14 17:55:46 -040079
80 /** When this is 0, modifications are allowed, when it's not, they're not.
81 * TODO: What about scrolling? */
82 private int mLocks = LOCK_ICONS_PENDING;
Joe Onorato6665c0f2009-09-02 15:27:24 -070083
Joe Onorato82ca5502009-10-15 16:59:23 -070084 private int mSlop;
Joe Onoratof7b0e012009-10-01 14:09:15 -070085 private int mMaxFlingVelocity;
86
Joe Onoratobcbeab82009-10-01 21:45:43 -070087 private Defines mDefines = new Defines();
Jason Samse48eae02010-02-09 15:55:48 -080088 private RenderScriptGL mRS;
Joe Onorato1feb3a82009-08-08 22:32:00 -070089 private RolloRS mRollo;
Joe Onorato9c1289c2009-08-17 11:03:03 -040090 private ArrayList<ApplicationInfo> mAllAppsList;
Jason Sams2e19c052009-10-20 18:19:55 -070091
Mike Cleron7d5d7462009-10-20 14:06:00 -070092 /**
93 * True when we are using arrow keys or trackball to drive navigation
94 */
95 private boolean mArrowNavigation = false;
Joe Onoratoeb8325a2009-11-08 13:20:30 -050096 private boolean mStartedScrolling;
97
98 /**
99 * Used to keep track of the selection when AllAppsView loses window focus.
100 * One of the SELECTION_ constants.
101 */
102 private int mLastSelection;
Jason Sams2e19c052009-10-20 18:19:55 -0700103
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800104 /**
105 * Used to keep track of the selection when AllAppsView loses window focus
106 */
107 private int mLastSelectedIcon;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500108
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800109 private VelocityTracker mVelocityTracker;
Joe Onoratobcbeab82009-10-01 21:45:43 -0700110 private int mTouchTracking;
Joe Onorato5162ea92009-09-03 09:39:42 -0700111 private int mMotionDownRawX;
112 private int mMotionDownRawY;
Joe Onorato82ca5502009-10-15 16:59:23 -0700113 private int mDownIconIndex = -1;
114 private int mCurrentIconIndex = -1;
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800115
Mike Cleronb64b67a2009-11-08 14:56:25 -0800116 private boolean mShouldGainFocus;
117
Joe Onorato6374c512010-01-06 20:42:25 -0800118 private boolean mHaveSurface = false;
Joe Onorato3a8820b2009-11-10 15:06:42 -0800119 private boolean mZoomDirty = false;
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800120 private boolean mAnimateNextZoom;
Joe Onorato6374c512010-01-06 20:42:25 -0800121 private float mNextZoom;
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800122 private float mZoom;
123 private float mPosX;
124 private float mVelocity;
125 private AAMessage mMessageProc;
Joe Onorato1feb3a82009-08-08 22:32:00 -0700126
Joe Onorato6665c0f2009-09-02 15:27:24 -0700127 static class Defines {
Joe Onoratoc567acb2009-08-31 14:34:43 -0700128 public static final int ALLOC_PARAMS = 0;
129 public static final int ALLOC_STATE = 1;
Joe Onorato7bb17492009-09-24 17:51:01 -0700130 public static final int ALLOC_ICON_IDS = 3;
131 public static final int ALLOC_LABEL_IDS = 4;
Jason Samsb4ecab22010-01-19 16:43:26 -0800132 public static final int ALLOC_VP_CONSTANTS = 5;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700133
134 public static final int COLUMNS_PER_PAGE = 4;
135 public static final int ROWS_PER_PAGE = 4;
Jason Sams78aebd82009-09-15 13:06:59 -0700136
Joe Onorato6665c0f2009-09-02 15:27:24 -0700137 public static final int ICON_WIDTH_PX = 64;
Jason Sams1a94ee32010-01-20 13:34:30 -0800138 public static final int ICON_TEXTURE_WIDTH_PX = 74;
139 public static final int SELECTION_TEXTURE_WIDTH_PX = 74 + 20;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700140
141 public static final int ICON_HEIGHT_PX = 64;
Jason Sams1a94ee32010-01-20 13:34:30 -0800142 public static final int ICON_TEXTURE_HEIGHT_PX = 74;
143 public static final int SELECTION_TEXTURE_HEIGHT_PX = 74 + 20;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700144 }
Joe Onorato7c312c12009-08-13 21:36:53 -0700145
146 public AllAppsView(Context context, AttributeSet attrs) {
147 super(context, attrs);
Joe Onorato93839052009-08-06 20:34:32 -0700148 setFocusable(true);
Joe Onoratob39e51a2009-10-28 15:47:49 -0400149 setSoundEffectsEnabled(false);
Joe Onorato93839052009-08-06 20:34:32 -0700150 getHolder().setFormat(PixelFormat.TRANSLUCENT);
Joe Onoratof7b0e012009-10-01 14:09:15 -0700151 final ViewConfiguration config = ViewConfiguration.get(context);
Joe Onorato82ca5502009-10-15 16:59:23 -0700152 mSlop = config.getScaledTouchSlop();
Joe Onoratof7b0e012009-10-01 14:09:15 -0700153 mMaxFlingVelocity = config.getScaledMaximumFlingVelocity();
154
Joe Onorato6665c0f2009-09-02 15:27:24 -0700155 setOnClickListener(this);
156 setOnLongClickListener(this);
Dianne Hackborne52a1b52009-09-30 22:36:20 -0700157 setZOrderOnTop(true);
Jason Samsfd22dac2009-09-20 17:24:16 -0700158 getHolder().setFormat(PixelFormat.TRANSLUCENT);
Jason Samse26d9fc2009-11-12 14:00:43 -0800159
160 mRS = createRenderScript(true);
161 }
162
Joe Onorato339cdd92010-02-17 14:07:31 -0500163 /**
164 * Note that this implementation prohibits this view from ever being reattached.
165 */
Jason Samse26d9fc2009-11-12 14:00:43 -0800166 @Override
167 protected void onDetachedFromWindow() {
168 destroyRenderScript();
Joe Onorato339cdd92010-02-17 14:07:31 -0500169 mRS.mMessageCallback = null;
170 mRS = null;
Joe Onorato93839052009-08-06 20:34:32 -0700171 }
172
Joe Onoratob39e51a2009-10-28 15:47:49 -0400173 /**
174 * If you have an attached click listener, View always plays the click sound!?!?
175 * Deal with sound effects by hand.
176 */
177 public void reallyPlaySoundEffect(int sound) {
178 boolean old = isSoundEffectsEnabled();
179 setSoundEffectsEnabled(true);
180 playSoundEffect(sound);
181 setSoundEffectsEnabled(old);
182 }
183
Joe Onorato7c312c12009-08-13 21:36:53 -0700184 public AllAppsView(Context context, AttributeSet attrs, int defStyle) {
185 this(context, attrs);
Joe Onorato93839052009-08-06 20:34:32 -0700186 }
187
Joe Onorato6665c0f2009-09-02 15:27:24 -0700188 public void setLauncher(Launcher launcher) {
189 mLauncher = launcher;
Joe Onorato93839052009-08-06 20:34:32 -0700190 }
191
Joe Onorato1feb3a82009-08-08 22:32:00 -0700192 @Override
Joe Onorato7bb17492009-09-24 17:51:01 -0700193 public void surfaceDestroyed(SurfaceHolder holder) {
194 super.surfaceDestroyed(holder);
Joe Onoratofab74402009-11-11 16:05:23 -0800195 // Without this, we leak mMessageCallback which leaks the context.
196 mRS.mMessageCallback = null;
Joe Onorato6374c512010-01-06 20:42:25 -0800197 // We may lose any callbacks that are pending, so make sure that we re-sync that
198 // on the next surfaceChanged.
199 mZoomDirty = true;
200 mHaveSurface = false;
Joe Onorato7bb17492009-09-24 17:51:01 -0700201 }
202
203 @Override
Joe Onorato93839052009-08-06 20:34:32 -0700204 public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
Joe Onoratoa30ce8e2009-11-11 08:16:49 -0800205 //long startTime = SystemClock.uptimeMillis();
Joe Onorato6665c0f2009-09-02 15:27:24 -0700206
Joe Onorato080d9b62009-11-02 12:01:11 -0500207 super.surfaceChanged(holder, format, w, h);
208
Joe Onorato6374c512010-01-06 20:42:25 -0800209 mHaveSurface = true;
210
Jason Samse26d9fc2009-11-12 14:00:43 -0800211 if (mRollo == null) {
Jason Sams90396672009-11-03 13:59:34 -0800212 mRollo = new RolloRS();
213 mRollo.init(getResources(), w, h);
214 if (mAllAppsList != null) {
215 mRollo.setApps(mAllAppsList);
Jason Sams90396672009-11-03 13:59:34 -0800216 }
Mike Cleronb64b67a2009-11-08 14:56:25 -0800217 if (mShouldGainFocus) {
218 gainFocus();
219 mShouldGainFocus = false;
220 }
Joe Onorato9c1289c2009-08-17 11:03:03 -0400221 }
Jason Samse26d9fc2009-11-12 14:00:43 -0800222 mRollo.dirtyCheck();
Jason Sams5612e432009-11-16 14:18:07 -0800223 mRollo.resize(w, h);
Joe Onoratoc567acb2009-08-31 14:34:43 -0700224
Joe Onorato339cdd92010-02-17 14:07:31 -0500225 if (mRS != null) {
226 mRS.mMessageCallback = mMessageProc = new AAMessage();
227 }
Joe Onoratocb75f362009-11-12 13:04:07 -0800228
Joe Onoratoc567acb2009-08-31 14:34:43 -0700229 Resources res = getContext().getResources();
230 int barHeight = (int)res.getDimension(R.dimen.button_bar_height);
Joe Onorato6665c0f2009-09-02 15:27:24 -0700231
Jason Sams76512482010-02-04 16:31:35 -0800232
233 if (mRollo.mUniformAlloc != null) {
234 float tf[] = new float[] {72.f, 72.f,
235 120.f, 120.f, 0.f, 0.f,
236 120.f, 680.f,
237 (2.f / 480.f), 0, -((float)w / 2) - 0.25f, -380.25f};
238 if (w > h) {
239 tf[6] = 40.f;
240 tf[7] = h - 40.f;
241 tf[9] = 1.f;
242 tf[10] = -((float)w / 2) - 0.25f;
243 tf[11] = -((float)h / 2) - 0.25f;
244 }
245
246 mRollo.mUniformAlloc.data(tf);
247 }
248
Joe Onoratoa30ce8e2009-11-11 08:16:49 -0800249 //long endTime = SystemClock.uptimeMillis();
250 //Log.d(TAG, "surfaceChanged took " + (endTime-startTime) + "ms");
Joe Onorato93839052009-08-06 20:34:32 -0700251 }
Jason Sams2e19c052009-10-20 18:19:55 -0700252
Joe Onorato93839052009-08-06 20:34:32 -0700253 @Override
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800254 public void onWindowFocusChanged(boolean hasWindowFocus) {
255 super.onWindowFocusChanged(hasWindowFocus);
256 if (mArrowNavigation) {
257 if (!hasWindowFocus) {
258 // Clear selection when we lose window focus
259 mLastSelectedIcon = mRollo.mState.selectedIconIndex;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500260 mRollo.setHomeSelected(SELECTED_NONE);
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800261 mRollo.clearSelectedIcon();
262 mRollo.mState.save();
263 } else if (hasWindowFocus) {
264 if (mRollo.mState.iconCount > 0) {
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500265 if (mLastSelection == SELECTION_ICONS) {
266 int selection = mLastSelectedIcon;
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800267 final int firstIcon = Math.round(mPosX) *
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500268 Defines.COLUMNS_PER_PAGE;
269 if (selection < 0 || // No selection
270 selection < firstIcon || // off the top of the screen
271 selection >= mRollo.mState.iconCount || // past last icon
272 selection >= firstIcon + // past last icon on screen
273 (Defines.COLUMNS_PER_PAGE * Defines.ROWS_PER_PAGE)) {
274 selection = firstIcon;
275 }
276
277 // Select the first icon when we gain window focus
278 mRollo.selectIcon(selection, SELECTED_FOCUSED);
279 mRollo.mState.save();
280 } else if (mLastSelection == SELECTION_HOME) {
281 mRollo.setHomeSelected(SELECTED_FOCUSED);
282 mRollo.mState.save();
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800283 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800284 }
285 }
286 }
287 }
288
289 @Override
Mike Cleron7d5d7462009-10-20 14:06:00 -0700290 protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
291 super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
Joe Onorato859b3a72009-10-28 15:17:01 -0400292
293 if (!isVisible()) {
294 return;
295 }
296
Mike Cleron7d5d7462009-10-20 14:06:00 -0700297 if (gainFocus) {
Jason Sams510ee042009-12-15 14:23:37 -0800298 if (mRollo != null) {
Mike Cleronb64b67a2009-11-08 14:56:25 -0800299 gainFocus();
300 } else {
301 mShouldGainFocus = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700302 }
303 } else {
Joe Onorato8eea3912009-12-09 13:01:06 -0800304 if (mRollo != null) {
Mike Cleronb64b67a2009-11-08 14:56:25 -0800305 if (mArrowNavigation) {
306 // Clear selection when we lose focus
307 mRollo.clearSelectedIcon();
308 mRollo.setHomeSelected(SELECTED_NONE);
309 mRollo.mState.save();
310 mArrowNavigation = false;
311 }
312 } else {
313 mShouldGainFocus = false;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700314 }
315 }
316 }
317
Mike Cleronb64b67a2009-11-08 14:56:25 -0800318 private void gainFocus() {
319 if (!mArrowNavigation && mRollo.mState.iconCount > 0) {
320 // Select the first icon when we gain keyboard focus
321 mArrowNavigation = true;
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800322 mRollo.selectIcon(Math.round(mPosX) * Defines.COLUMNS_PER_PAGE,
Mike Cleronb64b67a2009-11-08 14:56:25 -0800323 SELECTED_FOCUSED);
324 mRollo.mState.save();
325 }
326 }
327
Mike Cleron7d5d7462009-10-20 14:06:00 -0700328 @Override
329 public boolean onKeyDown(int keyCode, KeyEvent event) {
Jason Sams2e19c052009-10-20 18:19:55 -0700330
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800331 boolean handled = false;
Jason Samse26d9fc2009-11-12 14:00:43 -0800332
Joe Onorato859b3a72009-10-28 15:17:01 -0400333 if (!isVisible()) {
334 return false;
335 }
Joe Onoratoa13f5742009-11-02 17:15:19 -0500336 final int iconCount = mRollo.mState.iconCount;
337
Mike Cleron7d5d7462009-10-20 14:06:00 -0700338 if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
339 if (mArrowNavigation) {
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500340 if (mLastSelection == SELECTION_HOME) {
341 reallyPlaySoundEffect(SoundEffectConstants.CLICK);
342 mLauncher.closeAllApps(true);
343 } else {
344 int whichApp = mRollo.mState.selectedIconIndex;
345 if (whichApp >= 0) {
346 ApplicationInfo app = mAllAppsList.get(whichApp);
347 mLauncher.startActivitySafely(app.intent);
348 handled = true;
349 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700350 }
351 }
352 }
Jason Sams2e19c052009-10-20 18:19:55 -0700353
Joe Onorato478730f2009-11-16 18:54:43 -0800354 if (iconCount > 0) {
Mike Cleron7d5d7462009-10-20 14:06:00 -0700355 mArrowNavigation = true;
Jason Sams2e19c052009-10-20 18:19:55 -0700356
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800357 int currentSelection = mRollo.mState.selectedIconIndex;
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800358 int currentTopRow = Math.round(mPosX);
Jason Sams2e19c052009-10-20 18:19:55 -0700359
Mike Cleron7d5d7462009-10-20 14:06:00 -0700360 // The column of the current selection, in the range 0..COLUMNS_PER_PAGE-1
Joe Onoratoa13f5742009-11-02 17:15:19 -0500361 final int currentPageCol = currentSelection % Defines.COLUMNS_PER_PAGE;
Jason Sams2e19c052009-10-20 18:19:55 -0700362
Mike Cleron7d5d7462009-10-20 14:06:00 -0700363 // The row of the current selection, in the range 0..ROWS_PER_PAGE-1
Joe Onoratoa13f5742009-11-02 17:15:19 -0500364 final int currentPageRow = (currentSelection - (currentTopRow*Defines.COLUMNS_PER_PAGE))
Mike Cleron7d5d7462009-10-20 14:06:00 -0700365 / Defines.ROWS_PER_PAGE;
Jason Sams2e19c052009-10-20 18:19:55 -0700366
Mike Cleron7d5d7462009-10-20 14:06:00 -0700367 int newSelection = currentSelection;
368
369 switch (keyCode) {
370 case KeyEvent.KEYCODE_DPAD_UP:
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500371 if (mLastSelection == SELECTION_HOME) {
372 mRollo.setHomeSelected(SELECTED_NONE);
373 int lastRowCount = iconCount % Defines.COLUMNS_PER_PAGE;
374 if (lastRowCount == 0) {
375 lastRowCount = Defines.COLUMNS_PER_PAGE;
376 }
377 newSelection = iconCount - lastRowCount + (Defines.COLUMNS_PER_PAGE / 2);
378 if (newSelection >= iconCount) {
379 newSelection = iconCount-1;
380 }
381 int target = (newSelection / Defines.COLUMNS_PER_PAGE)
382 - (Defines.ROWS_PER_PAGE - 1);
383 if (target < 0) {
384 target = 0;
385 }
386 if (currentTopRow != target) {
387 mRollo.moveTo(target);
388 }
389 } else {
390 if (currentPageRow > 0) {
391 newSelection = currentSelection - Defines.COLUMNS_PER_PAGE;
392 } else if (currentTopRow > 0) {
393 newSelection = currentSelection - Defines.COLUMNS_PER_PAGE;
394 mRollo.moveTo(newSelection / Defines.COLUMNS_PER_PAGE);
Joe Onoratoaf5b4cb2009-12-08 17:51:22 -0800395 } else if (currentPageRow != 0) {
396 newSelection = currentTopRow * Defines.ROWS_PER_PAGE;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500397 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700398 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800399 handled = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700400 break;
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800401
Joe Onoratoa13f5742009-11-02 17:15:19 -0500402 case KeyEvent.KEYCODE_DPAD_DOWN: {
403 final int rowCount = iconCount / Defines.COLUMNS_PER_PAGE
404 + (iconCount % Defines.COLUMNS_PER_PAGE == 0 ? 0 : 1);
405 final int currentRow = currentSelection / Defines.COLUMNS_PER_PAGE;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500406 if (mLastSelection != SELECTION_HOME) {
407 if (currentRow < rowCount-1) {
408 mRollo.setHomeSelected(SELECTED_NONE);
Joe Onorato478730f2009-11-16 18:54:43 -0800409 if (currentSelection < 0) {
410 newSelection = 0;
411 } else {
412 newSelection = currentSelection + Defines.COLUMNS_PER_PAGE;
413 }
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500414 if (newSelection >= iconCount) {
415 // Go from D to G in this arrangement:
416 // A B C D
417 // E F G
418 newSelection = iconCount - 1;
419 }
420 if (currentPageRow >= Defines.ROWS_PER_PAGE - 1) {
421 mRollo.moveTo((newSelection / Defines.COLUMNS_PER_PAGE) -
422 Defines.ROWS_PER_PAGE + 1);
423 }
424 } else {
425 newSelection = -1;
426 mRollo.setHomeSelected(SELECTED_FOCUSED);
Mike Cleron7d5d7462009-10-20 14:06:00 -0700427 }
428 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800429 handled = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700430 break;
Joe Onoratoa13f5742009-11-02 17:15:19 -0500431 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700432 case KeyEvent.KEYCODE_DPAD_LEFT:
Joe Onoratoe9a3f3d2010-02-01 18:36:43 -0500433 if (mLastSelection != SELECTION_HOME) {
434 if (currentPageCol > 0) {
435 newSelection = currentSelection - 1;
436 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700437 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800438 handled = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700439 break;
440 case KeyEvent.KEYCODE_DPAD_RIGHT:
Joe Onoratoe9a3f3d2010-02-01 18:36:43 -0500441 if (mLastSelection != SELECTION_HOME) {
442 if ((currentPageCol < Defines.COLUMNS_PER_PAGE - 1) &&
443 (currentSelection < iconCount - 1)) {
444 newSelection = currentSelection + 1;
445 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700446 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800447 handled = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700448 break;
449 }
450 if (newSelection != currentSelection) {
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500451 mRollo.selectIcon(newSelection, SELECTED_FOCUSED);
Mike Cleron7d5d7462009-10-20 14:06:00 -0700452 mRollo.mState.save();
453 }
454 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800455 return handled;
Joe Onorato93839052009-08-06 20:34:32 -0700456 }
457
Joe Onorato93839052009-08-06 20:34:32 -0700458 @Override
459 public boolean onTouchEvent(MotionEvent ev)
460 {
Mike Cleron7d5d7462009-10-20 14:06:00 -0700461 mArrowNavigation = false;
Jason Sams2e19c052009-10-20 18:19:55 -0700462
Joe Onorato7bb17492009-09-24 17:51:01 -0700463 if (!isVisible()) {
Joe Onorato85a02a82009-09-08 12:34:22 -0700464 return true;
Joe Onoratoe3406a22009-09-03 14:36:25 -0700465 }
466
Joe Onoratofb0ca672009-09-14 17:55:46 -0400467 if (mLocks != 0) {
Joe Onorato85a02a82009-09-08 12:34:22 -0700468 return true;
469 }
470
471 super.onTouchEvent(ev);
472
Joe Onoratofb0ca672009-09-14 17:55:46 -0400473 int x = (int)ev.getX();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700474 int y = (int)ev.getY();
475
Joe Onoratobcbeab82009-10-01 21:45:43 -0700476 int action = ev.getAction();
477 switch (action) {
Joe Onoratofb0ca672009-09-14 17:55:46 -0400478 case MotionEvent.ACTION_DOWN:
Joe Onoratobcbeab82009-10-01 21:45:43 -0700479 if (y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]) {
480 mTouchTracking = TRACKING_HOME;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500481 mRollo.setHomeSelected(SELECTED_PRESSED);
Joe Onoratod63458b2009-10-15 21:19:09 -0700482 mRollo.mState.save();
Mike Cleron7d5d7462009-10-20 14:06:00 -0700483 mCurrentIconIndex = -1;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700484 } else {
Joe Onoratobcbeab82009-10-01 21:45:43 -0700485 mTouchTracking = TRACKING_FLING;
486
487 mMotionDownRawX = (int)ev.getRawX();
488 mMotionDownRawY = (int)ev.getRawY();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700489
Mike Cleron7d5d7462009-10-20 14:06:00 -0700490 mRollo.mState.newPositionX = ev.getRawY() / getHeight();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700491 mRollo.mState.newTouchDown = 1;
492
493 if (!mRollo.checkClickOK()) {
494 mRollo.clearSelectedIcon();
495 } else {
Joe Onorato82ca5502009-10-15 16:59:23 -0700496 mDownIconIndex = mCurrentIconIndex
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800497 = mRollo.selectIcon(x, y, mPosX, SELECTED_PRESSED);
Joe Onorato82ca5502009-10-15 16:59:23 -0700498 if (mDownIconIndex < 0) {
499 // if nothing was selected, no long press.
500 cancelLongPress();
501 }
Joe Onoratobcbeab82009-10-01 21:45:43 -0700502 }
503 mRollo.mState.save();
Jason Samsd8152b92009-10-13 17:19:10 -0700504 mRollo.move();
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800505 mVelocityTracker = VelocityTracker.obtain();
506 mVelocityTracker.addMovement(ev);
Joe Onoratobcbeab82009-10-01 21:45:43 -0700507 mStartedScrolling = false;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700508 }
Joe Onoratofb0ca672009-09-14 17:55:46 -0400509 break;
510 case MotionEvent.ACTION_MOVE:
511 case MotionEvent.ACTION_OUTSIDE:
Joe Onoratobcbeab82009-10-01 21:45:43 -0700512 if (mTouchTracking == TRACKING_HOME) {
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500513 mRollo.setHomeSelected(y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]
514 ? SELECTED_PRESSED : SELECTED_NONE);
Joe Onoratod63458b2009-10-15 21:19:09 -0700515 mRollo.mState.save();
Joe Onorato68ffd102009-10-15 17:59:43 -0700516 } else if (mTouchTracking == TRACKING_FLING) {
Joe Onorato82ca5502009-10-15 16:59:23 -0700517 int rawX = (int)ev.getRawX();
518 int rawY = (int)ev.getRawY();
519 int slop;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700520 slop = Math.abs(rawY - mMotionDownRawY);
Jason Samsd8152b92009-10-13 17:19:10 -0700521
Joe Onorato82ca5502009-10-15 16:59:23 -0700522 if (!mStartedScrolling && slop < mSlop) {
523 // don't update anything so when we do start scrolling
Joe Onoratobcbeab82009-10-01 21:45:43 -0700524 // below, we get the right delta.
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800525 mCurrentIconIndex = mRollo.chooseTappedIcon(x, y, mPosX);
Joe Onorato82ca5502009-10-15 16:59:23 -0700526 if (mDownIconIndex != mCurrentIconIndex) {
527 // If a different icon is selected, don't allow it to be picked up.
528 // This handles off-axis dragging.
529 cancelLongPress();
530 mCurrentIconIndex = -1;
531 }
Joe Onoratobcbeab82009-10-01 21:45:43 -0700532 } else {
Joe Onorato82ca5502009-10-15 16:59:23 -0700533 if (!mStartedScrolling) {
534 cancelLongPress();
535 mCurrentIconIndex = -1;
536 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700537 mRollo.mState.newPositionX = ev.getRawY() / getHeight();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700538 mRollo.mState.newTouchDown = 1;
Jason Samsd8152b92009-10-13 17:19:10 -0700539 mRollo.move();
Jason Sams86c87ed2009-09-18 13:55:55 -0700540
Joe Onoratobcbeab82009-10-01 21:45:43 -0700541 mStartedScrolling = true;
542 mRollo.clearSelectedIcon();
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800543 mVelocityTracker.addMovement(ev);
Joe Onoratobcbeab82009-10-01 21:45:43 -0700544 mRollo.mState.save();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700545 }
Joe Onoratofb0ca672009-09-14 17:55:46 -0400546 }
547 break;
548 case MotionEvent.ACTION_UP:
549 case MotionEvent.ACTION_CANCEL:
Joe Onoratobcbeab82009-10-01 21:45:43 -0700550 if (mTouchTracking == TRACKING_HOME) {
551 if (action == MotionEvent.ACTION_UP) {
552 if (y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]) {
Joe Onoratob39e51a2009-10-28 15:47:49 -0400553 reallyPlaySoundEffect(SoundEffectConstants.CLICK);
Joe Onoratobcbeab82009-10-01 21:45:43 -0700554 mLauncher.closeAllApps(true);
555 }
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500556 mRollo.setHomeSelected(SELECTED_NONE);
Joe Onoratod63458b2009-10-15 21:19:09 -0700557 mRollo.mState.save();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700558 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700559 mCurrentIconIndex = -1;
Joe Onorato68ffd102009-10-15 17:59:43 -0700560 } else if (mTouchTracking == TRACKING_FLING) {
Joe Onoratobcbeab82009-10-01 21:45:43 -0700561 mRollo.mState.newTouchDown = 0;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700562 mRollo.mState.newPositionX = ev.getRawY() / getHeight();
Jason Sams476339d2009-09-29 18:14:38 -0700563
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800564 mVelocityTracker.computeCurrentVelocity(1000 /* px/sec */, mMaxFlingVelocity);
565 mRollo.mState.flingVelocity = mVelocityTracker.getYVelocity() / getHeight();
Jason Sams12c14a82009-10-06 14:33:15 -0700566 mRollo.clearSelectedIcon();
567 mRollo.mState.save();
Jason Samsd8152b92009-10-13 17:19:10 -0700568 mRollo.fling();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700569
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800570 if (mVelocityTracker != null) {
571 mVelocityTracker.recycle();
572 mVelocityTracker = null;
Joe Onorato539ed9d2009-10-02 10:22:14 -0700573 }
Joe Onoratobcbeab82009-10-01 21:45:43 -0700574 }
Joe Onorato68ffd102009-10-15 17:59:43 -0700575 mTouchTracking = TRACKING_NONE;
576 break;
Joe Onorato93839052009-08-06 20:34:32 -0700577 }
Joe Onorato6665c0f2009-09-02 15:27:24 -0700578
579 return true;
Joe Onorato93839052009-08-06 20:34:32 -0700580 }
581
Joe Onorato6665c0f2009-09-02 15:27:24 -0700582 public void onClick(View v) {
Joe Onorato7bb17492009-09-24 17:51:01 -0700583 if (mLocks != 0 || !isVisible()) {
Joe Onoratofb0ca672009-09-14 17:55:46 -0400584 return;
585 }
Joe Onorato82ca5502009-10-15 16:59:23 -0700586 if (mRollo.checkClickOK() && mCurrentIconIndex == mDownIconIndex
587 && mCurrentIconIndex >= 0 && mCurrentIconIndex < mAllAppsList.size()) {
Joe Onoratob39e51a2009-10-28 15:47:49 -0400588 reallyPlaySoundEffect(SoundEffectConstants.CLICK);
Joe Onorato82ca5502009-10-15 16:59:23 -0700589 ApplicationInfo app = mAllAppsList.get(mCurrentIconIndex);
Joe Onorato6665c0f2009-09-02 15:27:24 -0700590 mLauncher.startActivitySafely(app.intent);
591 }
592 }
593
594 public boolean onLongClick(View v) {
Joe Onorato7bb17492009-09-24 17:51:01 -0700595 if (mLocks != 0 || !isVisible()) {
Joe Onoratofb0ca672009-09-14 17:55:46 -0400596 return true;
597 }
Joe Onorato82ca5502009-10-15 16:59:23 -0700598 if (mRollo.checkClickOK() && mCurrentIconIndex == mDownIconIndex
599 && mCurrentIconIndex >= 0 && mCurrentIconIndex < mAllAppsList.size()) {
600 ApplicationInfo app = mAllAppsList.get(mCurrentIconIndex);
Joe Onorato5162ea92009-09-03 09:39:42 -0700601
Jason Samsb4ecab22010-01-19 16:43:26 -0800602 Bitmap bmp = app.iconBitmap;
603 final int w = bmp.getWidth();
604 final int h = bmp.getHeight();
605
Joe Onorato5162ea92009-09-03 09:39:42 -0700606 // We don't really have an accurate location to use. This will do.
Jason Samsb4ecab22010-01-19 16:43:26 -0800607 int screenX = mMotionDownRawX - (w / 2);
608 int screenY = mMotionDownRawY - h;
Joe Onorato5162ea92009-09-03 09:39:42 -0700609
Joe Onoratobcbeab82009-10-01 21:45:43 -0700610 int left = (mDefines.ICON_TEXTURE_WIDTH_PX - mDefines.ICON_WIDTH_PX) / 2;
611 int top = (mDefines.ICON_TEXTURE_HEIGHT_PX - mDefines.ICON_HEIGHT_PX) / 2;
Jason Samsb4ecab22010-01-19 16:43:26 -0800612 mDragController.startDrag(bmp, screenX, screenY,
613 0, 0, w, h, this, app, DragController.DRAG_ACTION_COPY);
Joe Onoratoe3406a22009-09-03 14:36:25 -0700614
Joe Onorato7bb17492009-09-24 17:51:01 -0700615 mLauncher.closeAllApps(true);
Joe Onorato5162ea92009-09-03 09:39:42 -0700616 }
Joe Onorato6665c0f2009-09-02 15:27:24 -0700617 return true;
618 }
619
Joe Onorato52a653f2009-11-11 14:52:11 -0800620 @Override
621 public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
622 if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SELECTED) {
623 if (!isVisible()) {
624 return false;
625 }
626 String text = null;
627 int index;
628 int count = mAllAppsList.size() + 1; // +1 is home
629 int pos = -1;
630 switch (mLastSelection) {
631 case SELECTION_ICONS:
632 index = mRollo.mState.selectedIconIndex;
633 if (index >= 0) {
634 ApplicationInfo info = mAllAppsList.get(index);
635 if (info.title != null) {
636 text = info.title.toString();
637 pos = index;
638 }
639 }
640 break;
641 case SELECTION_HOME:
642 text = getContext().getString(R.string.all_apps_home_button_label);
643 pos = count;
644 break;
645 }
646 if (text != null) {
Joe Onorato52a653f2009-11-11 14:52:11 -0800647 event.setEnabled(true);
648 event.getText().add(text);
649 //event.setContentDescription(text);
650 event.setItemCount(count);
651 event.setCurrentItemIndex(pos);
652 }
653 }
654 return false;
655 }
656
Joe Onorato5162ea92009-09-03 09:39:42 -0700657 public void setDragController(DragController dragger) {
658 mDragController = dragger;
659 }
660
661 public void onDropCompleted(View target, boolean success) {
662 }
663
Joe Onorato4db52312009-10-06 11:17:43 -0700664 /**
Joe Onorato3a8820b2009-11-10 15:06:42 -0800665 * Zoom to the specifed level.
Joe Onorato4db52312009-10-06 11:17:43 -0700666 *
Joe Onorato3a8820b2009-11-10 15:06:42 -0800667 * @param zoom [0..1] 0 is hidden, 1 is open
Joe Onorato4db52312009-10-06 11:17:43 -0700668 */
Joe Onorato3a8820b2009-11-10 15:06:42 -0800669 public void zoom(float zoom, boolean animate) {
Joe Onoratofb0ca672009-09-14 17:55:46 -0400670 cancelLongPress();
Joe Onorato6374c512010-01-06 20:42:25 -0800671 mNextZoom = zoom;
672 mAnimateNextZoom = animate;
673 // if we do setZoom while we don't have a surface, we won't
674 // get the callbacks that actually set mZoom.
675 if (mRollo == null || !mHaveSurface) {
Joe Onorato3a8820b2009-11-10 15:06:42 -0800676 mZoomDirty = true;
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800677 mZoom = zoom;
Joe Onorato3a8820b2009-11-10 15:06:42 -0800678 return;
Joe Onorato85a02a82009-09-08 12:34:22 -0700679 } else {
Joe Onorato3a8820b2009-11-10 15:06:42 -0800680 mRollo.setZoom(zoom, animate);
Joe Onoratoc567acb2009-08-31 14:34:43 -0700681 }
Joe Onoratofb0ca672009-09-14 17:55:46 -0400682 }
683
684 public boolean isVisible() {
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800685 return mZoom > 0.001f;
Joe Onorato3a8820b2009-11-10 15:06:42 -0800686 }
687
688 public boolean isOpaque() {
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800689 return mZoom > 0.999f;
Joe Onoratofb0ca672009-09-14 17:55:46 -0400690 }
Joe Onoratoc567acb2009-08-31 14:34:43 -0700691
Joe Onorato9c1289c2009-08-17 11:03:03 -0400692 public void setApps(ArrayList<ApplicationInfo> list) {
Joe Onorato339cdd92010-02-17 14:07:31 -0500693 if (mRS == null) {
694 // We've been removed from the window. Don't bother with all this.
695 return;
696 }
697
Joe Onorato9c1289c2009-08-17 11:03:03 -0400698 mAllAppsList = list;
699 if (mRollo != null) {
Joe Onorato3ecbd812009-12-11 13:38:54 -0800700 mRollo.setApps(list);
Joe Onorato9c1289c2009-08-17 11:03:03 -0400701 }
Joe Onoratofb0ca672009-09-14 17:55:46 -0400702 mLocks &= ~LOCK_ICONS_PENDING;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700703 }
704
Joe Onoratoa8138d52009-10-06 19:25:30 -0700705 public void addApps(ArrayList<ApplicationInfo> list) {
Joe Onorato2d804762009-11-05 16:02:32 -0500706 if (mAllAppsList == null) {
707 // Not done loading yet. We'll find out about it later.
708 return;
709 }
Joe Onorato339cdd92010-02-17 14:07:31 -0500710 if (mRS == null) {
711 // We've been removed from the window. Don't bother with all this.
712 return;
713 }
Joe Onorato2d804762009-11-05 16:02:32 -0500714
Joe Onoratoa8138d52009-10-06 19:25:30 -0700715 final int N = list.size();
Joe Onorato8eea3912009-12-09 13:01:06 -0800716 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700717 mRollo.reallocAppsList(mRollo.mState.iconCount + N);
718 }
719
720 for (int i=0; i<N; i++) {
721 final ApplicationInfo item = list.get(i);
Joe Onoratob0c27f22009-12-01 16:19:38 -0800722 int index = Collections.binarySearch(mAllAppsList, item,
723 LauncherModel.APP_NAME_COMPARATOR);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700724 if (index < 0) {
725 index = -(index+1);
726 }
727 mAllAppsList.add(index, item);
Joe Onorato8eea3912009-12-09 13:01:06 -0800728 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700729 mRollo.addApp(index, item);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700730 }
731 }
732
Joe Onorato8eea3912009-12-09 13:01:06 -0800733 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700734 mRollo.saveAppsList();
735 }
Joe Onoratoc567acb2009-08-31 14:34:43 -0700736 }
737
Joe Onoratoa8138d52009-10-06 19:25:30 -0700738 public void removeApps(ArrayList<ApplicationInfo> list) {
Joe Onorato2d804762009-11-05 16:02:32 -0500739 if (mAllAppsList == null) {
740 // Not done loading yet. We'll find out about it later.
741 return;
742 }
743
Joe Onoratoa8138d52009-10-06 19:25:30 -0700744 final int N = list.size();
745 for (int i=0; i<N; i++) {
746 final ApplicationInfo item = list.get(i);
Joe Onoratocb9f7982009-10-31 16:32:02 -0400747 int index = findAppByComponent(mAllAppsList, item);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700748 if (index >= 0) {
Joe Onoratoa276fc52009-12-08 17:02:02 -0800749 int ic = mRollo != null ? mRollo.mState.iconCount : 666;
Joe Onoratoa8138d52009-10-06 19:25:30 -0700750 mAllAppsList.remove(index);
Joe Onorato8eea3912009-12-09 13:01:06 -0800751 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700752 mRollo.removeApp(index);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700753 }
754 } else {
Joe Onoratoa30ce8e2009-11-11 08:16:49 -0800755 Log.w(TAG, "couldn't find a match for item \"" + item + "\"");
Joe Onoratoa8138d52009-10-06 19:25:30 -0700756 // Try to recover. This should keep us from crashing for now.
757 }
758 }
759
Joe Onorato8eea3912009-12-09 13:01:06 -0800760 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700761 mRollo.saveAppsList();
762 }
763 }
764
765 public void updateApps(String packageName, ArrayList<ApplicationInfo> list) {
766 // Just remove and add, because they may need to be re-sorted.
767 removeApps(list);
768 addApps(list);
769 }
770
Joe Onoratocb9f7982009-10-31 16:32:02 -0400771 private static int findAppByComponent(ArrayList<ApplicationInfo> list, ApplicationInfo item) {
772 ComponentName component = item.intent.getComponent();
773 final int N = list.size();
774 for (int i=0; i<N; i++) {
775 ApplicationInfo x = list.get(i);
776 if (x.intent.getComponent().equals(component)) {
777 return i;
778 }
Joe Onoratoa8138d52009-10-06 19:25:30 -0700779 }
Joe Onoratocb9f7982009-10-31 16:32:02 -0400780 return -1;
781 }
Joe Onoratoa8138d52009-10-06 19:25:30 -0700782
Joe Onoratoc567acb2009-08-31 14:34:43 -0700783 private static int countPages(int iconCount) {
784 int iconsPerPage = Defines.COLUMNS_PER_PAGE * Defines.ROWS_PER_PAGE;
785 int pages = iconCount / iconsPerPage;
786 if (pages*iconsPerPage != iconCount) {
787 pages++;
788 }
789 return pages;
Joe Onorato9c1289c2009-08-17 11:03:03 -0400790 }
791
Joe Onoratocb75f362009-11-12 13:04:07 -0800792 class AAMessage extends RenderScript.RSMessage {
793 public void run() {
794 mPosX = ((float)mData[0]) / (1 << 16);
795 mVelocity = ((float)mData[1]) / (1 << 16);
796 mZoom = ((float)mData[2]) / (1 << 16);
797 mZoomDirty = false;
798 }
Joe Onoratocb75f362009-11-12 13:04:07 -0800799 }
800
Joe Onorato93839052009-08-06 20:34:32 -0700801 public class RolloRS {
Joe Onoratobf15cb42009-08-07 14:33:40 -0700802
Joe Onorato1feb3a82009-08-08 22:32:00 -0700803 // Allocations ======
Joe Onorato93839052009-08-06 20:34:32 -0700804 private int mWidth;
805 private int mHeight;
806
807 private Resources mRes;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700808 private Script mScript;
809 private Script.Invokable mInvokeMove;
Jason Samsc1c521e2009-10-19 14:45:45 -0700810 private Script.Invokable mInvokeMoveTo;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700811 private Script.Invokable mInvokeFling;
812 private Script.Invokable mInvokeResetWAR;
Joe Onorato3a8820b2009-11-10 15:06:42 -0800813 private Script.Invokable mInvokeSetZoom;
Jason Samsc1c521e2009-10-19 14:45:45 -0700814
Jason Samscd689e12009-09-29 15:28:22 -0700815 private ProgramStore mPSIcons;
Jason Samsc8514792009-10-29 14:27:29 -0700816 private ProgramFragment mPFTexMip;
Jason Sams6ec11bc2010-01-19 17:56:52 -0800817 private ProgramFragment mPFTexMipAlpha;
Jason Samsc8514792009-10-29 14:27:29 -0700818 private ProgramFragment mPFTexNearest;
Joe Onorato93839052009-08-06 20:34:32 -0700819 private ProgramVertex mPV;
Jason Samsb4ecab22010-01-19 16:43:26 -0800820 private ProgramVertex mPVCurve;
Jason Sams0aa71662009-10-02 18:43:18 -0700821 private SimpleMesh mMesh;
Jason Sams5612e432009-11-16 14:18:07 -0800822 private ProgramVertex.MatrixAllocation mPVA;
Joe Onorato93839052009-08-06 20:34:32 -0700823
Jason Samsb4ecab22010-01-19 16:43:26 -0800824 private Allocation mUniformAlloc;
825
Joe Onoratod63458b2009-10-15 21:19:09 -0700826 private Allocation mHomeButtonNormal;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500827 private Allocation mHomeButtonFocused;
Joe Onoratod63458b2009-10-15 21:19:09 -0700828 private Allocation mHomeButtonPressed;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700829
Joe Onoratobf15cb42009-08-07 14:33:40 -0700830 private Allocation[] mIcons;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700831 private int[] mIconIds;
Joe Onoratoa8138d52009-10-06 19:25:30 -0700832 private Allocation mAllocIconIds;
Joe Onorato93839052009-08-06 20:34:32 -0700833
Joe Onoratobf15cb42009-08-07 14:33:40 -0700834 private Allocation[] mLabels;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700835 private int[] mLabelIds;
Joe Onoratoa8138d52009-10-06 19:25:30 -0700836 private Allocation mAllocLabelIds;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700837 private Allocation mSelectedIcon;
Joe Onorato93839052009-08-06 20:34:32 -0700838
Joe Onorato6665c0f2009-09-02 15:27:24 -0700839 private int[] mTouchYBorders;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700840 private int[] mTouchXBorders;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700841
842 private Bitmap mSelectionBitmap;
Joe Onorato1291a8c2009-09-15 15:07:25 -0400843 private Canvas mSelectionCanvas;
Joe Onorato93839052009-08-06 20:34:32 -0700844
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700845 Params mParams;
Joe Onorato1feb3a82009-08-08 22:32:00 -0700846 State mState;
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700847
Jason Sams78aebd82009-09-15 13:06:59 -0700848 class BaseAlloc {
849 Allocation mAlloc;
850 Type mType;
851
852 void save() {
853 mAlloc.data(this);
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700854 }
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700855 }
856
Jason Sams476339d2009-09-29 18:14:38 -0700857 private boolean checkClickOK() {
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800858 return (Math.abs(mVelocity) < 0.4f) &&
859 (Math.abs(mPosX - Math.round(mPosX)) < 0.4f);
Jason Sams476339d2009-09-29 18:14:38 -0700860 }
861
Jason Sams78aebd82009-09-15 13:06:59 -0700862 class Params extends BaseAlloc {
863 Params() {
864 mType = Type.createFromClass(mRS, Params.class, 1, "ParamsClass");
865 mAlloc = Allocation.createTyped(mRS, mType);
866 save();
Joe Onorato1feb3a82009-08-08 22:32:00 -0700867 }
Jason Sams78aebd82009-09-15 13:06:59 -0700868 public int bubbleWidth;
869 public int bubbleHeight;
870 public int bubbleBitmapWidth;
871 public int bubbleBitmapHeight;
Joe Onoratobcbeab82009-10-01 21:45:43 -0700872
Joe Onoratobcbeab82009-10-01 21:45:43 -0700873 public int homeButtonWidth;
874 public int homeButtonHeight;
875 public int homeButtonTextureWidth;
876 public int homeButtonTextureHeight;
Jason Sams78aebd82009-09-15 13:06:59 -0700877 }
878
879 class State extends BaseAlloc {
Jason Sams86c87ed2009-09-18 13:55:55 -0700880 public float newPositionX;
881 public int newTouchDown;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700882 public float flingVelocity;
Jason Sams78aebd82009-09-15 13:06:59 -0700883 public int iconCount;
Jason Sams78aebd82009-09-15 13:06:59 -0700884 public int selectedIconIndex = -1;
885 public int selectedIconTexture;
Joe Onorato7bb17492009-09-24 17:51:01 -0700886 public float zoomTarget;
Joe Onoratod63458b2009-10-15 21:19:09 -0700887 public int homeButtonId;
Jason Samsc1c521e2009-10-19 14:45:45 -0700888 public float targetPos;
Jason Sams78aebd82009-09-15 13:06:59 -0700889
890 State() {
891 mType = Type.createFromClass(mRS, State.class, 1, "StateClass");
892 mAlloc = Allocation.createTyped(mRS, mType);
893 save();
894 }
Joe Onorato1feb3a82009-08-08 22:32:00 -0700895 }
896
897 public RolloRS() {
898 }
899
900 public void init(Resources res, int width, int height) {
901 mRes = res;
902 mWidth = width;
903 mHeight = height;
Jason Samscd689e12009-09-29 15:28:22 -0700904 initProgramVertex();
905 initProgramFragment();
906 initProgramStore();
Joe Onorato1feb3a82009-08-08 22:32:00 -0700907 initGl();
908 initData();
Joe Onorato6665c0f2009-09-02 15:27:24 -0700909 initTouchState();
Joe Onorato1feb3a82009-08-08 22:32:00 -0700910 initRs();
911 }
912
Jason Sams82e1a272010-02-04 17:32:57 -0800913 public void initMesh() {
Jason Samsb4ecab22010-01-19 16:43:26 -0800914 SimpleMesh.TriangleMeshBuilder tm = new SimpleMesh.TriangleMeshBuilder(mRS, 2, 0);
Jason Sams0aa71662009-10-02 18:43:18 -0700915
Jason Samsb4ecab22010-01-19 16:43:26 -0800916 for (int ct=0; ct < 16; ct++) {
Jason Sams76512482010-02-04 16:31:35 -0800917 float pos = (1.f / (16.f - 1)) * ct;
Jason Samsb4ecab22010-01-19 16:43:26 -0800918 tm.addVertex(0.0f, pos);
919 tm.addVertex(1.0f, pos);
Jason Samsd8152b92009-10-13 17:19:10 -0700920 }
Jason Samsb4ecab22010-01-19 16:43:26 -0800921 for (int ct=0; ct < (16 * 2 - 2); ct+= 2) {
Jason Samsd8152b92009-10-13 17:19:10 -0700922 tm.addTriangle(ct, ct+1, ct+2);
923 tm.addTriangle(ct+1, ct+3, ct+2);
924 }
Jason Samsb4ecab22010-01-19 16:43:26 -0800925 mMesh = tm.create();
926 mMesh.setName("SMCell");
Jason Samsd8152b92009-10-13 17:19:10 -0700927 }
928
Jason Sams5612e432009-11-16 14:18:07 -0800929 void resize(int w, int h) {
930 mPVA.setupProjectionNormalized(w, h);
931 mWidth = w;
932 mHeight = h;
933 }
934
Jason Samscd689e12009-09-29 15:28:22 -0700935 private void initProgramVertex() {
Jason Sams5612e432009-11-16 14:18:07 -0800936 mPVA = new ProgramVertex.MatrixAllocation(mRS);
937 resize(mWidth, mHeight);
Joe Onorato93839052009-08-06 20:34:32 -0700938
939 ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS, null, null);
Jason Sams0aa71662009-10-02 18:43:18 -0700940 pvb.setTextureMatrixEnable(true);
Joe Onorato93839052009-08-06 20:34:32 -0700941 mPV = pvb.create();
942 mPV.setName("PV");
Jason Sams5612e432009-11-16 14:18:07 -0800943 mPV.bindAllocation(mPVA);
Joe Onorato93839052009-08-06 20:34:32 -0700944
Jason Samsb4ecab22010-01-19 16:43:26 -0800945 Element.Builder eb = new Element.Builder(mRS);
946 eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 2), "ImgSize");
947 eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 4), "Position");
Jason Sams66ed54e2010-02-04 12:39:27 -0800948 eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 2), "BendPos");
949 eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 4), "ScaleOffset");
Jason Samsb4ecab22010-01-19 16:43:26 -0800950 Element e = eb.create();
951
952 mUniformAlloc = Allocation.createSized(mRS, e, 1);
953
Jason Sams82e1a272010-02-04 17:32:57 -0800954 initMesh();
Jason Samsb4ecab22010-01-19 16:43:26 -0800955 ProgramVertex.ShaderBuilder sb = new ProgramVertex.ShaderBuilder(mRS);
956 String t = new String("void main() {\n" +
957 // Animation
958 " float ani = UNI_Position.z;\n" +
959
Jason Sams66ed54e2010-02-04 12:39:27 -0800960 " float bendY1 = UNI_BendPos.x;\n" +
961 " float bendY2 = UNI_BendPos.y;\n" +
Jason Sams76512482010-02-04 16:31:35 -0800962 " float bendAngle = 47.0 * (3.14 / 180.0);\n" +
963 " float bendDistance = bendY1 * 0.4;\n" +
Jason Sams66ed54e2010-02-04 12:39:27 -0800964 " float distanceDimLevel = 0.6;\n" +
965
966 " float bendStep = (bendAngle / bendDistance) * (bendAngle * 0.5);\n" +
967 " float aDy = cos(bendAngle);\n" +
968 " float aDz = sin(bendAngle);\n" +
969
Jason Samsb4ecab22010-01-19 16:43:26 -0800970 " float scale = (2.0 / 480.0);\n" +
971 " float x = UNI_Position.x + UNI_ImgSize.x * (1.0 - ani) * (ATTRIB_position.x - 0.5);\n" +
972 " float ys= UNI_Position.y + UNI_ImgSize.y * (1.0 - ani) * ATTRIB_position.y;\n" +
973 " float y = 0.0;\n" +
974 " float z = 0.0;\n" +
975 " float lum = 1.0;\n" +
976
Jason Sams66ed54e2010-02-04 12:39:27 -0800977 " float cv = min(ys, bendY1 - bendDistance) - (bendY1 - bendDistance);\n" +
978 " y += cv * aDy;\n" +
979 " z += -cv * aDz;\n" +
980 " cv = clamp(ys, bendY1 - bendDistance, bendY1) - bendY1;\n" + // curve range
981 " lum += cv / bendDistance * distanceDimLevel;\n" +
982 " y += cv * cos(cv * bendStep);\n" +
983 " z += cv * sin(cv * bendStep);\n" +
Jason Samsb4ecab22010-01-19 16:43:26 -0800984
Jason Sams66ed54e2010-02-04 12:39:27 -0800985 " cv = max(ys, bendY2 + bendDistance) - (bendY2 + bendDistance);\n" +
986 " y += cv * aDy;\n" +
987 " z += cv * aDz;\n" +
988 " cv = clamp(ys, bendY2, bendY2 + bendDistance) - bendY2;\n" +
989 " lum -= cv / bendDistance * distanceDimLevel;\n" +
990 " y += cv * cos(cv * bendStep);\n" +
991 " z += cv * sin(cv * bendStep);\n" +
Jason Samsb4ecab22010-01-19 16:43:26 -0800992
Jason Sams66ed54e2010-02-04 12:39:27 -0800993 " y += clamp(ys, bendY1, bendY2);\n" +
Jason Samsb4ecab22010-01-19 16:43:26 -0800994
995 " vec4 pos;\n" +
Jason Sams66ed54e2010-02-04 12:39:27 -0800996 " pos.x = (x + UNI_ScaleOffset.z) * UNI_ScaleOffset.x;\n" +
997 " pos.y = (y + UNI_ScaleOffset.w) * UNI_ScaleOffset.x;\n" +
998 " pos.z = z * UNI_ScaleOffset.x;\n" +
Jason Samsb4ecab22010-01-19 16:43:26 -0800999 " pos.w = 1.0;\n" +
1000
1001 " pos.x *= 1.0 + ani * 4.0;\n" +
1002 " pos.y *= 1.0 + ani * 4.0;\n" +
1003 " pos.z -= ani * 1.5;\n" +
1004 " lum *= 1.0 - ani;\n" +
1005
1006 " gl_Position = UNI_MVP * pos;\n" +
1007 " varColor.rgba = vec4(lum, lum, lum, 1.0);\n" +
1008 " varTex0.xy = ATTRIB_position;\n" +
1009 " varTex0.y = 1.0 - varTex0.y;\n" +
1010 " varTex0.zw = vec2(0.0, 0.0);\n" +
1011 "}\n");
1012 sb.setShader(t);
1013 sb.addConstant(mUniformAlloc.getType());
1014 sb.addInput(mMesh.getVertexType(0).getElement());
1015 mPVCurve = sb.create();
1016 mPVCurve.setName("PVCurve");
1017 mPVCurve.bindAllocation(mPVA);
1018 mPVCurve.bindConstants(mUniformAlloc, 1);
1019
Joe Onorato93839052009-08-06 20:34:32 -07001020 mRS.contextBindProgramVertex(mPV);
Jason Samscd689e12009-09-29 15:28:22 -07001021 }
Joe Onorato93839052009-08-06 20:34:32 -07001022
Jason Samscd689e12009-09-29 15:28:22 -07001023 private void initProgramFragment() {
1024 Sampler.Builder sb = new Sampler.Builder(mRS);
Jason Samsc8514792009-10-29 14:27:29 -07001025 sb.setMin(Sampler.Value.LINEAR_MIP_LINEAR);
Jason Samsb4ecab22010-01-19 16:43:26 -08001026 sb.setMag(Sampler.Value.NEAREST);
Jason Samscd689e12009-09-29 15:28:22 -07001027 sb.setWrapS(Sampler.Value.CLAMP);
1028 sb.setWrapT(Sampler.Value.CLAMP);
1029 Sampler linear = sb.create();
1030
1031 sb.setMin(Sampler.Value.NEAREST);
1032 sb.setMag(Sampler.Value.NEAREST);
1033 Sampler nearest = sb.create();
1034
Jason Sams72f1d312009-12-17 16:58:25 -08001035 ProgramFragment.Builder bf = new ProgramFragment.Builder(mRS);
Jason Samsb4ecab22010-01-19 16:43:26 -08001036 bf.setTexture(ProgramFragment.Builder.EnvMode.MODULATE,
Jason Sams72f1d312009-12-17 16:58:25 -08001037 ProgramFragment.Builder.Format.RGBA, 0);
Jason Samsc8514792009-10-29 14:27:29 -07001038 mPFTexMip = bf.create();
1039 mPFTexMip.setName("PFTexMip");
1040 mPFTexMip.bindSampler(linear, 0);
1041
1042 mPFTexNearest = bf.create();
1043 mPFTexNearest.setName("PFTexNearest");
1044 mPFTexNearest.bindSampler(nearest, 0);
Jason Sams6ec11bc2010-01-19 17:56:52 -08001045
1046 bf.setTexture(ProgramFragment.Builder.EnvMode.MODULATE,
1047 ProgramFragment.Builder.Format.ALPHA, 0);
1048 mPFTexMipAlpha = bf.create();
1049 mPFTexMipAlpha.setName("PFTexMipAlpha");
1050 mPFTexMipAlpha.bindSampler(linear, 0);
1051
Jason Samscd689e12009-09-29 15:28:22 -07001052 }
1053
1054 private void initProgramStore() {
1055 ProgramStore.Builder bs = new ProgramStore.Builder(mRS, null, null);
1056 bs.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
Jason Sams12c14a82009-10-06 14:33:15 -07001057 bs.setColorMask(true,true,true,false);
Jason Samscd689e12009-09-29 15:28:22 -07001058 bs.setDitherEnable(true);
1059 bs.setBlendFunc(ProgramStore.BlendSrcFunc.SRC_ALPHA,
1060 ProgramStore.BlendDstFunc.ONE_MINUS_SRC_ALPHA);
1061 mPSIcons = bs.create();
1062 mPSIcons.setName("PSIcons");
Jason Samscd689e12009-09-29 15:28:22 -07001063 }
1064
1065 private void initGl() {
Joe Onorato6665c0f2009-09-02 15:27:24 -07001066 mTouchXBorders = new int[Defines.COLUMNS_PER_PAGE+1];
Joe Onorato6665c0f2009-09-02 15:27:24 -07001067 mTouchYBorders = new int[Defines.ROWS_PER_PAGE+1];
Joe Onoratobf15cb42009-08-07 14:33:40 -07001068 }
Jason Sams78aebd82009-09-15 13:06:59 -07001069
Joe Onorato1feb3a82009-08-08 22:32:00 -07001070 private void initData() {
Jason Sams78aebd82009-09-15 13:06:59 -07001071 mParams = new Params();
1072 mState = new State();
Joe Onorato43e7bcf2009-08-08 18:53:53 -07001073
Joe Onoratobf15cb42009-08-07 14:33:40 -07001074 final Utilities.BubbleText bubble = new Utilities.BubbleText(getContext());
Joe Onorato93839052009-08-06 20:34:32 -07001075
Joe Onorato43e7bcf2009-08-08 18:53:53 -07001076 mParams.bubbleWidth = bubble.getBubbleWidth();
1077 mParams.bubbleHeight = bubble.getMaxBubbleHeight();
1078 mParams.bubbleBitmapWidth = bubble.getBitmapWidth();
1079 mParams.bubbleBitmapHeight = bubble.getBitmapHeight();
Joe Onorato43e7bcf2009-08-08 18:53:53 -07001080
Joe Onoratod63458b2009-10-15 21:19:09 -07001081 mHomeButtonNormal = Allocation.createFromBitmapResource(mRS, mRes,
1082 R.drawable.home_button_normal, Element.RGBA_8888(mRS), false);
1083 mHomeButtonNormal.uploadToTexture(0);
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001084 mHomeButtonFocused = Allocation.createFromBitmapResource(mRS, mRes,
1085 R.drawable.home_button_focused, Element.RGBA_8888(mRS), false);
1086 mHomeButtonFocused.uploadToTexture(0);
Joe Onoratod63458b2009-10-15 21:19:09 -07001087 mHomeButtonPressed = Allocation.createFromBitmapResource(mRS, mRes,
1088 R.drawable.home_button_pressed, Element.RGBA_8888(mRS), false);
1089 mHomeButtonPressed.uploadToTexture(0);
Joe Onoratobcbeab82009-10-01 21:45:43 -07001090 mParams.homeButtonWidth = 76;
1091 mParams.homeButtonHeight = 68;
1092 mParams.homeButtonTextureWidth = 128;
1093 mParams.homeButtonTextureHeight = 128;
Joe Onoratoc567acb2009-08-31 14:34:43 -07001094
Joe Onoratod63458b2009-10-15 21:19:09 -07001095 mState.homeButtonId = mHomeButtonNormal.getID();
1096
Joe Onorato1feb3a82009-08-08 22:32:00 -07001097 mParams.save();
1098 mState.save();
Joe Onorato9c1289c2009-08-17 11:03:03 -04001099
Jason Sams1a94ee32010-01-20 13:34:30 -08001100 mSelectionBitmap = Bitmap.createBitmap(Defines.SELECTION_TEXTURE_WIDTH_PX,
1101 Defines.SELECTION_TEXTURE_HEIGHT_PX, Bitmap.Config.ARGB_8888);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001102 mSelectionCanvas = new Canvas(mSelectionBitmap);
Joe Onorato6665c0f2009-09-02 15:27:24 -07001103
Joe Onorato9c1289c2009-08-17 11:03:03 -04001104 setApps(null);
Joe Onorato93839052009-08-06 20:34:32 -07001105 }
1106
Jason Sams37e7c2b2009-10-19 12:55:43 -07001107 private void initScript(int id) {
1108 }
1109
1110 private void initRs() {
Joe Onorato93839052009-08-06 20:34:32 -07001111 ScriptC.Builder sb = new ScriptC.Builder(mRS);
Jason Samsd15f3ef2010-01-06 14:58:06 -08001112 sb.setScript(mRes, R.raw.allapps);
Joe Onorato93839052009-08-06 20:34:32 -07001113 sb.setRoot(true);
Joe Onoratobcbeab82009-10-01 21:45:43 -07001114 sb.addDefines(mDefines);
Jason Sams78aebd82009-09-15 13:06:59 -07001115 sb.setType(mParams.mType, "params", Defines.ALLOC_PARAMS);
1116 sb.setType(mState.mType, "state", Defines.ALLOC_STATE);
Jason Samsb4ecab22010-01-19 16:43:26 -08001117 sb.setType(mUniformAlloc.getType(), "vpConstants", Defines.ALLOC_VP_CONSTANTS);
Jason Sams37e7c2b2009-10-19 12:55:43 -07001118 mInvokeMove = sb.addInvokable("move");
1119 mInvokeFling = sb.addInvokable("fling");
Jason Samsc1c521e2009-10-19 14:45:45 -07001120 mInvokeMoveTo = sb.addInvokable("moveTo");
Jason Sams37e7c2b2009-10-19 12:55:43 -07001121 mInvokeResetWAR = sb.addInvokable("resetHWWar");
Joe Onorato3a8820b2009-11-10 15:06:42 -08001122 mInvokeSetZoom = sb.addInvokable("setZoom");
Jason Sams37e7c2b2009-10-19 12:55:43 -07001123 mScript = sb.create();
1124 mScript.setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
1125 mScript.bindAllocation(mParams.mAlloc, Defines.ALLOC_PARAMS);
1126 mScript.bindAllocation(mState.mAlloc, Defines.ALLOC_STATE);
1127 mScript.bindAllocation(mAllocIconIds, Defines.ALLOC_ICON_IDS);
1128 mScript.bindAllocation(mAllocLabelIds, Defines.ALLOC_LABEL_IDS);
Jason Samsb4ecab22010-01-19 16:43:26 -08001129 mScript.bindAllocation(mUniformAlloc, Defines.ALLOC_VP_CONSTANTS);
Joe Onorato93839052009-08-06 20:34:32 -07001130
Jason Sams37e7c2b2009-10-19 12:55:43 -07001131 mRS.contextBindRootScript(mScript);
Joe Onorato93839052009-08-06 20:34:32 -07001132 }
Joe Onorato93839052009-08-06 20:34:32 -07001133
Jason Sams20df7c72009-11-05 12:30:24 -08001134 void dirtyCheck() {
Jason Sams510ee042009-12-15 14:23:37 -08001135 if (mZoomDirty) {
Joe Onorato6374c512010-01-06 20:42:25 -08001136 setZoom(mNextZoom, mAnimateNextZoom);
Jason Sams20df7c72009-11-05 12:30:24 -08001137 }
1138 }
1139
Joe Onorato9c1289c2009-08-17 11:03:03 -04001140 private void setApps(ArrayList<ApplicationInfo> list) {
1141 final int count = list != null ? list.size() : 0;
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001142 int allocCount = count;
Joe Onoratoa8138d52009-10-06 19:25:30 -07001143 if (allocCount < 1) {
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001144 allocCount = 1;
1145 }
1146
Joe Onorato9c1289c2009-08-17 11:03:03 -04001147 mIcons = new Allocation[count];
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001148 mIconIds = new int[allocCount];
Joe Onoratoa8138d52009-10-06 19:25:30 -07001149 mAllocIconIds = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001150
1151 mLabels = new Allocation[count];
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001152 mLabelIds = new int[allocCount];
Joe Onoratoa8138d52009-10-06 19:25:30 -07001153 mAllocLabelIds = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001154
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001155 Element ie8888 = Element.RGBA_8888(mRS);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001156
Joe Onorato9c1289c2009-08-17 11:03:03 -04001157 mState.iconCount = count;
Joe Onorato8eea3912009-12-09 13:01:06 -08001158 for (int i=0; i < mState.iconCount; i++) {
1159 createAppIconAllocations(i, list.get(i));
Joe Onorato3ecbd812009-12-11 13:38:54 -08001160 }
Jason Sams510ee042009-12-15 14:23:37 -08001161 for (int i=0; i < mState.iconCount; i++) {
1162 uploadAppIcon(i, list.get(i));
Joe Onorato8eea3912009-12-09 13:01:06 -08001163 }
Joe Onoratoa8138d52009-10-06 19:25:30 -07001164 saveAppsList();
1165 }
1166
Joe Onorato3a8820b2009-11-10 15:06:42 -08001167 private void setZoom(float zoom, boolean animate) {
1168 mRollo.clearSelectedIcon();
1169 mRollo.setHomeSelected(SELECTED_NONE);
1170 if (zoom > 0.001f) {
1171 mRollo.mState.zoomTarget = zoom;
1172 } else {
1173 mRollo.mState.zoomTarget = 0;
1174 }
1175 mRollo.mState.save();
1176 if (!animate) {
1177 mRollo.mInvokeSetZoom.execute();
1178 }
1179 }
1180
Joe Onorato8eea3912009-12-09 13:01:06 -08001181 private void createAppIconAllocations(int index, ApplicationInfo item) {
Joe Onoratoa8138d52009-10-06 19:25:30 -07001182 mIcons[index] = Allocation.createFromBitmap(mRS, item.iconBitmap,
Jason Samsc8514792009-10-29 14:27:29 -07001183 Element.RGBA_8888(mRS), true);
Joe Onoratoa8138d52009-10-06 19:25:30 -07001184 mLabels[index] = Allocation.createFromBitmap(mRS, item.titleBitmap,
Jason Sams6ec11bc2010-01-19 17:56:52 -08001185 Element.A_8(mRS), true);
Joe Onoratoa8138d52009-10-06 19:25:30 -07001186 mIconIds[index] = mIcons[index].getID();
1187 mLabelIds[index] = mLabels[index].getID();
1188 }
1189
Joe Onorato8eea3912009-12-09 13:01:06 -08001190 private void uploadAppIcon(int index, ApplicationInfo item) {
1191 if (mIconIds[index] != mIcons[index].getID()) {
1192 throw new IllegalStateException("uploadAppIcon index=" + index
1193 + " mIcons[index].getID=" + mIcons[index].getID()
1194 + " mIconsIds[index]=" + mIconIds[index]
1195 + " item=" + item);
1196 }
1197 mIcons[index].uploadToTexture(0);
1198 mLabels[index].uploadToTexture(0);
1199 }
1200
Joe Onoratoa8138d52009-10-06 19:25:30 -07001201 /**
1202 * Puts the empty spaces at the end. Updates mState.iconCount. You must
1203 * fill in the values and call saveAppsList().
1204 */
1205 private void reallocAppsList(int count) {
1206 Allocation[] icons = new Allocation[count];
1207 int[] iconIds = new int[count];
1208 mAllocIconIds = Allocation.createSized(mRS, Element.USER_I32(mRS), count);
1209
1210 Allocation[] labels = new Allocation[count];
1211 int[] labelIds = new int[count];
1212 mAllocLabelIds = Allocation.createSized(mRS, Element.USER_I32(mRS), count);
1213
Joe Onoratobf173f12009-12-08 13:29:38 -08001214 final int oldCount = mRollo.mState.iconCount;
Joe Onoratoa8138d52009-10-06 19:25:30 -07001215
1216 System.arraycopy(mIcons, 0, icons, 0, oldCount);
1217 System.arraycopy(mIconIds, 0, iconIds, 0, oldCount);
1218 System.arraycopy(mLabels, 0, labels, 0, oldCount);
1219 System.arraycopy(mLabelIds, 0, labelIds, 0, oldCount);
1220
1221 mIcons = icons;
1222 mIconIds = iconIds;
1223 mLabels = labels;
1224 mLabelIds = labelIds;
1225 }
1226
1227 /**
1228 * Handle the allocations for the new app. Make sure you call saveAppsList when done.
1229 */
1230 private void addApp(int index, ApplicationInfo item) {
1231 final int count = mState.iconCount - index;
1232 final int dest = index + 1;
1233
1234 System.arraycopy(mIcons, index, mIcons, dest, count);
1235 System.arraycopy(mIconIds, index, mIconIds, dest, count);
1236 System.arraycopy(mLabels, index, mLabels, dest, count);
1237 System.arraycopy(mLabelIds, index, mLabelIds, dest, count);
1238
Joe Onorato8eea3912009-12-09 13:01:06 -08001239 createAppIconAllocations(index, item);
Jason Sams510ee042009-12-15 14:23:37 -08001240 uploadAppIcon(index, item);
Joe Onorato8eea3912009-12-09 13:01:06 -08001241 mRollo.mState.iconCount++;
Joe Onoratoa8138d52009-10-06 19:25:30 -07001242 }
1243
1244 /**
1245 * Handle the allocations for the removed app. Make sure you call saveAppsList when done.
1246 */
1247 private void removeApp(int index) {
1248 final int count = mState.iconCount - index - 1;
1249 final int src = index + 1;
1250
1251 System.arraycopy(mIcons, src, mIcons, index, count);
1252 System.arraycopy(mIconIds, src, mIconIds, index, count);
1253 System.arraycopy(mLabels, src, mLabels, index, count);
1254 System.arraycopy(mLabelIds, src, mLabelIds, index, count);
1255
Joe Onoratoa276fc52009-12-08 17:02:02 -08001256 mRollo.mState.iconCount--;
Joe Onorato8eea3912009-12-09 13:01:06 -08001257 final int last = mState.iconCount;
Joe Onoratoa276fc52009-12-08 17:02:02 -08001258
Joe Onoratoa8138d52009-10-06 19:25:30 -07001259 mIcons[last] = null;
1260 mIconIds[last] = 0;
1261 mLabels[last] = null;
1262 mLabelIds[last] = 0;
1263 }
1264
1265 /**
1266 * Send the apps list structures to RS.
1267 */
1268 private void saveAppsList() {
Joe Onorato4700fed2010-03-01 15:26:36 -08001269 // WTF: how could mScript be not null but mAllocIconIds null b/2460740.
1270 if (mScript != null && mAllocIconIds != null) {
Joe Onoratobf5350d2010-02-22 14:46:10 -08001271 mRS.contextBindRootScript(null);
1272
1273 mAllocIconIds.data(mIconIds);
1274 mAllocLabelIds.data(mLabelIds);
1275
Jason Sams37e7c2b2009-10-19 12:55:43 -07001276 mScript.bindAllocation(mAllocIconIds, Defines.ALLOC_ICON_IDS);
1277 mScript.bindAllocation(mAllocLabelIds, Defines.ALLOC_LABEL_IDS);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001278
Joe Onoratobf5350d2010-02-22 14:46:10 -08001279 mState.save();
Joe Onoratoa8138d52009-10-06 19:25:30 -07001280
Joe Onoratobf5350d2010-02-22 14:46:10 -08001281 // Note: mScript may be null if we haven't initialized it yet.
1282 // In that case, this is a no-op.
1283 if (mInvokeResetWAR != null) {
1284 mInvokeResetWAR.execute();
1285 }
1286
Joe Onoratob8315542010-02-03 20:39:25 -08001287 mRS.contextBindRootScript(mScript);
1288 }
Joe Onorato9c1289c2009-08-17 11:03:03 -04001289 }
Joe Onorato6665c0f2009-09-02 15:27:24 -07001290
1291 void initTouchState() {
1292 int width = getWidth();
1293 int height = getHeight();
Jason Sams37e7c2b2009-10-19 12:55:43 -07001294 int cellHeight = 145;//iconsSize / Defines.ROWS_PER_PAGE;
1295 int cellWidth = width / Defines.COLUMNS_PER_PAGE;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001296
Jason Sams37e7c2b2009-10-19 12:55:43 -07001297 int centerY = (height / 2);
1298 mTouchYBorders[0] = centerY - (cellHeight * 2);
1299 mTouchYBorders[1] = centerY - cellHeight;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001300 mTouchYBorders[2] = centerY;
Jason Sams37e7c2b2009-10-19 12:55:43 -07001301 mTouchYBorders[3] = centerY + cellHeight;
1302 mTouchYBorders[4] = centerY + (cellHeight * 2);
Jason Sams78aebd82009-09-15 13:06:59 -07001303
Joe Onorato6665c0f2009-09-02 15:27:24 -07001304 int centerX = (width / 2);
Jason Sams37e7c2b2009-10-19 12:55:43 -07001305 mTouchXBorders[0] = 0;
1306 mTouchXBorders[1] = centerX - (width / 4);
Joe Onorato6665c0f2009-09-02 15:27:24 -07001307 mTouchXBorders[2] = centerX;
Jason Sams37e7c2b2009-10-19 12:55:43 -07001308 mTouchXBorders[3] = centerX + (width / 4);
1309 mTouchXBorders[4] = width;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001310 }
1311
Joe Onorato664457d2009-10-28 16:30:34 -04001312 void fling() {
1313 mInvokeFling.execute();
1314 }
1315
1316 void move() {
1317 mInvokeMove.execute();
1318 }
1319
1320 void moveTo(float row) {
1321 mState.targetPos = row;
1322 mState.save();
1323 mInvokeMoveTo.execute();
1324 }
1325
Jason Sams37e7c2b2009-10-19 12:55:43 -07001326 int chooseTappedIcon(int x, int y, float pos) {
1327 // Adjust for scroll position if not zero.
1328 y += (pos - ((int)pos)) * (mTouchYBorders[1] - mTouchYBorders[0]);
Jason Sams86c87ed2009-09-18 13:55:55 -07001329
Joe Onorato6665c0f2009-09-02 15:27:24 -07001330 int col = -1;
1331 int row = -1;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001332 for (int i=0; i<Defines.COLUMNS_PER_PAGE; i++) {
1333 if (x >= mTouchXBorders[i] && x < mTouchXBorders[i+1]) {
1334 col = i;
1335 break;
1336 }
1337 }
1338 for (int i=0; i<Defines.ROWS_PER_PAGE; i++) {
1339 if (y >= mTouchYBorders[i] && y < mTouchYBorders[i+1]) {
1340 row = i;
1341 break;
1342 }
1343 }
1344
1345 if (row < 0 || col < 0) {
1346 return -1;
1347 }
1348
Joe Onorato664457d2009-10-28 16:30:34 -04001349 int index = (((int)pos) * Defines.COLUMNS_PER_PAGE)
Joe Onorato6665c0f2009-09-02 15:27:24 -07001350 + (row * Defines.ROWS_PER_PAGE) + col;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001351
Joe Onorato664457d2009-10-28 16:30:34 -04001352 if (index >= mState.iconCount) {
1353 return -1;
1354 } else {
1355 return index;
1356 }
Jason Samsc1c521e2009-10-19 14:45:45 -07001357 }
1358
Joe Onorato6665c0f2009-09-02 15:27:24 -07001359 /**
1360 * You need to call save() on mState on your own after calling this.
Joe Onorato82ca5502009-10-15 16:59:23 -07001361 *
1362 * @return the index of the icon that was selected.
Joe Onorato6665c0f2009-09-02 15:27:24 -07001363 */
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001364 int selectIcon(int x, int y, float pos, int pressed) {
Joe Onorato82ca5502009-10-15 16:59:23 -07001365 final int index = chooseTappedIcon(x, y, pos);
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001366 selectIcon(index, pressed);
Joe Onorato82ca5502009-10-15 16:59:23 -07001367 return index;
Joe Onorato1291a8c2009-09-15 15:07:25 -04001368 }
1369
Joe Onoratoc61cff92009-11-08 11:54:39 -05001370 /**
1371 * Select the icon at the given index.
1372 *
1373 * @param index The index.
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001374 * @param pressed one of SELECTED_PRESSED or SELECTED_FOCUSED
Joe Onoratoc61cff92009-11-08 11:54:39 -05001375 */
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001376 void selectIcon(int index, int pressed) {
Joe Onorato2d804762009-11-05 16:02:32 -05001377 if (mAllAppsList == null || index < 0 || index >= mAllAppsList.size()) {
Joe Onorato6665c0f2009-09-02 15:27:24 -07001378 mState.selectedIconIndex = -1;
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001379 if (mLastSelection == SELECTION_ICONS) {
1380 mLastSelection = SELECTION_NONE;
1381 }
Joe Onorato6665c0f2009-09-02 15:27:24 -07001382 } else {
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001383 if (pressed == SELECTED_FOCUSED) {
1384 mLastSelection = SELECTION_ICONS;
1385 }
1386
Joe Onorato52a653f2009-11-11 14:52:11 -08001387 int prev = mState.selectedIconIndex;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001388 mState.selectedIconIndex = index;
Joe Onorato1291a8c2009-09-15 15:07:25 -04001389
Joe Onorato52a653f2009-11-11 14:52:11 -08001390 ApplicationInfo info = mAllAppsList.get(index);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001391 Bitmap selectionBitmap = mSelectionBitmap;
1392
1393 Utilities.drawSelectedAllAppsBitmap(mSelectionCanvas,
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001394 selectionBitmap.getWidth(), selectionBitmap.getHeight(),
Joe Onorato52a653f2009-11-11 14:52:11 -08001395 pressed == SELECTED_PRESSED, info.iconBitmap);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001396
1397 mSelectedIcon = Allocation.createFromBitmap(mRS, selectionBitmap,
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001398 Element.RGBA_8888(mRS), false);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001399 mSelectedIcon.uploadToTexture(0);
1400 mState.selectedIconTexture = mSelectedIcon.getID();
Joe Onorato52a653f2009-11-11 14:52:11 -08001401
1402 if (prev != index) {
1403 if (info.title != null && info.title.length() > 0) {
Joe Onorato52a653f2009-11-11 14:52:11 -08001404 //setContentDescription(info.title);
1405 sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
1406 }
1407 }
Joe Onorato6665c0f2009-09-02 15:27:24 -07001408 }
1409 }
1410
1411 /**
1412 * You need to call save() on mState on your own after calling this.
1413 */
1414 void clearSelectedIcon() {
Joe Onorato2ca51dc2009-09-16 11:44:14 -04001415 mState.selectedIconIndex = -1;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001416 }
Joe Onoratoa8138d52009-10-06 19:25:30 -07001417
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001418 void setHomeSelected(int mode) {
Joe Onorato52a653f2009-11-11 14:52:11 -08001419 final int prev = mLastSelection;
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001420 switch (mode) {
1421 case SELECTED_NONE:
Joe Onoratod63458b2009-10-15 21:19:09 -07001422 mState.homeButtonId = mHomeButtonNormal.getID();
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001423 break;
1424 case SELECTED_FOCUSED:
1425 mLastSelection = SELECTION_HOME;
1426 mState.homeButtonId = mHomeButtonFocused.getID();
Joe Onorato52a653f2009-11-11 14:52:11 -08001427 if (prev != SELECTION_HOME) {
Joe Onorato52a653f2009-11-11 14:52:11 -08001428 sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
1429 }
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001430 break;
1431 case SELECTED_PRESSED:
1432 mState.homeButtonId = mHomeButtonPressed.getID();
1433 break;
Joe Onoratod63458b2009-10-15 21:19:09 -07001434 }
1435 }
Joe Onoratobe386092009-11-17 17:32:16 -08001436
1437 public void dumpState() {
1438 Log.d(TAG, "mRollo.mWidth=" + mWidth);
1439 Log.d(TAG, "mRollo.mHeight=" + mHeight);
1440 Log.d(TAG, "mRollo.mIcons=" + mIcons);
1441 if (mIcons != null) {
1442 Log.d(TAG, "mRollo.mIcons.length=" + mIcons.length);
1443 }
1444 if (mIconIds != null) {
1445 Log.d(TAG, "mRollo.mIconIds.length=" + mIconIds.length);
1446 }
1447 Log.d(TAG, "mRollo.mIconIds=" + Arrays.toString(mIconIds));
1448 if (mLabelIds != null) {
1449 Log.d(TAG, "mRollo.mLabelIds.length=" + mLabelIds.length);
1450 }
1451 Log.d(TAG, "mRollo.mLabelIds=" + Arrays.toString(mLabelIds));
1452 Log.d(TAG, "mRollo.mTouchXBorders=" + Arrays.toString(mTouchXBorders));
1453 Log.d(TAG, "mRollo.mTouchYBorders=" + Arrays.toString(mTouchYBorders));
Joe Onoratobe386092009-11-17 17:32:16 -08001454 Log.d(TAG, "mRollo.mState.newPositionX=" + mState.newPositionX);
1455 Log.d(TAG, "mRollo.mState.newTouchDown=" + mState.newTouchDown);
1456 Log.d(TAG, "mRollo.mState.flingVelocity=" + mState.flingVelocity);
1457 Log.d(TAG, "mRollo.mState.iconCount=" + mState.iconCount);
1458 Log.d(TAG, "mRollo.mState.selectedIconIndex=" + mState.selectedIconIndex);
1459 Log.d(TAG, "mRollo.mState.selectedIconTexture=" + mState.selectedIconTexture);
1460 Log.d(TAG, "mRollo.mState.zoomTarget=" + mState.zoomTarget);
1461 Log.d(TAG, "mRollo.mState.homeButtonId=" + mState.homeButtonId);
1462 Log.d(TAG, "mRollo.mState.targetPos=" + mState.targetPos);
1463 Log.d(TAG, "mRollo.mParams.bubbleWidth=" + mParams.bubbleWidth);
1464 Log.d(TAG, "mRollo.mParams.bubbleHeight=" + mParams.bubbleHeight);
1465 Log.d(TAG, "mRollo.mParams.bubbleBitmapWidth=" + mParams.bubbleBitmapWidth);
1466 Log.d(TAG, "mRollo.mParams.bubbleBitmapHeight=" + mParams.bubbleBitmapHeight);
1467 Log.d(TAG, "mRollo.mParams.homeButtonWidth=" + mParams.homeButtonWidth);
1468 Log.d(TAG, "mRollo.mParams.homeButtonHeight=" + mParams.homeButtonHeight);
1469 Log.d(TAG, "mRollo.mParams.homeButtonTextureWidth=" + mParams.homeButtonTextureWidth);
1470 Log.d(TAG, "mRollo.mParams.homeButtonTextureHeight=" + mParams.homeButtonTextureHeight);
1471 }
1472 }
1473
1474 public void dumpState() {
1475 Log.d(TAG, "mRS=" + mRS);
1476 Log.d(TAG, "mRollo=" + mRollo);
1477 ApplicationInfo.dumpApplicationInfoList(TAG, "mAllAppsList", mAllAppsList);
1478 Log.d(TAG, "mArrowNavigation=" + mArrowNavigation);
1479 Log.d(TAG, "mStartedScrolling=" + mStartedScrolling);
1480 Log.d(TAG, "mLastSelection=" + mLastSelection);
1481 Log.d(TAG, "mLastSelectedIcon=" + mLastSelectedIcon);
1482 Log.d(TAG, "mVelocityTracker=" + mVelocityTracker);
1483 Log.d(TAG, "mTouchTracking=" + mTouchTracking);
1484 Log.d(TAG, "mShouldGainFocus=" + mShouldGainFocus);
1485 Log.d(TAG, "mZoomDirty=" + mZoomDirty);
1486 Log.d(TAG, "mAnimateNextZoom=" + mAnimateNextZoom);
1487 Log.d(TAG, "mZoom=" + mZoom);
1488 Log.d(TAG, "mPosX=" + mPosX);
1489 Log.d(TAG, "mVelocity=" + mVelocity);
1490 Log.d(TAG, "mMessageProc=" + mMessageProc);
1491 if (mRollo != null) {
1492 mRollo.dumpState();
1493 }
1494 if (mRS != null) {
1495 mRS.contextDump(0);
1496 }
Joe Onorato9c1289c2009-08-17 11:03:03 -04001497 }
Joe Onorato93839052009-08-06 20:34:32 -07001498}
1499
1500