blob: a5ad1835d919f8c60b3b578d763efcb07f046e14 [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 Onoratobcbeab82009-10-01 21:45:43 -0700143
144 public int SCREEN_WIDTH_PX;
145 public int SCREEN_HEIGHT_PX;
146
Joe Onoratobcbeab82009-10-01 21:45:43 -0700147 public void recompute(int w, int h) {
148 SCREEN_WIDTH_PX = 480;
149 SCREEN_HEIGHT_PX = 800;
Joe Onoratobcbeab82009-10-01 21:45:43 -0700150 }
Joe Onoratoc567acb2009-08-31 14:34:43 -0700151 }
Joe Onorato7c312c12009-08-13 21:36:53 -0700152
153 public AllAppsView(Context context, AttributeSet attrs) {
154 super(context, attrs);
Joe Onorato93839052009-08-06 20:34:32 -0700155 setFocusable(true);
Joe Onoratob39e51a2009-10-28 15:47:49 -0400156 setSoundEffectsEnabled(false);
Joe Onorato93839052009-08-06 20:34:32 -0700157 getHolder().setFormat(PixelFormat.TRANSLUCENT);
Joe Onoratof7b0e012009-10-01 14:09:15 -0700158 final ViewConfiguration config = ViewConfiguration.get(context);
Joe Onorato82ca5502009-10-15 16:59:23 -0700159 mSlop = config.getScaledTouchSlop();
Joe Onoratof7b0e012009-10-01 14:09:15 -0700160 mMaxFlingVelocity = config.getScaledMaximumFlingVelocity();
161
Joe Onorato6665c0f2009-09-02 15:27:24 -0700162 setOnClickListener(this);
163 setOnLongClickListener(this);
Dianne Hackborne52a1b52009-09-30 22:36:20 -0700164 setZOrderOnTop(true);
Jason Samsfd22dac2009-09-20 17:24:16 -0700165 getHolder().setFormat(PixelFormat.TRANSLUCENT);
Jason Samse26d9fc2009-11-12 14:00:43 -0800166
167 mRS = createRenderScript(true);
168 }
169
170 @Override
171 protected void onDetachedFromWindow() {
172 destroyRenderScript();
Joe Onorato93839052009-08-06 20:34:32 -0700173 }
174
Joe Onoratob39e51a2009-10-28 15:47:49 -0400175 /**
176 * If you have an attached click listener, View always plays the click sound!?!?
177 * Deal with sound effects by hand.
178 */
179 public void reallyPlaySoundEffect(int sound) {
180 boolean old = isSoundEffectsEnabled();
181 setSoundEffectsEnabled(true);
182 playSoundEffect(sound);
183 setSoundEffectsEnabled(old);
184 }
185
Joe Onorato7c312c12009-08-13 21:36:53 -0700186 public AllAppsView(Context context, AttributeSet attrs, int defStyle) {
187 this(context, attrs);
Joe Onorato93839052009-08-06 20:34:32 -0700188 }
189
Joe Onorato6665c0f2009-09-02 15:27:24 -0700190 public void setLauncher(Launcher launcher) {
191 mLauncher = launcher;
Joe Onorato93839052009-08-06 20:34:32 -0700192 }
193
Joe Onorato1feb3a82009-08-08 22:32:00 -0700194 @Override
Joe Onorato7bb17492009-09-24 17:51:01 -0700195 public void surfaceDestroyed(SurfaceHolder holder) {
196 super.surfaceDestroyed(holder);
Joe Onoratofab74402009-11-11 16:05:23 -0800197 // Without this, we leak mMessageCallback which leaks the context.
198 mRS.mMessageCallback = null;
Joe Onorato6374c512010-01-06 20:42:25 -0800199 // We may lose any callbacks that are pending, so make sure that we re-sync that
200 // on the next surfaceChanged.
201 mZoomDirty = true;
202 mHaveSurface = false;
Joe Onorato7bb17492009-09-24 17:51:01 -0700203 }
204
205 @Override
Joe Onorato93839052009-08-06 20:34:32 -0700206 public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
Joe Onoratoa30ce8e2009-11-11 08:16:49 -0800207 //long startTime = SystemClock.uptimeMillis();
Joe Onorato6665c0f2009-09-02 15:27:24 -0700208
Joe Onorato080d9b62009-11-02 12:01:11 -0500209 super.surfaceChanged(holder, format, w, h);
210
Joe Onorato6374c512010-01-06 20:42:25 -0800211 mHaveSurface = true;
212
Jason Samse26d9fc2009-11-12 14:00:43 -0800213 if (mRollo == null) {
Jason Sams90396672009-11-03 13:59:34 -0800214 mRollo = new RolloRS();
215 mRollo.init(getResources(), w, h);
216 if (mAllAppsList != null) {
217 mRollo.setApps(mAllAppsList);
Jason Sams90396672009-11-03 13:59:34 -0800218 }
Mike Cleronb64b67a2009-11-08 14:56:25 -0800219 if (mShouldGainFocus) {
220 gainFocus();
221 mShouldGainFocus = false;
222 }
Joe Onorato9c1289c2009-08-17 11:03:03 -0400223 }
Jason Samse26d9fc2009-11-12 14:00:43 -0800224 mRollo.dirtyCheck();
Jason Sams5612e432009-11-16 14:18:07 -0800225 mRollo.resize(w, h);
Joe Onoratoc567acb2009-08-31 14:34:43 -0700226
Joe Onoratocb75f362009-11-12 13:04:07 -0800227 mRS.mMessageCallback = mMessageProc = new AAMessage();
228
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) {
693 mAllAppsList = list;
694 if (mRollo != null) {
Joe Onorato3ecbd812009-12-11 13:38:54 -0800695 mRollo.setApps(list);
Joe Onorato9c1289c2009-08-17 11:03:03 -0400696 }
Joe Onoratofb0ca672009-09-14 17:55:46 -0400697 mLocks &= ~LOCK_ICONS_PENDING;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700698 }
699
Joe Onoratoa8138d52009-10-06 19:25:30 -0700700 public void addApps(ArrayList<ApplicationInfo> list) {
Joe Onorato2d804762009-11-05 16:02:32 -0500701 if (mAllAppsList == null) {
702 // Not done loading yet. We'll find out about it later.
703 return;
704 }
705
Joe Onoratoa8138d52009-10-06 19:25:30 -0700706 final int N = list.size();
Joe Onorato8eea3912009-12-09 13:01:06 -0800707 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700708 mRollo.reallocAppsList(mRollo.mState.iconCount + N);
709 }
710
711 for (int i=0; i<N; i++) {
712 final ApplicationInfo item = list.get(i);
Joe Onoratob0c27f22009-12-01 16:19:38 -0800713 int index = Collections.binarySearch(mAllAppsList, item,
714 LauncherModel.APP_NAME_COMPARATOR);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700715 if (index < 0) {
716 index = -(index+1);
717 }
718 mAllAppsList.add(index, item);
Joe Onorato8eea3912009-12-09 13:01:06 -0800719 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700720 mRollo.addApp(index, item);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700721 }
722 }
723
Joe Onorato8eea3912009-12-09 13:01:06 -0800724 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700725 mRollo.saveAppsList();
726 }
Joe Onoratoc567acb2009-08-31 14:34:43 -0700727 }
728
Joe Onoratoa8138d52009-10-06 19:25:30 -0700729 public void removeApps(ArrayList<ApplicationInfo> list) {
Joe Onorato2d804762009-11-05 16:02:32 -0500730 if (mAllAppsList == null) {
731 // Not done loading yet. We'll find out about it later.
732 return;
733 }
734
Joe Onoratoa8138d52009-10-06 19:25:30 -0700735 final int N = list.size();
736 for (int i=0; i<N; i++) {
737 final ApplicationInfo item = list.get(i);
Joe Onoratocb9f7982009-10-31 16:32:02 -0400738 int index = findAppByComponent(mAllAppsList, item);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700739 if (index >= 0) {
Joe Onoratoa276fc52009-12-08 17:02:02 -0800740 int ic = mRollo != null ? mRollo.mState.iconCount : 666;
Joe Onoratoa8138d52009-10-06 19:25:30 -0700741 mAllAppsList.remove(index);
Joe Onorato8eea3912009-12-09 13:01:06 -0800742 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700743 mRollo.removeApp(index);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700744 }
745 } else {
Joe Onoratoa30ce8e2009-11-11 08:16:49 -0800746 Log.w(TAG, "couldn't find a match for item \"" + item + "\"");
Joe Onoratoa8138d52009-10-06 19:25:30 -0700747 // Try to recover. This should keep us from crashing for now.
748 }
749 }
750
Joe Onorato8eea3912009-12-09 13:01:06 -0800751 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700752 mRollo.saveAppsList();
753 }
754 }
755
756 public void updateApps(String packageName, ArrayList<ApplicationInfo> list) {
757 // Just remove and add, because they may need to be re-sorted.
758 removeApps(list);
759 addApps(list);
760 }
761
Joe Onoratocb9f7982009-10-31 16:32:02 -0400762 private static int findAppByComponent(ArrayList<ApplicationInfo> list, ApplicationInfo item) {
763 ComponentName component = item.intent.getComponent();
764 final int N = list.size();
765 for (int i=0; i<N; i++) {
766 ApplicationInfo x = list.get(i);
767 if (x.intent.getComponent().equals(component)) {
768 return i;
769 }
Joe Onoratoa8138d52009-10-06 19:25:30 -0700770 }
Joe Onoratocb9f7982009-10-31 16:32:02 -0400771 return -1;
772 }
Joe Onoratoa8138d52009-10-06 19:25:30 -0700773
Joe Onoratoc567acb2009-08-31 14:34:43 -0700774 private static int countPages(int iconCount) {
775 int iconsPerPage = Defines.COLUMNS_PER_PAGE * Defines.ROWS_PER_PAGE;
776 int pages = iconCount / iconsPerPage;
777 if (pages*iconsPerPage != iconCount) {
778 pages++;
779 }
780 return pages;
Joe Onorato9c1289c2009-08-17 11:03:03 -0400781 }
782
Joe Onoratocb75f362009-11-12 13:04:07 -0800783 class AAMessage extends RenderScript.RSMessage {
784 public void run() {
785 mPosX = ((float)mData[0]) / (1 << 16);
786 mVelocity = ((float)mData[1]) / (1 << 16);
787 mZoom = ((float)mData[2]) / (1 << 16);
788 mZoomDirty = false;
789 }
Joe Onoratocb75f362009-11-12 13:04:07 -0800790 }
791
Joe Onorato93839052009-08-06 20:34:32 -0700792 public class RolloRS {
Joe Onoratobf15cb42009-08-07 14:33:40 -0700793
Joe Onorato1feb3a82009-08-08 22:32:00 -0700794 // Allocations ======
Joe Onorato93839052009-08-06 20:34:32 -0700795 private int mWidth;
796 private int mHeight;
797
798 private Resources mRes;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700799 private Script mScript;
800 private Script.Invokable mInvokeMove;
Jason Samsc1c521e2009-10-19 14:45:45 -0700801 private Script.Invokable mInvokeMoveTo;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700802 private Script.Invokable mInvokeFling;
803 private Script.Invokable mInvokeResetWAR;
Joe Onorato3a8820b2009-11-10 15:06:42 -0800804 private Script.Invokable mInvokeSetZoom;
Jason Samsc1c521e2009-10-19 14:45:45 -0700805
Jason Samscd689e12009-09-29 15:28:22 -0700806 private ProgramStore mPSIcons;
Joe Onorato93839052009-08-06 20:34:32 -0700807 private ProgramStore mPSText;
Jason Samscd689e12009-09-29 15:28:22 -0700808 private ProgramFragment mPFColor;
Jason Samsc8514792009-10-29 14:27:29 -0700809 private ProgramFragment mPFTexMip;
Jason Sams6ec11bc2010-01-19 17:56:52 -0800810 private ProgramFragment mPFTexMipAlpha;
Jason Samsc8514792009-10-29 14:27:29 -0700811 private ProgramFragment mPFTexNearest;
Joe Onorato93839052009-08-06 20:34:32 -0700812 private ProgramVertex mPV;
Joe Onorato93839052009-08-06 20:34:32 -0700813 private ProgramVertex mPVOrtho;
Jason Samsb4ecab22010-01-19 16:43:26 -0800814 private ProgramVertex mPVCurve;
Jason Sams0aa71662009-10-02 18:43:18 -0700815 private SimpleMesh mMesh;
Jason Sams5612e432009-11-16 14:18:07 -0800816 private ProgramVertex.MatrixAllocation mPVA;
Joe Onorato93839052009-08-06 20:34:32 -0700817
Jason Samsb4ecab22010-01-19 16:43:26 -0800818 private Allocation mUniformAlloc;
819
Joe Onoratod63458b2009-10-15 21:19:09 -0700820 private Allocation mHomeButtonNormal;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500821 private Allocation mHomeButtonFocused;
Joe Onoratod63458b2009-10-15 21:19:09 -0700822 private Allocation mHomeButtonPressed;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700823
Joe Onoratobf15cb42009-08-07 14:33:40 -0700824 private Allocation[] mIcons;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700825 private int[] mIconIds;
Joe Onoratoa8138d52009-10-06 19:25:30 -0700826 private Allocation mAllocIconIds;
Joe Onorato93839052009-08-06 20:34:32 -0700827
Joe Onoratobf15cb42009-08-07 14:33:40 -0700828 private Allocation[] mLabels;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700829 private int[] mLabelIds;
Joe Onoratoa8138d52009-10-06 19:25:30 -0700830 private Allocation mAllocLabelIds;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700831 private Allocation mSelectedIcon;
Joe Onorato93839052009-08-06 20:34:32 -0700832
Joe Onorato6665c0f2009-09-02 15:27:24 -0700833 private int[] mTouchYBorders;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700834 private int[] mTouchXBorders;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700835
836 private Bitmap mSelectionBitmap;
Joe Onorato1291a8c2009-09-15 15:07:25 -0400837 private Canvas mSelectionCanvas;
Joe Onorato93839052009-08-06 20:34:32 -0700838
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700839 Params mParams;
Joe Onorato1feb3a82009-08-08 22:32:00 -0700840 State mState;
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700841
Jason Sams78aebd82009-09-15 13:06:59 -0700842 class BaseAlloc {
843 Allocation mAlloc;
844 Type mType;
845
846 void save() {
847 mAlloc.data(this);
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700848 }
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700849 }
850
Jason Sams476339d2009-09-29 18:14:38 -0700851 private boolean checkClickOK() {
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800852 return (Math.abs(mVelocity) < 0.4f) &&
853 (Math.abs(mPosX - Math.round(mPosX)) < 0.4f);
Jason Sams476339d2009-09-29 18:14:38 -0700854 }
855
Jason Sams78aebd82009-09-15 13:06:59 -0700856 class Params extends BaseAlloc {
857 Params() {
858 mType = Type.createFromClass(mRS, Params.class, 1, "ParamsClass");
859 mAlloc = Allocation.createTyped(mRS, mType);
860 save();
Joe Onorato1feb3a82009-08-08 22:32:00 -0700861 }
Jason Sams78aebd82009-09-15 13:06:59 -0700862 public int bubbleWidth;
863 public int bubbleHeight;
864 public int bubbleBitmapWidth;
865 public int bubbleBitmapHeight;
Joe Onoratobcbeab82009-10-01 21:45:43 -0700866
Joe Onoratobcbeab82009-10-01 21:45:43 -0700867 public int homeButtonWidth;
868 public int homeButtonHeight;
869 public int homeButtonTextureWidth;
870 public int homeButtonTextureHeight;
Jason Sams78aebd82009-09-15 13:06:59 -0700871 }
872
873 class State extends BaseAlloc {
Jason Sams86c87ed2009-09-18 13:55:55 -0700874 public float newPositionX;
875 public int newTouchDown;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700876 public float flingVelocity;
Jason Sams78aebd82009-09-15 13:06:59 -0700877 public int iconCount;
Jason Sams78aebd82009-09-15 13:06:59 -0700878 public int selectedIconIndex = -1;
879 public int selectedIconTexture;
Joe Onorato7bb17492009-09-24 17:51:01 -0700880 public float zoomTarget;
Joe Onoratod63458b2009-10-15 21:19:09 -0700881 public int homeButtonId;
Jason Samsc1c521e2009-10-19 14:45:45 -0700882 public float targetPos;
Jason Sams78aebd82009-09-15 13:06:59 -0700883
884 State() {
885 mType = Type.createFromClass(mRS, State.class, 1, "StateClass");
886 mAlloc = Allocation.createTyped(mRS, mType);
887 save();
888 }
Joe Onorato1feb3a82009-08-08 22:32:00 -0700889 }
890
891 public RolloRS() {
892 }
893
894 public void init(Resources res, int width, int height) {
895 mRes = res;
896 mWidth = width;
897 mHeight = height;
Joe Onoratobcbeab82009-10-01 21:45:43 -0700898 mDefines.recompute(width, height);
Jason Samscd689e12009-09-29 15:28:22 -0700899 initProgramVertex();
900 initProgramFragment();
901 initProgramStore();
Jason Samsb4ecab22010-01-19 16:43:26 -0800902 //initMesh();
Joe Onorato1feb3a82009-08-08 22:32:00 -0700903 initGl();
904 initData();
Joe Onorato6665c0f2009-09-02 15:27:24 -0700905 initTouchState();
Joe Onorato1feb3a82009-08-08 22:32:00 -0700906 initRs();
907 }
908
Jason Samsb4ecab22010-01-19 16:43:26 -0800909 public void initMesh2() {
910 SimpleMesh.TriangleMeshBuilder tm = new SimpleMesh.TriangleMeshBuilder(mRS, 2, 0);
Jason Sams0aa71662009-10-02 18:43:18 -0700911
Jason Samsb4ecab22010-01-19 16:43:26 -0800912 for (int ct=0; ct < 16; ct++) {
Jason Sams76512482010-02-04 16:31:35 -0800913 float pos = (1.f / (16.f - 1)) * ct;
Jason Samsb4ecab22010-01-19 16:43:26 -0800914 tm.addVertex(0.0f, pos);
915 tm.addVertex(1.0f, pos);
Jason Samsd8152b92009-10-13 17:19:10 -0700916 }
Jason Samsb4ecab22010-01-19 16:43:26 -0800917 for (int ct=0; ct < (16 * 2 - 2); ct+= 2) {
Jason Samsd8152b92009-10-13 17:19:10 -0700918 tm.addTriangle(ct, ct+1, ct+2);
919 tm.addTriangle(ct+1, ct+3, ct+2);
920 }
Jason Samsb4ecab22010-01-19 16:43:26 -0800921 mMesh = tm.create();
922 mMesh.setName("SMCell");
Jason Samsd8152b92009-10-13 17:19:10 -0700923 }
924
Jason Sams5612e432009-11-16 14:18:07 -0800925 void resize(int w, int h) {
926 mPVA.setupProjectionNormalized(w, h);
927 mWidth = w;
928 mHeight = h;
929 }
930
Jason Samscd689e12009-09-29 15:28:22 -0700931 private void initProgramVertex() {
Jason Sams5612e432009-11-16 14:18:07 -0800932 mPVA = new ProgramVertex.MatrixAllocation(mRS);
933 resize(mWidth, mHeight);
Joe Onorato93839052009-08-06 20:34:32 -0700934
935 ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS, null, null);
Jason Sams0aa71662009-10-02 18:43:18 -0700936 pvb.setTextureMatrixEnable(true);
Joe Onorato93839052009-08-06 20:34:32 -0700937 mPV = pvb.create();
938 mPV.setName("PV");
Jason Sams5612e432009-11-16 14:18:07 -0800939 mPV.bindAllocation(mPVA);
Joe Onorato93839052009-08-06 20:34:32 -0700940
Jason Samsb4ecab22010-01-19 16:43:26 -0800941 Element.Builder eb = new Element.Builder(mRS);
942 eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 2), "ImgSize");
943 eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 4), "Position");
Jason Sams66ed54e2010-02-04 12:39:27 -0800944 eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 2), "BendPos");
945 eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 4), "ScaleOffset");
Jason Samsb4ecab22010-01-19 16:43:26 -0800946 Element e = eb.create();
947
948 mUniformAlloc = Allocation.createSized(mRS, e, 1);
949
950 initMesh2();
951 ProgramVertex.ShaderBuilder sb = new ProgramVertex.ShaderBuilder(mRS);
952 String t = new String("void main() {\n" +
953 // Animation
954 " float ani = UNI_Position.z;\n" +
955
Jason Sams66ed54e2010-02-04 12:39:27 -0800956 " float bendY1 = UNI_BendPos.x;\n" +
957 " float bendY2 = UNI_BendPos.y;\n" +
Jason Sams76512482010-02-04 16:31:35 -0800958 " float bendAngle = 47.0 * (3.14 / 180.0);\n" +
959 " float bendDistance = bendY1 * 0.4;\n" +
Jason Sams66ed54e2010-02-04 12:39:27 -0800960 " float distanceDimLevel = 0.6;\n" +
961
962 " float bendStep = (bendAngle / bendDistance) * (bendAngle * 0.5);\n" +
963 " float aDy = cos(bendAngle);\n" +
964 " float aDz = sin(bendAngle);\n" +
965
Jason Samsb4ecab22010-01-19 16:43:26 -0800966 " float scale = (2.0 / 480.0);\n" +
967 " float x = UNI_Position.x + UNI_ImgSize.x * (1.0 - ani) * (ATTRIB_position.x - 0.5);\n" +
968 " float ys= UNI_Position.y + UNI_ImgSize.y * (1.0 - ani) * ATTRIB_position.y;\n" +
969 " float y = 0.0;\n" +
970 " float z = 0.0;\n" +
971 " float lum = 1.0;\n" +
972
Jason Sams66ed54e2010-02-04 12:39:27 -0800973 " float cv = min(ys, bendY1 - bendDistance) - (bendY1 - bendDistance);\n" +
974 " y += cv * aDy;\n" +
975 " z += -cv * aDz;\n" +
976 " cv = clamp(ys, bendY1 - bendDistance, bendY1) - bendY1;\n" + // curve range
977 " lum += cv / bendDistance * distanceDimLevel;\n" +
978 " y += cv * cos(cv * bendStep);\n" +
979 " z += cv * sin(cv * bendStep);\n" +
Jason Samsb4ecab22010-01-19 16:43:26 -0800980
Jason Sams66ed54e2010-02-04 12:39:27 -0800981 " cv = max(ys, bendY2 + bendDistance) - (bendY2 + bendDistance);\n" +
982 " y += cv * aDy;\n" +
983 " z += cv * aDz;\n" +
984 " cv = clamp(ys, bendY2, bendY2 + bendDistance) - bendY2;\n" +
985 " lum -= cv / bendDistance * distanceDimLevel;\n" +
986 " y += cv * cos(cv * bendStep);\n" +
987 " z += cv * sin(cv * bendStep);\n" +
Jason Samsb4ecab22010-01-19 16:43:26 -0800988
Jason Sams66ed54e2010-02-04 12:39:27 -0800989 " y += clamp(ys, bendY1, bendY2);\n" +
Jason Samsb4ecab22010-01-19 16:43:26 -0800990
991 " vec4 pos;\n" +
Jason Sams66ed54e2010-02-04 12:39:27 -0800992 " pos.x = (x + UNI_ScaleOffset.z) * UNI_ScaleOffset.x;\n" +
993 " pos.y = (y + UNI_ScaleOffset.w) * UNI_ScaleOffset.x;\n" +
994 " pos.z = z * UNI_ScaleOffset.x;\n" +
Jason Samsb4ecab22010-01-19 16:43:26 -0800995 " pos.w = 1.0;\n" +
996
997 " pos.x *= 1.0 + ani * 4.0;\n" +
998 " pos.y *= 1.0 + ani * 4.0;\n" +
999 " pos.z -= ani * 1.5;\n" +
1000 " lum *= 1.0 - ani;\n" +
1001
1002 " gl_Position = UNI_MVP * pos;\n" +
1003 " varColor.rgba = vec4(lum, lum, lum, 1.0);\n" +
1004 " varTex0.xy = ATTRIB_position;\n" +
1005 " varTex0.y = 1.0 - varTex0.y;\n" +
1006 " varTex0.zw = vec2(0.0, 0.0);\n" +
1007 "}\n");
1008 sb.setShader(t);
1009 sb.addConstant(mUniformAlloc.getType());
1010 sb.addInput(mMesh.getVertexType(0).getElement());
1011 mPVCurve = sb.create();
1012 mPVCurve.setName("PVCurve");
1013 mPVCurve.bindAllocation(mPVA);
1014 mPVCurve.bindConstants(mUniformAlloc, 1);
1015
Jason Sams66ed54e2010-02-04 12:39:27 -08001016 float tf[] = new float[] {72.f, 72.f,
1017 120.f, 120.f, 0.f, 0.f,
1018 120.f, 680.f,
1019 (2.f / 480.f), 0, -240.f, -380.f};
Jason Samsb4ecab22010-01-19 16:43:26 -08001020 mUniformAlloc.data(tf);
1021
Jason Sams37e7c2b2009-10-19 12:55:43 -07001022 //pva = new ProgramVertex.MatrixAllocation(mRS);
1023 //pva.setupOrthoWindow(mWidth, mHeight);
1024 //pvb.setTextureMatrixEnable(true);
1025 //mPVOrtho = pvb.create();
1026 //mPVOrtho.setName("PVOrtho");
1027 //mPVOrtho.bindAllocation(pva);
Joe Onorato93839052009-08-06 20:34:32 -07001028
1029 mRS.contextBindProgramVertex(mPV);
Jason Samscd689e12009-09-29 15:28:22 -07001030 }
Joe Onorato93839052009-08-06 20:34:32 -07001031
Jason Samscd689e12009-09-29 15:28:22 -07001032 private void initProgramFragment() {
1033 Sampler.Builder sb = new Sampler.Builder(mRS);
Jason Samsc8514792009-10-29 14:27:29 -07001034 sb.setMin(Sampler.Value.LINEAR_MIP_LINEAR);
Jason Samsb4ecab22010-01-19 16:43:26 -08001035 sb.setMag(Sampler.Value.NEAREST);
Jason Samscd689e12009-09-29 15:28:22 -07001036 sb.setWrapS(Sampler.Value.CLAMP);
1037 sb.setWrapT(Sampler.Value.CLAMP);
1038 Sampler linear = sb.create();
1039
1040 sb.setMin(Sampler.Value.NEAREST);
1041 sb.setMag(Sampler.Value.NEAREST);
1042 Sampler nearest = sb.create();
1043
Jason Sams72f1d312009-12-17 16:58:25 -08001044 ProgramFragment.Builder bf = new ProgramFragment.Builder(mRS);
Jason Sams37e7c2b2009-10-19 12:55:43 -07001045 //mPFColor = bf.create();
1046 //mPFColor.setName("PFColor");
Jason Samscd689e12009-09-29 15:28:22 -07001047
Jason Samsb4ecab22010-01-19 16:43:26 -08001048 bf.setTexture(ProgramFragment.Builder.EnvMode.MODULATE,
Jason Sams72f1d312009-12-17 16:58:25 -08001049 ProgramFragment.Builder.Format.RGBA, 0);
Jason Samsc8514792009-10-29 14:27:29 -07001050 mPFTexMip = bf.create();
1051 mPFTexMip.setName("PFTexMip");
1052 mPFTexMip.bindSampler(linear, 0);
1053
1054 mPFTexNearest = bf.create();
1055 mPFTexNearest.setName("PFTexNearest");
1056 mPFTexNearest.bindSampler(nearest, 0);
Jason Sams6ec11bc2010-01-19 17:56:52 -08001057
1058 bf.setTexture(ProgramFragment.Builder.EnvMode.MODULATE,
1059 ProgramFragment.Builder.Format.ALPHA, 0);
1060 mPFTexMipAlpha = bf.create();
1061 mPFTexMipAlpha.setName("PFTexMipAlpha");
1062 mPFTexMipAlpha.bindSampler(linear, 0);
1063
Jason Samscd689e12009-09-29 15:28:22 -07001064 }
1065
1066 private void initProgramStore() {
1067 ProgramStore.Builder bs = new ProgramStore.Builder(mRS, null, null);
1068 bs.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
Jason Sams12c14a82009-10-06 14:33:15 -07001069 bs.setColorMask(true,true,true,false);
Jason Samscd689e12009-09-29 15:28:22 -07001070 bs.setDitherEnable(true);
1071 bs.setBlendFunc(ProgramStore.BlendSrcFunc.SRC_ALPHA,
1072 ProgramStore.BlendDstFunc.ONE_MINUS_SRC_ALPHA);
1073 mPSIcons = bs.create();
1074 mPSIcons.setName("PSIcons");
1075
1076 //bs.setDitherEnable(false);
1077 //mPSText = bs.create();
1078 //mPSText.setName("PSText");
1079 }
1080
1081 private void initGl() {
Joe Onorato6665c0f2009-09-02 15:27:24 -07001082 mTouchXBorders = new int[Defines.COLUMNS_PER_PAGE+1];
Joe Onorato6665c0f2009-09-02 15:27:24 -07001083 mTouchYBorders = new int[Defines.ROWS_PER_PAGE+1];
Joe Onoratobf15cb42009-08-07 14:33:40 -07001084 }
Jason Sams78aebd82009-09-15 13:06:59 -07001085
Joe Onorato1feb3a82009-08-08 22:32:00 -07001086 private void initData() {
Jason Sams78aebd82009-09-15 13:06:59 -07001087 mParams = new Params();
1088 mState = new State();
Joe Onorato43e7bcf2009-08-08 18:53:53 -07001089
Joe Onoratobf15cb42009-08-07 14:33:40 -07001090 final Utilities.BubbleText bubble = new Utilities.BubbleText(getContext());
Joe Onorato93839052009-08-06 20:34:32 -07001091
Joe Onorato43e7bcf2009-08-08 18:53:53 -07001092 mParams.bubbleWidth = bubble.getBubbleWidth();
1093 mParams.bubbleHeight = bubble.getMaxBubbleHeight();
1094 mParams.bubbleBitmapWidth = bubble.getBitmapWidth();
1095 mParams.bubbleBitmapHeight = bubble.getBitmapHeight();
Joe Onorato43e7bcf2009-08-08 18:53:53 -07001096
Joe Onoratod63458b2009-10-15 21:19:09 -07001097 mHomeButtonNormal = Allocation.createFromBitmapResource(mRS, mRes,
1098 R.drawable.home_button_normal, Element.RGBA_8888(mRS), false);
1099 mHomeButtonNormal.uploadToTexture(0);
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001100 mHomeButtonFocused = Allocation.createFromBitmapResource(mRS, mRes,
1101 R.drawable.home_button_focused, Element.RGBA_8888(mRS), false);
1102 mHomeButtonFocused.uploadToTexture(0);
Joe Onoratod63458b2009-10-15 21:19:09 -07001103 mHomeButtonPressed = Allocation.createFromBitmapResource(mRS, mRes,
1104 R.drawable.home_button_pressed, Element.RGBA_8888(mRS), false);
1105 mHomeButtonPressed.uploadToTexture(0);
Joe Onoratobcbeab82009-10-01 21:45:43 -07001106 mParams.homeButtonWidth = 76;
1107 mParams.homeButtonHeight = 68;
1108 mParams.homeButtonTextureWidth = 128;
1109 mParams.homeButtonTextureHeight = 128;
Joe Onoratoc567acb2009-08-31 14:34:43 -07001110
Joe Onoratod63458b2009-10-15 21:19:09 -07001111 mState.homeButtonId = mHomeButtonNormal.getID();
1112
Joe Onorato1feb3a82009-08-08 22:32:00 -07001113 mParams.save();
1114 mState.save();
Joe Onorato9c1289c2009-08-17 11:03:03 -04001115
Jason Sams1a94ee32010-01-20 13:34:30 -08001116 mSelectionBitmap = Bitmap.createBitmap(Defines.SELECTION_TEXTURE_WIDTH_PX,
1117 Defines.SELECTION_TEXTURE_HEIGHT_PX, Bitmap.Config.ARGB_8888);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001118 mSelectionCanvas = new Canvas(mSelectionBitmap);
Joe Onorato6665c0f2009-09-02 15:27:24 -07001119
Joe Onorato9c1289c2009-08-17 11:03:03 -04001120 setApps(null);
Joe Onorato93839052009-08-06 20:34:32 -07001121 }
1122
Jason Sams37e7c2b2009-10-19 12:55:43 -07001123 private void initScript(int id) {
1124 }
1125
1126 private void initRs() {
Joe Onorato93839052009-08-06 20:34:32 -07001127 ScriptC.Builder sb = new ScriptC.Builder(mRS);
Jason Samsd15f3ef2010-01-06 14:58:06 -08001128 sb.setScript(mRes, R.raw.allapps);
Joe Onorato93839052009-08-06 20:34:32 -07001129 sb.setRoot(true);
Joe Onoratobcbeab82009-10-01 21:45:43 -07001130 sb.addDefines(mDefines);
Jason Sams78aebd82009-09-15 13:06:59 -07001131 sb.setType(mParams.mType, "params", Defines.ALLOC_PARAMS);
1132 sb.setType(mState.mType, "state", Defines.ALLOC_STATE);
Jason Samsb4ecab22010-01-19 16:43:26 -08001133 sb.setType(mUniformAlloc.getType(), "vpConstants", Defines.ALLOC_VP_CONSTANTS);
Jason Sams37e7c2b2009-10-19 12:55:43 -07001134 mInvokeMove = sb.addInvokable("move");
1135 mInvokeFling = sb.addInvokable("fling");
Jason Samsc1c521e2009-10-19 14:45:45 -07001136 mInvokeMoveTo = sb.addInvokable("moveTo");
Jason Sams37e7c2b2009-10-19 12:55:43 -07001137 mInvokeResetWAR = sb.addInvokable("resetHWWar");
Joe Onorato3a8820b2009-11-10 15:06:42 -08001138 mInvokeSetZoom = sb.addInvokable("setZoom");
Jason Sams37e7c2b2009-10-19 12:55:43 -07001139 mScript = sb.create();
1140 mScript.setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
1141 mScript.bindAllocation(mParams.mAlloc, Defines.ALLOC_PARAMS);
1142 mScript.bindAllocation(mState.mAlloc, Defines.ALLOC_STATE);
1143 mScript.bindAllocation(mAllocIconIds, Defines.ALLOC_ICON_IDS);
1144 mScript.bindAllocation(mAllocLabelIds, Defines.ALLOC_LABEL_IDS);
Jason Samsb4ecab22010-01-19 16:43:26 -08001145 mScript.bindAllocation(mUniformAlloc, Defines.ALLOC_VP_CONSTANTS);
Joe Onorato93839052009-08-06 20:34:32 -07001146
Jason Sams37e7c2b2009-10-19 12:55:43 -07001147 mRS.contextBindRootScript(mScript);
Joe Onorato93839052009-08-06 20:34:32 -07001148 }
Joe Onorato93839052009-08-06 20:34:32 -07001149
Jason Sams20df7c72009-11-05 12:30:24 -08001150 void dirtyCheck() {
Jason Sams510ee042009-12-15 14:23:37 -08001151 if (mZoomDirty) {
Joe Onorato6374c512010-01-06 20:42:25 -08001152 setZoom(mNextZoom, mAnimateNextZoom);
Jason Sams20df7c72009-11-05 12:30:24 -08001153 }
1154 }
1155
Joe Onorato9c1289c2009-08-17 11:03:03 -04001156 private void setApps(ArrayList<ApplicationInfo> list) {
1157 final int count = list != null ? list.size() : 0;
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001158 int allocCount = count;
Joe Onoratoa8138d52009-10-06 19:25:30 -07001159 if (allocCount < 1) {
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001160 allocCount = 1;
1161 }
1162
Joe Onorato9c1289c2009-08-17 11:03:03 -04001163 mIcons = new Allocation[count];
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001164 mIconIds = new int[allocCount];
Joe Onoratoa8138d52009-10-06 19:25:30 -07001165 mAllocIconIds = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001166
1167 mLabels = new Allocation[count];
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001168 mLabelIds = new int[allocCount];
Joe Onoratoa8138d52009-10-06 19:25:30 -07001169 mAllocLabelIds = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001170
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001171 Element ie8888 = Element.RGBA_8888(mRS);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001172
Joe Onorato9c1289c2009-08-17 11:03:03 -04001173 mState.iconCount = count;
Joe Onorato8eea3912009-12-09 13:01:06 -08001174 for (int i=0; i < mState.iconCount; i++) {
1175 createAppIconAllocations(i, list.get(i));
Joe Onorato3ecbd812009-12-11 13:38:54 -08001176 }
Jason Sams510ee042009-12-15 14:23:37 -08001177 for (int i=0; i < mState.iconCount; i++) {
1178 uploadAppIcon(i, list.get(i));
Joe Onorato8eea3912009-12-09 13:01:06 -08001179 }
Joe Onoratoa8138d52009-10-06 19:25:30 -07001180 saveAppsList();
1181 }
1182
Joe Onorato3a8820b2009-11-10 15:06:42 -08001183 private void setZoom(float zoom, boolean animate) {
1184 mRollo.clearSelectedIcon();
1185 mRollo.setHomeSelected(SELECTED_NONE);
1186 if (zoom > 0.001f) {
1187 mRollo.mState.zoomTarget = zoom;
1188 } else {
1189 mRollo.mState.zoomTarget = 0;
1190 }
1191 mRollo.mState.save();
1192 if (!animate) {
1193 mRollo.mInvokeSetZoom.execute();
1194 }
1195 }
1196
Joe Onorato8eea3912009-12-09 13:01:06 -08001197 private void createAppIconAllocations(int index, ApplicationInfo item) {
Joe Onoratoa8138d52009-10-06 19:25:30 -07001198 mIcons[index] = Allocation.createFromBitmap(mRS, item.iconBitmap,
Jason Samsc8514792009-10-29 14:27:29 -07001199 Element.RGBA_8888(mRS), true);
Joe Onoratoa8138d52009-10-06 19:25:30 -07001200 mLabels[index] = Allocation.createFromBitmap(mRS, item.titleBitmap,
Jason Sams6ec11bc2010-01-19 17:56:52 -08001201 Element.A_8(mRS), true);
Joe Onoratoa8138d52009-10-06 19:25:30 -07001202 mIconIds[index] = mIcons[index].getID();
1203 mLabelIds[index] = mLabels[index].getID();
1204 }
1205
Joe Onorato8eea3912009-12-09 13:01:06 -08001206 private void uploadAppIcon(int index, ApplicationInfo item) {
1207 if (mIconIds[index] != mIcons[index].getID()) {
1208 throw new IllegalStateException("uploadAppIcon index=" + index
1209 + " mIcons[index].getID=" + mIcons[index].getID()
1210 + " mIconsIds[index]=" + mIconIds[index]
1211 + " item=" + item);
1212 }
1213 mIcons[index].uploadToTexture(0);
1214 mLabels[index].uploadToTexture(0);
1215 }
1216
Joe Onoratoa8138d52009-10-06 19:25:30 -07001217 /**
1218 * Puts the empty spaces at the end. Updates mState.iconCount. You must
1219 * fill in the values and call saveAppsList().
1220 */
1221 private void reallocAppsList(int count) {
1222 Allocation[] icons = new Allocation[count];
1223 int[] iconIds = new int[count];
1224 mAllocIconIds = Allocation.createSized(mRS, Element.USER_I32(mRS), count);
1225
1226 Allocation[] labels = new Allocation[count];
1227 int[] labelIds = new int[count];
1228 mAllocLabelIds = Allocation.createSized(mRS, Element.USER_I32(mRS), count);
1229
Joe Onoratobf173f12009-12-08 13:29:38 -08001230 final int oldCount = mRollo.mState.iconCount;
Joe Onoratoa8138d52009-10-06 19:25:30 -07001231
1232 System.arraycopy(mIcons, 0, icons, 0, oldCount);
1233 System.arraycopy(mIconIds, 0, iconIds, 0, oldCount);
1234 System.arraycopy(mLabels, 0, labels, 0, oldCount);
1235 System.arraycopy(mLabelIds, 0, labelIds, 0, oldCount);
1236
1237 mIcons = icons;
1238 mIconIds = iconIds;
1239 mLabels = labels;
1240 mLabelIds = labelIds;
1241 }
1242
1243 /**
1244 * Handle the allocations for the new app. Make sure you call saveAppsList when done.
1245 */
1246 private void addApp(int index, ApplicationInfo item) {
1247 final int count = mState.iconCount - index;
1248 final int dest = index + 1;
1249
1250 System.arraycopy(mIcons, index, mIcons, dest, count);
1251 System.arraycopy(mIconIds, index, mIconIds, dest, count);
1252 System.arraycopy(mLabels, index, mLabels, dest, count);
1253 System.arraycopy(mLabelIds, index, mLabelIds, dest, count);
1254
Joe Onorato8eea3912009-12-09 13:01:06 -08001255 createAppIconAllocations(index, item);
Jason Sams510ee042009-12-15 14:23:37 -08001256 uploadAppIcon(index, item);
Joe Onorato8eea3912009-12-09 13:01:06 -08001257 mRollo.mState.iconCount++;
Joe Onoratoa8138d52009-10-06 19:25:30 -07001258 }
1259
1260 /**
1261 * Handle the allocations for the removed app. Make sure you call saveAppsList when done.
1262 */
1263 private void removeApp(int index) {
1264 final int count = mState.iconCount - index - 1;
1265 final int src = index + 1;
1266
1267 System.arraycopy(mIcons, src, mIcons, index, count);
1268 System.arraycopy(mIconIds, src, mIconIds, index, count);
1269 System.arraycopy(mLabels, src, mLabels, index, count);
1270 System.arraycopy(mLabelIds, src, mLabelIds, index, count);
1271
Joe Onoratoa276fc52009-12-08 17:02:02 -08001272 mRollo.mState.iconCount--;
Joe Onorato8eea3912009-12-09 13:01:06 -08001273 final int last = mState.iconCount;
Joe Onoratoa276fc52009-12-08 17:02:02 -08001274
Joe Onoratoa8138d52009-10-06 19:25:30 -07001275 mIcons[last] = null;
1276 mIconIds[last] = 0;
1277 mLabels[last] = null;
1278 mLabelIds[last] = 0;
1279 }
1280
1281 /**
1282 * Send the apps list structures to RS.
1283 */
1284 private void saveAppsList() {
1285 mRS.contextBindRootScript(null);
Jason Samsd8152b92009-10-13 17:19:10 -07001286
Joe Onoratoa8138d52009-10-06 19:25:30 -07001287 mAllocIconIds.data(mIconIds);
1288 mAllocLabelIds.data(mLabelIds);
1289
Jason Sams37e7c2b2009-10-19 12:55:43 -07001290 if (mScript != null) { // this happens when we init it
1291 mScript.bindAllocation(mAllocIconIds, Defines.ALLOC_ICON_IDS);
1292 mScript.bindAllocation(mAllocLabelIds, Defines.ALLOC_LABEL_IDS);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001293 }
1294
1295 mState.save();
Joe Onoratoa8138d52009-10-06 19:25:30 -07001296
1297 // Note: mScript may be null if we haven't initialized it yet.
1298 // In that case, this is a no-op.
Jason Sams37e7c2b2009-10-19 12:55:43 -07001299 if (mInvokeResetWAR != null) {
1300 mInvokeResetWAR.execute();
Jason Sams41b61c82009-10-15 15:40:54 -07001301 }
Joe Onoratob8315542010-02-03 20:39:25 -08001302 if (mScript != null) {
1303 mRS.contextBindRootScript(mScript);
1304 }
Joe Onorato9c1289c2009-08-17 11:03:03 -04001305 }
Joe Onorato6665c0f2009-09-02 15:27:24 -07001306
1307 void initTouchState() {
1308 int width = getWidth();
1309 int height = getHeight();
Jason Sams37e7c2b2009-10-19 12:55:43 -07001310 int cellHeight = 145;//iconsSize / Defines.ROWS_PER_PAGE;
1311 int cellWidth = width / Defines.COLUMNS_PER_PAGE;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001312
Jason Sams37e7c2b2009-10-19 12:55:43 -07001313 int centerY = (height / 2);
1314 mTouchYBorders[0] = centerY - (cellHeight * 2);
1315 mTouchYBorders[1] = centerY - cellHeight;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001316 mTouchYBorders[2] = centerY;
Jason Sams37e7c2b2009-10-19 12:55:43 -07001317 mTouchYBorders[3] = centerY + cellHeight;
1318 mTouchYBorders[4] = centerY + (cellHeight * 2);
Jason Sams78aebd82009-09-15 13:06:59 -07001319
Joe Onorato6665c0f2009-09-02 15:27:24 -07001320 int centerX = (width / 2);
Jason Sams37e7c2b2009-10-19 12:55:43 -07001321 mTouchXBorders[0] = 0;
1322 mTouchXBorders[1] = centerX - (width / 4);
Joe Onorato6665c0f2009-09-02 15:27:24 -07001323 mTouchXBorders[2] = centerX;
Jason Sams37e7c2b2009-10-19 12:55:43 -07001324 mTouchXBorders[3] = centerX + (width / 4);
1325 mTouchXBorders[4] = width;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001326 }
1327
Joe Onorato664457d2009-10-28 16:30:34 -04001328 void fling() {
1329 mInvokeFling.execute();
1330 }
1331
1332 void move() {
1333 mInvokeMove.execute();
1334 }
1335
1336 void moveTo(float row) {
1337 mState.targetPos = row;
1338 mState.save();
1339 mInvokeMoveTo.execute();
1340 }
1341
Jason Sams37e7c2b2009-10-19 12:55:43 -07001342 int chooseTappedIcon(int x, int y, float pos) {
1343 // Adjust for scroll position if not zero.
1344 y += (pos - ((int)pos)) * (mTouchYBorders[1] - mTouchYBorders[0]);
Jason Sams86c87ed2009-09-18 13:55:55 -07001345
Joe Onorato6665c0f2009-09-02 15:27:24 -07001346 int col = -1;
1347 int row = -1;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001348 for (int i=0; i<Defines.COLUMNS_PER_PAGE; i++) {
1349 if (x >= mTouchXBorders[i] && x < mTouchXBorders[i+1]) {
1350 col = i;
1351 break;
1352 }
1353 }
1354 for (int i=0; i<Defines.ROWS_PER_PAGE; i++) {
1355 if (y >= mTouchYBorders[i] && y < mTouchYBorders[i+1]) {
1356 row = i;
1357 break;
1358 }
1359 }
1360
1361 if (row < 0 || col < 0) {
1362 return -1;
1363 }
1364
Joe Onorato664457d2009-10-28 16:30:34 -04001365 int index = (((int)pos) * Defines.COLUMNS_PER_PAGE)
Joe Onorato6665c0f2009-09-02 15:27:24 -07001366 + (row * Defines.ROWS_PER_PAGE) + col;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001367
Joe Onorato664457d2009-10-28 16:30:34 -04001368 if (index >= mState.iconCount) {
1369 return -1;
1370 } else {
1371 return index;
1372 }
Jason Samsc1c521e2009-10-19 14:45:45 -07001373 }
1374
Joe Onorato6665c0f2009-09-02 15:27:24 -07001375 /**
1376 * You need to call save() on mState on your own after calling this.
Joe Onorato82ca5502009-10-15 16:59:23 -07001377 *
1378 * @return the index of the icon that was selected.
Joe Onorato6665c0f2009-09-02 15:27:24 -07001379 */
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001380 int selectIcon(int x, int y, float pos, int pressed) {
Joe Onorato82ca5502009-10-15 16:59:23 -07001381 final int index = chooseTappedIcon(x, y, pos);
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001382 selectIcon(index, pressed);
Joe Onorato82ca5502009-10-15 16:59:23 -07001383 return index;
Joe Onorato1291a8c2009-09-15 15:07:25 -04001384 }
1385
Joe Onoratoc61cff92009-11-08 11:54:39 -05001386 /**
1387 * Select the icon at the given index.
1388 *
1389 * @param index The index.
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001390 * @param pressed one of SELECTED_PRESSED or SELECTED_FOCUSED
Joe Onoratoc61cff92009-11-08 11:54:39 -05001391 */
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001392 void selectIcon(int index, int pressed) {
Joe Onorato2d804762009-11-05 16:02:32 -05001393 if (mAllAppsList == null || index < 0 || index >= mAllAppsList.size()) {
Joe Onorato6665c0f2009-09-02 15:27:24 -07001394 mState.selectedIconIndex = -1;
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001395 if (mLastSelection == SELECTION_ICONS) {
1396 mLastSelection = SELECTION_NONE;
1397 }
Joe Onorato6665c0f2009-09-02 15:27:24 -07001398 } else {
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001399 if (pressed == SELECTED_FOCUSED) {
1400 mLastSelection = SELECTION_ICONS;
1401 }
1402
Joe Onorato52a653f2009-11-11 14:52:11 -08001403 int prev = mState.selectedIconIndex;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001404 mState.selectedIconIndex = index;
Joe Onorato1291a8c2009-09-15 15:07:25 -04001405
Joe Onorato52a653f2009-11-11 14:52:11 -08001406 ApplicationInfo info = mAllAppsList.get(index);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001407 Bitmap selectionBitmap = mSelectionBitmap;
1408
1409 Utilities.drawSelectedAllAppsBitmap(mSelectionCanvas,
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001410 selectionBitmap.getWidth(), selectionBitmap.getHeight(),
Joe Onorato52a653f2009-11-11 14:52:11 -08001411 pressed == SELECTED_PRESSED, info.iconBitmap);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001412
1413 mSelectedIcon = Allocation.createFromBitmap(mRS, selectionBitmap,
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001414 Element.RGBA_8888(mRS), false);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001415 mSelectedIcon.uploadToTexture(0);
1416 mState.selectedIconTexture = mSelectedIcon.getID();
Joe Onorato52a653f2009-11-11 14:52:11 -08001417
1418 if (prev != index) {
1419 if (info.title != null && info.title.length() > 0) {
Joe Onorato52a653f2009-11-11 14:52:11 -08001420 //setContentDescription(info.title);
1421 sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
1422 }
1423 }
Joe Onorato6665c0f2009-09-02 15:27:24 -07001424 }
1425 }
1426
1427 /**
1428 * You need to call save() on mState on your own after calling this.
1429 */
1430 void clearSelectedIcon() {
Joe Onorato2ca51dc2009-09-16 11:44:14 -04001431 mState.selectedIconIndex = -1;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001432 }
Joe Onoratoa8138d52009-10-06 19:25:30 -07001433
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001434 void setHomeSelected(int mode) {
Joe Onorato52a653f2009-11-11 14:52:11 -08001435 final int prev = mLastSelection;
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001436 switch (mode) {
1437 case SELECTED_NONE:
Joe Onoratod63458b2009-10-15 21:19:09 -07001438 mState.homeButtonId = mHomeButtonNormal.getID();
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001439 break;
1440 case SELECTED_FOCUSED:
1441 mLastSelection = SELECTION_HOME;
1442 mState.homeButtonId = mHomeButtonFocused.getID();
Joe Onorato52a653f2009-11-11 14:52:11 -08001443 if (prev != SELECTION_HOME) {
Joe Onorato52a653f2009-11-11 14:52:11 -08001444 sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
1445 }
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001446 break;
1447 case SELECTED_PRESSED:
1448 mState.homeButtonId = mHomeButtonPressed.getID();
1449 break;
Joe Onoratod63458b2009-10-15 21:19:09 -07001450 }
1451 }
Joe Onoratobe386092009-11-17 17:32:16 -08001452
1453 public void dumpState() {
1454 Log.d(TAG, "mRollo.mWidth=" + mWidth);
1455 Log.d(TAG, "mRollo.mHeight=" + mHeight);
1456 Log.d(TAG, "mRollo.mIcons=" + mIcons);
1457 if (mIcons != null) {
1458 Log.d(TAG, "mRollo.mIcons.length=" + mIcons.length);
1459 }
1460 if (mIconIds != null) {
1461 Log.d(TAG, "mRollo.mIconIds.length=" + mIconIds.length);
1462 }
1463 Log.d(TAG, "mRollo.mIconIds=" + Arrays.toString(mIconIds));
1464 if (mLabelIds != null) {
1465 Log.d(TAG, "mRollo.mLabelIds.length=" + mLabelIds.length);
1466 }
1467 Log.d(TAG, "mRollo.mLabelIds=" + Arrays.toString(mLabelIds));
1468 Log.d(TAG, "mRollo.mTouchXBorders=" + Arrays.toString(mTouchXBorders));
1469 Log.d(TAG, "mRollo.mTouchYBorders=" + Arrays.toString(mTouchYBorders));
Joe Onoratobe386092009-11-17 17:32:16 -08001470 Log.d(TAG, "mRollo.mState.newPositionX=" + mState.newPositionX);
1471 Log.d(TAG, "mRollo.mState.newTouchDown=" + mState.newTouchDown);
1472 Log.d(TAG, "mRollo.mState.flingVelocity=" + mState.flingVelocity);
1473 Log.d(TAG, "mRollo.mState.iconCount=" + mState.iconCount);
1474 Log.d(TAG, "mRollo.mState.selectedIconIndex=" + mState.selectedIconIndex);
1475 Log.d(TAG, "mRollo.mState.selectedIconTexture=" + mState.selectedIconTexture);
1476 Log.d(TAG, "mRollo.mState.zoomTarget=" + mState.zoomTarget);
1477 Log.d(TAG, "mRollo.mState.homeButtonId=" + mState.homeButtonId);
1478 Log.d(TAG, "mRollo.mState.targetPos=" + mState.targetPos);
1479 Log.d(TAG, "mRollo.mParams.bubbleWidth=" + mParams.bubbleWidth);
1480 Log.d(TAG, "mRollo.mParams.bubbleHeight=" + mParams.bubbleHeight);
1481 Log.d(TAG, "mRollo.mParams.bubbleBitmapWidth=" + mParams.bubbleBitmapWidth);
1482 Log.d(TAG, "mRollo.mParams.bubbleBitmapHeight=" + mParams.bubbleBitmapHeight);
1483 Log.d(TAG, "mRollo.mParams.homeButtonWidth=" + mParams.homeButtonWidth);
1484 Log.d(TAG, "mRollo.mParams.homeButtonHeight=" + mParams.homeButtonHeight);
1485 Log.d(TAG, "mRollo.mParams.homeButtonTextureWidth=" + mParams.homeButtonTextureWidth);
1486 Log.d(TAG, "mRollo.mParams.homeButtonTextureHeight=" + mParams.homeButtonTextureHeight);
1487 }
1488 }
1489
1490 public void dumpState() {
1491 Log.d(TAG, "mRS=" + mRS);
1492 Log.d(TAG, "mRollo=" + mRollo);
1493 ApplicationInfo.dumpApplicationInfoList(TAG, "mAllAppsList", mAllAppsList);
1494 Log.d(TAG, "mArrowNavigation=" + mArrowNavigation);
1495 Log.d(TAG, "mStartedScrolling=" + mStartedScrolling);
1496 Log.d(TAG, "mLastSelection=" + mLastSelection);
1497 Log.d(TAG, "mLastSelectedIcon=" + mLastSelectedIcon);
1498 Log.d(TAG, "mVelocityTracker=" + mVelocityTracker);
1499 Log.d(TAG, "mTouchTracking=" + mTouchTracking);
1500 Log.d(TAG, "mShouldGainFocus=" + mShouldGainFocus);
1501 Log.d(TAG, "mZoomDirty=" + mZoomDirty);
1502 Log.d(TAG, "mAnimateNextZoom=" + mAnimateNextZoom);
1503 Log.d(TAG, "mZoom=" + mZoom);
1504 Log.d(TAG, "mPosX=" + mPosX);
1505 Log.d(TAG, "mVelocity=" + mVelocity);
1506 Log.d(TAG, "mMessageProc=" + mMessageProc);
1507 if (mRollo != null) {
1508 mRollo.dumpState();
1509 }
1510 if (mRS != null) {
1511 mRS.contextDump(0);
1512 }
Joe Onorato9c1289c2009-08-17 11:03:03 -04001513 }
Joe Onorato93839052009-08-06 20:34:32 -07001514}
1515
1516