blob: 9b81042b7b8bf88697101758c3574b66d4a12cc2 [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
Joe Onoratoa30ce8e2009-11-11 08:16:49 -0800232 //long endTime = SystemClock.uptimeMillis();
233 //Log.d(TAG, "surfaceChanged took " + (endTime-startTime) + "ms");
Joe Onorato93839052009-08-06 20:34:32 -0700234 }
Jason Sams2e19c052009-10-20 18:19:55 -0700235
Joe Onorato93839052009-08-06 20:34:32 -0700236 @Override
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800237 public void onWindowFocusChanged(boolean hasWindowFocus) {
238 super.onWindowFocusChanged(hasWindowFocus);
239 if (mArrowNavigation) {
240 if (!hasWindowFocus) {
241 // Clear selection when we lose window focus
242 mLastSelectedIcon = mRollo.mState.selectedIconIndex;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500243 mRollo.setHomeSelected(SELECTED_NONE);
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800244 mRollo.clearSelectedIcon();
245 mRollo.mState.save();
246 } else if (hasWindowFocus) {
247 if (mRollo.mState.iconCount > 0) {
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500248 if (mLastSelection == SELECTION_ICONS) {
249 int selection = mLastSelectedIcon;
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800250 final int firstIcon = Math.round(mPosX) *
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500251 Defines.COLUMNS_PER_PAGE;
252 if (selection < 0 || // No selection
253 selection < firstIcon || // off the top of the screen
254 selection >= mRollo.mState.iconCount || // past last icon
255 selection >= firstIcon + // past last icon on screen
256 (Defines.COLUMNS_PER_PAGE * Defines.ROWS_PER_PAGE)) {
257 selection = firstIcon;
258 }
259
260 // Select the first icon when we gain window focus
261 mRollo.selectIcon(selection, SELECTED_FOCUSED);
262 mRollo.mState.save();
263 } else if (mLastSelection == SELECTION_HOME) {
264 mRollo.setHomeSelected(SELECTED_FOCUSED);
265 mRollo.mState.save();
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800266 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800267 }
268 }
269 }
270 }
271
272 @Override
Mike Cleron7d5d7462009-10-20 14:06:00 -0700273 protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
274 super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
Joe Onorato859b3a72009-10-28 15:17:01 -0400275
276 if (!isVisible()) {
277 return;
278 }
279
Mike Cleron7d5d7462009-10-20 14:06:00 -0700280 if (gainFocus) {
Jason Sams510ee042009-12-15 14:23:37 -0800281 if (mRollo != null) {
Mike Cleronb64b67a2009-11-08 14:56:25 -0800282 gainFocus();
283 } else {
284 mShouldGainFocus = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700285 }
286 } else {
Joe Onorato8eea3912009-12-09 13:01:06 -0800287 if (mRollo != null) {
Mike Cleronb64b67a2009-11-08 14:56:25 -0800288 if (mArrowNavigation) {
289 // Clear selection when we lose focus
290 mRollo.clearSelectedIcon();
291 mRollo.setHomeSelected(SELECTED_NONE);
292 mRollo.mState.save();
293 mArrowNavigation = false;
294 }
295 } else {
296 mShouldGainFocus = false;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700297 }
298 }
299 }
300
Mike Cleronb64b67a2009-11-08 14:56:25 -0800301 private void gainFocus() {
302 if (!mArrowNavigation && mRollo.mState.iconCount > 0) {
303 // Select the first icon when we gain keyboard focus
304 mArrowNavigation = true;
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800305 mRollo.selectIcon(Math.round(mPosX) * Defines.COLUMNS_PER_PAGE,
Mike Cleronb64b67a2009-11-08 14:56:25 -0800306 SELECTED_FOCUSED);
307 mRollo.mState.save();
308 }
309 }
310
Mike Cleron7d5d7462009-10-20 14:06:00 -0700311 @Override
312 public boolean onKeyDown(int keyCode, KeyEvent event) {
Jason Sams2e19c052009-10-20 18:19:55 -0700313
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800314 boolean handled = false;
Jason Samse26d9fc2009-11-12 14:00:43 -0800315
Joe Onorato859b3a72009-10-28 15:17:01 -0400316 if (!isVisible()) {
317 return false;
318 }
Joe Onoratoa13f5742009-11-02 17:15:19 -0500319 final int iconCount = mRollo.mState.iconCount;
320
Mike Cleron7d5d7462009-10-20 14:06:00 -0700321 if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
322 if (mArrowNavigation) {
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500323 if (mLastSelection == SELECTION_HOME) {
324 reallyPlaySoundEffect(SoundEffectConstants.CLICK);
325 mLauncher.closeAllApps(true);
326 } else {
327 int whichApp = mRollo.mState.selectedIconIndex;
328 if (whichApp >= 0) {
329 ApplicationInfo app = mAllAppsList.get(whichApp);
330 mLauncher.startActivitySafely(app.intent);
331 handled = true;
332 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700333 }
334 }
335 }
Jason Sams2e19c052009-10-20 18:19:55 -0700336
Joe Onorato478730f2009-11-16 18:54:43 -0800337 if (iconCount > 0) {
Mike Cleron7d5d7462009-10-20 14:06:00 -0700338 mArrowNavigation = true;
Jason Sams2e19c052009-10-20 18:19:55 -0700339
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800340 int currentSelection = mRollo.mState.selectedIconIndex;
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800341 int currentTopRow = Math.round(mPosX);
Jason Sams2e19c052009-10-20 18:19:55 -0700342
Mike Cleron7d5d7462009-10-20 14:06:00 -0700343 // The column of the current selection, in the range 0..COLUMNS_PER_PAGE-1
Joe Onoratoa13f5742009-11-02 17:15:19 -0500344 final int currentPageCol = currentSelection % Defines.COLUMNS_PER_PAGE;
Jason Sams2e19c052009-10-20 18:19:55 -0700345
Mike Cleron7d5d7462009-10-20 14:06:00 -0700346 // The row of the current selection, in the range 0..ROWS_PER_PAGE-1
Joe Onoratoa13f5742009-11-02 17:15:19 -0500347 final int currentPageRow = (currentSelection - (currentTopRow*Defines.COLUMNS_PER_PAGE))
Mike Cleron7d5d7462009-10-20 14:06:00 -0700348 / Defines.ROWS_PER_PAGE;
Jason Sams2e19c052009-10-20 18:19:55 -0700349
Mike Cleron7d5d7462009-10-20 14:06:00 -0700350 int newSelection = currentSelection;
351
352 switch (keyCode) {
353 case KeyEvent.KEYCODE_DPAD_UP:
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500354 if (mLastSelection == SELECTION_HOME) {
355 mRollo.setHomeSelected(SELECTED_NONE);
356 int lastRowCount = iconCount % Defines.COLUMNS_PER_PAGE;
357 if (lastRowCount == 0) {
358 lastRowCount = Defines.COLUMNS_PER_PAGE;
359 }
360 newSelection = iconCount - lastRowCount + (Defines.COLUMNS_PER_PAGE / 2);
361 if (newSelection >= iconCount) {
362 newSelection = iconCount-1;
363 }
364 int target = (newSelection / Defines.COLUMNS_PER_PAGE)
365 - (Defines.ROWS_PER_PAGE - 1);
366 if (target < 0) {
367 target = 0;
368 }
369 if (currentTopRow != target) {
370 mRollo.moveTo(target);
371 }
372 } else {
373 if (currentPageRow > 0) {
374 newSelection = currentSelection - Defines.COLUMNS_PER_PAGE;
375 } else if (currentTopRow > 0) {
376 newSelection = currentSelection - Defines.COLUMNS_PER_PAGE;
377 mRollo.moveTo(newSelection / Defines.COLUMNS_PER_PAGE);
Joe Onoratoaf5b4cb2009-12-08 17:51:22 -0800378 } else if (currentPageRow != 0) {
379 newSelection = currentTopRow * Defines.ROWS_PER_PAGE;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500380 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700381 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800382 handled = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700383 break;
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800384
Joe Onoratoa13f5742009-11-02 17:15:19 -0500385 case KeyEvent.KEYCODE_DPAD_DOWN: {
386 final int rowCount = iconCount / Defines.COLUMNS_PER_PAGE
387 + (iconCount % Defines.COLUMNS_PER_PAGE == 0 ? 0 : 1);
388 final int currentRow = currentSelection / Defines.COLUMNS_PER_PAGE;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500389 if (mLastSelection != SELECTION_HOME) {
390 if (currentRow < rowCount-1) {
391 mRollo.setHomeSelected(SELECTED_NONE);
Joe Onorato478730f2009-11-16 18:54:43 -0800392 if (currentSelection < 0) {
393 newSelection = 0;
394 } else {
395 newSelection = currentSelection + Defines.COLUMNS_PER_PAGE;
396 }
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500397 if (newSelection >= iconCount) {
398 // Go from D to G in this arrangement:
399 // A B C D
400 // E F G
401 newSelection = iconCount - 1;
402 }
403 if (currentPageRow >= Defines.ROWS_PER_PAGE - 1) {
404 mRollo.moveTo((newSelection / Defines.COLUMNS_PER_PAGE) -
405 Defines.ROWS_PER_PAGE + 1);
406 }
407 } else {
408 newSelection = -1;
409 mRollo.setHomeSelected(SELECTED_FOCUSED);
Mike Cleron7d5d7462009-10-20 14:06:00 -0700410 }
411 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800412 handled = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700413 break;
Joe Onoratoa13f5742009-11-02 17:15:19 -0500414 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700415 case KeyEvent.KEYCODE_DPAD_LEFT:
Joe Onoratoe9a3f3d2010-02-01 18:36:43 -0500416 if (mLastSelection != SELECTION_HOME) {
417 if (currentPageCol > 0) {
418 newSelection = currentSelection - 1;
419 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700420 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800421 handled = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700422 break;
423 case KeyEvent.KEYCODE_DPAD_RIGHT:
Joe Onoratoe9a3f3d2010-02-01 18:36:43 -0500424 if (mLastSelection != SELECTION_HOME) {
425 if ((currentPageCol < Defines.COLUMNS_PER_PAGE - 1) &&
426 (currentSelection < iconCount - 1)) {
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 }
433 if (newSelection != currentSelection) {
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500434 mRollo.selectIcon(newSelection, SELECTED_FOCUSED);
Mike Cleron7d5d7462009-10-20 14:06:00 -0700435 mRollo.mState.save();
436 }
437 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800438 return handled;
Joe Onorato93839052009-08-06 20:34:32 -0700439 }
440
Joe Onorato93839052009-08-06 20:34:32 -0700441 @Override
442 public boolean onTouchEvent(MotionEvent ev)
443 {
Mike Cleron7d5d7462009-10-20 14:06:00 -0700444 mArrowNavigation = false;
Jason Sams2e19c052009-10-20 18:19:55 -0700445
Joe Onorato7bb17492009-09-24 17:51:01 -0700446 if (!isVisible()) {
Joe Onorato85a02a82009-09-08 12:34:22 -0700447 return true;
Joe Onoratoe3406a22009-09-03 14:36:25 -0700448 }
449
Joe Onoratofb0ca672009-09-14 17:55:46 -0400450 if (mLocks != 0) {
Joe Onorato85a02a82009-09-08 12:34:22 -0700451 return true;
452 }
453
454 super.onTouchEvent(ev);
455
Joe Onoratofb0ca672009-09-14 17:55:46 -0400456 int x = (int)ev.getX();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700457 int y = (int)ev.getY();
458
Joe Onoratobcbeab82009-10-01 21:45:43 -0700459 int action = ev.getAction();
460 switch (action) {
Joe Onoratofb0ca672009-09-14 17:55:46 -0400461 case MotionEvent.ACTION_DOWN:
Joe Onoratobcbeab82009-10-01 21:45:43 -0700462 if (y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]) {
463 mTouchTracking = TRACKING_HOME;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500464 mRollo.setHomeSelected(SELECTED_PRESSED);
Joe Onoratod63458b2009-10-15 21:19:09 -0700465 mRollo.mState.save();
Mike Cleron7d5d7462009-10-20 14:06:00 -0700466 mCurrentIconIndex = -1;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700467 } else {
Joe Onoratobcbeab82009-10-01 21:45:43 -0700468 mTouchTracking = TRACKING_FLING;
469
470 mMotionDownRawX = (int)ev.getRawX();
471 mMotionDownRawY = (int)ev.getRawY();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700472
Mike Cleron7d5d7462009-10-20 14:06:00 -0700473 mRollo.mState.newPositionX = ev.getRawY() / getHeight();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700474 mRollo.mState.newTouchDown = 1;
475
476 if (!mRollo.checkClickOK()) {
477 mRollo.clearSelectedIcon();
478 } else {
Joe Onorato82ca5502009-10-15 16:59:23 -0700479 mDownIconIndex = mCurrentIconIndex
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800480 = mRollo.selectIcon(x, y, mPosX, SELECTED_PRESSED);
Joe Onorato82ca5502009-10-15 16:59:23 -0700481 if (mDownIconIndex < 0) {
482 // if nothing was selected, no long press.
483 cancelLongPress();
484 }
Joe Onoratobcbeab82009-10-01 21:45:43 -0700485 }
486 mRollo.mState.save();
Jason Samsd8152b92009-10-13 17:19:10 -0700487 mRollo.move();
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800488 mVelocityTracker = VelocityTracker.obtain();
489 mVelocityTracker.addMovement(ev);
Joe Onoratobcbeab82009-10-01 21:45:43 -0700490 mStartedScrolling = false;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700491 }
Joe Onoratofb0ca672009-09-14 17:55:46 -0400492 break;
493 case MotionEvent.ACTION_MOVE:
494 case MotionEvent.ACTION_OUTSIDE:
Joe Onoratobcbeab82009-10-01 21:45:43 -0700495 if (mTouchTracking == TRACKING_HOME) {
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500496 mRollo.setHomeSelected(y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]
497 ? SELECTED_PRESSED : SELECTED_NONE);
Joe Onoratod63458b2009-10-15 21:19:09 -0700498 mRollo.mState.save();
Joe Onorato68ffd102009-10-15 17:59:43 -0700499 } else if (mTouchTracking == TRACKING_FLING) {
Joe Onorato82ca5502009-10-15 16:59:23 -0700500 int rawX = (int)ev.getRawX();
501 int rawY = (int)ev.getRawY();
502 int slop;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700503 slop = Math.abs(rawY - mMotionDownRawY);
Jason Samsd8152b92009-10-13 17:19:10 -0700504
Joe Onorato82ca5502009-10-15 16:59:23 -0700505 if (!mStartedScrolling && slop < mSlop) {
506 // don't update anything so when we do start scrolling
Joe Onoratobcbeab82009-10-01 21:45:43 -0700507 // below, we get the right delta.
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800508 mCurrentIconIndex = mRollo.chooseTappedIcon(x, y, mPosX);
Joe Onorato82ca5502009-10-15 16:59:23 -0700509 if (mDownIconIndex != mCurrentIconIndex) {
510 // If a different icon is selected, don't allow it to be picked up.
511 // This handles off-axis dragging.
512 cancelLongPress();
513 mCurrentIconIndex = -1;
514 }
Joe Onoratobcbeab82009-10-01 21:45:43 -0700515 } else {
Joe Onorato82ca5502009-10-15 16:59:23 -0700516 if (!mStartedScrolling) {
517 cancelLongPress();
518 mCurrentIconIndex = -1;
519 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700520 mRollo.mState.newPositionX = ev.getRawY() / getHeight();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700521 mRollo.mState.newTouchDown = 1;
Jason Samsd8152b92009-10-13 17:19:10 -0700522 mRollo.move();
Jason Sams86c87ed2009-09-18 13:55:55 -0700523
Joe Onoratobcbeab82009-10-01 21:45:43 -0700524 mStartedScrolling = true;
525 mRollo.clearSelectedIcon();
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800526 mVelocityTracker.addMovement(ev);
Joe Onoratobcbeab82009-10-01 21:45:43 -0700527 mRollo.mState.save();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700528 }
Joe Onoratofb0ca672009-09-14 17:55:46 -0400529 }
530 break;
531 case MotionEvent.ACTION_UP:
532 case MotionEvent.ACTION_CANCEL:
Joe Onoratobcbeab82009-10-01 21:45:43 -0700533 if (mTouchTracking == TRACKING_HOME) {
534 if (action == MotionEvent.ACTION_UP) {
535 if (y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]) {
Joe Onoratob39e51a2009-10-28 15:47:49 -0400536 reallyPlaySoundEffect(SoundEffectConstants.CLICK);
Joe Onoratobcbeab82009-10-01 21:45:43 -0700537 mLauncher.closeAllApps(true);
538 }
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500539 mRollo.setHomeSelected(SELECTED_NONE);
Joe Onoratod63458b2009-10-15 21:19:09 -0700540 mRollo.mState.save();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700541 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700542 mCurrentIconIndex = -1;
Joe Onorato68ffd102009-10-15 17:59:43 -0700543 } else if (mTouchTracking == TRACKING_FLING) {
Joe Onoratobcbeab82009-10-01 21:45:43 -0700544 mRollo.mState.newTouchDown = 0;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700545 mRollo.mState.newPositionX = ev.getRawY() / getHeight();
Jason Sams476339d2009-09-29 18:14:38 -0700546
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800547 mVelocityTracker.computeCurrentVelocity(1000 /* px/sec */, mMaxFlingVelocity);
548 mRollo.mState.flingVelocity = mVelocityTracker.getYVelocity() / getHeight();
Jason Sams12c14a82009-10-06 14:33:15 -0700549 mRollo.clearSelectedIcon();
550 mRollo.mState.save();
Jason Samsd8152b92009-10-13 17:19:10 -0700551 mRollo.fling();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700552
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800553 if (mVelocityTracker != null) {
554 mVelocityTracker.recycle();
555 mVelocityTracker = null;
Joe Onorato539ed9d2009-10-02 10:22:14 -0700556 }
Joe Onoratobcbeab82009-10-01 21:45:43 -0700557 }
Joe Onorato68ffd102009-10-15 17:59:43 -0700558 mTouchTracking = TRACKING_NONE;
559 break;
Joe Onorato93839052009-08-06 20:34:32 -0700560 }
Joe Onorato6665c0f2009-09-02 15:27:24 -0700561
562 return true;
Joe Onorato93839052009-08-06 20:34:32 -0700563 }
564
Joe Onorato6665c0f2009-09-02 15:27:24 -0700565 public void onClick(View v) {
Joe Onorato7bb17492009-09-24 17:51:01 -0700566 if (mLocks != 0 || !isVisible()) {
Joe Onoratofb0ca672009-09-14 17:55:46 -0400567 return;
568 }
Joe Onorato82ca5502009-10-15 16:59:23 -0700569 if (mRollo.checkClickOK() && mCurrentIconIndex == mDownIconIndex
570 && mCurrentIconIndex >= 0 && mCurrentIconIndex < mAllAppsList.size()) {
Joe Onoratob39e51a2009-10-28 15:47:49 -0400571 reallyPlaySoundEffect(SoundEffectConstants.CLICK);
Joe Onorato82ca5502009-10-15 16:59:23 -0700572 ApplicationInfo app = mAllAppsList.get(mCurrentIconIndex);
Joe Onorato6665c0f2009-09-02 15:27:24 -0700573 mLauncher.startActivitySafely(app.intent);
574 }
575 }
576
577 public boolean onLongClick(View v) {
Joe Onorato7bb17492009-09-24 17:51:01 -0700578 if (mLocks != 0 || !isVisible()) {
Joe Onoratofb0ca672009-09-14 17:55:46 -0400579 return true;
580 }
Joe Onorato82ca5502009-10-15 16:59:23 -0700581 if (mRollo.checkClickOK() && mCurrentIconIndex == mDownIconIndex
582 && mCurrentIconIndex >= 0 && mCurrentIconIndex < mAllAppsList.size()) {
583 ApplicationInfo app = mAllAppsList.get(mCurrentIconIndex);
Joe Onorato5162ea92009-09-03 09:39:42 -0700584
Jason Samsb4ecab22010-01-19 16:43:26 -0800585 Bitmap bmp = app.iconBitmap;
586 final int w = bmp.getWidth();
587 final int h = bmp.getHeight();
588
Joe Onorato5162ea92009-09-03 09:39:42 -0700589 // We don't really have an accurate location to use. This will do.
Jason Samsb4ecab22010-01-19 16:43:26 -0800590 int screenX = mMotionDownRawX - (w / 2);
591 int screenY = mMotionDownRawY - h;
Joe Onorato5162ea92009-09-03 09:39:42 -0700592
Joe Onoratobcbeab82009-10-01 21:45:43 -0700593 int left = (mDefines.ICON_TEXTURE_WIDTH_PX - mDefines.ICON_WIDTH_PX) / 2;
594 int top = (mDefines.ICON_TEXTURE_HEIGHT_PX - mDefines.ICON_HEIGHT_PX) / 2;
Jason Samsb4ecab22010-01-19 16:43:26 -0800595 mDragController.startDrag(bmp, screenX, screenY,
596 0, 0, w, h, this, app, DragController.DRAG_ACTION_COPY);
Joe Onoratoe3406a22009-09-03 14:36:25 -0700597
Joe Onorato7bb17492009-09-24 17:51:01 -0700598 mLauncher.closeAllApps(true);
Joe Onorato5162ea92009-09-03 09:39:42 -0700599 }
Joe Onorato6665c0f2009-09-02 15:27:24 -0700600 return true;
601 }
602
Joe Onorato52a653f2009-11-11 14:52:11 -0800603 @Override
604 public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
605 if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SELECTED) {
606 if (!isVisible()) {
607 return false;
608 }
609 String text = null;
610 int index;
611 int count = mAllAppsList.size() + 1; // +1 is home
612 int pos = -1;
613 switch (mLastSelection) {
614 case SELECTION_ICONS:
615 index = mRollo.mState.selectedIconIndex;
616 if (index >= 0) {
617 ApplicationInfo info = mAllAppsList.get(index);
618 if (info.title != null) {
619 text = info.title.toString();
620 pos = index;
621 }
622 }
623 break;
624 case SELECTION_HOME:
625 text = getContext().getString(R.string.all_apps_home_button_label);
626 pos = count;
627 break;
628 }
629 if (text != null) {
Joe Onorato52a653f2009-11-11 14:52:11 -0800630 event.setEnabled(true);
631 event.getText().add(text);
632 //event.setContentDescription(text);
633 event.setItemCount(count);
634 event.setCurrentItemIndex(pos);
635 }
636 }
637 return false;
638 }
639
Joe Onorato5162ea92009-09-03 09:39:42 -0700640 public void setDragController(DragController dragger) {
641 mDragController = dragger;
642 }
643
644 public void onDropCompleted(View target, boolean success) {
645 }
646
Joe Onorato4db52312009-10-06 11:17:43 -0700647 /**
Joe Onorato3a8820b2009-11-10 15:06:42 -0800648 * Zoom to the specifed level.
Joe Onorato4db52312009-10-06 11:17:43 -0700649 *
Joe Onorato3a8820b2009-11-10 15:06:42 -0800650 * @param zoom [0..1] 0 is hidden, 1 is open
Joe Onorato4db52312009-10-06 11:17:43 -0700651 */
Joe Onorato3a8820b2009-11-10 15:06:42 -0800652 public void zoom(float zoom, boolean animate) {
Joe Onoratofb0ca672009-09-14 17:55:46 -0400653 cancelLongPress();
Joe Onorato6374c512010-01-06 20:42:25 -0800654 mNextZoom = zoom;
655 mAnimateNextZoom = animate;
656 // if we do setZoom while we don't have a surface, we won't
657 // get the callbacks that actually set mZoom.
658 if (mRollo == null || !mHaveSurface) {
Joe Onorato3a8820b2009-11-10 15:06:42 -0800659 mZoomDirty = true;
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800660 mZoom = zoom;
Joe Onorato3a8820b2009-11-10 15:06:42 -0800661 return;
Joe Onorato85a02a82009-09-08 12:34:22 -0700662 } else {
Joe Onorato3a8820b2009-11-10 15:06:42 -0800663 mRollo.setZoom(zoom, animate);
Joe Onoratoc567acb2009-08-31 14:34:43 -0700664 }
Joe Onoratofb0ca672009-09-14 17:55:46 -0400665 }
666
667 public boolean isVisible() {
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800668 return mZoom > 0.001f;
Joe Onorato3a8820b2009-11-10 15:06:42 -0800669 }
670
671 public boolean isOpaque() {
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800672 return mZoom > 0.999f;
Joe Onoratofb0ca672009-09-14 17:55:46 -0400673 }
Joe Onoratoc567acb2009-08-31 14:34:43 -0700674
Joe Onorato9c1289c2009-08-17 11:03:03 -0400675 public void setApps(ArrayList<ApplicationInfo> list) {
676 mAllAppsList = list;
677 if (mRollo != null) {
Joe Onorato3ecbd812009-12-11 13:38:54 -0800678 mRollo.setApps(list);
Joe Onorato9c1289c2009-08-17 11:03:03 -0400679 }
Joe Onoratofb0ca672009-09-14 17:55:46 -0400680 mLocks &= ~LOCK_ICONS_PENDING;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700681 }
682
Joe Onoratoa8138d52009-10-06 19:25:30 -0700683 public void addApps(ArrayList<ApplicationInfo> list) {
Joe Onorato2d804762009-11-05 16:02:32 -0500684 if (mAllAppsList == null) {
685 // Not done loading yet. We'll find out about it later.
686 return;
687 }
688
Joe Onoratoa8138d52009-10-06 19:25:30 -0700689 final int N = list.size();
Joe Onorato8eea3912009-12-09 13:01:06 -0800690 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700691 mRollo.reallocAppsList(mRollo.mState.iconCount + N);
692 }
693
694 for (int i=0; i<N; i++) {
695 final ApplicationInfo item = list.get(i);
Joe Onoratob0c27f22009-12-01 16:19:38 -0800696 int index = Collections.binarySearch(mAllAppsList, item,
697 LauncherModel.APP_NAME_COMPARATOR);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700698 if (index < 0) {
699 index = -(index+1);
700 }
701 mAllAppsList.add(index, item);
Joe Onorato8eea3912009-12-09 13:01:06 -0800702 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700703 mRollo.addApp(index, item);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700704 }
705 }
706
Joe Onorato8eea3912009-12-09 13:01:06 -0800707 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700708 mRollo.saveAppsList();
709 }
Joe Onoratoc567acb2009-08-31 14:34:43 -0700710 }
711
Joe Onoratoa8138d52009-10-06 19:25:30 -0700712 public void removeApps(ArrayList<ApplicationInfo> list) {
Joe Onorato2d804762009-11-05 16:02:32 -0500713 if (mAllAppsList == null) {
714 // Not done loading yet. We'll find out about it later.
715 return;
716 }
717
Joe Onoratoa8138d52009-10-06 19:25:30 -0700718 final int N = list.size();
719 for (int i=0; i<N; i++) {
720 final ApplicationInfo item = list.get(i);
Joe Onoratocb9f7982009-10-31 16:32:02 -0400721 int index = findAppByComponent(mAllAppsList, item);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700722 if (index >= 0) {
Joe Onoratoa276fc52009-12-08 17:02:02 -0800723 int ic = mRollo != null ? mRollo.mState.iconCount : 666;
Joe Onoratoa8138d52009-10-06 19:25:30 -0700724 mAllAppsList.remove(index);
Joe Onorato8eea3912009-12-09 13:01:06 -0800725 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700726 mRollo.removeApp(index);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700727 }
728 } else {
Joe Onoratoa30ce8e2009-11-11 08:16:49 -0800729 Log.w(TAG, "couldn't find a match for item \"" + item + "\"");
Joe Onoratoa8138d52009-10-06 19:25:30 -0700730 // Try to recover. This should keep us from crashing for now.
731 }
732 }
733
Joe Onorato8eea3912009-12-09 13:01:06 -0800734 if (mRollo != null) {
Joe Onoratoa8138d52009-10-06 19:25:30 -0700735 mRollo.saveAppsList();
736 }
737 }
738
739 public void updateApps(String packageName, ArrayList<ApplicationInfo> list) {
740 // Just remove and add, because they may need to be re-sorted.
741 removeApps(list);
742 addApps(list);
743 }
744
Joe Onoratocb9f7982009-10-31 16:32:02 -0400745 private static int findAppByComponent(ArrayList<ApplicationInfo> list, ApplicationInfo item) {
746 ComponentName component = item.intent.getComponent();
747 final int N = list.size();
748 for (int i=0; i<N; i++) {
749 ApplicationInfo x = list.get(i);
750 if (x.intent.getComponent().equals(component)) {
751 return i;
752 }
Joe Onoratoa8138d52009-10-06 19:25:30 -0700753 }
Joe Onoratocb9f7982009-10-31 16:32:02 -0400754 return -1;
755 }
Joe Onoratoa8138d52009-10-06 19:25:30 -0700756
Joe Onoratoc567acb2009-08-31 14:34:43 -0700757 private static int countPages(int iconCount) {
758 int iconsPerPage = Defines.COLUMNS_PER_PAGE * Defines.ROWS_PER_PAGE;
759 int pages = iconCount / iconsPerPage;
760 if (pages*iconsPerPage != iconCount) {
761 pages++;
762 }
763 return pages;
Joe Onorato9c1289c2009-08-17 11:03:03 -0400764 }
765
Joe Onoratocb75f362009-11-12 13:04:07 -0800766 class AAMessage extends RenderScript.RSMessage {
767 public void run() {
768 mPosX = ((float)mData[0]) / (1 << 16);
769 mVelocity = ((float)mData[1]) / (1 << 16);
770 mZoom = ((float)mData[2]) / (1 << 16);
771 mZoomDirty = false;
772 }
Joe Onoratocb75f362009-11-12 13:04:07 -0800773 }
774
Joe Onorato93839052009-08-06 20:34:32 -0700775 public class RolloRS {
Joe Onoratobf15cb42009-08-07 14:33:40 -0700776
Joe Onorato1feb3a82009-08-08 22:32:00 -0700777 // Allocations ======
Joe Onorato93839052009-08-06 20:34:32 -0700778 private int mWidth;
779 private int mHeight;
780
781 private Resources mRes;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700782 private Script mScript;
783 private Script.Invokable mInvokeMove;
Jason Samsc1c521e2009-10-19 14:45:45 -0700784 private Script.Invokable mInvokeMoveTo;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700785 private Script.Invokable mInvokeFling;
786 private Script.Invokable mInvokeResetWAR;
Joe Onorato3a8820b2009-11-10 15:06:42 -0800787 private Script.Invokable mInvokeSetZoom;
Jason Samsc1c521e2009-10-19 14:45:45 -0700788
Jason Samscd689e12009-09-29 15:28:22 -0700789 private ProgramStore mPSIcons;
Joe Onorato93839052009-08-06 20:34:32 -0700790 private ProgramStore mPSText;
Jason Samscd689e12009-09-29 15:28:22 -0700791 private ProgramFragment mPFColor;
Jason Samsc8514792009-10-29 14:27:29 -0700792 private ProgramFragment mPFTexMip;
Jason Sams6ec11bc2010-01-19 17:56:52 -0800793 private ProgramFragment mPFTexMipAlpha;
Jason Samsc8514792009-10-29 14:27:29 -0700794 private ProgramFragment mPFTexNearest;
Joe Onorato93839052009-08-06 20:34:32 -0700795 private ProgramVertex mPV;
Joe Onorato93839052009-08-06 20:34:32 -0700796 private ProgramVertex mPVOrtho;
Jason Samsb4ecab22010-01-19 16:43:26 -0800797 private ProgramVertex mPVCurve;
Jason Sams0aa71662009-10-02 18:43:18 -0700798 private SimpleMesh mMesh;
Jason Sams5612e432009-11-16 14:18:07 -0800799 private ProgramVertex.MatrixAllocation mPVA;
Joe Onorato93839052009-08-06 20:34:32 -0700800
Jason Samsb4ecab22010-01-19 16:43:26 -0800801 private Allocation mUniformAlloc;
802
Joe Onoratod63458b2009-10-15 21:19:09 -0700803 private Allocation mHomeButtonNormal;
Joe Onoratoeb8325a2009-11-08 13:20:30 -0500804 private Allocation mHomeButtonFocused;
Joe Onoratod63458b2009-10-15 21:19:09 -0700805 private Allocation mHomeButtonPressed;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700806
Joe Onoratobf15cb42009-08-07 14:33:40 -0700807 private Allocation[] mIcons;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700808 private int[] mIconIds;
Joe Onoratoa8138d52009-10-06 19:25:30 -0700809 private Allocation mAllocIconIds;
Joe Onorato93839052009-08-06 20:34:32 -0700810
Joe Onoratobf15cb42009-08-07 14:33:40 -0700811 private Allocation[] mLabels;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700812 private int[] mLabelIds;
Joe Onoratoa8138d52009-10-06 19:25:30 -0700813 private Allocation mAllocLabelIds;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700814 private Allocation mSelectedIcon;
Joe Onorato93839052009-08-06 20:34:32 -0700815
Joe Onorato6665c0f2009-09-02 15:27:24 -0700816 private int[] mTouchYBorders;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700817 private int[] mTouchXBorders;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700818
819 private Bitmap mSelectionBitmap;
Joe Onorato1291a8c2009-09-15 15:07:25 -0400820 private Canvas mSelectionCanvas;
Joe Onorato93839052009-08-06 20:34:32 -0700821
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700822 Params mParams;
Joe Onorato1feb3a82009-08-08 22:32:00 -0700823 State mState;
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700824
Jason Sams78aebd82009-09-15 13:06:59 -0700825 class BaseAlloc {
826 Allocation mAlloc;
827 Type mType;
828
829 void save() {
830 mAlloc.data(this);
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700831 }
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700832 }
833
Jason Sams476339d2009-09-29 18:14:38 -0700834 private boolean checkClickOK() {
Joe Onorato68ba5ca2009-11-12 14:23:43 -0800835 return (Math.abs(mVelocity) < 0.4f) &&
836 (Math.abs(mPosX - Math.round(mPosX)) < 0.4f);
Jason Sams476339d2009-09-29 18:14:38 -0700837 }
838
Jason Sams78aebd82009-09-15 13:06:59 -0700839 class Params extends BaseAlloc {
840 Params() {
841 mType = Type.createFromClass(mRS, Params.class, 1, "ParamsClass");
842 mAlloc = Allocation.createTyped(mRS, mType);
843 save();
Joe Onorato1feb3a82009-08-08 22:32:00 -0700844 }
Jason Sams78aebd82009-09-15 13:06:59 -0700845 public int bubbleWidth;
846 public int bubbleHeight;
847 public int bubbleBitmapWidth;
848 public int bubbleBitmapHeight;
Joe Onoratobcbeab82009-10-01 21:45:43 -0700849
Joe Onoratobcbeab82009-10-01 21:45:43 -0700850 public int homeButtonWidth;
851 public int homeButtonHeight;
852 public int homeButtonTextureWidth;
853 public int homeButtonTextureHeight;
Jason Sams78aebd82009-09-15 13:06:59 -0700854 }
855
856 class State extends BaseAlloc {
Jason Sams86c87ed2009-09-18 13:55:55 -0700857 public float newPositionX;
858 public int newTouchDown;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700859 public float flingVelocity;
Jason Sams78aebd82009-09-15 13:06:59 -0700860 public int iconCount;
Jason Sams78aebd82009-09-15 13:06:59 -0700861 public int selectedIconIndex = -1;
862 public int selectedIconTexture;
Joe Onorato7bb17492009-09-24 17:51:01 -0700863 public float zoomTarget;
Joe Onoratod63458b2009-10-15 21:19:09 -0700864 public int homeButtonId;
Jason Samsc1c521e2009-10-19 14:45:45 -0700865 public float targetPos;
Jason Sams78aebd82009-09-15 13:06:59 -0700866
867 State() {
868 mType = Type.createFromClass(mRS, State.class, 1, "StateClass");
869 mAlloc = Allocation.createTyped(mRS, mType);
870 save();
871 }
Joe Onorato1feb3a82009-08-08 22:32:00 -0700872 }
873
874 public RolloRS() {
875 }
876
877 public void init(Resources res, int width, int height) {
878 mRes = res;
879 mWidth = width;
880 mHeight = height;
Joe Onoratobcbeab82009-10-01 21:45:43 -0700881 mDefines.recompute(width, height);
Jason Samscd689e12009-09-29 15:28:22 -0700882 initProgramVertex();
883 initProgramFragment();
884 initProgramStore();
Jason Samsb4ecab22010-01-19 16:43:26 -0800885 //initMesh();
Joe Onorato1feb3a82009-08-08 22:32:00 -0700886 initGl();
887 initData();
Joe Onorato6665c0f2009-09-02 15:27:24 -0700888 initTouchState();
Joe Onorato1feb3a82009-08-08 22:32:00 -0700889 initRs();
890 }
891
Jason Samsb4ecab22010-01-19 16:43:26 -0800892 public void initMesh2() {
893 SimpleMesh.TriangleMeshBuilder tm = new SimpleMesh.TriangleMeshBuilder(mRS, 2, 0);
Jason Sams0aa71662009-10-02 18:43:18 -0700894
Jason Samsb4ecab22010-01-19 16:43:26 -0800895 for (int ct=0; ct < 16; ct++) {
896 float pos = (1.f / 16.f) * ct;
897 tm.addVertex(0.0f, pos);
898 tm.addVertex(1.0f, pos);
Jason Samsd8152b92009-10-13 17:19:10 -0700899 }
Jason Samsb4ecab22010-01-19 16:43:26 -0800900 for (int ct=0; ct < (16 * 2 - 2); ct+= 2) {
Jason Samsd8152b92009-10-13 17:19:10 -0700901 tm.addTriangle(ct, ct+1, ct+2);
902 tm.addTriangle(ct+1, ct+3, ct+2);
903 }
Jason Samsb4ecab22010-01-19 16:43:26 -0800904 mMesh = tm.create();
905 mMesh.setName("SMCell");
Jason Samsd8152b92009-10-13 17:19:10 -0700906 }
907
Jason Sams5612e432009-11-16 14:18:07 -0800908 void resize(int w, int h) {
909 mPVA.setupProjectionNormalized(w, h);
910 mWidth = w;
911 mHeight = h;
912 }
913
Jason Samscd689e12009-09-29 15:28:22 -0700914 private void initProgramVertex() {
Jason Sams5612e432009-11-16 14:18:07 -0800915 mPVA = new ProgramVertex.MatrixAllocation(mRS);
916 resize(mWidth, mHeight);
Joe Onorato93839052009-08-06 20:34:32 -0700917
918 ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS, null, null);
Jason Sams0aa71662009-10-02 18:43:18 -0700919 pvb.setTextureMatrixEnable(true);
Joe Onorato93839052009-08-06 20:34:32 -0700920 mPV = pvb.create();
921 mPV.setName("PV");
Jason Sams5612e432009-11-16 14:18:07 -0800922 mPV.bindAllocation(mPVA);
Joe Onorato93839052009-08-06 20:34:32 -0700923
Jason Samsb4ecab22010-01-19 16:43:26 -0800924 Element.Builder eb = new Element.Builder(mRS);
925 eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 2), "ImgSize");
926 eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 4), "Position");
Jason Sams66ed54e2010-02-04 12:39:27 -0800927 eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 2), "BendPos");
928 eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 4), "ScaleOffset");
Jason Samsb4ecab22010-01-19 16:43:26 -0800929 Element e = eb.create();
930
931 mUniformAlloc = Allocation.createSized(mRS, e, 1);
932
933 initMesh2();
934 ProgramVertex.ShaderBuilder sb = new ProgramVertex.ShaderBuilder(mRS);
935 String t = new String("void main() {\n" +
936 // Animation
937 " float ani = UNI_Position.z;\n" +
938
Jason Sams66ed54e2010-02-04 12:39:27 -0800939 " float bendAngle = 47.0 * (3.14 / 180.0);\n" +
940 " float bendDistance = 50.0;\n" +
941 " float bendY1 = UNI_BendPos.x;\n" +
942 " float bendY2 = UNI_BendPos.y;\n" +
943 " float distanceDimLevel = 0.6;\n" +
944
945 " float bendStep = (bendAngle / bendDistance) * (bendAngle * 0.5);\n" +
946 " float aDy = cos(bendAngle);\n" +
947 " float aDz = sin(bendAngle);\n" +
948
Jason Samsb4ecab22010-01-19 16:43:26 -0800949 " float scale = (2.0 / 480.0);\n" +
950 " float x = UNI_Position.x + UNI_ImgSize.x * (1.0 - ani) * (ATTRIB_position.x - 0.5);\n" +
951 " float ys= UNI_Position.y + UNI_ImgSize.y * (1.0 - ani) * ATTRIB_position.y;\n" +
952 " float y = 0.0;\n" +
953 " float z = 0.0;\n" +
954 " float lum = 1.0;\n" +
955
Jason Sams66ed54e2010-02-04 12:39:27 -0800956 " float cv = min(ys, bendY1 - bendDistance) - (bendY1 - bendDistance);\n" +
957 " y += cv * aDy;\n" +
958 " z += -cv * aDz;\n" +
959 " cv = clamp(ys, bendY1 - bendDistance, bendY1) - bendY1;\n" + // curve range
960 " lum += cv / bendDistance * distanceDimLevel;\n" +
961 " y += cv * cos(cv * bendStep);\n" +
962 " z += cv * sin(cv * bendStep);\n" +
Jason Samsb4ecab22010-01-19 16:43:26 -0800963
Jason Sams66ed54e2010-02-04 12:39:27 -0800964 " cv = max(ys, bendY2 + bendDistance) - (bendY2 + bendDistance);\n" +
965 " y += cv * aDy;\n" +
966 " z += cv * aDz;\n" +
967 " cv = clamp(ys, bendY2, bendY2 + bendDistance) - bendY2;\n" +
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 " y += clamp(ys, bendY1, bendY2);\n" +
Jason Samsb4ecab22010-01-19 16:43:26 -0800973
974 " vec4 pos;\n" +
Jason Sams66ed54e2010-02-04 12:39:27 -0800975 " pos.x = (x + UNI_ScaleOffset.z) * UNI_ScaleOffset.x;\n" +
976 " pos.y = (y + UNI_ScaleOffset.w) * UNI_ScaleOffset.x;\n" +
977 " pos.z = z * UNI_ScaleOffset.x;\n" +
Jason Samsb4ecab22010-01-19 16:43:26 -0800978 " pos.w = 1.0;\n" +
979
980 " pos.x *= 1.0 + ani * 4.0;\n" +
981 " pos.y *= 1.0 + ani * 4.0;\n" +
982 " pos.z -= ani * 1.5;\n" +
983 " lum *= 1.0 - ani;\n" +
984
985 " gl_Position = UNI_MVP * pos;\n" +
986 " varColor.rgba = vec4(lum, lum, lum, 1.0);\n" +
987 " varTex0.xy = ATTRIB_position;\n" +
988 " varTex0.y = 1.0 - varTex0.y;\n" +
989 " varTex0.zw = vec2(0.0, 0.0);\n" +
990 "}\n");
991 sb.setShader(t);
992 sb.addConstant(mUniformAlloc.getType());
993 sb.addInput(mMesh.getVertexType(0).getElement());
994 mPVCurve = sb.create();
995 mPVCurve.setName("PVCurve");
996 mPVCurve.bindAllocation(mPVA);
997 mPVCurve.bindConstants(mUniformAlloc, 1);
998
Jason Sams66ed54e2010-02-04 12:39:27 -0800999 float tf[] = new float[] {72.f, 72.f,
1000 120.f, 120.f, 0.f, 0.f,
1001 120.f, 680.f,
1002 (2.f / 480.f), 0, -240.f, -380.f};
Jason Samsb4ecab22010-01-19 16:43:26 -08001003 mUniformAlloc.data(tf);
1004
Jason Sams37e7c2b2009-10-19 12:55:43 -07001005 //pva = new ProgramVertex.MatrixAllocation(mRS);
1006 //pva.setupOrthoWindow(mWidth, mHeight);
1007 //pvb.setTextureMatrixEnable(true);
1008 //mPVOrtho = pvb.create();
1009 //mPVOrtho.setName("PVOrtho");
1010 //mPVOrtho.bindAllocation(pva);
Joe Onorato93839052009-08-06 20:34:32 -07001011
1012 mRS.contextBindProgramVertex(mPV);
Jason Samscd689e12009-09-29 15:28:22 -07001013 }
Joe Onorato93839052009-08-06 20:34:32 -07001014
Jason Samscd689e12009-09-29 15:28:22 -07001015 private void initProgramFragment() {
1016 Sampler.Builder sb = new Sampler.Builder(mRS);
Jason Samsc8514792009-10-29 14:27:29 -07001017 sb.setMin(Sampler.Value.LINEAR_MIP_LINEAR);
Jason Samsb4ecab22010-01-19 16:43:26 -08001018 sb.setMag(Sampler.Value.NEAREST);
Jason Samscd689e12009-09-29 15:28:22 -07001019 sb.setWrapS(Sampler.Value.CLAMP);
1020 sb.setWrapT(Sampler.Value.CLAMP);
1021 Sampler linear = sb.create();
1022
1023 sb.setMin(Sampler.Value.NEAREST);
1024 sb.setMag(Sampler.Value.NEAREST);
1025 Sampler nearest = sb.create();
1026
Jason Sams72f1d312009-12-17 16:58:25 -08001027 ProgramFragment.Builder bf = new ProgramFragment.Builder(mRS);
Jason Sams37e7c2b2009-10-19 12:55:43 -07001028 //mPFColor = bf.create();
1029 //mPFColor.setName("PFColor");
Jason Samscd689e12009-09-29 15:28:22 -07001030
Jason Samsb4ecab22010-01-19 16:43:26 -08001031 bf.setTexture(ProgramFragment.Builder.EnvMode.MODULATE,
Jason Sams72f1d312009-12-17 16:58:25 -08001032 ProgramFragment.Builder.Format.RGBA, 0);
Jason Samsc8514792009-10-29 14:27:29 -07001033 mPFTexMip = bf.create();
1034 mPFTexMip.setName("PFTexMip");
1035 mPFTexMip.bindSampler(linear, 0);
1036
1037 mPFTexNearest = bf.create();
1038 mPFTexNearest.setName("PFTexNearest");
1039 mPFTexNearest.bindSampler(nearest, 0);
Jason Sams6ec11bc2010-01-19 17:56:52 -08001040
1041 bf.setTexture(ProgramFragment.Builder.EnvMode.MODULATE,
1042 ProgramFragment.Builder.Format.ALPHA, 0);
1043 mPFTexMipAlpha = bf.create();
1044 mPFTexMipAlpha.setName("PFTexMipAlpha");
1045 mPFTexMipAlpha.bindSampler(linear, 0);
1046
Jason Samscd689e12009-09-29 15:28:22 -07001047 }
1048
1049 private void initProgramStore() {
1050 ProgramStore.Builder bs = new ProgramStore.Builder(mRS, null, null);
1051 bs.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
Jason Sams12c14a82009-10-06 14:33:15 -07001052 bs.setColorMask(true,true,true,false);
Jason Samscd689e12009-09-29 15:28:22 -07001053 bs.setDitherEnable(true);
1054 bs.setBlendFunc(ProgramStore.BlendSrcFunc.SRC_ALPHA,
1055 ProgramStore.BlendDstFunc.ONE_MINUS_SRC_ALPHA);
1056 mPSIcons = bs.create();
1057 mPSIcons.setName("PSIcons");
1058
1059 //bs.setDitherEnable(false);
1060 //mPSText = bs.create();
1061 //mPSText.setName("PSText");
1062 }
1063
1064 private void initGl() {
Joe Onorato6665c0f2009-09-02 15:27:24 -07001065 mTouchXBorders = new int[Defines.COLUMNS_PER_PAGE+1];
Joe Onorato6665c0f2009-09-02 15:27:24 -07001066 mTouchYBorders = new int[Defines.ROWS_PER_PAGE+1];
Joe Onoratobf15cb42009-08-07 14:33:40 -07001067 }
Jason Sams78aebd82009-09-15 13:06:59 -07001068
Joe Onorato1feb3a82009-08-08 22:32:00 -07001069 private void initData() {
Jason Sams78aebd82009-09-15 13:06:59 -07001070 mParams = new Params();
1071 mState = new State();
Joe Onorato43e7bcf2009-08-08 18:53:53 -07001072
Joe Onoratobf15cb42009-08-07 14:33:40 -07001073 final Utilities.BubbleText bubble = new Utilities.BubbleText(getContext());
Joe Onorato93839052009-08-06 20:34:32 -07001074
Joe Onorato43e7bcf2009-08-08 18:53:53 -07001075 mParams.bubbleWidth = bubble.getBubbleWidth();
1076 mParams.bubbleHeight = bubble.getMaxBubbleHeight();
1077 mParams.bubbleBitmapWidth = bubble.getBitmapWidth();
1078 mParams.bubbleBitmapHeight = bubble.getBitmapHeight();
Joe Onorato43e7bcf2009-08-08 18:53:53 -07001079
Joe Onoratod63458b2009-10-15 21:19:09 -07001080 mHomeButtonNormal = Allocation.createFromBitmapResource(mRS, mRes,
1081 R.drawable.home_button_normal, Element.RGBA_8888(mRS), false);
1082 mHomeButtonNormal.uploadToTexture(0);
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001083 mHomeButtonFocused = Allocation.createFromBitmapResource(mRS, mRes,
1084 R.drawable.home_button_focused, Element.RGBA_8888(mRS), false);
1085 mHomeButtonFocused.uploadToTexture(0);
Joe Onoratod63458b2009-10-15 21:19:09 -07001086 mHomeButtonPressed = Allocation.createFromBitmapResource(mRS, mRes,
1087 R.drawable.home_button_pressed, Element.RGBA_8888(mRS), false);
1088 mHomeButtonPressed.uploadToTexture(0);
Joe Onoratobcbeab82009-10-01 21:45:43 -07001089 mParams.homeButtonWidth = 76;
1090 mParams.homeButtonHeight = 68;
1091 mParams.homeButtonTextureWidth = 128;
1092 mParams.homeButtonTextureHeight = 128;
Joe Onoratoc567acb2009-08-31 14:34:43 -07001093
Joe Onoratod63458b2009-10-15 21:19:09 -07001094 mState.homeButtonId = mHomeButtonNormal.getID();
1095
Joe Onorato1feb3a82009-08-08 22:32:00 -07001096 mParams.save();
1097 mState.save();
Joe Onorato9c1289c2009-08-17 11:03:03 -04001098
Jason Sams1a94ee32010-01-20 13:34:30 -08001099 mSelectionBitmap = Bitmap.createBitmap(Defines.SELECTION_TEXTURE_WIDTH_PX,
1100 Defines.SELECTION_TEXTURE_HEIGHT_PX, Bitmap.Config.ARGB_8888);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001101 mSelectionCanvas = new Canvas(mSelectionBitmap);
Joe Onorato6665c0f2009-09-02 15:27:24 -07001102
Joe Onorato9c1289c2009-08-17 11:03:03 -04001103 setApps(null);
Joe Onorato93839052009-08-06 20:34:32 -07001104 }
1105
Jason Sams37e7c2b2009-10-19 12:55:43 -07001106 private void initScript(int id) {
1107 }
1108
1109 private void initRs() {
Joe Onorato93839052009-08-06 20:34:32 -07001110 ScriptC.Builder sb = new ScriptC.Builder(mRS);
Jason Samsd15f3ef2010-01-06 14:58:06 -08001111 sb.setScript(mRes, R.raw.allapps);
Joe Onorato93839052009-08-06 20:34:32 -07001112 sb.setRoot(true);
Joe Onoratobcbeab82009-10-01 21:45:43 -07001113 sb.addDefines(mDefines);
Jason Sams78aebd82009-09-15 13:06:59 -07001114 sb.setType(mParams.mType, "params", Defines.ALLOC_PARAMS);
1115 sb.setType(mState.mType, "state", Defines.ALLOC_STATE);
Jason Samsb4ecab22010-01-19 16:43:26 -08001116 sb.setType(mUniformAlloc.getType(), "vpConstants", Defines.ALLOC_VP_CONSTANTS);
Jason Sams37e7c2b2009-10-19 12:55:43 -07001117 mInvokeMove = sb.addInvokable("move");
1118 mInvokeFling = sb.addInvokable("fling");
Jason Samsc1c521e2009-10-19 14:45:45 -07001119 mInvokeMoveTo = sb.addInvokable("moveTo");
Jason Sams37e7c2b2009-10-19 12:55:43 -07001120 mInvokeResetWAR = sb.addInvokable("resetHWWar");
Joe Onorato3a8820b2009-11-10 15:06:42 -08001121 mInvokeSetZoom = sb.addInvokable("setZoom");
Jason Sams37e7c2b2009-10-19 12:55:43 -07001122 mScript = sb.create();
1123 mScript.setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
1124 mScript.bindAllocation(mParams.mAlloc, Defines.ALLOC_PARAMS);
1125 mScript.bindAllocation(mState.mAlloc, Defines.ALLOC_STATE);
1126 mScript.bindAllocation(mAllocIconIds, Defines.ALLOC_ICON_IDS);
1127 mScript.bindAllocation(mAllocLabelIds, Defines.ALLOC_LABEL_IDS);
Jason Samsb4ecab22010-01-19 16:43:26 -08001128 mScript.bindAllocation(mUniformAlloc, Defines.ALLOC_VP_CONSTANTS);
Joe Onorato93839052009-08-06 20:34:32 -07001129
Jason Sams37e7c2b2009-10-19 12:55:43 -07001130 mRS.contextBindRootScript(mScript);
Joe Onorato93839052009-08-06 20:34:32 -07001131 }
Joe Onorato93839052009-08-06 20:34:32 -07001132
Jason Sams20df7c72009-11-05 12:30:24 -08001133 void dirtyCheck() {
Jason Sams510ee042009-12-15 14:23:37 -08001134 if (mZoomDirty) {
Joe Onorato6374c512010-01-06 20:42:25 -08001135 setZoom(mNextZoom, mAnimateNextZoom);
Jason Sams20df7c72009-11-05 12:30:24 -08001136 }
1137 }
1138
Joe Onorato9c1289c2009-08-17 11:03:03 -04001139 private void setApps(ArrayList<ApplicationInfo> list) {
1140 final int count = list != null ? list.size() : 0;
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001141 int allocCount = count;
Joe Onoratoa8138d52009-10-06 19:25:30 -07001142 if (allocCount < 1) {
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001143 allocCount = 1;
1144 }
1145
Joe Onorato9c1289c2009-08-17 11:03:03 -04001146 mIcons = new Allocation[count];
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001147 mIconIds = new int[allocCount];
Joe Onoratoa8138d52009-10-06 19:25:30 -07001148 mAllocIconIds = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001149
1150 mLabels = new Allocation[count];
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001151 mLabelIds = new int[allocCount];
Joe Onoratoa8138d52009-10-06 19:25:30 -07001152 mAllocLabelIds = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001153
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001154 Element ie8888 = Element.RGBA_8888(mRS);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001155
Joe Onorato9c1289c2009-08-17 11:03:03 -04001156 mState.iconCount = count;
Joe Onorato8eea3912009-12-09 13:01:06 -08001157 for (int i=0; i < mState.iconCount; i++) {
1158 createAppIconAllocations(i, list.get(i));
Joe Onorato3ecbd812009-12-11 13:38:54 -08001159 }
Jason Sams510ee042009-12-15 14:23:37 -08001160 for (int i=0; i < mState.iconCount; i++) {
1161 uploadAppIcon(i, list.get(i));
Joe Onorato8eea3912009-12-09 13:01:06 -08001162 }
Joe Onoratoa8138d52009-10-06 19:25:30 -07001163 saveAppsList();
1164 }
1165
Joe Onorato3a8820b2009-11-10 15:06:42 -08001166 private void setZoom(float zoom, boolean animate) {
1167 mRollo.clearSelectedIcon();
1168 mRollo.setHomeSelected(SELECTED_NONE);
1169 if (zoom > 0.001f) {
1170 mRollo.mState.zoomTarget = zoom;
1171 } else {
1172 mRollo.mState.zoomTarget = 0;
1173 }
1174 mRollo.mState.save();
1175 if (!animate) {
1176 mRollo.mInvokeSetZoom.execute();
1177 }
1178 }
1179
Joe Onorato8eea3912009-12-09 13:01:06 -08001180 private void createAppIconAllocations(int index, ApplicationInfo item) {
Joe Onoratoa8138d52009-10-06 19:25:30 -07001181 mIcons[index] = Allocation.createFromBitmap(mRS, item.iconBitmap,
Jason Samsc8514792009-10-29 14:27:29 -07001182 Element.RGBA_8888(mRS), true);
Joe Onoratoa8138d52009-10-06 19:25:30 -07001183 mLabels[index] = Allocation.createFromBitmap(mRS, item.titleBitmap,
Jason Sams6ec11bc2010-01-19 17:56:52 -08001184 Element.A_8(mRS), true);
Joe Onoratoa8138d52009-10-06 19:25:30 -07001185 mIconIds[index] = mIcons[index].getID();
1186 mLabelIds[index] = mLabels[index].getID();
1187 }
1188
Joe Onorato8eea3912009-12-09 13:01:06 -08001189 private void uploadAppIcon(int index, ApplicationInfo item) {
1190 if (mIconIds[index] != mIcons[index].getID()) {
1191 throw new IllegalStateException("uploadAppIcon index=" + index
1192 + " mIcons[index].getID=" + mIcons[index].getID()
1193 + " mIconsIds[index]=" + mIconIds[index]
1194 + " item=" + item);
1195 }
1196 mIcons[index].uploadToTexture(0);
1197 mLabels[index].uploadToTexture(0);
1198 }
1199
Joe Onoratoa8138d52009-10-06 19:25:30 -07001200 /**
1201 * Puts the empty spaces at the end. Updates mState.iconCount. You must
1202 * fill in the values and call saveAppsList().
1203 */
1204 private void reallocAppsList(int count) {
1205 Allocation[] icons = new Allocation[count];
1206 int[] iconIds = new int[count];
1207 mAllocIconIds = Allocation.createSized(mRS, Element.USER_I32(mRS), count);
1208
1209 Allocation[] labels = new Allocation[count];
1210 int[] labelIds = new int[count];
1211 mAllocLabelIds = Allocation.createSized(mRS, Element.USER_I32(mRS), count);
1212
Joe Onoratobf173f12009-12-08 13:29:38 -08001213 final int oldCount = mRollo.mState.iconCount;
Joe Onoratoa8138d52009-10-06 19:25:30 -07001214
1215 System.arraycopy(mIcons, 0, icons, 0, oldCount);
1216 System.arraycopy(mIconIds, 0, iconIds, 0, oldCount);
1217 System.arraycopy(mLabels, 0, labels, 0, oldCount);
1218 System.arraycopy(mLabelIds, 0, labelIds, 0, oldCount);
1219
1220 mIcons = icons;
1221 mIconIds = iconIds;
1222 mLabels = labels;
1223 mLabelIds = labelIds;
1224 }
1225
1226 /**
1227 * Handle the allocations for the new app. Make sure you call saveAppsList when done.
1228 */
1229 private void addApp(int index, ApplicationInfo item) {
1230 final int count = mState.iconCount - index;
1231 final int dest = index + 1;
1232
1233 System.arraycopy(mIcons, index, mIcons, dest, count);
1234 System.arraycopy(mIconIds, index, mIconIds, dest, count);
1235 System.arraycopy(mLabels, index, mLabels, dest, count);
1236 System.arraycopy(mLabelIds, index, mLabelIds, dest, count);
1237
Joe Onorato8eea3912009-12-09 13:01:06 -08001238 createAppIconAllocations(index, item);
Jason Sams510ee042009-12-15 14:23:37 -08001239 uploadAppIcon(index, item);
Joe Onorato8eea3912009-12-09 13:01:06 -08001240 mRollo.mState.iconCount++;
Joe Onoratoa8138d52009-10-06 19:25:30 -07001241 }
1242
1243 /**
1244 * Handle the allocations for the removed app. Make sure you call saveAppsList when done.
1245 */
1246 private void removeApp(int index) {
1247 final int count = mState.iconCount - index - 1;
1248 final int src = index + 1;
1249
1250 System.arraycopy(mIcons, src, mIcons, index, count);
1251 System.arraycopy(mIconIds, src, mIconIds, index, count);
1252 System.arraycopy(mLabels, src, mLabels, index, count);
1253 System.arraycopy(mLabelIds, src, mLabelIds, index, count);
1254
Joe Onoratoa276fc52009-12-08 17:02:02 -08001255 mRollo.mState.iconCount--;
Joe Onorato8eea3912009-12-09 13:01:06 -08001256 final int last = mState.iconCount;
Joe Onoratoa276fc52009-12-08 17:02:02 -08001257
Joe Onoratoa8138d52009-10-06 19:25:30 -07001258 mIcons[last] = null;
1259 mIconIds[last] = 0;
1260 mLabels[last] = null;
1261 mLabelIds[last] = 0;
1262 }
1263
1264 /**
1265 * Send the apps list structures to RS.
1266 */
1267 private void saveAppsList() {
1268 mRS.contextBindRootScript(null);
Jason Samsd8152b92009-10-13 17:19:10 -07001269
Joe Onoratoa8138d52009-10-06 19:25:30 -07001270 mAllocIconIds.data(mIconIds);
1271 mAllocLabelIds.data(mLabelIds);
1272
Jason Sams37e7c2b2009-10-19 12:55:43 -07001273 if (mScript != null) { // this happens when we init it
1274 mScript.bindAllocation(mAllocIconIds, Defines.ALLOC_ICON_IDS);
1275 mScript.bindAllocation(mAllocLabelIds, Defines.ALLOC_LABEL_IDS);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001276 }
1277
1278 mState.save();
Joe Onoratoa8138d52009-10-06 19:25:30 -07001279
1280 // Note: mScript may be null if we haven't initialized it yet.
1281 // In that case, this is a no-op.
Jason Sams37e7c2b2009-10-19 12:55:43 -07001282 if (mInvokeResetWAR != null) {
1283 mInvokeResetWAR.execute();
Jason Sams41b61c82009-10-15 15:40:54 -07001284 }
Joe Onoratob8315542010-02-03 20:39:25 -08001285 if (mScript != null) {
1286 mRS.contextBindRootScript(mScript);
1287 }
Joe Onorato9c1289c2009-08-17 11:03:03 -04001288 }
Joe Onorato6665c0f2009-09-02 15:27:24 -07001289
1290 void initTouchState() {
1291 int width = getWidth();
1292 int height = getHeight();
Jason Sams37e7c2b2009-10-19 12:55:43 -07001293 int cellHeight = 145;//iconsSize / Defines.ROWS_PER_PAGE;
1294 int cellWidth = width / Defines.COLUMNS_PER_PAGE;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001295
Jason Sams37e7c2b2009-10-19 12:55:43 -07001296 int centerY = (height / 2);
1297 mTouchYBorders[0] = centerY - (cellHeight * 2);
1298 mTouchYBorders[1] = centerY - cellHeight;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001299 mTouchYBorders[2] = centerY;
Jason Sams37e7c2b2009-10-19 12:55:43 -07001300 mTouchYBorders[3] = centerY + cellHeight;
1301 mTouchYBorders[4] = centerY + (cellHeight * 2);
Jason Sams78aebd82009-09-15 13:06:59 -07001302
Joe Onorato6665c0f2009-09-02 15:27:24 -07001303 int centerX = (width / 2);
Jason Sams37e7c2b2009-10-19 12:55:43 -07001304 mTouchXBorders[0] = 0;
1305 mTouchXBorders[1] = centerX - (width / 4);
Joe Onorato6665c0f2009-09-02 15:27:24 -07001306 mTouchXBorders[2] = centerX;
Jason Sams37e7c2b2009-10-19 12:55:43 -07001307 mTouchXBorders[3] = centerX + (width / 4);
1308 mTouchXBorders[4] = width;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001309 }
1310
Joe Onorato664457d2009-10-28 16:30:34 -04001311 void fling() {
1312 mInvokeFling.execute();
1313 }
1314
1315 void move() {
1316 mInvokeMove.execute();
1317 }
1318
1319 void moveTo(float row) {
1320 mState.targetPos = row;
1321 mState.save();
1322 mInvokeMoveTo.execute();
1323 }
1324
Jason Sams37e7c2b2009-10-19 12:55:43 -07001325 int chooseTappedIcon(int x, int y, float pos) {
1326 // Adjust for scroll position if not zero.
1327 y += (pos - ((int)pos)) * (mTouchYBorders[1] - mTouchYBorders[0]);
Jason Sams86c87ed2009-09-18 13:55:55 -07001328
Joe Onorato6665c0f2009-09-02 15:27:24 -07001329 int col = -1;
1330 int row = -1;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001331 for (int i=0; i<Defines.COLUMNS_PER_PAGE; i++) {
1332 if (x >= mTouchXBorders[i] && x < mTouchXBorders[i+1]) {
1333 col = i;
1334 break;
1335 }
1336 }
1337 for (int i=0; i<Defines.ROWS_PER_PAGE; i++) {
1338 if (y >= mTouchYBorders[i] && y < mTouchYBorders[i+1]) {
1339 row = i;
1340 break;
1341 }
1342 }
1343
1344 if (row < 0 || col < 0) {
1345 return -1;
1346 }
1347
Joe Onorato664457d2009-10-28 16:30:34 -04001348 int index = (((int)pos) * Defines.COLUMNS_PER_PAGE)
Joe Onorato6665c0f2009-09-02 15:27:24 -07001349 + (row * Defines.ROWS_PER_PAGE) + col;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001350
Joe Onorato664457d2009-10-28 16:30:34 -04001351 if (index >= mState.iconCount) {
1352 return -1;
1353 } else {
1354 return index;
1355 }
Jason Samsc1c521e2009-10-19 14:45:45 -07001356 }
1357
Joe Onorato6665c0f2009-09-02 15:27:24 -07001358 /**
1359 * You need to call save() on mState on your own after calling this.
Joe Onorato82ca5502009-10-15 16:59:23 -07001360 *
1361 * @return the index of the icon that was selected.
Joe Onorato6665c0f2009-09-02 15:27:24 -07001362 */
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001363 int selectIcon(int x, int y, float pos, int pressed) {
Joe Onorato82ca5502009-10-15 16:59:23 -07001364 final int index = chooseTappedIcon(x, y, pos);
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001365 selectIcon(index, pressed);
Joe Onorato82ca5502009-10-15 16:59:23 -07001366 return index;
Joe Onorato1291a8c2009-09-15 15:07:25 -04001367 }
1368
Joe Onoratoc61cff92009-11-08 11:54:39 -05001369 /**
1370 * Select the icon at the given index.
1371 *
1372 * @param index The index.
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001373 * @param pressed one of SELECTED_PRESSED or SELECTED_FOCUSED
Joe Onoratoc61cff92009-11-08 11:54:39 -05001374 */
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001375 void selectIcon(int index, int pressed) {
Joe Onorato2d804762009-11-05 16:02:32 -05001376 if (mAllAppsList == null || index < 0 || index >= mAllAppsList.size()) {
Joe Onorato6665c0f2009-09-02 15:27:24 -07001377 mState.selectedIconIndex = -1;
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001378 if (mLastSelection == SELECTION_ICONS) {
1379 mLastSelection = SELECTION_NONE;
1380 }
Joe Onorato6665c0f2009-09-02 15:27:24 -07001381 } else {
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001382 if (pressed == SELECTED_FOCUSED) {
1383 mLastSelection = SELECTION_ICONS;
1384 }
1385
Joe Onorato52a653f2009-11-11 14:52:11 -08001386 int prev = mState.selectedIconIndex;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001387 mState.selectedIconIndex = index;
Joe Onorato1291a8c2009-09-15 15:07:25 -04001388
Joe Onorato52a653f2009-11-11 14:52:11 -08001389 ApplicationInfo info = mAllAppsList.get(index);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001390 Bitmap selectionBitmap = mSelectionBitmap;
1391
1392 Utilities.drawSelectedAllAppsBitmap(mSelectionCanvas,
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001393 selectionBitmap.getWidth(), selectionBitmap.getHeight(),
Joe Onorato52a653f2009-11-11 14:52:11 -08001394 pressed == SELECTED_PRESSED, info.iconBitmap);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001395
1396 mSelectedIcon = Allocation.createFromBitmap(mRS, selectionBitmap,
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001397 Element.RGBA_8888(mRS), false);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001398 mSelectedIcon.uploadToTexture(0);
1399 mState.selectedIconTexture = mSelectedIcon.getID();
Joe Onorato52a653f2009-11-11 14:52:11 -08001400
1401 if (prev != index) {
1402 if (info.title != null && info.title.length() > 0) {
Joe Onorato52a653f2009-11-11 14:52:11 -08001403 //setContentDescription(info.title);
1404 sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
1405 }
1406 }
Joe Onorato6665c0f2009-09-02 15:27:24 -07001407 }
1408 }
1409
1410 /**
1411 * You need to call save() on mState on your own after calling this.
1412 */
1413 void clearSelectedIcon() {
Joe Onorato2ca51dc2009-09-16 11:44:14 -04001414 mState.selectedIconIndex = -1;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001415 }
Joe Onoratoa8138d52009-10-06 19:25:30 -07001416
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001417 void setHomeSelected(int mode) {
Joe Onorato52a653f2009-11-11 14:52:11 -08001418 final int prev = mLastSelection;
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001419 switch (mode) {
1420 case SELECTED_NONE:
Joe Onoratod63458b2009-10-15 21:19:09 -07001421 mState.homeButtonId = mHomeButtonNormal.getID();
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001422 break;
1423 case SELECTED_FOCUSED:
1424 mLastSelection = SELECTION_HOME;
1425 mState.homeButtonId = mHomeButtonFocused.getID();
Joe Onorato52a653f2009-11-11 14:52:11 -08001426 if (prev != SELECTION_HOME) {
Joe Onorato52a653f2009-11-11 14:52:11 -08001427 sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
1428 }
Joe Onoratoeb8325a2009-11-08 13:20:30 -05001429 break;
1430 case SELECTED_PRESSED:
1431 mState.homeButtonId = mHomeButtonPressed.getID();
1432 break;
Joe Onoratod63458b2009-10-15 21:19:09 -07001433 }
1434 }
Joe Onoratobe386092009-11-17 17:32:16 -08001435
1436 public void dumpState() {
1437 Log.d(TAG, "mRollo.mWidth=" + mWidth);
1438 Log.d(TAG, "mRollo.mHeight=" + mHeight);
1439 Log.d(TAG, "mRollo.mIcons=" + mIcons);
1440 if (mIcons != null) {
1441 Log.d(TAG, "mRollo.mIcons.length=" + mIcons.length);
1442 }
1443 if (mIconIds != null) {
1444 Log.d(TAG, "mRollo.mIconIds.length=" + mIconIds.length);
1445 }
1446 Log.d(TAG, "mRollo.mIconIds=" + Arrays.toString(mIconIds));
1447 if (mLabelIds != null) {
1448 Log.d(TAG, "mRollo.mLabelIds.length=" + mLabelIds.length);
1449 }
1450 Log.d(TAG, "mRollo.mLabelIds=" + Arrays.toString(mLabelIds));
1451 Log.d(TAG, "mRollo.mTouchXBorders=" + Arrays.toString(mTouchXBorders));
1452 Log.d(TAG, "mRollo.mTouchYBorders=" + Arrays.toString(mTouchYBorders));
Joe Onoratobe386092009-11-17 17:32:16 -08001453 Log.d(TAG, "mRollo.mState.newPositionX=" + mState.newPositionX);
1454 Log.d(TAG, "mRollo.mState.newTouchDown=" + mState.newTouchDown);
1455 Log.d(TAG, "mRollo.mState.flingVelocity=" + mState.flingVelocity);
1456 Log.d(TAG, "mRollo.mState.iconCount=" + mState.iconCount);
1457 Log.d(TAG, "mRollo.mState.selectedIconIndex=" + mState.selectedIconIndex);
1458 Log.d(TAG, "mRollo.mState.selectedIconTexture=" + mState.selectedIconTexture);
1459 Log.d(TAG, "mRollo.mState.zoomTarget=" + mState.zoomTarget);
1460 Log.d(TAG, "mRollo.mState.homeButtonId=" + mState.homeButtonId);
1461 Log.d(TAG, "mRollo.mState.targetPos=" + mState.targetPos);
1462 Log.d(TAG, "mRollo.mParams.bubbleWidth=" + mParams.bubbleWidth);
1463 Log.d(TAG, "mRollo.mParams.bubbleHeight=" + mParams.bubbleHeight);
1464 Log.d(TAG, "mRollo.mParams.bubbleBitmapWidth=" + mParams.bubbleBitmapWidth);
1465 Log.d(TAG, "mRollo.mParams.bubbleBitmapHeight=" + mParams.bubbleBitmapHeight);
1466 Log.d(TAG, "mRollo.mParams.homeButtonWidth=" + mParams.homeButtonWidth);
1467 Log.d(TAG, "mRollo.mParams.homeButtonHeight=" + mParams.homeButtonHeight);
1468 Log.d(TAG, "mRollo.mParams.homeButtonTextureWidth=" + mParams.homeButtonTextureWidth);
1469 Log.d(TAG, "mRollo.mParams.homeButtonTextureHeight=" + mParams.homeButtonTextureHeight);
1470 }
1471 }
1472
1473 public void dumpState() {
1474 Log.d(TAG, "mRS=" + mRS);
1475 Log.d(TAG, "mRollo=" + mRollo);
1476 ApplicationInfo.dumpApplicationInfoList(TAG, "mAllAppsList", mAllAppsList);
1477 Log.d(TAG, "mArrowNavigation=" + mArrowNavigation);
1478 Log.d(TAG, "mStartedScrolling=" + mStartedScrolling);
1479 Log.d(TAG, "mLastSelection=" + mLastSelection);
1480 Log.d(TAG, "mLastSelectedIcon=" + mLastSelectedIcon);
1481 Log.d(TAG, "mVelocityTracker=" + mVelocityTracker);
1482 Log.d(TAG, "mTouchTracking=" + mTouchTracking);
1483 Log.d(TAG, "mShouldGainFocus=" + mShouldGainFocus);
1484 Log.d(TAG, "mZoomDirty=" + mZoomDirty);
1485 Log.d(TAG, "mAnimateNextZoom=" + mAnimateNextZoom);
1486 Log.d(TAG, "mZoom=" + mZoom);
1487 Log.d(TAG, "mPosX=" + mPosX);
1488 Log.d(TAG, "mVelocity=" + mVelocity);
1489 Log.d(TAG, "mMessageProc=" + mMessageProc);
1490 if (mRollo != null) {
1491 mRollo.dumpState();
1492 }
1493 if (mRS != null) {
1494 mRS.contextDump(0);
1495 }
Joe Onorato9c1289c2009-08-17 11:03:03 -04001496 }
Joe Onorato93839052009-08-06 20:34:32 -07001497}
1498
1499