blob: ef14555530cad14cb8bc59a635eed96bc0ead0d4 [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;
34import android.renderscript.RenderScript;
35import android.renderscript.Sampler;
36import android.renderscript.Script;
37import android.renderscript.ScriptC;
38import android.renderscript.SimpleMesh;
39import android.renderscript.Type;
Joe Onorato93839052009-08-06 20:34:32 -070040import android.util.AttributeSet;
41import android.util.Log;
Joe Onoratod769a632009-08-11 17:09:02 -070042import android.view.KeyEvent;
43import android.view.MotionEvent;
Joe Onoratob39e51a2009-10-28 15:47:49 -040044import android.view.SoundEffectConstants;
Joe Onorato93839052009-08-06 20:34:32 -070045import android.view.SurfaceHolder;
Joe Onoratod769a632009-08-11 17:09:02 -070046import android.view.VelocityTracker;
Mike Cleron4a5c1e12009-11-03 10:17:05 -080047import android.view.View;
Joe Onoratod769a632009-08-11 17:09:02 -070048import android.view.ViewConfiguration;
Joe Onorato52a653f2009-11-11 14:52:11 -080049import android.view.accessibility.AccessibilityEvent;
Mike Cleron4a5c1e12009-11-03 10:17:05 -080050
51import java.util.ArrayList;
Joe Onoratobe386092009-11-17 17:32:16 -080052import java.util.Arrays;
Mike Cleron4a5c1e12009-11-03 10:17:05 -080053import java.util.Collections;
54import java.util.Comparator;
Joe Onorato93839052009-08-06 20:34:32 -070055
56
Joe Onorato6665c0f2009-09-02 15:27:24 -070057public class AllAppsView extends RSSurfaceView
Joe Onorato5162ea92009-09-03 09:39:42 -070058 implements View.OnClickListener, View.OnLongClickListener, DragSource {
Joe Onorato9c1289c2009-08-17 11:03:03 -040059 private static final String TAG = "Launcher.AllAppsView";
60
Joe Onoratofb0ca672009-09-14 17:55:46 -040061 /** Bit for mLocks for when there are icons being loaded. */
62 private static final int LOCK_ICONS_PENDING = 1;
63
Joe Onorato68ffd102009-10-15 17:59:43 -070064 private static final int TRACKING_NONE = 0;
65 private static final int TRACKING_FLING = 1;
66 private static final int TRACKING_HOME = 2;
Joe Onoratobcbeab82009-10-01 21:45:43 -070067
Joe Onoratoeb8325a2009-11-08 13:20:30 -050068 private static final int SELECTED_NONE = 0;
69 private static final int SELECTED_FOCUSED = 1;
70 private static final int SELECTED_PRESSED = 2;
71
72 private static final int SELECTION_NONE = 0;
73 private static final int SELECTION_ICONS = 1;
74 private static final int SELECTION_HOME = 2;
75
Joe Onorato6665c0f2009-09-02 15:27:24 -070076 private Launcher mLauncher;
Joe Onorato5162ea92009-09-03 09:39:42 -070077 private DragController mDragController;
Joe Onoratofb0ca672009-09-14 17:55:46 -040078
79 /** When this is 0, modifications are allowed, when it's not, they're not.
80 * TODO: What about scrolling? */
81 private int mLocks = LOCK_ICONS_PENDING;
Joe Onorato6665c0f2009-09-02 15:27:24 -070082
Joe Onorato82ca5502009-10-15 16:59:23 -070083 private int mSlop;
Joe Onoratof7b0e012009-10-01 14:09:15 -070084 private int mMaxFlingVelocity;
85
Joe Onoratobcbeab82009-10-01 21:45:43 -070086 private Defines mDefines = new Defines();
Joe Onorato1feb3a82009-08-08 22:32:00 -070087 private RenderScript mRS;
88 private RolloRS mRollo;
Joe Onorato9c1289c2009-08-17 11:03:03 -040089 private ArrayList<ApplicationInfo> mAllAppsList;
Jason Sams2e19c052009-10-20 18:19:55 -070090
Mike Cleron7d5d7462009-10-20 14:06:00 -070091 /**
92 * True when we are using arrow keys or trackball to drive navigation
93 */
94 private boolean mArrowNavigation = false;
Joe Onoratoeb8325a2009-11-08 13:20:30 -050095 private boolean mStartedScrolling;
96
97 /**
98 * Used to keep track of the selection when AllAppsView loses window focus.
99 * One of the SELECTION_ constants.
100 */
101 private int mLastSelection;
Jason Sams2e19c052009-10-20 18:19:55 -0700102
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800103 /**
104 * Used to keep track of the selection when AllAppsView loses window focus
105 */
106 private int mLastSelectedIcon;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500107
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800108 private VelocityTracker mVelocityTracker;
Joe Onoratobcbeab82009-10-01 21:45:43 -0700109 private int mTouchTracking;
Joe Onorato5162ea92009-09-03 09:39:42 -0700110 private int mMotionDownRawX;
111 private int mMotionDownRawY;
Joe Onorato82ca5502009-10-15 16:59:23 -0700112 private int mDownIconIndex = -1;
113 private int mCurrentIconIndex = -1;
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800114
Mike Cleronb64b67a2009-11-08 14:56:25 -0800115 private boolean mShouldGainFocus;
116
Joe Onorato6374c512010-01-06 20:42:25 -0800117 private boolean mHaveSurface = false;
Joe Onorato3a8820b2009-11-10 15:06:42 -0800118 private boolean mZoomDirty = false;
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800119 private boolean mAnimateNextZoom;
Joe Onorato6374c512010-01-06 20:42:25 -0800120 private float mNextZoom;
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800121 private float mZoom;
122 private float mPosX;
123 private float mVelocity;
124 private AAMessage mMessageProc;
Joe Onorato1feb3a82009-08-08 22:32:00 -0700125
Joe Onorato6665c0f2009-09-02 15:27:24 -0700126 static class Defines {
Joe Onoratoc567acb2009-08-31 14:34:43 -0700127 public static final int ALLOC_PARAMS = 0;
128 public static final int ALLOC_STATE = 1;
Joe Onorato7bb17492009-09-24 17:51:01 -0700129 public static final int ALLOC_ICON_IDS = 3;
130 public static final int ALLOC_LABEL_IDS = 4;
Jason Samsb4ecab22010-01-19 16:43:26 -0800131 public static final int ALLOC_VP_CONSTANTS = 5;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700132
133 public static final int COLUMNS_PER_PAGE = 4;
134 public static final int ROWS_PER_PAGE = 4;
Jason Sams78aebd82009-09-15 13:06:59 -0700135
Joe Onorato6665c0f2009-09-02 15:27:24 -0700136 public static final int ICON_WIDTH_PX = 64;
Jason Sams1a94ee32010-01-20 13:34:30 -0800137 public static final int ICON_TEXTURE_WIDTH_PX = 74;
138 public static final int SELECTION_TEXTURE_WIDTH_PX = 74 + 20;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700139
140 public static final int ICON_HEIGHT_PX = 64;
Jason Sams1a94ee32010-01-20 13:34:30 -0800141 public static final int ICON_TEXTURE_HEIGHT_PX = 74;
142 public static final int SELECTION_TEXTURE_HEIGHT_PX = 74 + 20;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700143 }
Joe Onorato7c312c12009-08-13 21:36:53 -0700144
145 public AllAppsView(Context context, AttributeSet attrs) {
146 super(context, attrs);
Joe Onorato93839052009-08-06 20:34:32 -0700147 setFocusable(true);
Joe Onoratob39e51a2009-10-28 15:47:49 -0400148 setSoundEffectsEnabled(false);
Joe Onorato93839052009-08-06 20:34:32 -0700149 getHolder().setFormat(PixelFormat.TRANSLUCENT);
Joe Onoratof7b0e012009-10-01 14:09:15 -0700150 final ViewConfiguration config = ViewConfiguration.get(context);
Joe Onorato82ca5502009-10-15 16:59:23 -0700151 mSlop = config.getScaledTouchSlop();
Joe Onoratof7b0e012009-10-01 14:09:15 -0700152 mMaxFlingVelocity = config.getScaledMaximumFlingVelocity();
153
Joe Onorato6665c0f2009-09-02 15:27:24 -0700154 setOnClickListener(this);
155 setOnLongClickListener(this);
Dianne Hackborne52a1b52009-09-30 22:36:20 -0700156 setZOrderOnTop(true);
Jason Samsfd22dac2009-09-20 17:24:16 -0700157 getHolder().setFormat(PixelFormat.TRANSLUCENT);
Jason Samse26d9fc2009-11-12 14:00:43 -0800158
159 mRS = createRenderScript(true);
160 }
161
162 @Override
163 protected void onDetachedFromWindow() {
164 destroyRenderScript();
Joe Onorato93839052009-08-06 20:34:32 -0700165 }
166
Joe Onoratob39e51a2009-10-28 15:47:49 -0400167 /**
168 * If you have an attached click listener, View always plays the click sound!?!?
169 * Deal with sound effects by hand.
170 */
171 public void reallyPlaySoundEffect(int sound) {
172 boolean old = isSoundEffectsEnabled();
173 setSoundEffectsEnabled(true);
174 playSoundEffect(sound);
175 setSoundEffectsEnabled(old);
176 }
177
Joe Onorato7c312c12009-08-13 21:36:53 -0700178 public AllAppsView(Context context, AttributeSet attrs, int defStyle) {
179 this(context, attrs);
Joe Onorato93839052009-08-06 20:34:32 -0700180 }
181
Joe Onorato6665c0f2009-09-02 15:27:24 -0700182 public void setLauncher(Launcher launcher) {
183 mLauncher = launcher;
Joe Onorato93839052009-08-06 20:34:32 -0700184 }
185
Joe Onorato1feb3a82009-08-08 22:32:00 -0700186 @Override
Joe Onorato7bb17492009-09-24 17:51:01 -0700187 public void surfaceDestroyed(SurfaceHolder holder) {
188 super.surfaceDestroyed(holder);
Joe Onoratofab74402009-11-11 16:05:23 -0800189 // Without this, we leak mMessageCallback which leaks the context.
190 mRS.mMessageCallback = null;
Joe Onorato6374c512010-01-06 20:42:25 -0800191 // We may lose any callbacks that are pending, so make sure that we re-sync that
192 // on the next surfaceChanged.
193 mZoomDirty = true;
194 mHaveSurface = false;
Joe Onorato7bb17492009-09-24 17:51:01 -0700195 }
196
197 @Override
Joe Onorato93839052009-08-06 20:34:32 -0700198 public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
Joe Onoratoa30ce8e2009-11-11 08:16:49 -0800199 //long startTime = SystemClock.uptimeMillis();
Joe Onorato6665c0f2009-09-02 15:27:24 -0700200
Joe Onorato080d9b62009-11-02 12:01:11 -0500201 super.surfaceChanged(holder, format, w, h);
202
Joe Onorato6374c512010-01-06 20:42:25 -0800203 mHaveSurface = true;
204
Jason Samse26d9fc2009-11-12 14:00:43 -0800205 if (mRollo == null) {
Jason Sams90396672009-11-03 13:59:34 -0800206 mRollo = new RolloRS();
207 mRollo.init(getResources(), w, h);
208 if (mAllAppsList != null) {
209 mRollo.setApps(mAllAppsList);
Jason Sams90396672009-11-03 13:59:34 -0800210 }
Mike Cleronb64b67a2009-11-08 14:56:25 -0800211 if (mShouldGainFocus) {
212 gainFocus();
213 mShouldGainFocus = false;
214 }
Joe Onorato9c1289c2009-08-17 11:03:03 -0400215 }
Jason Samse26d9fc2009-11-12 14:00:43 -0800216 mRollo.dirtyCheck();
Jason Sams5612e432009-11-16 14:18:07 -0800217 mRollo.resize(w, h);
Joe Onoratoc567acb2009-08-31 14:34:43 -0700218
Joe Onoratocb75f362009-11-12 13:04:07 -0800219 mRS.mMessageCallback = mMessageProc = new AAMessage();
220
Joe Onoratoc567acb2009-08-31 14:34:43 -0700221 Resources res = getContext().getResources();
222 int barHeight = (int)res.getDimension(R.dimen.button_bar_height);
Joe Onorato6665c0f2009-09-02 15:27:24 -0700223
Jason Sams76512482010-02-04 16:31:35 -0800224
225 if (mRollo.mUniformAlloc != null) {
226 float tf[] = new float[] {72.f, 72.f,
227 120.f, 120.f, 0.f, 0.f,
228 120.f, 680.f,
229 (2.f / 480.f), 0, -((float)w / 2) - 0.25f, -380.25f};
230 if (w > h) {
231 tf[6] = 40.f;
232 tf[7] = h - 40.f;
233 tf[9] = 1.f;
234 tf[10] = -((float)w / 2) - 0.25f;
235 tf[11] = -((float)h / 2) - 0.25f;
236 }
237
238 mRollo.mUniformAlloc.data(tf);
239 }
240
Joe Onoratoa30ce8e2009-11-11 08:16:49 -0800241 //long endTime = SystemClock.uptimeMillis();
242 //Log.d(TAG, "surfaceChanged took " + (endTime-startTime) + "ms");
Joe Onorato93839052009-08-06 20:34:32 -0700243 }
Jason Sams2e19c052009-10-20 18:19:55 -0700244
Joe Onorato93839052009-08-06 20:34:32 -0700245 @Override
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800246 public void onWindowFocusChanged(boolean hasWindowFocus) {
247 super.onWindowFocusChanged(hasWindowFocus);
248 if (mArrowNavigation) {
249 if (!hasWindowFocus) {
250 // Clear selection when we lose window focus
251 mLastSelectedIcon = mRollo.mState.selectedIconIndex;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500252 mRollo.setHomeSelected(SELECTED_NONE);
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800253 mRollo.clearSelectedIcon();
254 mRollo.mState.save();
255 } else if (hasWindowFocus) {
256 if (mRollo.mState.iconCount > 0) {
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500257 if (mLastSelection == SELECTION_ICONS) {
258 int selection = mLastSelectedIcon;
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800259 final int firstIcon = Math.round(mPosX) *
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500260 Defines.COLUMNS_PER_PAGE;
261 if (selection < 0 || // No selection
262 selection < firstIcon || // off the top of the screen
263 selection >= mRollo.mState.iconCount || // past last icon
264 selection >= firstIcon + // past last icon on screen
265 (Defines.COLUMNS_PER_PAGE * Defines.ROWS_PER_PAGE)) {
266 selection = firstIcon;
267 }
268
269 // Select the first icon when we gain window focus
270 mRollo.selectIcon(selection, SELECTED_FOCUSED);
271 mRollo.mState.save();
272 } else if (mLastSelection == SELECTION_HOME) {
273 mRollo.setHomeSelected(SELECTED_FOCUSED);
274 mRollo.mState.save();
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800275 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800276 }
277 }
278 }
279 }
280
281 @Override
Mike Cleron7d5d7462009-10-20 14:06:00 -0700282 protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
283 super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
Joe Onorato859b3a72009-10-28 15:17:01 -0400284
285 if (!isVisible()) {
286 return;
287 }
288
Mike Cleron7d5d7462009-10-20 14:06:00 -0700289 if (gainFocus) {
Jason Sams510ee042009-12-15 14:23:37 -0800290 if (mRollo != null) {
Mike Cleronb64b67a2009-11-08 14:56:25 -0800291 gainFocus();
292 } else {
293 mShouldGainFocus = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700294 }
295 } else {
Joe Onorato8eea3912009-12-09 13:01:06 -0800296 if (mRollo != null) {
Mike Cleronb64b67a2009-11-08 14:56:25 -0800297 if (mArrowNavigation) {
298 // Clear selection when we lose focus
299 mRollo.clearSelectedIcon();
300 mRollo.setHomeSelected(SELECTED_NONE);
301 mRollo.mState.save();
302 mArrowNavigation = false;
303 }
304 } else {
305 mShouldGainFocus = false;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700306 }
307 }
308 }
309
Mike Cleronb64b67a2009-11-08 14:56:25 -0800310 private void gainFocus() {
311 if (!mArrowNavigation && mRollo.mState.iconCount > 0) {
312 // Select the first icon when we gain keyboard focus
313 mArrowNavigation = true;
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800314 mRollo.selectIcon(Math.round(mPosX) * Defines.COLUMNS_PER_PAGE,
Mike Cleronb64b67a2009-11-08 14:56:25 -0800315 SELECTED_FOCUSED);
316 mRollo.mState.save();
317 }
318 }
319
Mike Cleron7d5d7462009-10-20 14:06:00 -0700320 @Override
321 public boolean onKeyDown(int keyCode, KeyEvent event) {
Jason Sams2e19c052009-10-20 18:19:55 -0700322
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800323 boolean handled = false;
Jason Samse26d9fc2009-11-12 14:00:43 -0800324
Joe Onorato859b3a72009-10-28 15:17:01 -0400325 if (!isVisible()) {
326 return false;
327 }
Joe Onoratoa13f5742009-11-02 17:15:19 -0500328 final int iconCount = mRollo.mState.iconCount;
329
Mike Cleron7d5d7462009-10-20 14:06:00 -0700330 if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
331 if (mArrowNavigation) {
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500332 if (mLastSelection == SELECTION_HOME) {
333 reallyPlaySoundEffect(SoundEffectConstants.CLICK);
334 mLauncher.closeAllApps(true);
335 } else {
336 int whichApp = mRollo.mState.selectedIconIndex;
337 if (whichApp >= 0) {
338 ApplicationInfo app = mAllAppsList.get(whichApp);
339 mLauncher.startActivitySafely(app.intent);
340 handled = true;
341 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700342 }
343 }
344 }
Jason Sams2e19c052009-10-20 18:19:55 -0700345
Joe Onorato478730f2009-11-16 18:54:43 -0800346 if (iconCount > 0) {
Mike Cleron7d5d7462009-10-20 14:06:00 -0700347 mArrowNavigation = true;
Jason Sams2e19c052009-10-20 18:19:55 -0700348
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800349 int currentSelection = mRollo.mState.selectedIconIndex;
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800350 int currentTopRow = Math.round(mPosX);
Jason Sams2e19c052009-10-20 18:19:55 -0700351
Mike Cleron7d5d7462009-10-20 14:06:00 -0700352 // The column of the current selection, in the range 0..COLUMNS_PER_PAGE-1
Joe Onoratoa13f5742009-11-02 17:15:19 -0500353 final int currentPageCol = currentSelection % Defines.COLUMNS_PER_PAGE;
Jason Sams2e19c052009-10-20 18:19:55 -0700354
Mike Cleron7d5d7462009-10-20 14:06:00 -0700355 // The row of the current selection, in the range 0..ROWS_PER_PAGE-1
Joe Onoratoa13f5742009-11-02 17:15:19 -0500356 final int currentPageRow = (currentSelection - (currentTopRow*Defines.COLUMNS_PER_PAGE))
Mike Cleron7d5d7462009-10-20 14:06:00 -0700357 / Defines.ROWS_PER_PAGE;
Jason Sams2e19c052009-10-20 18:19:55 -0700358
Mike Cleron7d5d7462009-10-20 14:06:00 -0700359 int newSelection = currentSelection;
360
361 switch (keyCode) {
362 case KeyEvent.KEYCODE_DPAD_UP:
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500363 if (mLastSelection == SELECTION_HOME) {
364 mRollo.setHomeSelected(SELECTED_NONE);
365 int lastRowCount = iconCount % Defines.COLUMNS_PER_PAGE;
366 if (lastRowCount == 0) {
367 lastRowCount = Defines.COLUMNS_PER_PAGE;
368 }
369 newSelection = iconCount - lastRowCount + (Defines.COLUMNS_PER_PAGE / 2);
370 if (newSelection >= iconCount) {
371 newSelection = iconCount-1;
372 }
373 int target = (newSelection / Defines.COLUMNS_PER_PAGE)
374 - (Defines.ROWS_PER_PAGE - 1);
375 if (target < 0) {
376 target = 0;
377 }
378 if (currentTopRow != target) {
379 mRollo.moveTo(target);
380 }
381 } else {
382 if (currentPageRow > 0) {
383 newSelection = currentSelection - Defines.COLUMNS_PER_PAGE;
384 } else if (currentTopRow > 0) {
385 newSelection = currentSelection - Defines.COLUMNS_PER_PAGE;
386 mRollo.moveTo(newSelection / Defines.COLUMNS_PER_PAGE);
Joe Onoratoaf5b4cb2009-12-08 17:51:22 -0800387 } else if (currentPageRow != 0) {
388 newSelection = currentTopRow * Defines.ROWS_PER_PAGE;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500389 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700390 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800391 handled = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700392 break;
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800393
Joe Onoratoa13f5742009-11-02 17:15:19 -0500394 case KeyEvent.KEYCODE_DPAD_DOWN: {
395 final int rowCount = iconCount / Defines.COLUMNS_PER_PAGE
396 + (iconCount % Defines.COLUMNS_PER_PAGE == 0 ? 0 : 1);
397 final int currentRow = currentSelection / Defines.COLUMNS_PER_PAGE;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500398 if (mLastSelection != SELECTION_HOME) {
399 if (currentRow < rowCount-1) {
400 mRollo.setHomeSelected(SELECTED_NONE);
Joe Onorato478730f2009-11-16 18:54:43 -0800401 if (currentSelection < 0) {
402 newSelection = 0;
403 } else {
404 newSelection = currentSelection + Defines.COLUMNS_PER_PAGE;
405 }
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500406 if (newSelection >= iconCount) {
407 // Go from D to G in this arrangement:
408 // A B C D
409 // E F G
410 newSelection = iconCount - 1;
411 }
412 if (currentPageRow >= Defines.ROWS_PER_PAGE - 1) {
413 mRollo.moveTo((newSelection / Defines.COLUMNS_PER_PAGE) -
414 Defines.ROWS_PER_PAGE + 1);
415 }
416 } else {
417 newSelection = -1;
418 mRollo.setHomeSelected(SELECTED_FOCUSED);
Mike Cleron7d5d7462009-10-20 14:06:00 -0700419 }
420 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800421 handled = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700422 break;
Joe Onoratoa13f5742009-11-02 17:15:19 -0500423 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700424 case KeyEvent.KEYCODE_DPAD_LEFT:
Joe Onoratoe9a3f3d2010-02-01 18:36:43 -0500425 if (mLastSelection != SELECTION_HOME) {
426 if (currentPageCol > 0) {
427 newSelection = currentSelection - 1;
428 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700429 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800430 handled = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700431 break;
432 case KeyEvent.KEYCODE_DPAD_RIGHT:
Joe Onoratoe9a3f3d2010-02-01 18:36:43 -0500433 if (mLastSelection != SELECTION_HOME) {
434 if ((currentPageCol < Defines.COLUMNS_PER_PAGE - 1) &&
435 (currentSelection < iconCount - 1)) {
436 newSelection = currentSelection + 1;
437 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700438 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800439 handled = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700440 break;
441 }
442 if (newSelection != currentSelection) {
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500443 mRollo.selectIcon(newSelection, SELECTED_FOCUSED);
Mike Cleron7d5d7462009-10-20 14:06:00 -0700444 mRollo.mState.save();
445 }
446 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800447 return handled;
Joe Onorato93839052009-08-06 20:34:32 -0700448 }
449
Joe Onorato93839052009-08-06 20:34:32 -0700450 @Override
451 public boolean onTouchEvent(MotionEvent ev)
452 {
Mike Cleron7d5d7462009-10-20 14:06:00 -0700453 mArrowNavigation = false;
Jason Sams2e19c052009-10-20 18:19:55 -0700454
Joe Onorato7bb17492009-09-24 17:51:01 -0700455 if (!isVisible()) {
Joe Onorato85a02a82009-09-08 12:34:22 -0700456 return true;
Joe Onoratoe3406a22009-09-03 14:36:25 -0700457 }
458
Joe Onoratofb0ca672009-09-14 17:55:46 -0400459 if (mLocks != 0) {
Joe Onorato85a02a82009-09-08 12:34:22 -0700460 return true;
461 }
462
463 super.onTouchEvent(ev);
464
Joe Onoratofb0ca672009-09-14 17:55:46 -0400465 int x = (int)ev.getX();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700466 int y = (int)ev.getY();
467
Joe Onoratobcbeab82009-10-01 21:45:43 -0700468 int action = ev.getAction();
469 switch (action) {
Joe Onoratofb0ca672009-09-14 17:55:46 -0400470 case MotionEvent.ACTION_DOWN:
Joe Onoratobcbeab82009-10-01 21:45:43 -0700471 if (y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]) {
472 mTouchTracking = TRACKING_HOME;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500473 mRollo.setHomeSelected(SELECTED_PRESSED);
Joe Onoratod63458b2009-10-15 21:19:09 -0700474 mRollo.mState.save();
Mike Cleron7d5d7462009-10-20 14:06:00 -0700475 mCurrentIconIndex = -1;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700476 } else {
Joe Onoratobcbeab82009-10-01 21:45:43 -0700477 mTouchTracking = TRACKING_FLING;
478
479 mMotionDownRawX = (int)ev.getRawX();
480 mMotionDownRawY = (int)ev.getRawY();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700481
Mike Cleron7d5d7462009-10-20 14:06:00 -0700482 mRollo.mState.newPositionX = ev.getRawY() / getHeight();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700483 mRollo.mState.newTouchDown = 1;
484
485 if (!mRollo.checkClickOK()) {
486 mRollo.clearSelectedIcon();
487 } else {
Joe Onorato82ca5502009-10-15 16:59:23 -0700488 mDownIconIndex = mCurrentIconIndex
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800489 = mRollo.selectIcon(x, y, mPosX, SELECTED_PRESSED);
Joe Onorato82ca5502009-10-15 16:59:23 -0700490 if (mDownIconIndex < 0) {
491 // if nothing was selected, no long press.
492 cancelLongPress();
493 }
Joe Onoratobcbeab82009-10-01 21:45:43 -0700494 }
495 mRollo.mState.save();
Jason Samsd8152b92009-10-13 17:19:10 -0700496 mRollo.move();
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800497 mVelocityTracker = VelocityTracker.obtain();
498 mVelocityTracker.addMovement(ev);
Joe Onoratobcbeab82009-10-01 21:45:43 -0700499 mStartedScrolling = false;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700500 }
Joe Onoratofb0ca672009-09-14 17:55:46 -0400501 break;
502 case MotionEvent.ACTION_MOVE:
503 case MotionEvent.ACTION_OUTSIDE:
Joe Onoratobcbeab82009-10-01 21:45:43 -0700504 if (mTouchTracking == TRACKING_HOME) {
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500505 mRollo.setHomeSelected(y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]
506 ? SELECTED_PRESSED : SELECTED_NONE);
Joe Onoratod63458b2009-10-15 21:19:09 -0700507 mRollo.mState.save();
Joe Onorato68ffd102009-10-15 17:59:43 -0700508 } else if (mTouchTracking == TRACKING_FLING) {
Joe Onorato82ca5502009-10-15 16:59:23 -0700509 int rawX = (int)ev.getRawX();
510 int rawY = (int)ev.getRawY();
511 int slop;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700512 slop = Math.abs(rawY - mMotionDownRawY);
Jason Samsd8152b92009-10-13 17:19:10 -0700513
Joe Onorato82ca5502009-10-15 16:59:23 -0700514 if (!mStartedScrolling && slop < mSlop) {
515 // don't update anything so when we do start scrolling
Joe Onoratobcbeab82009-10-01 21:45:43 -0700516 // below, we get the right delta.
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800517 mCurrentIconIndex = mRollo.chooseTappedIcon(x, y, mPosX);
Joe Onorato82ca5502009-10-15 16:59:23 -0700518 if (mDownIconIndex != mCurrentIconIndex) {
519 // If a different icon is selected, don't allow it to be picked up.
520 // This handles off-axis dragging.
521 cancelLongPress();
522 mCurrentIconIndex = -1;
523 }
Joe Onoratobcbeab82009-10-01 21:45:43 -0700524 } else {
Joe Onorato82ca5502009-10-15 16:59:23 -0700525 if (!mStartedScrolling) {
526 cancelLongPress();
527 mCurrentIconIndex = -1;
528 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700529 mRollo.mState.newPositionX = ev.getRawY() / getHeight();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700530 mRollo.mState.newTouchDown = 1;
Jason Samsd8152b92009-10-13 17:19:10 -0700531 mRollo.move();
Jason Sams86c87ed2009-09-18 13:55:55 -0700532
Joe Onoratobcbeab82009-10-01 21:45:43 -0700533 mStartedScrolling = true;
534 mRollo.clearSelectedIcon();
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800535 mVelocityTracker.addMovement(ev);
Joe Onoratobcbeab82009-10-01 21:45:43 -0700536 mRollo.mState.save();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700537 }
Joe Onoratofb0ca672009-09-14 17:55:46 -0400538 }
539 break;
540 case MotionEvent.ACTION_UP:
541 case MotionEvent.ACTION_CANCEL:
Joe Onoratobcbeab82009-10-01 21:45:43 -0700542 if (mTouchTracking == TRACKING_HOME) {
543 if (action == MotionEvent.ACTION_UP) {
544 if (y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]) {
Joe Onoratob39e51a2009-10-28 15:47:49 -0400545 reallyPlaySoundEffect(SoundEffectConstants.CLICK);
Joe Onoratobcbeab82009-10-01 21:45:43 -0700546 mLauncher.closeAllApps(true);
547 }
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500548 mRollo.setHomeSelected(SELECTED_NONE);
Joe Onoratod63458b2009-10-15 21:19:09 -0700549 mRollo.mState.save();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700550 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700551 mCurrentIconIndex = -1;
Joe Onorato68ffd102009-10-15 17:59:43 -0700552 } else if (mTouchTracking == TRACKING_FLING) {
Joe Onoratobcbeab82009-10-01 21:45:43 -0700553 mRollo.mState.newTouchDown = 0;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700554 mRollo.mState.newPositionX = ev.getRawY() / getHeight();
Jason Sams476339d2009-09-29 18:14:38 -0700555
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800556 mVelocityTracker.computeCurrentVelocity(1000 /* px/sec */, mMaxFlingVelocity);
557 mRollo.mState.flingVelocity = mVelocityTracker.getYVelocity() / getHeight();
Jason Sams12c14a82009-10-06 14:33:15 -0700558 mRollo.clearSelectedIcon();
559 mRollo.mState.save();
Jason Samsd8152b92009-10-13 17:19:10 -0700560 mRollo.fling();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700561
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800562 if (mVelocityTracker != null) {
563 mVelocityTracker.recycle();
564 mVelocityTracker = null;
Joe Onorato539ed9d2009-10-02 10:22:14 -0700565 }
Joe Onoratobcbeab82009-10-01 21:45:43 -0700566 }
Joe Onorato68ffd102009-10-15 17:59:43 -0700567 mTouchTracking = TRACKING_NONE;
568 break;
Joe Onorato93839052009-08-06 20:34:32 -0700569 }
Joe Onorato6665c0f2009-09-02 15:27:24 -0700570
571 return true;
Joe Onorato93839052009-08-06 20:34:32 -0700572 }
573
Joe Onorato6665c0f2009-09-02 15:27:24 -0700574 public void onClick(View v) {
Joe Onorato7bb17492009-09-24 17:51:01 -0700575 if (mLocks != 0 || !isVisible()) {
Joe Onoratofb0ca672009-09-14 17:55:46 -0400576 return;
577 }
Joe Onorato82ca5502009-10-15 16:59:23 -0700578 if (mRollo.checkClickOK() && mCurrentIconIndex == mDownIconIndex
579 && mCurrentIconIndex >= 0 && mCurrentIconIndex < mAllAppsList.size()) {
Joe Onoratob39e51a2009-10-28 15:47:49 -0400580 reallyPlaySoundEffect(SoundEffectConstants.CLICK);
Joe Onorato82ca5502009-10-15 16:59:23 -0700581 ApplicationInfo app = mAllAppsList.get(mCurrentIconIndex);
Joe Onorato6665c0f2009-09-02 15:27:24 -0700582 mLauncher.startActivitySafely(app.intent);
583 }
584 }
585
586 public boolean onLongClick(View v) {
Joe Onorato7bb17492009-09-24 17:51:01 -0700587 if (mLocks != 0 || !isVisible()) {
Joe Onoratofb0ca672009-09-14 17:55:46 -0400588 return true;
589 }
Joe Onorato82ca5502009-10-15 16:59:23 -0700590 if (mRollo.checkClickOK() && mCurrentIconIndex == mDownIconIndex
591 && mCurrentIconIndex >= 0 && mCurrentIconIndex < mAllAppsList.size()) {
592 ApplicationInfo app = mAllAppsList.get(mCurrentIconIndex);
Joe Onorato5162ea92009-09-03 09:39:42 -0700593
Jason Samsb4ecab22010-01-19 16:43:26 -0800594 Bitmap bmp = app.iconBitmap;
595 final int w = bmp.getWidth();
596 final int h = bmp.getHeight();
597
Joe Onorato5162ea92009-09-03 09:39:42 -0700598 // We don't really have an accurate location to use. This will do.
Jason Samsb4ecab22010-01-19 16:43:26 -0800599 int screenX = mMotionDownRawX - (w / 2);
600 int screenY = mMotionDownRawY - h;
Joe Onorato5162ea92009-09-03 09:39:42 -0700601
Joe Onoratobcbeab82009-10-01 21:45:43 -0700602 int left = (mDefines.ICON_TEXTURE_WIDTH_PX - mDefines.ICON_WIDTH_PX) / 2;
603 int top = (mDefines.ICON_TEXTURE_HEIGHT_PX - mDefines.ICON_HEIGHT_PX) / 2;
Jason Samsb4ecab22010-01-19 16:43:26 -0800604 mDragController.startDrag(bmp, screenX, screenY,
605 0, 0, w, h, this, app, DragController.DRAG_ACTION_COPY);
Joe Onoratoe3406a22009-09-03 14:36:25 -0700606
Joe Onorato7bb17492009-09-24 17:51:01 -0700607 mLauncher.closeAllApps(true);
Joe Onorato5162ea92009-09-03 09:39:42 -0700608 }
Joe Onorato6665c0f2009-09-02 15:27:24 -0700609 return true;
610 }
611
Joe Onorato52a653f2009-11-11 14:52:11 -0800612 @Override
613 public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
614 if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SELECTED) {
615 if (!isVisible()) {
616 return false;
617 }
618 String text = null;
619 int index;
620 int count = mAllAppsList.size() + 1; // +1 is home
621 int pos = -1;
622 switch (mLastSelection) {
623 case SELECTION_ICONS:
624 index = mRollo.mState.selectedIconIndex;
625 if (index >= 0) {
626 ApplicationInfo info = mAllAppsList.get(index);
627 if (info.title != null) {
628 text = info.title.toString();
629 pos = index;
630 }
631 }
632 break;
633 case SELECTION_HOME:
634 text = getContext().getString(R.string.all_apps_home_button_label);
635 pos = count;
636 break;
637 }
638 if (text != null) {
Joe Onorato52a653f2009-11-11 14:52:11 -0800639 event.setEnabled(true);
640 event.getText().add(text);
641 //event.setContentDescription(text);
642 event.setItemCount(count);
643 event.setCurrentItemIndex(pos);
644 }
645 }
646 return false;
647 }
648
Joe Onorato5162ea92009-09-03 09:39:42 -0700649 public void setDragController(DragController dragger) {
650 mDragController = dragger;
651 }
652
653 public void onDropCompleted(View target, boolean success) {
654 }
655
Joe Onorato4db52312009-10-06 11:17:43 -0700656 /**
Joe Onorato3a8820b2009-11-10 15:06:42 -0800657 * Zoom to the specifed level.
Joe Onorato4db52312009-10-06 11:17:43 -0700658 *
Joe Onorato3a8820b2009-11-10 15:06:42 -0800659 * @param zoom [0..1] 0 is hidden, 1 is open
Joe Onorato4db52312009-10-06 11:17:43 -0700660 */
Joe Onorato3a8820b2009-11-10 15:06:42 -0800661 public void zoom(float zoom, boolean animate) {
Joe Onoratofb0ca672009-09-14 17:55:46 -0400662 cancelLongPress();
Joe Onorato6374c512010-01-06 20:42:25 -0800663 mNextZoom = zoom;
664 mAnimateNextZoom = animate;
665 // if we do setZoom while we don't have a surface, we won't
666 // get the callbacks that actually set mZoom.
667 if (mRollo == null || !mHaveSurface) {
Joe Onorato3a8820b2009-11-10 15:06:42 -0800668 mZoomDirty = true;
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800669 mZoom = zoom;
Joe Onorato3a8820b2009-11-10 15:06:42 -0800670 return;
Joe Onorato85a02a82009-09-08 12:34:22 -0700671 } else {
Joe Onorato3a8820b2009-11-10 15:06:42 -0800672 mRollo.setZoom(zoom, animate);
Joe Onoratoc567acb2009-08-31 14:34:43 -0700673 }
Joe Onoratofb0ca672009-09-14 17:55:46 -0400674 }
675
676 public boolean isVisible() {
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800677 return mZoom > 0.001f;
Joe Onorato3a8820b2009-11-10 15:06:42 -0800678 }
679
680 public boolean isOpaque() {
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800681 return mZoom > 0.999f;
Joe Onoratofb0ca672009-09-14 17:55:46 -0400682 }
Joe Onoratoc567acb2009-08-31 14:34:43 -0700683
Joe Onorato9c1289c2009-08-17 11:03:03 -0400684 public void setApps(ArrayList<ApplicationInfo> list) {
685 mAllAppsList = list;
686 if (mRollo != null) {
Joe Onorato3ecbd812009-12-11 13:38:54 -0800687 mRollo.setApps(list);
Joe Onorato9c1289c2009-08-17 11:03:03 -0400688 }
Joe Onoratofb0ca672009-09-14 17:55:46 -0400689 mLocks &= ~LOCK_ICONS_PENDING;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700690 }
691
Joe Onoratoa8138d52009-10-06 19:25:30 -0700692 public void addApps(ArrayList<ApplicationInfo> list) {
Joe Onorato2d804762009-11-05 16:02:32 -0500693 if (mAllAppsList == null) {
694 // Not done loading yet. We'll find out about it later.
695 return;
696 }
697
Joe Onoratoa8138d52009-10-06 19:25:30 -0700698 final int N = list.size();
Joe Onorato8eea3912009-12-09 13:01:06 -0800699 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700700 mRollo.reallocAppsList(mRollo.mState.iconCount + N);
701 }
702
703 for (int i=0; i<N; i++) {
704 final ApplicationInfo item = list.get(i);
Joe Onoratob0c27f22009-12-01 16:19:38 -0800705 int index = Collections.binarySearch(mAllAppsList, item,
706 LauncherModel.APP_NAME_COMPARATOR);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700707 if (index < 0) {
708 index = -(index+1);
709 }
710 mAllAppsList.add(index, item);
Joe Onorato8eea3912009-12-09 13:01:06 -0800711 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700712 mRollo.addApp(index, item);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700713 }
714 }
715
Joe Onorato8eea3912009-12-09 13:01:06 -0800716 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700717 mRollo.saveAppsList();
718 }
Joe Onoratoc567acb2009-08-31 14:34:43 -0700719 }
720
Joe Onoratoa8138d52009-10-06 19:25:30 -0700721 public void removeApps(ArrayList<ApplicationInfo> list) {
Joe Onorato2d804762009-11-05 16:02:32 -0500722 if (mAllAppsList == null) {
723 // Not done loading yet. We'll find out about it later.
724 return;
725 }
726
Joe Onoratoa8138d52009-10-06 19:25:30 -0700727 final int N = list.size();
728 for (int i=0; i<N; i++) {
729 final ApplicationInfo item = list.get(i);
Joe Onoratocb9f7982009-10-31 16:32:02 -0400730 int index = findAppByComponent(mAllAppsList, item);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700731 if (index >= 0) {
Joe Onoratoa276fc52009-12-08 17:02:02 -0800732 int ic = mRollo != null ? mRollo.mState.iconCount : 666;
Joe Onoratoa8138d52009-10-06 19:25:30 -0700733 mAllAppsList.remove(index);
Joe Onorato8eea3912009-12-09 13:01:06 -0800734 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700735 mRollo.removeApp(index);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700736 }
737 } else {
Joe Onoratoa30ce8e2009-11-11 08:16:49 -0800738 Log.w(TAG, "couldn't find a match for item \"" + item + "\"");
Joe Onoratoa8138d52009-10-06 19:25:30 -0700739 // Try to recover. This should keep us from crashing for now.
740 }
741 }
742
Joe Onorato8eea3912009-12-09 13:01:06 -0800743 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700744 mRollo.saveAppsList();
745 }
746 }
747
748 public void updateApps(String packageName, ArrayList<ApplicationInfo> list) {
749 // Just remove and add, because they may need to be re-sorted.
750 removeApps(list);
751 addApps(list);
752 }
753
Joe Onoratocb9f7982009-10-31 16:32:02 -0400754 private static int findAppByComponent(ArrayList<ApplicationInfo> list, ApplicationInfo item) {
755 ComponentName component = item.intent.getComponent();
756 final int N = list.size();
757 for (int i=0; i<N; i++) {
758 ApplicationInfo x = list.get(i);
759 if (x.intent.getComponent().equals(component)) {
760 return i;
761 }
Joe Onoratoa8138d52009-10-06 19:25:30 -0700762 }
Joe Onoratocb9f7982009-10-31 16:32:02 -0400763 return -1;
764 }
Joe Onoratoa8138d52009-10-06 19:25:30 -0700765
Joe Onoratoc567acb2009-08-31 14:34:43 -0700766 private static int countPages(int iconCount) {
767 int iconsPerPage = Defines.COLUMNS_PER_PAGE * Defines.ROWS_PER_PAGE;
768 int pages = iconCount / iconsPerPage;
769 if (pages*iconsPerPage != iconCount) {
770 pages++;
771 }
772 return pages;
Joe Onorato9c1289c2009-08-17 11:03:03 -0400773 }
774
Joe Onoratocb75f362009-11-12 13:04:07 -0800775 class AAMessage extends RenderScript.RSMessage {
776 public void run() {
777 mPosX = ((float)mData[0]) / (1 << 16);
778 mVelocity = ((float)mData[1]) / (1 << 16);
779 mZoom = ((float)mData[2]) / (1 << 16);
780 mZoomDirty = false;
781 }
Joe Onoratocb75f362009-11-12 13:04:07 -0800782 }
783
Joe Onorato93839052009-08-06 20:34:32 -0700784 public class RolloRS {
Joe Onoratobf15cb42009-08-07 14:33:40 -0700785
Joe Onorato1feb3a82009-08-08 22:32:00 -0700786 // Allocations ======
Joe Onorato93839052009-08-06 20:34:32 -0700787 private int mWidth;
788 private int mHeight;
789
790 private Resources mRes;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700791 private Script mScript;
792 private Script.Invokable mInvokeMove;
Jason Samsc1c521e2009-10-19 14:45:45 -0700793 private Script.Invokable mInvokeMoveTo;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700794 private Script.Invokable mInvokeFling;
795 private Script.Invokable mInvokeResetWAR;
Joe Onorato3a8820b2009-11-10 15:06:42 -0800796 private Script.Invokable mInvokeSetZoom;
Jason Samsc1c521e2009-10-19 14:45:45 -0700797
Jason Samscd689e12009-09-29 15:28:22 -0700798 private ProgramStore mPSIcons;
Joe Onorato93839052009-08-06 20:34:32 -0700799 private ProgramStore mPSText;
Jason Samscd689e12009-09-29 15:28:22 -0700800 private ProgramFragment mPFColor;
Jason Samsc8514792009-10-29 14:27:29 -0700801 private ProgramFragment mPFTexMip;
Jason Sams6ec11bc2010-01-19 17:56:52 -0800802 private ProgramFragment mPFTexMipAlpha;
Jason Samsc8514792009-10-29 14:27:29 -0700803 private ProgramFragment mPFTexNearest;
Joe Onorato93839052009-08-06 20:34:32 -0700804 private ProgramVertex mPV;
Joe Onorato93839052009-08-06 20:34:32 -0700805 private ProgramVertex mPVOrtho;
Jason Samsb4ecab22010-01-19 16:43:26 -0800806 private ProgramVertex mPVCurve;
Jason Sams0aa71662009-10-02 18:43:18 -0700807 private SimpleMesh mMesh;
Jason Sams5612e432009-11-16 14:18:07 -0800808 private ProgramVertex.MatrixAllocation mPVA;
Joe Onorato93839052009-08-06 20:34:32 -0700809
Jason Samsb4ecab22010-01-19 16:43:26 -0800810 private Allocation mUniformAlloc;
811
Joe Onoratod63458b2009-10-15 21:19:09 -0700812 private Allocation mHomeButtonNormal;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500813 private Allocation mHomeButtonFocused;
Joe Onoratod63458b2009-10-15 21:19:09 -0700814 private Allocation mHomeButtonPressed;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700815
Joe Onoratobf15cb42009-08-07 14:33:40 -0700816 private Allocation[] mIcons;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700817 private int[] mIconIds;
Joe Onoratoa8138d52009-10-06 19:25:30 -0700818 private Allocation mAllocIconIds;
Joe Onorato93839052009-08-06 20:34:32 -0700819
Joe Onoratobf15cb42009-08-07 14:33:40 -0700820 private Allocation[] mLabels;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700821 private int[] mLabelIds;
Joe Onoratoa8138d52009-10-06 19:25:30 -0700822 private Allocation mAllocLabelIds;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700823 private Allocation mSelectedIcon;
Joe Onorato93839052009-08-06 20:34:32 -0700824
Joe Onorato6665c0f2009-09-02 15:27:24 -0700825 private int[] mTouchYBorders;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700826 private int[] mTouchXBorders;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700827
828 private Bitmap mSelectionBitmap;
Joe Onorato1291a8c2009-09-15 15:07:25 -0400829 private Canvas mSelectionCanvas;
Joe Onorato93839052009-08-06 20:34:32 -0700830
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700831 Params mParams;
Joe Onorato1feb3a82009-08-08 22:32:00 -0700832 State mState;
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700833
Jason Sams78aebd82009-09-15 13:06:59 -0700834 class BaseAlloc {
835 Allocation mAlloc;
836 Type mType;
837
838 void save() {
839 mAlloc.data(this);
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700840 }
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700841 }
842
Jason Sams476339d2009-09-29 18:14:38 -0700843 private boolean checkClickOK() {
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800844 return (Math.abs(mVelocity) < 0.4f) &&
845 (Math.abs(mPosX - Math.round(mPosX)) < 0.4f);
Jason Sams476339d2009-09-29 18:14:38 -0700846 }
847
Jason Sams78aebd82009-09-15 13:06:59 -0700848 class Params extends BaseAlloc {
849 Params() {
850 mType = Type.createFromClass(mRS, Params.class, 1, "ParamsClass");
851 mAlloc = Allocation.createTyped(mRS, mType);
852 save();
Joe Onorato1feb3a82009-08-08 22:32:00 -0700853 }
Jason Sams78aebd82009-09-15 13:06:59 -0700854 public int bubbleWidth;
855 public int bubbleHeight;
856 public int bubbleBitmapWidth;
857 public int bubbleBitmapHeight;
Joe Onoratobcbeab82009-10-01 21:45:43 -0700858
Joe Onoratobcbeab82009-10-01 21:45:43 -0700859 public int homeButtonWidth;
860 public int homeButtonHeight;
861 public int homeButtonTextureWidth;
862 public int homeButtonTextureHeight;
Jason Sams78aebd82009-09-15 13:06:59 -0700863 }
864
865 class State extends BaseAlloc {
Jason Sams86c87ed2009-09-18 13:55:55 -0700866 public float newPositionX;
867 public int newTouchDown;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700868 public float flingVelocity;
Jason Sams78aebd82009-09-15 13:06:59 -0700869 public int iconCount;
Jason Sams78aebd82009-09-15 13:06:59 -0700870 public int selectedIconIndex = -1;
871 public int selectedIconTexture;
Joe Onorato7bb17492009-09-24 17:51:01 -0700872 public float zoomTarget;
Joe Onoratod63458b2009-10-15 21:19:09 -0700873 public int homeButtonId;
Jason Samsc1c521e2009-10-19 14:45:45 -0700874 public float targetPos;
Jason Sams78aebd82009-09-15 13:06:59 -0700875
876 State() {
877 mType = Type.createFromClass(mRS, State.class, 1, "StateClass");
878 mAlloc = Allocation.createTyped(mRS, mType);
879 save();
880 }
Joe Onorato1feb3a82009-08-08 22:32:00 -0700881 }
882
883 public RolloRS() {
884 }
885
886 public void init(Resources res, int width, int height) {
887 mRes = res;
888 mWidth = width;
889 mHeight = height;
Jason Samscd689e12009-09-29 15:28:22 -0700890 initProgramVertex();
891 initProgramFragment();
892 initProgramStore();
Jason Samsb4ecab22010-01-19 16:43:26 -0800893 //initMesh();
Joe Onorato1feb3a82009-08-08 22:32:00 -0700894 initGl();
895 initData();
Joe Onorato6665c0f2009-09-02 15:27:24 -0700896 initTouchState();
Joe Onorato1feb3a82009-08-08 22:32:00 -0700897 initRs();
898 }
899
Jason Samsb4ecab22010-01-19 16:43:26 -0800900 public void initMesh2() {
901 SimpleMesh.TriangleMeshBuilder tm = new SimpleMesh.TriangleMeshBuilder(mRS, 2, 0);
Jason Sams0aa71662009-10-02 18:43:18 -0700902
Jason Samsb4ecab22010-01-19 16:43:26 -0800903 for (int ct=0; ct < 16; ct++) {
Jason Sams76512482010-02-04 16:31:35 -0800904 float pos = (1.f / (16.f - 1)) * ct;
Jason Samsb4ecab22010-01-19 16:43:26 -0800905 tm.addVertex(0.0f, pos);
906 tm.addVertex(1.0f, pos);
Jason Samsd8152b92009-10-13 17:19:10 -0700907 }
Jason Samsb4ecab22010-01-19 16:43:26 -0800908 for (int ct=0; ct < (16 * 2 - 2); ct+= 2) {
Jason Samsd8152b92009-10-13 17:19:10 -0700909 tm.addTriangle(ct, ct+1, ct+2);
910 tm.addTriangle(ct+1, ct+3, ct+2);
911 }
Jason Samsb4ecab22010-01-19 16:43:26 -0800912 mMesh = tm.create();
913 mMesh.setName("SMCell");
Jason Samsd8152b92009-10-13 17:19:10 -0700914 }
915
Jason Sams5612e432009-11-16 14:18:07 -0800916 void resize(int w, int h) {
917 mPVA.setupProjectionNormalized(w, h);
918 mWidth = w;
919 mHeight = h;
920 }
921
Jason Samscd689e12009-09-29 15:28:22 -0700922 private void initProgramVertex() {
Jason Sams5612e432009-11-16 14:18:07 -0800923 mPVA = new ProgramVertex.MatrixAllocation(mRS);
924 resize(mWidth, mHeight);
Joe Onorato93839052009-08-06 20:34:32 -0700925
926 ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS, null, null);
Jason Sams0aa71662009-10-02 18:43:18 -0700927 pvb.setTextureMatrixEnable(true);
Joe Onorato93839052009-08-06 20:34:32 -0700928 mPV = pvb.create();
929 mPV.setName("PV");
Jason Sams5612e432009-11-16 14:18:07 -0800930 mPV.bindAllocation(mPVA);
Joe Onorato93839052009-08-06 20:34:32 -0700931
Jason Samsb4ecab22010-01-19 16:43:26 -0800932 Element.Builder eb = new Element.Builder(mRS);
933 eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 2), "ImgSize");
934 eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 4), "Position");
Jason Sams66ed54e2010-02-04 12:39:27 -0800935 eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 2), "BendPos");
936 eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 4), "ScaleOffset");
Jason Samsb4ecab22010-01-19 16:43:26 -0800937 Element e = eb.create();
938
939 mUniformAlloc = Allocation.createSized(mRS, e, 1);
940
941 initMesh2();
942 ProgramVertex.ShaderBuilder sb = new ProgramVertex.ShaderBuilder(mRS);
943 String t = new String("void main() {\n" +
944 // Animation
945 " float ani = UNI_Position.z;\n" +
946
Jason Sams66ed54e2010-02-04 12:39:27 -0800947 " float bendY1 = UNI_BendPos.x;\n" +
948 " float bendY2 = UNI_BendPos.y;\n" +
Jason Sams76512482010-02-04 16:31:35 -0800949 " float bendAngle = 47.0 * (3.14 / 180.0);\n" +
950 " float bendDistance = bendY1 * 0.4;\n" +
Jason Sams66ed54e2010-02-04 12:39:27 -0800951 " float distanceDimLevel = 0.6;\n" +
952
953 " float bendStep = (bendAngle / bendDistance) * (bendAngle * 0.5);\n" +
954 " float aDy = cos(bendAngle);\n" +
955 " float aDz = sin(bendAngle);\n" +
956
Jason Samsb4ecab22010-01-19 16:43:26 -0800957 " float scale = (2.0 / 480.0);\n" +
958 " float x = UNI_Position.x + UNI_ImgSize.x * (1.0 - ani) * (ATTRIB_position.x - 0.5);\n" +
959 " float ys= UNI_Position.y + UNI_ImgSize.y * (1.0 - ani) * ATTRIB_position.y;\n" +
960 " float y = 0.0;\n" +
961 " float z = 0.0;\n" +
962 " float lum = 1.0;\n" +
963
Jason Sams66ed54e2010-02-04 12:39:27 -0800964 " float cv = min(ys, bendY1 - bendDistance) - (bendY1 - bendDistance);\n" +
965 " y += cv * aDy;\n" +
966 " z += -cv * aDz;\n" +
967 " cv = clamp(ys, bendY1 - bendDistance, bendY1) - bendY1;\n" + // curve range
968 " lum += cv / bendDistance * distanceDimLevel;\n" +
969 " y += cv * cos(cv * bendStep);\n" +
970 " z += cv * sin(cv * bendStep);\n" +
Jason Samsb4ecab22010-01-19 16:43:26 -0800971
Jason Sams66ed54e2010-02-04 12:39:27 -0800972 " cv = max(ys, bendY2 + bendDistance) - (bendY2 + bendDistance);\n" +
973 " y += cv * aDy;\n" +
974 " z += cv * aDz;\n" +
975 " cv = clamp(ys, bendY2, bendY2 + bendDistance) - bendY2;\n" +
976 " lum -= cv / bendDistance * distanceDimLevel;\n" +
977 " y += cv * cos(cv * bendStep);\n" +
978 " z += cv * sin(cv * bendStep);\n" +
Jason Samsb4ecab22010-01-19 16:43:26 -0800979
Jason Sams66ed54e2010-02-04 12:39:27 -0800980 " y += clamp(ys, bendY1, bendY2);\n" +
Jason Samsb4ecab22010-01-19 16:43:26 -0800981
982 " vec4 pos;\n" +
Jason Sams66ed54e2010-02-04 12:39:27 -0800983 " pos.x = (x + UNI_ScaleOffset.z) * UNI_ScaleOffset.x;\n" +
984 " pos.y = (y + UNI_ScaleOffset.w) * UNI_ScaleOffset.x;\n" +
985 " pos.z = z * UNI_ScaleOffset.x;\n" +
Jason Samsb4ecab22010-01-19 16:43:26 -0800986 " pos.w = 1.0;\n" +
987
988 " pos.x *= 1.0 + ani * 4.0;\n" +
989 " pos.y *= 1.0 + ani * 4.0;\n" +
990 " pos.z -= ani * 1.5;\n" +
991 " lum *= 1.0 - ani;\n" +
992
993 " gl_Position = UNI_MVP * pos;\n" +
994 " varColor.rgba = vec4(lum, lum, lum, 1.0);\n" +
995 " varTex0.xy = ATTRIB_position;\n" +
996 " varTex0.y = 1.0 - varTex0.y;\n" +
997 " varTex0.zw = vec2(0.0, 0.0);\n" +
998 "}\n");
999 sb.setShader(t);
1000 sb.addConstant(mUniformAlloc.getType());
1001 sb.addInput(mMesh.getVertexType(0).getElement());
1002 mPVCurve = sb.create();
1003 mPVCurve.setName("PVCurve");
1004 mPVCurve.bindAllocation(mPVA);
1005 mPVCurve.bindConstants(mUniformAlloc, 1);
1006
Jason Sams66ed54e2010-02-04 12:39:27 -08001007 float tf[] = new float[] {72.f, 72.f,
1008 120.f, 120.f, 0.f, 0.f,
1009 120.f, 680.f,
1010 (2.f / 480.f), 0, -240.f, -380.f};
Jason Samsb4ecab22010-01-19 16:43:26 -08001011 mUniformAlloc.data(tf);
1012
Jason Sams37e7c2b2009-10-19 12:55:43 -07001013 //pva = new ProgramVertex.MatrixAllocation(mRS);
1014 //pva.setupOrthoWindow(mWidth, mHeight);
1015 //pvb.setTextureMatrixEnable(true);
1016 //mPVOrtho = pvb.create();
1017 //mPVOrtho.setName("PVOrtho");
1018 //mPVOrtho.bindAllocation(pva);
Joe Onorato93839052009-08-06 20:34:32 -07001019
1020 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 Sams37e7c2b2009-10-19 12:55:43 -07001036 //mPFColor = bf.create();
1037 //mPFColor.setName("PFColor");
Jason Samscd689e12009-09-29 15:28:22 -07001038
Jason Samsb4ecab22010-01-19 16:43:26 -08001039 bf.setTexture(ProgramFragment.Builder.EnvMode.MODULATE,
Jason Sams72f1d312009-12-17 16:58:25 -08001040 ProgramFragment.Builder.Format.RGBA, 0);
Jason Samsc8514792009-10-29 14:27:29 -07001041 mPFTexMip = bf.create();
1042 mPFTexMip.setName("PFTexMip");
1043 mPFTexMip.bindSampler(linear, 0);
1044
1045 mPFTexNearest = bf.create();
1046 mPFTexNearest.setName("PFTexNearest");
1047 mPFTexNearest.bindSampler(nearest, 0);
Jason Sams6ec11bc2010-01-19 17:56:52 -08001048
1049 bf.setTexture(ProgramFragment.Builder.EnvMode.MODULATE,
1050 ProgramFragment.Builder.Format.ALPHA, 0);
1051 mPFTexMipAlpha = bf.create();
1052 mPFTexMipAlpha.setName("PFTexMipAlpha");
1053 mPFTexMipAlpha.bindSampler(linear, 0);
1054
Jason Samscd689e12009-09-29 15:28:22 -07001055 }
1056
1057 private void initProgramStore() {
1058 ProgramStore.Builder bs = new ProgramStore.Builder(mRS, null, null);
1059 bs.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
Jason Sams12c14a82009-10-06 14:33:15 -07001060 bs.setColorMask(true,true,true,false);
Jason Samscd689e12009-09-29 15:28:22 -07001061 bs.setDitherEnable(true);
1062 bs.setBlendFunc(ProgramStore.BlendSrcFunc.SRC_ALPHA,
1063 ProgramStore.BlendDstFunc.ONE_MINUS_SRC_ALPHA);
1064 mPSIcons = bs.create();
1065 mPSIcons.setName("PSIcons");
1066
1067 //bs.setDitherEnable(false);
1068 //mPSText = bs.create();
1069 //mPSText.setName("PSText");
1070 }
1071
1072 private void initGl() {
Joe Onorato6665c0f2009-09-02 15:27:24 -07001073 mTouchXBorders = new int[Defines.COLUMNS_PER_PAGE+1];
Joe Onorato6665c0f2009-09-02 15:27:24 -07001074 mTouchYBorders = new int[Defines.ROWS_PER_PAGE+1];
Joe Onoratobf15cb42009-08-07 14:33:40 -07001075 }
Jason Sams78aebd82009-09-15 13:06:59 -07001076
Joe Onorato1feb3a82009-08-08 22:32:00 -07001077 private void initData() {
Jason Sams78aebd82009-09-15 13:06:59 -07001078 mParams = new Params();
1079 mState = new State();
Joe Onorato43e7bcf2009-08-08 18:53:53 -07001080
Joe Onoratobf15cb42009-08-07 14:33:40 -07001081 final Utilities.BubbleText bubble = new Utilities.BubbleText(getContext());
Joe Onorato93839052009-08-06 20:34:32 -07001082
Joe Onorato43e7bcf2009-08-08 18:53:53 -07001083 mParams.bubbleWidth = bubble.getBubbleWidth();
1084 mParams.bubbleHeight = bubble.getMaxBubbleHeight();
1085 mParams.bubbleBitmapWidth = bubble.getBitmapWidth();
1086 mParams.bubbleBitmapHeight = bubble.getBitmapHeight();
Joe Onorato43e7bcf2009-08-08 18:53:53 -07001087
Joe Onoratod63458b2009-10-15 21:19:09 -07001088 mHomeButtonNormal = Allocation.createFromBitmapResource(mRS, mRes,
1089 R.drawable.home_button_normal, Element.RGBA_8888(mRS), false);
1090 mHomeButtonNormal.uploadToTexture(0);
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001091 mHomeButtonFocused = Allocation.createFromBitmapResource(mRS, mRes,
1092 R.drawable.home_button_focused, Element.RGBA_8888(mRS), false);
1093 mHomeButtonFocused.uploadToTexture(0);
Joe Onoratod63458b2009-10-15 21:19:09 -07001094 mHomeButtonPressed = Allocation.createFromBitmapResource(mRS, mRes,
1095 R.drawable.home_button_pressed, Element.RGBA_8888(mRS), false);
1096 mHomeButtonPressed.uploadToTexture(0);
Joe Onoratobcbeab82009-10-01 21:45:43 -07001097 mParams.homeButtonWidth = 76;
1098 mParams.homeButtonHeight = 68;
1099 mParams.homeButtonTextureWidth = 128;
1100 mParams.homeButtonTextureHeight = 128;
Joe Onoratoc567acb2009-08-31 14:34:43 -07001101
Joe Onoratod63458b2009-10-15 21:19:09 -07001102 mState.homeButtonId = mHomeButtonNormal.getID();
1103
Joe Onorato1feb3a82009-08-08 22:32:00 -07001104 mParams.save();
1105 mState.save();
Joe Onorato9c1289c2009-08-17 11:03:03 -04001106
Jason Sams1a94ee32010-01-20 13:34:30 -08001107 mSelectionBitmap = Bitmap.createBitmap(Defines.SELECTION_TEXTURE_WIDTH_PX,
1108 Defines.SELECTION_TEXTURE_HEIGHT_PX, Bitmap.Config.ARGB_8888);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001109 mSelectionCanvas = new Canvas(mSelectionBitmap);
Joe Onorato6665c0f2009-09-02 15:27:24 -07001110
Joe Onorato9c1289c2009-08-17 11:03:03 -04001111 setApps(null);
Joe Onorato93839052009-08-06 20:34:32 -07001112 }
1113
Jason Sams37e7c2b2009-10-19 12:55:43 -07001114 private void initScript(int id) {
1115 }
1116
1117 private void initRs() {
Joe Onorato93839052009-08-06 20:34:32 -07001118 ScriptC.Builder sb = new ScriptC.Builder(mRS);
Jason Samsd15f3ef2010-01-06 14:58:06 -08001119 sb.setScript(mRes, R.raw.allapps);
Joe Onorato93839052009-08-06 20:34:32 -07001120 sb.setRoot(true);
Joe Onoratobcbeab82009-10-01 21:45:43 -07001121 sb.addDefines(mDefines);
Jason Sams78aebd82009-09-15 13:06:59 -07001122 sb.setType(mParams.mType, "params", Defines.ALLOC_PARAMS);
1123 sb.setType(mState.mType, "state", Defines.ALLOC_STATE);
Jason Samsb4ecab22010-01-19 16:43:26 -08001124 sb.setType(mUniformAlloc.getType(), "vpConstants", Defines.ALLOC_VP_CONSTANTS);
Jason Sams37e7c2b2009-10-19 12:55:43 -07001125 mInvokeMove = sb.addInvokable("move");
1126 mInvokeFling = sb.addInvokable("fling");
Jason Samsc1c521e2009-10-19 14:45:45 -07001127 mInvokeMoveTo = sb.addInvokable("moveTo");
Jason Sams37e7c2b2009-10-19 12:55:43 -07001128 mInvokeResetWAR = sb.addInvokable("resetHWWar");
Joe Onorato3a8820b2009-11-10 15:06:42 -08001129 mInvokeSetZoom = sb.addInvokable("setZoom");
Jason Sams37e7c2b2009-10-19 12:55:43 -07001130 mScript = sb.create();
1131 mScript.setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
1132 mScript.bindAllocation(mParams.mAlloc, Defines.ALLOC_PARAMS);
1133 mScript.bindAllocation(mState.mAlloc, Defines.ALLOC_STATE);
1134 mScript.bindAllocation(mAllocIconIds, Defines.ALLOC_ICON_IDS);
1135 mScript.bindAllocation(mAllocLabelIds, Defines.ALLOC_LABEL_IDS);
Jason Samsb4ecab22010-01-19 16:43:26 -08001136 mScript.bindAllocation(mUniformAlloc, Defines.ALLOC_VP_CONSTANTS);
Joe Onorato93839052009-08-06 20:34:32 -07001137
Jason Sams37e7c2b2009-10-19 12:55:43 -07001138 mRS.contextBindRootScript(mScript);
Joe Onorato93839052009-08-06 20:34:32 -07001139 }
Joe Onorato93839052009-08-06 20:34:32 -07001140
Jason Sams20df7c72009-11-05 12:30:24 -08001141 void dirtyCheck() {
Jason Sams510ee042009-12-15 14:23:37 -08001142 if (mZoomDirty) {
Joe Onorato6374c512010-01-06 20:42:25 -08001143 setZoom(mNextZoom, mAnimateNextZoom);
Jason Sams20df7c72009-11-05 12:30:24 -08001144 }
1145 }
1146
Joe Onorato9c1289c2009-08-17 11:03:03 -04001147 private void setApps(ArrayList<ApplicationInfo> list) {
1148 final int count = list != null ? list.size() : 0;
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001149 int allocCount = count;
Joe Onoratoa8138d52009-10-06 19:25:30 -07001150 if (allocCount < 1) {
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001151 allocCount = 1;
1152 }
1153
Joe Onorato9c1289c2009-08-17 11:03:03 -04001154 mIcons = new Allocation[count];
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001155 mIconIds = new int[allocCount];
Joe Onoratoa8138d52009-10-06 19:25:30 -07001156 mAllocIconIds = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001157
1158 mLabels = new Allocation[count];
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001159 mLabelIds = new int[allocCount];
Joe Onoratoa8138d52009-10-06 19:25:30 -07001160 mAllocLabelIds = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001161
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001162 Element ie8888 = Element.RGBA_8888(mRS);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001163
Joe Onorato9c1289c2009-08-17 11:03:03 -04001164 mState.iconCount = count;
Joe Onorato8eea3912009-12-09 13:01:06 -08001165 for (int i=0; i < mState.iconCount; i++) {
1166 createAppIconAllocations(i, list.get(i));
Joe Onorato3ecbd812009-12-11 13:38:54 -08001167 }
Jason Sams510ee042009-12-15 14:23:37 -08001168 for (int i=0; i < mState.iconCount; i++) {
1169 uploadAppIcon(i, list.get(i));
Joe Onorato8eea3912009-12-09 13:01:06 -08001170 }
Joe Onoratoa8138d52009-10-06 19:25:30 -07001171 saveAppsList();
1172 }
1173
Joe Onorato3a8820b2009-11-10 15:06:42 -08001174 private void setZoom(float zoom, boolean animate) {
1175 mRollo.clearSelectedIcon();
1176 mRollo.setHomeSelected(SELECTED_NONE);
1177 if (zoom > 0.001f) {
1178 mRollo.mState.zoomTarget = zoom;
1179 } else {
1180 mRollo.mState.zoomTarget = 0;
1181 }
1182 mRollo.mState.save();
1183 if (!animate) {
1184 mRollo.mInvokeSetZoom.execute();
1185 }
1186 }
1187
Joe Onorato8eea3912009-12-09 13:01:06 -08001188 private void createAppIconAllocations(int index, ApplicationInfo item) {
Joe Onoratoa8138d52009-10-06 19:25:30 -07001189 mIcons[index] = Allocation.createFromBitmap(mRS, item.iconBitmap,
Jason Samsc8514792009-10-29 14:27:29 -07001190 Element.RGBA_8888(mRS), true);
Joe Onoratoa8138d52009-10-06 19:25:30 -07001191 mLabels[index] = Allocation.createFromBitmap(mRS, item.titleBitmap,
Jason Sams6ec11bc2010-01-19 17:56:52 -08001192 Element.A_8(mRS), true);
Joe Onoratoa8138d52009-10-06 19:25:30 -07001193 mIconIds[index] = mIcons[index].getID();
1194 mLabelIds[index] = mLabels[index].getID();
1195 }
1196
Joe Onorato8eea3912009-12-09 13:01:06 -08001197 private void uploadAppIcon(int index, ApplicationInfo item) {
1198 if (mIconIds[index] != mIcons[index].getID()) {
1199 throw new IllegalStateException("uploadAppIcon index=" + index
1200 + " mIcons[index].getID=" + mIcons[index].getID()
1201 + " mIconsIds[index]=" + mIconIds[index]
1202 + " item=" + item);
1203 }
1204 mIcons[index].uploadToTexture(0);
1205 mLabels[index].uploadToTexture(0);
1206 }
1207
Joe Onoratoa8138d52009-10-06 19:25:30 -07001208 /**
1209 * Puts the empty spaces at the end. Updates mState.iconCount. You must
1210 * fill in the values and call saveAppsList().
1211 */
1212 private void reallocAppsList(int count) {
1213 Allocation[] icons = new Allocation[count];
1214 int[] iconIds = new int[count];
1215 mAllocIconIds = Allocation.createSized(mRS, Element.USER_I32(mRS), count);
1216
1217 Allocation[] labels = new Allocation[count];
1218 int[] labelIds = new int[count];
1219 mAllocLabelIds = Allocation.createSized(mRS, Element.USER_I32(mRS), count);
1220
Joe Onoratobf173f12009-12-08 13:29:38 -08001221 final int oldCount = mRollo.mState.iconCount;
Joe Onoratoa8138d52009-10-06 19:25:30 -07001222
1223 System.arraycopy(mIcons, 0, icons, 0, oldCount);
1224 System.arraycopy(mIconIds, 0, iconIds, 0, oldCount);
1225 System.arraycopy(mLabels, 0, labels, 0, oldCount);
1226 System.arraycopy(mLabelIds, 0, labelIds, 0, oldCount);
1227
1228 mIcons = icons;
1229 mIconIds = iconIds;
1230 mLabels = labels;
1231 mLabelIds = labelIds;
1232 }
1233
1234 /**
1235 * Handle the allocations for the new app. Make sure you call saveAppsList when done.
1236 */
1237 private void addApp(int index, ApplicationInfo item) {
1238 final int count = mState.iconCount - index;
1239 final int dest = index + 1;
1240
1241 System.arraycopy(mIcons, index, mIcons, dest, count);
1242 System.arraycopy(mIconIds, index, mIconIds, dest, count);
1243 System.arraycopy(mLabels, index, mLabels, dest, count);
1244 System.arraycopy(mLabelIds, index, mLabelIds, dest, count);
1245
Joe Onorato8eea3912009-12-09 13:01:06 -08001246 createAppIconAllocations(index, item);
Jason Sams510ee042009-12-15 14:23:37 -08001247 uploadAppIcon(index, item);
Joe Onorato8eea3912009-12-09 13:01:06 -08001248 mRollo.mState.iconCount++;
Joe Onoratoa8138d52009-10-06 19:25:30 -07001249 }
1250
1251 /**
1252 * Handle the allocations for the removed app. Make sure you call saveAppsList when done.
1253 */
1254 private void removeApp(int index) {
1255 final int count = mState.iconCount - index - 1;
1256 final int src = index + 1;
1257
1258 System.arraycopy(mIcons, src, mIcons, index, count);
1259 System.arraycopy(mIconIds, src, mIconIds, index, count);
1260 System.arraycopy(mLabels, src, mLabels, index, count);
1261 System.arraycopy(mLabelIds, src, mLabelIds, index, count);
1262
Joe Onoratoa276fc52009-12-08 17:02:02 -08001263 mRollo.mState.iconCount--;
Joe Onorato8eea3912009-12-09 13:01:06 -08001264 final int last = mState.iconCount;
Joe Onoratoa276fc52009-12-08 17:02:02 -08001265
Joe Onoratoa8138d52009-10-06 19:25:30 -07001266 mIcons[last] = null;
1267 mIconIds[last] = 0;
1268 mLabels[last] = null;
1269 mLabelIds[last] = 0;
1270 }
1271
1272 /**
1273 * Send the apps list structures to RS.
1274 */
1275 private void saveAppsList() {
1276 mRS.contextBindRootScript(null);
Jason Samsd8152b92009-10-13 17:19:10 -07001277
Joe Onoratoa8138d52009-10-06 19:25:30 -07001278 mAllocIconIds.data(mIconIds);
1279 mAllocLabelIds.data(mLabelIds);
1280
Jason Sams37e7c2b2009-10-19 12:55:43 -07001281 if (mScript != null) { // this happens when we init it
1282 mScript.bindAllocation(mAllocIconIds, Defines.ALLOC_ICON_IDS);
1283 mScript.bindAllocation(mAllocLabelIds, Defines.ALLOC_LABEL_IDS);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001284 }
1285
1286 mState.save();
Joe Onoratoa8138d52009-10-06 19:25:30 -07001287
1288 // Note: mScript may be null if we haven't initialized it yet.
1289 // In that case, this is a no-op.
Jason Sams37e7c2b2009-10-19 12:55:43 -07001290 if (mInvokeResetWAR != null) {
1291 mInvokeResetWAR.execute();
Jason Sams41b61c82009-10-15 15:40:54 -07001292 }
Joe Onoratob8315542010-02-03 20:39:25 -08001293 if (mScript != null) {
1294 mRS.contextBindRootScript(mScript);
1295 }
Joe Onorato9c1289c2009-08-17 11:03:03 -04001296 }
Joe Onorato6665c0f2009-09-02 15:27:24 -07001297
1298 void initTouchState() {
1299 int width = getWidth();
1300 int height = getHeight();
Jason Sams37e7c2b2009-10-19 12:55:43 -07001301 int cellHeight = 145;//iconsSize / Defines.ROWS_PER_PAGE;
1302 int cellWidth = width / Defines.COLUMNS_PER_PAGE;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001303
Jason Sams37e7c2b2009-10-19 12:55:43 -07001304 int centerY = (height / 2);
1305 mTouchYBorders[0] = centerY - (cellHeight * 2);
1306 mTouchYBorders[1] = centerY - cellHeight;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001307 mTouchYBorders[2] = centerY;
Jason Sams37e7c2b2009-10-19 12:55:43 -07001308 mTouchYBorders[3] = centerY + cellHeight;
1309 mTouchYBorders[4] = centerY + (cellHeight * 2);
Jason Sams78aebd82009-09-15 13:06:59 -07001310
Joe Onorato6665c0f2009-09-02 15:27:24 -07001311 int centerX = (width / 2);
Jason Sams37e7c2b2009-10-19 12:55:43 -07001312 mTouchXBorders[0] = 0;
1313 mTouchXBorders[1] = centerX - (width / 4);
Joe Onorato6665c0f2009-09-02 15:27:24 -07001314 mTouchXBorders[2] = centerX;
Jason Sams37e7c2b2009-10-19 12:55:43 -07001315 mTouchXBorders[3] = centerX + (width / 4);
1316 mTouchXBorders[4] = width;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001317 }
1318
Joe Onorato664457d2009-10-28 16:30:34 -04001319 void fling() {
1320 mInvokeFling.execute();
1321 }
1322
1323 void move() {
1324 mInvokeMove.execute();
1325 }
1326
1327 void moveTo(float row) {
1328 mState.targetPos = row;
1329 mState.save();
1330 mInvokeMoveTo.execute();
1331 }
1332
Jason Sams37e7c2b2009-10-19 12:55:43 -07001333 int chooseTappedIcon(int x, int y, float pos) {
1334 // Adjust for scroll position if not zero.
1335 y += (pos - ((int)pos)) * (mTouchYBorders[1] - mTouchYBorders[0]);
Jason Sams86c87ed2009-09-18 13:55:55 -07001336
Joe Onorato6665c0f2009-09-02 15:27:24 -07001337 int col = -1;
1338 int row = -1;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001339 for (int i=0; i<Defines.COLUMNS_PER_PAGE; i++) {
1340 if (x >= mTouchXBorders[i] && x < mTouchXBorders[i+1]) {
1341 col = i;
1342 break;
1343 }
1344 }
1345 for (int i=0; i<Defines.ROWS_PER_PAGE; i++) {
1346 if (y >= mTouchYBorders[i] && y < mTouchYBorders[i+1]) {
1347 row = i;
1348 break;
1349 }
1350 }
1351
1352 if (row < 0 || col < 0) {
1353 return -1;
1354 }
1355
Joe Onorato664457d2009-10-28 16:30:34 -04001356 int index = (((int)pos) * Defines.COLUMNS_PER_PAGE)
Joe Onorato6665c0f2009-09-02 15:27:24 -07001357 + (row * Defines.ROWS_PER_PAGE) + col;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001358
Joe Onorato664457d2009-10-28 16:30:34 -04001359 if (index >= mState.iconCount) {
1360 return -1;
1361 } else {
1362 return index;
1363 }
Jason Samsc1c521e2009-10-19 14:45:45 -07001364 }
1365
Joe Onorato6665c0f2009-09-02 15:27:24 -07001366 /**
1367 * You need to call save() on mState on your own after calling this.
Joe Onorato82ca5502009-10-15 16:59:23 -07001368 *
1369 * @return the index of the icon that was selected.
Joe Onorato6665c0f2009-09-02 15:27:24 -07001370 */
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001371 int selectIcon(int x, int y, float pos, int pressed) {
Joe Onorato82ca5502009-10-15 16:59:23 -07001372 final int index = chooseTappedIcon(x, y, pos);
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001373 selectIcon(index, pressed);
Joe Onorato82ca5502009-10-15 16:59:23 -07001374 return index;
Joe Onorato1291a8c2009-09-15 15:07:25 -04001375 }
1376
Joe Onoratoc61cff92009-11-08 11:54:39 -05001377 /**
1378 * Select the icon at the given index.
1379 *
1380 * @param index The index.
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001381 * @param pressed one of SELECTED_PRESSED or SELECTED_FOCUSED
Joe Onoratoc61cff92009-11-08 11:54:39 -05001382 */
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001383 void selectIcon(int index, int pressed) {
Joe Onorato2d804762009-11-05 16:02:32 -05001384 if (mAllAppsList == null || index < 0 || index >= mAllAppsList.size()) {
Joe Onorato6665c0f2009-09-02 15:27:24 -07001385 mState.selectedIconIndex = -1;
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001386 if (mLastSelection == SELECTION_ICONS) {
1387 mLastSelection = SELECTION_NONE;
1388 }
Joe Onorato6665c0f2009-09-02 15:27:24 -07001389 } else {
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001390 if (pressed == SELECTED_FOCUSED) {
1391 mLastSelection = SELECTION_ICONS;
1392 }
1393
Joe Onorato52a653f2009-11-11 14:52:11 -08001394 int prev = mState.selectedIconIndex;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001395 mState.selectedIconIndex = index;
Joe Onorato1291a8c2009-09-15 15:07:25 -04001396
Joe Onorato52a653f2009-11-11 14:52:11 -08001397 ApplicationInfo info = mAllAppsList.get(index);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001398 Bitmap selectionBitmap = mSelectionBitmap;
1399
1400 Utilities.drawSelectedAllAppsBitmap(mSelectionCanvas,
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001401 selectionBitmap.getWidth(), selectionBitmap.getHeight(),
Joe Onorato52a653f2009-11-11 14:52:11 -08001402 pressed == SELECTED_PRESSED, info.iconBitmap);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001403
1404 mSelectedIcon = Allocation.createFromBitmap(mRS, selectionBitmap,
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001405 Element.RGBA_8888(mRS), false);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001406 mSelectedIcon.uploadToTexture(0);
1407 mState.selectedIconTexture = mSelectedIcon.getID();
Joe Onorato52a653f2009-11-11 14:52:11 -08001408
1409 if (prev != index) {
1410 if (info.title != null && info.title.length() > 0) {
Joe Onorato52a653f2009-11-11 14:52:11 -08001411 //setContentDescription(info.title);
1412 sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
1413 }
1414 }
Joe Onorato6665c0f2009-09-02 15:27:24 -07001415 }
1416 }
1417
1418 /**
1419 * You need to call save() on mState on your own after calling this.
1420 */
1421 void clearSelectedIcon() {
Joe Onorato2ca51dc2009-09-16 11:44:14 -04001422 mState.selectedIconIndex = -1;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001423 }
Joe Onoratoa8138d52009-10-06 19:25:30 -07001424
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001425 void setHomeSelected(int mode) {
Joe Onorato52a653f2009-11-11 14:52:11 -08001426 final int prev = mLastSelection;
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001427 switch (mode) {
1428 case SELECTED_NONE:
Joe Onoratod63458b2009-10-15 21:19:09 -07001429 mState.homeButtonId = mHomeButtonNormal.getID();
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001430 break;
1431 case SELECTED_FOCUSED:
1432 mLastSelection = SELECTION_HOME;
1433 mState.homeButtonId = mHomeButtonFocused.getID();
Joe Onorato52a653f2009-11-11 14:52:11 -08001434 if (prev != SELECTION_HOME) {
Joe Onorato52a653f2009-11-11 14:52:11 -08001435 sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
1436 }
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001437 break;
1438 case SELECTED_PRESSED:
1439 mState.homeButtonId = mHomeButtonPressed.getID();
1440 break;
Joe Onoratod63458b2009-10-15 21:19:09 -07001441 }
1442 }
Joe Onoratobe386092009-11-17 17:32:16 -08001443
1444 public void dumpState() {
1445 Log.d(TAG, "mRollo.mWidth=" + mWidth);
1446 Log.d(TAG, "mRollo.mHeight=" + mHeight);
1447 Log.d(TAG, "mRollo.mIcons=" + mIcons);
1448 if (mIcons != null) {
1449 Log.d(TAG, "mRollo.mIcons.length=" + mIcons.length);
1450 }
1451 if (mIconIds != null) {
1452 Log.d(TAG, "mRollo.mIconIds.length=" + mIconIds.length);
1453 }
1454 Log.d(TAG, "mRollo.mIconIds=" + Arrays.toString(mIconIds));
1455 if (mLabelIds != null) {
1456 Log.d(TAG, "mRollo.mLabelIds.length=" + mLabelIds.length);
1457 }
1458 Log.d(TAG, "mRollo.mLabelIds=" + Arrays.toString(mLabelIds));
1459 Log.d(TAG, "mRollo.mTouchXBorders=" + Arrays.toString(mTouchXBorders));
1460 Log.d(TAG, "mRollo.mTouchYBorders=" + Arrays.toString(mTouchYBorders));
Joe Onoratobe386092009-11-17 17:32:16 -08001461 Log.d(TAG, "mRollo.mState.newPositionX=" + mState.newPositionX);
1462 Log.d(TAG, "mRollo.mState.newTouchDown=" + mState.newTouchDown);
1463 Log.d(TAG, "mRollo.mState.flingVelocity=" + mState.flingVelocity);
1464 Log.d(TAG, "mRollo.mState.iconCount=" + mState.iconCount);
1465 Log.d(TAG, "mRollo.mState.selectedIconIndex=" + mState.selectedIconIndex);
1466 Log.d(TAG, "mRollo.mState.selectedIconTexture=" + mState.selectedIconTexture);
1467 Log.d(TAG, "mRollo.mState.zoomTarget=" + mState.zoomTarget);
1468 Log.d(TAG, "mRollo.mState.homeButtonId=" + mState.homeButtonId);
1469 Log.d(TAG, "mRollo.mState.targetPos=" + mState.targetPos);
1470 Log.d(TAG, "mRollo.mParams.bubbleWidth=" + mParams.bubbleWidth);
1471 Log.d(TAG, "mRollo.mParams.bubbleHeight=" + mParams.bubbleHeight);
1472 Log.d(TAG, "mRollo.mParams.bubbleBitmapWidth=" + mParams.bubbleBitmapWidth);
1473 Log.d(TAG, "mRollo.mParams.bubbleBitmapHeight=" + mParams.bubbleBitmapHeight);
1474 Log.d(TAG, "mRollo.mParams.homeButtonWidth=" + mParams.homeButtonWidth);
1475 Log.d(TAG, "mRollo.mParams.homeButtonHeight=" + mParams.homeButtonHeight);
1476 Log.d(TAG, "mRollo.mParams.homeButtonTextureWidth=" + mParams.homeButtonTextureWidth);
1477 Log.d(TAG, "mRollo.mParams.homeButtonTextureHeight=" + mParams.homeButtonTextureHeight);
1478 }
1479 }
1480
1481 public void dumpState() {
1482 Log.d(TAG, "mRS=" + mRS);
1483 Log.d(TAG, "mRollo=" + mRollo);
1484 ApplicationInfo.dumpApplicationInfoList(TAG, "mAllAppsList", mAllAppsList);
1485 Log.d(TAG, "mArrowNavigation=" + mArrowNavigation);
1486 Log.d(TAG, "mStartedScrolling=" + mStartedScrolling);
1487 Log.d(TAG, "mLastSelection=" + mLastSelection);
1488 Log.d(TAG, "mLastSelectedIcon=" + mLastSelectedIcon);
1489 Log.d(TAG, "mVelocityTracker=" + mVelocityTracker);
1490 Log.d(TAG, "mTouchTracking=" + mTouchTracking);
1491 Log.d(TAG, "mShouldGainFocus=" + mShouldGainFocus);
1492 Log.d(TAG, "mZoomDirty=" + mZoomDirty);
1493 Log.d(TAG, "mAnimateNextZoom=" + mAnimateNextZoom);
1494 Log.d(TAG, "mZoom=" + mZoom);
1495 Log.d(TAG, "mPosX=" + mPosX);
1496 Log.d(TAG, "mVelocity=" + mVelocity);
1497 Log.d(TAG, "mMessageProc=" + mMessageProc);
1498 if (mRollo != null) {
1499 mRollo.dumpState();
1500 }
1501 if (mRS != null) {
1502 mRS.contextDump(0);
1503 }
Joe Onorato9c1289c2009-08-17 11:03:03 -04001504 }
Joe Onorato93839052009-08-06 20:34:32 -07001505}
1506
1507