blob: 5a315dd787ad51d1053078e2f528781ea223c115 [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;
Mike Cleron4a5c1e12009-11-03 10:17:05 -080049
50import java.util.ArrayList;
51import java.util.Collections;
52import java.util.Comparator;
Joe Onorato93839052009-08-06 20:34:32 -070053
54
Joe Onorato6665c0f2009-09-02 15:27:24 -070055public class AllAppsView extends RSSurfaceView
Joe Onorato5162ea92009-09-03 09:39:42 -070056 implements View.OnClickListener, View.OnLongClickListener, DragSource {
Joe Onorato9c1289c2009-08-17 11:03:03 -040057 private static final String TAG = "Launcher.AllAppsView";
58
Joe Onoratofb0ca672009-09-14 17:55:46 -040059 /** Bit for mLocks for when there are icons being loaded. */
60 private static final int LOCK_ICONS_PENDING = 1;
61
Joe Onorato68ffd102009-10-15 17:59:43 -070062 private static final int TRACKING_NONE = 0;
63 private static final int TRACKING_FLING = 1;
64 private static final int TRACKING_HOME = 2;
Joe Onoratobcbeab82009-10-01 21:45:43 -070065
Joe Onorato6665c0f2009-09-02 15:27:24 -070066 private Launcher mLauncher;
Joe Onorato5162ea92009-09-03 09:39:42 -070067 private DragController mDragController;
Joe Onoratofb0ca672009-09-14 17:55:46 -040068
69 /** When this is 0, modifications are allowed, when it's not, they're not.
70 * TODO: What about scrolling? */
71 private int mLocks = LOCK_ICONS_PENDING;
Joe Onorato6665c0f2009-09-02 15:27:24 -070072
Joe Onorato82ca5502009-10-15 16:59:23 -070073 private int mSlop;
Joe Onoratof7b0e012009-10-01 14:09:15 -070074 private int mMaxFlingVelocity;
75
Joe Onoratobcbeab82009-10-01 21:45:43 -070076 private Defines mDefines = new Defines();
Joe Onorato1feb3a82009-08-08 22:32:00 -070077 private RenderScript mRS;
78 private RolloRS mRollo;
Joe Onorato9c1289c2009-08-17 11:03:03 -040079 private ArrayList<ApplicationInfo> mAllAppsList;
Jason Sams2e19c052009-10-20 18:19:55 -070080
Mike Cleron7d5d7462009-10-20 14:06:00 -070081 /**
82 * True when we are using arrow keys or trackball to drive navigation
83 */
84 private boolean mArrowNavigation = false;
Jason Sams2e19c052009-10-20 18:19:55 -070085
Mike Cleron4a5c1e12009-11-03 10:17:05 -080086 /**
87 * Used to keep track of the selection when AllAppsView loses window focus
88 */
89 private int mLastSelectedIcon;
90
Joe Onorato6665c0f2009-09-02 15:27:24 -070091 private boolean mStartedScrolling;
Joe Onoratod769a632009-08-11 17:09:02 -070092 private VelocityTracker mVelocity;
Joe Onoratobcbeab82009-10-01 21:45:43 -070093 private int mTouchTracking;
Joe Onorato5162ea92009-09-03 09:39:42 -070094 private int mMotionDownRawX;
95 private int mMotionDownRawY;
Joe Onorato82ca5502009-10-15 16:59:23 -070096 private int mDownIconIndex = -1;
97 private int mCurrentIconIndex = -1;
Mike Cleron4a5c1e12009-11-03 10:17:05 -080098
Joe Onorato1feb3a82009-08-08 22:32:00 -070099
Joe Onorato6665c0f2009-09-02 15:27:24 -0700100 static class Defines {
Joe Onoratoc567acb2009-08-31 14:34:43 -0700101 public static final int ALLOC_PARAMS = 0;
102 public static final int ALLOC_STATE = 1;
Joe Onorato7bb17492009-09-24 17:51:01 -0700103 public static final int ALLOC_ICON_IDS = 3;
104 public static final int ALLOC_LABEL_IDS = 4;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700105
106 public static final int COLUMNS_PER_PAGE = 4;
107 public static final int ROWS_PER_PAGE = 4;
Jason Sams78aebd82009-09-15 13:06:59 -0700108
Joe Onorato6665c0f2009-09-02 15:27:24 -0700109 public static final int ICON_WIDTH_PX = 64;
110 public static final int ICON_TEXTURE_WIDTH_PX = 128;
111
112 public static final int ICON_HEIGHT_PX = 64;
113 public static final int ICON_TEXTURE_HEIGHT_PX = 128;
Joe Onoratobcbeab82009-10-01 21:45:43 -0700114
115 public int SCREEN_WIDTH_PX;
116 public int SCREEN_HEIGHT_PX;
117
Joe Onoratobcbeab82009-10-01 21:45:43 -0700118 public void recompute(int w, int h) {
119 SCREEN_WIDTH_PX = 480;
120 SCREEN_HEIGHT_PX = 800;
Joe Onoratobcbeab82009-10-01 21:45:43 -0700121 }
Joe Onoratoc567acb2009-08-31 14:34:43 -0700122 }
Joe Onorato7c312c12009-08-13 21:36:53 -0700123
124 public AllAppsView(Context context, AttributeSet attrs) {
125 super(context, attrs);
Joe Onorato93839052009-08-06 20:34:32 -0700126 setFocusable(true);
Joe Onoratob39e51a2009-10-28 15:47:49 -0400127 setSoundEffectsEnabled(false);
Joe Onorato93839052009-08-06 20:34:32 -0700128 getHolder().setFormat(PixelFormat.TRANSLUCENT);
Joe Onoratof7b0e012009-10-01 14:09:15 -0700129 final ViewConfiguration config = ViewConfiguration.get(context);
Joe Onorato82ca5502009-10-15 16:59:23 -0700130 mSlop = config.getScaledTouchSlop();
Joe Onoratof7b0e012009-10-01 14:09:15 -0700131 mMaxFlingVelocity = config.getScaledMaximumFlingVelocity();
132
Joe Onorato6665c0f2009-09-02 15:27:24 -0700133 setOnClickListener(this);
134 setOnLongClickListener(this);
Dianne Hackborne52a1b52009-09-30 22:36:20 -0700135 setZOrderOnTop(true);
Jason Samsfd22dac2009-09-20 17:24:16 -0700136 getHolder().setFormat(PixelFormat.TRANSLUCENT);
Joe Onorato93839052009-08-06 20:34:32 -0700137 }
138
Joe Onoratob39e51a2009-10-28 15:47:49 -0400139 /**
140 * If you have an attached click listener, View always plays the click sound!?!?
141 * Deal with sound effects by hand.
142 */
143 public void reallyPlaySoundEffect(int sound) {
144 boolean old = isSoundEffectsEnabled();
145 setSoundEffectsEnabled(true);
146 playSoundEffect(sound);
147 setSoundEffectsEnabled(old);
148 }
149
Joe Onorato7c312c12009-08-13 21:36:53 -0700150 public AllAppsView(Context context, AttributeSet attrs, int defStyle) {
151 this(context, attrs);
Joe Onorato93839052009-08-06 20:34:32 -0700152 }
153
Joe Onorato6665c0f2009-09-02 15:27:24 -0700154 public void setLauncher(Launcher launcher) {
155 mLauncher = launcher;
Joe Onorato93839052009-08-06 20:34:32 -0700156 }
157
Joe Onorato1feb3a82009-08-08 22:32:00 -0700158 @Override
Joe Onorato7bb17492009-09-24 17:51:01 -0700159 public void surfaceDestroyed(SurfaceHolder holder) {
160 super.surfaceDestroyed(holder);
Jason Sams20df7c72009-11-05 12:30:24 -0800161 mRollo.mHasSurface = false;
Joe Onorato7bb17492009-09-24 17:51:01 -0700162 }
163
164 @Override
Joe Onorato93839052009-08-06 20:34:32 -0700165 public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
Joe Onorato080d9b62009-11-02 12:01:11 -0500166 Log.d(TAG, "starting surfaceChanged");
Joe Onorato6665c0f2009-09-02 15:27:24 -0700167 long startTime = SystemClock.uptimeMillis();
168
Joe Onorato080d9b62009-11-02 12:01:11 -0500169 super.surfaceChanged(holder, format, w, h);
170
Jason Sams90396672009-11-03 13:59:34 -0800171 if (mRS == null) {
Jason Sams81134792009-10-27 15:38:42 -0700172
Jason Sams90396672009-11-03 13:59:34 -0800173 mRS = createRenderScript(true);
174 mRollo = new RolloRS();
Jason Sams20df7c72009-11-05 12:30:24 -0800175 mRollo.mHasSurface = true;
Jason Sams90396672009-11-03 13:59:34 -0800176 mRollo.init(getResources(), w, h);
177 if (mAllAppsList != null) {
178 mRollo.setApps(mAllAppsList);
179 Log.d(TAG, "surfaceChanged... calling mRollo.setApps");
180 }
Jason Sams20df7c72009-11-05 12:30:24 -0800181 } else {
182 mRollo.mHasSurface = true;
183 mRollo.dirtyCheck();
Joe Onorato9c1289c2009-08-17 11:03:03 -0400184 }
Joe Onoratoc567acb2009-08-31 14:34:43 -0700185
186 Resources res = getContext().getResources();
187 int barHeight = (int)res.getDimension(R.dimen.button_bar_height);
Joe Onorato6665c0f2009-09-02 15:27:24 -0700188
189 long endTime = SystemClock.uptimeMillis();
190 Log.d(TAG, "surfaceChanged took " + (endTime-startTime) + "ms");
Joe Onorato93839052009-08-06 20:34:32 -0700191 }
Jason Sams2e19c052009-10-20 18:19:55 -0700192
Joe Onorato93839052009-08-06 20:34:32 -0700193 @Override
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800194 public void onWindowFocusChanged(boolean hasWindowFocus) {
195 super.onWindowFocusChanged(hasWindowFocus);
196 if (mArrowNavigation) {
197 if (!hasWindowFocus) {
198 // Clear selection when we lose window focus
199 mLastSelectedIcon = mRollo.mState.selectedIconIndex;
200 mRollo.clearSelectedIcon();
201 mRollo.mState.save();
202 } else if (hasWindowFocus) {
203 if (mRollo.mState.iconCount > 0) {
204 int selection = mLastSelectedIcon;
205 final int firstIcon = Math.round(mRollo.mMessageProc.mPosX) *
206 Defines.COLUMNS_PER_PAGE;
207 if (selection < 0 || // No selection
208 selection < firstIcon || // off the top of the screen
209 selection >= mRollo.mState.iconCount || // past last icon
210 selection >= firstIcon + // past last icon on screen
211 (Defines.COLUMNS_PER_PAGE * Defines.ROWS_PER_PAGE)) {
212 selection = firstIcon;
213 }
214
215 // Select the first icon when we gain window focus
216 mRollo.selectIcon(selection);
217 mRollo.mState.save();
218 }
219 }
220 }
221 }
222
223 @Override
Mike Cleron7d5d7462009-10-20 14:06:00 -0700224 protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
225 super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
Joe Onorato859b3a72009-10-28 15:17:01 -0400226
227 if (!isVisible()) {
228 return;
229 }
230
Mike Cleron7d5d7462009-10-20 14:06:00 -0700231 if (gainFocus) {
232 if (!mArrowNavigation && mRollo.mState.iconCount > 0) {
233 // Select the first icon when we gain keyboard focus
234 mArrowNavigation = true;
235 mRollo.selectIcon(Math.round(mRollo.mMessageProc.mPosX) * Defines.COLUMNS_PER_PAGE);
236 mRollo.mState.save();
237 }
238 } else {
239 if (mArrowNavigation) {
240 // Clear selection when we lose focus
241 mRollo.clearSelectedIcon();
242 mRollo.mState.save();
243 mArrowNavigation = false;
244 }
245 }
246 }
247
248 @Override
249 public boolean onKeyDown(int keyCode, KeyEvent event) {
Jason Sams2e19c052009-10-20 18:19:55 -0700250
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800251 boolean handled = false;
252
Joe Onorato859b3a72009-10-28 15:17:01 -0400253 if (!isVisible()) {
254 return false;
255 }
256
Joe Onoratoa13f5742009-11-02 17:15:19 -0500257 final int iconCount = mRollo.mState.iconCount;
258
Mike Cleron7d5d7462009-10-20 14:06:00 -0700259 if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
260 if (mArrowNavigation) {
261 int whichApp = mRollo.mState.selectedIconIndex;
262 if (whichApp >= 0) {
263 ApplicationInfo app = mAllAppsList.get(whichApp);
264 mLauncher.startActivitySafely(app.intent);
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800265 handled = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700266 }
267 }
268 }
Jason Sams2e19c052009-10-20 18:19:55 -0700269
Joe Onoratoa13f5742009-11-02 17:15:19 -0500270 if (mArrowNavigation && iconCount > 0) {
Mike Cleron7d5d7462009-10-20 14:06:00 -0700271 mArrowNavigation = true;
Jason Sams2e19c052009-10-20 18:19:55 -0700272
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800273 int currentSelection = mRollo.mState.selectedIconIndex;
274 int currentTopRow = Math.round(mRollo.mMessageProc.mPosX);
Jason Sams2e19c052009-10-20 18:19:55 -0700275
Mike Cleron7d5d7462009-10-20 14:06:00 -0700276 // The column of the current selection, in the range 0..COLUMNS_PER_PAGE-1
Joe Onoratoa13f5742009-11-02 17:15:19 -0500277 final int currentPageCol = currentSelection % Defines.COLUMNS_PER_PAGE;
Jason Sams2e19c052009-10-20 18:19:55 -0700278
Mike Cleron7d5d7462009-10-20 14:06:00 -0700279 // The row of the current selection, in the range 0..ROWS_PER_PAGE-1
Joe Onoratoa13f5742009-11-02 17:15:19 -0500280 final int currentPageRow = (currentSelection - (currentTopRow*Defines.COLUMNS_PER_PAGE))
Mike Cleron7d5d7462009-10-20 14:06:00 -0700281 / Defines.ROWS_PER_PAGE;
Jason Sams2e19c052009-10-20 18:19:55 -0700282
Mike Cleron7d5d7462009-10-20 14:06:00 -0700283 int newSelection = currentSelection;
284
285 switch (keyCode) {
286 case KeyEvent.KEYCODE_DPAD_UP:
287 if (currentPageRow > 0) {
288 newSelection = currentSelection - Defines.COLUMNS_PER_PAGE;
289 } else if (currentTopRow > 0) {
Jason Sams2e19c052009-10-20 18:19:55 -0700290 newSelection = currentSelection - Defines.COLUMNS_PER_PAGE;
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800291 mRollo.moveTo(newSelection / Defines.COLUMNS_PER_PAGE);
Mike Cleron7d5d7462009-10-20 14:06:00 -0700292 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800293 handled = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700294 break;
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800295
Joe Onoratoa13f5742009-11-02 17:15:19 -0500296 case KeyEvent.KEYCODE_DPAD_DOWN: {
297 final int rowCount = iconCount / Defines.COLUMNS_PER_PAGE
298 + (iconCount % Defines.COLUMNS_PER_PAGE == 0 ? 0 : 1);
299 final int currentRow = currentSelection / Defines.COLUMNS_PER_PAGE;
300 if (currentRow < rowCount-1) {
301 newSelection = currentSelection + Defines.COLUMNS_PER_PAGE;
302 if (newSelection >= iconCount) {
303 // Go from D to G in this arrangement:
304 // A B C D
305 // E F G
306 newSelection = iconCount - 1;
307 }
308 if (currentPageRow >= Defines.ROWS_PER_PAGE - 1) {
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800309 mRollo.moveTo((newSelection / Defines.COLUMNS_PER_PAGE) -
310 Defines.ROWS_PER_PAGE + 1);
Mike Cleron7d5d7462009-10-20 14:06:00 -0700311 }
312 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800313 handled = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700314 break;
Joe Onoratoa13f5742009-11-02 17:15:19 -0500315 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700316 case KeyEvent.KEYCODE_DPAD_LEFT:
317 if (currentPageCol > 0) {
318 newSelection = currentSelection - 1;
319 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800320 handled = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700321 break;
322 case KeyEvent.KEYCODE_DPAD_RIGHT:
Jason Sams2e19c052009-10-20 18:19:55 -0700323 if ((currentPageCol < Defines.COLUMNS_PER_PAGE - 1) &&
Joe Onoratoa13f5742009-11-02 17:15:19 -0500324 (currentSelection < iconCount - 1)) {
Mike Cleron7d5d7462009-10-20 14:06:00 -0700325 newSelection = currentSelection + 1;
326 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800327 handled = true;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700328 break;
329 }
330 if (newSelection != currentSelection) {
331 mRollo.selectIcon(newSelection);
332 mRollo.mState.save();
333 }
334 }
Mike Cleron4a5c1e12009-11-03 10:17:05 -0800335 return handled;
Joe Onorato93839052009-08-06 20:34:32 -0700336 }
337
Joe Onorato93839052009-08-06 20:34:32 -0700338 @Override
339 public boolean onTouchEvent(MotionEvent ev)
340 {
Mike Cleron7d5d7462009-10-20 14:06:00 -0700341 mArrowNavigation = false;
Jason Sams2e19c052009-10-20 18:19:55 -0700342
Joe Onorato7bb17492009-09-24 17:51:01 -0700343 if (!isVisible()) {
Joe Onorato85a02a82009-09-08 12:34:22 -0700344 return true;
Joe Onoratoe3406a22009-09-03 14:36:25 -0700345 }
346
Joe Onoratofb0ca672009-09-14 17:55:46 -0400347 if (mLocks != 0) {
Joe Onorato85a02a82009-09-08 12:34:22 -0700348 return true;
349 }
350
351 super.onTouchEvent(ev);
352
Joe Onoratofb0ca672009-09-14 17:55:46 -0400353 int x = (int)ev.getX();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700354 int y = (int)ev.getY();
355
Joe Onoratobcbeab82009-10-01 21:45:43 -0700356 int action = ev.getAction();
357 switch (action) {
Joe Onoratofb0ca672009-09-14 17:55:46 -0400358 case MotionEvent.ACTION_DOWN:
Joe Onoratobcbeab82009-10-01 21:45:43 -0700359 if (y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]) {
360 mTouchTracking = TRACKING_HOME;
Joe Onoratod63458b2009-10-15 21:19:09 -0700361 mRollo.setHomeSelected(true);
362 mRollo.mState.save();
Mike Cleron7d5d7462009-10-20 14:06:00 -0700363 mCurrentIconIndex = -1;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700364 } else {
Joe Onoratobcbeab82009-10-01 21:45:43 -0700365 mTouchTracking = TRACKING_FLING;
366
367 mMotionDownRawX = (int)ev.getRawX();
368 mMotionDownRawY = (int)ev.getRawY();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700369
Mike Cleron7d5d7462009-10-20 14:06:00 -0700370 mRollo.mState.newPositionX = ev.getRawY() / getHeight();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700371 mRollo.mState.newTouchDown = 1;
372
373 if (!mRollo.checkClickOK()) {
374 mRollo.clearSelectedIcon();
375 } else {
Joe Onorato82ca5502009-10-15 16:59:23 -0700376 mDownIconIndex = mCurrentIconIndex
377 = mRollo.selectIcon(x, y, mRollo.mMessageProc.mPosX);
378 if (mDownIconIndex < 0) {
379 // if nothing was selected, no long press.
380 cancelLongPress();
381 }
Joe Onoratobcbeab82009-10-01 21:45:43 -0700382 }
383 mRollo.mState.save();
Jason Samsd8152b92009-10-13 17:19:10 -0700384 mRollo.move();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700385 mVelocity = VelocityTracker.obtain();
386 mVelocity.addMovement(ev);
387 mStartedScrolling = false;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700388 }
Joe Onoratofb0ca672009-09-14 17:55:46 -0400389 break;
390 case MotionEvent.ACTION_MOVE:
391 case MotionEvent.ACTION_OUTSIDE:
Joe Onoratobcbeab82009-10-01 21:45:43 -0700392 if (mTouchTracking == TRACKING_HOME) {
Joe Onoratod63458b2009-10-15 21:19:09 -0700393 mRollo.setHomeSelected(y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]);
394 mRollo.mState.save();
Joe Onorato68ffd102009-10-15 17:59:43 -0700395 } else if (mTouchTracking == TRACKING_FLING) {
Joe Onorato82ca5502009-10-15 16:59:23 -0700396 int rawX = (int)ev.getRawX();
397 int rawY = (int)ev.getRawY();
398 int slop;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700399 slop = Math.abs(rawY - mMotionDownRawY);
Jason Samsd8152b92009-10-13 17:19:10 -0700400
Joe Onorato82ca5502009-10-15 16:59:23 -0700401 if (!mStartedScrolling && slop < mSlop) {
402 // don't update anything so when we do start scrolling
Joe Onoratobcbeab82009-10-01 21:45:43 -0700403 // below, we get the right delta.
Joe Onorato82ca5502009-10-15 16:59:23 -0700404 mCurrentIconIndex = mRollo.chooseTappedIcon(x, y, mRollo.mMessageProc.mPosX);
405 if (mDownIconIndex != mCurrentIconIndex) {
406 // If a different icon is selected, don't allow it to be picked up.
407 // This handles off-axis dragging.
408 cancelLongPress();
409 mCurrentIconIndex = -1;
410 }
Joe Onoratobcbeab82009-10-01 21:45:43 -0700411 } else {
Joe Onorato82ca5502009-10-15 16:59:23 -0700412 if (!mStartedScrolling) {
413 cancelLongPress();
414 mCurrentIconIndex = -1;
415 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700416 mRollo.mState.newPositionX = ev.getRawY() / getHeight();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700417 mRollo.mState.newTouchDown = 1;
Jason Samsd8152b92009-10-13 17:19:10 -0700418 mRollo.move();
Jason Sams86c87ed2009-09-18 13:55:55 -0700419
Joe Onoratobcbeab82009-10-01 21:45:43 -0700420 mStartedScrolling = true;
421 mRollo.clearSelectedIcon();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700422 mVelocity.addMovement(ev);
423 mRollo.mState.save();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700424 }
Joe Onoratofb0ca672009-09-14 17:55:46 -0400425 }
426 break;
427 case MotionEvent.ACTION_UP:
428 case MotionEvent.ACTION_CANCEL:
Joe Onoratobcbeab82009-10-01 21:45:43 -0700429 if (mTouchTracking == TRACKING_HOME) {
430 if (action == MotionEvent.ACTION_UP) {
431 if (y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]) {
Joe Onoratob39e51a2009-10-28 15:47:49 -0400432 reallyPlaySoundEffect(SoundEffectConstants.CLICK);
Joe Onoratobcbeab82009-10-01 21:45:43 -0700433 mLauncher.closeAllApps(true);
434 }
Joe Onoratod63458b2009-10-15 21:19:09 -0700435 mRollo.setHomeSelected(false);
436 mRollo.mState.save();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700437 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700438 mCurrentIconIndex = -1;
Joe Onorato68ffd102009-10-15 17:59:43 -0700439 } else if (mTouchTracking == TRACKING_FLING) {
Joe Onoratobcbeab82009-10-01 21:45:43 -0700440 mRollo.mState.newTouchDown = 0;
Mike Cleron7d5d7462009-10-20 14:06:00 -0700441 mRollo.mState.newPositionX = ev.getRawY() / getHeight();
Jason Sams476339d2009-09-29 18:14:38 -0700442
Jason Sams12c14a82009-10-06 14:33:15 -0700443 mVelocity.computeCurrentVelocity(1000 /* px/sec */, mMaxFlingVelocity);
Jason Sams37e7c2b2009-10-19 12:55:43 -0700444 mRollo.mState.flingVelocity = mVelocity.getYVelocity() / getHeight();
Jason Sams12c14a82009-10-06 14:33:15 -0700445 mRollo.clearSelectedIcon();
446 mRollo.mState.save();
Jason Samsd8152b92009-10-13 17:19:10 -0700447 mRollo.fling();
Joe Onoratobcbeab82009-10-01 21:45:43 -0700448
Joe Onorato539ed9d2009-10-02 10:22:14 -0700449 if (mVelocity != null) {
450 mVelocity.recycle();
451 mVelocity = null;
452 }
Joe Onoratobcbeab82009-10-01 21:45:43 -0700453 }
Joe Onorato68ffd102009-10-15 17:59:43 -0700454 mTouchTracking = TRACKING_NONE;
455 break;
Joe Onorato93839052009-08-06 20:34:32 -0700456 }
Joe Onorato6665c0f2009-09-02 15:27:24 -0700457
458 return true;
Joe Onorato93839052009-08-06 20:34:32 -0700459 }
460
Joe Onorato6665c0f2009-09-02 15:27:24 -0700461 public void onClick(View v) {
Joe Onorato7bb17492009-09-24 17:51:01 -0700462 if (mLocks != 0 || !isVisible()) {
Joe Onoratofb0ca672009-09-14 17:55:46 -0400463 return;
464 }
Joe Onorato82ca5502009-10-15 16:59:23 -0700465 if (mRollo.checkClickOK() && mCurrentIconIndex == mDownIconIndex
466 && mCurrentIconIndex >= 0 && mCurrentIconIndex < mAllAppsList.size()) {
Joe Onoratob39e51a2009-10-28 15:47:49 -0400467 reallyPlaySoundEffect(SoundEffectConstants.CLICK);
Joe Onorato82ca5502009-10-15 16:59:23 -0700468 ApplicationInfo app = mAllAppsList.get(mCurrentIconIndex);
Joe Onorato6665c0f2009-09-02 15:27:24 -0700469 mLauncher.startActivitySafely(app.intent);
470 }
471 }
472
473 public boolean onLongClick(View v) {
Joe Onorato7bb17492009-09-24 17:51:01 -0700474 if (mLocks != 0 || !isVisible()) {
Joe Onoratofb0ca672009-09-14 17:55:46 -0400475 return true;
476 }
Joe Onorato82ca5502009-10-15 16:59:23 -0700477 if (mRollo.checkClickOK() && mCurrentIconIndex == mDownIconIndex
478 && mCurrentIconIndex >= 0 && mCurrentIconIndex < mAllAppsList.size()) {
479 ApplicationInfo app = mAllAppsList.get(mCurrentIconIndex);
Joe Onorato5162ea92009-09-03 09:39:42 -0700480
481 // We don't really have an accurate location to use. This will do.
Joe Onoratobcbeab82009-10-01 21:45:43 -0700482 int screenX = mMotionDownRawX - (mDefines.ICON_WIDTH_PX / 2);
483 int screenY = mMotionDownRawY - mDefines.ICON_HEIGHT_PX;
Joe Onorato5162ea92009-09-03 09:39:42 -0700484
Joe Onoratobcbeab82009-10-01 21:45:43 -0700485 int left = (mDefines.ICON_TEXTURE_WIDTH_PX - mDefines.ICON_WIDTH_PX) / 2;
486 int top = (mDefines.ICON_TEXTURE_HEIGHT_PX - mDefines.ICON_HEIGHT_PX) / 2;
Joe Onorato5162ea92009-09-03 09:39:42 -0700487 mDragController.startDrag(app.iconBitmap, screenX, screenY,
Joe Onoratobcbeab82009-10-01 21:45:43 -0700488 left, top, mDefines.ICON_WIDTH_PX, mDefines.ICON_HEIGHT_PX,
Joe Onorato5162ea92009-09-03 09:39:42 -0700489 this, app, DragController.DRAG_ACTION_COPY);
Joe Onoratoe3406a22009-09-03 14:36:25 -0700490
Joe Onorato7bb17492009-09-24 17:51:01 -0700491 mLauncher.closeAllApps(true);
Joe Onorato5162ea92009-09-03 09:39:42 -0700492 }
Joe Onorato6665c0f2009-09-02 15:27:24 -0700493 return true;
494 }
495
Joe Onorato5162ea92009-09-03 09:39:42 -0700496 public void setDragController(DragController dragger) {
497 mDragController = dragger;
498 }
499
500 public void onDropCompleted(View target, boolean success) {
501 }
502
Joe Onorato4db52312009-10-06 11:17:43 -0700503 /**
504 * Zoom to the specifed amount.
505 *
506 * @param amount [0..1] 0 is hidden, 1 is open
Joe Onorato4db52312009-10-06 11:17:43 -0700507 */
Jason Sams12c14a82009-10-06 14:33:15 -0700508 public void zoom(float amount) {
Joe Onorato7bb17492009-09-24 17:51:01 -0700509 if (mRollo == null) {
510 return;
511 }
512
Joe Onoratofb0ca672009-09-14 17:55:46 -0400513 cancelLongPress();
Joe Onoratofb0ca672009-09-14 17:55:46 -0400514 mRollo.clearSelectedIcon();
Joe Onorato1d708e72009-10-15 21:29:21 -0700515 mRollo.setHomeSelected(false);
Joe Onorato85a02a82009-09-08 12:34:22 -0700516 if (amount > 0.001f) {
Joe Onoratoc5acd422009-10-01 14:21:24 -0700517 // set in readback, so we're correct even before the next frame
Jason Sams12c14a82009-10-06 14:33:15 -0700518 mRollo.mState.zoomTarget = amount;
Joe Onorato85a02a82009-09-08 12:34:22 -0700519 } else {
Joe Onorato7bb17492009-09-24 17:51:01 -0700520 mRollo.mState.zoomTarget = 0;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700521 }
Joe Onoratofb0ca672009-09-14 17:55:46 -0400522 mRollo.mState.save();
Joe Onoratofb0ca672009-09-14 17:55:46 -0400523 }
524
525 public boolean isVisible() {
Joe Onorato7bb17492009-09-24 17:51:01 -0700526 if (mRollo == null) {
527 return false;
528 }
Jason Sams12c14a82009-10-06 14:33:15 -0700529 return mRollo.mMessageProc.mZoom > 0.001f;
Joe Onoratofb0ca672009-09-14 17:55:46 -0400530 }
Joe Onoratoc567acb2009-08-31 14:34:43 -0700531
Mike Cleronb6082fa02009-10-19 17:03:36 -0700532 /*
Joe Onorato93839052009-08-06 20:34:32 -0700533 @Override
534 public boolean onTrackballEvent(MotionEvent ev)
535 {
536 float x = ev.getX();
537 float y = ev.getY();
538 //Float tx = new Float(x);
539 //Float ty = new Float(y);
540 //Log.e("rs", "tbe " + tx.toString() + ", " + ty.toString());
541
542
543 return true;
544 }
Mike Cleronb6082fa02009-10-19 17:03:36 -0700545 */
Joe Onorato93839052009-08-06 20:34:32 -0700546
Joe Onorato9c1289c2009-08-17 11:03:03 -0400547 public void setApps(ArrayList<ApplicationInfo> list) {
548 mAllAppsList = list;
549 if (mRollo != null) {
550 mRollo.setApps(list);
551 }
Joe Onoratofb0ca672009-09-14 17:55:46 -0400552 mLocks &= ~LOCK_ICONS_PENDING;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700553 }
554
Joe Onoratoa8138d52009-10-06 19:25:30 -0700555 public void addApps(ArrayList<ApplicationInfo> list) {
556 final int N = list.size();
557 if (mRollo != null) {
558 mRollo.reallocAppsList(mRollo.mState.iconCount + N);
559 }
560
561 for (int i=0; i<N; i++) {
562 final ApplicationInfo item = list.get(i);
563 int index = Collections.binarySearch(mAllAppsList, item, mAppNameComp);
564 if (index < 0) {
565 index = -(index+1);
566 }
Joe Onorato0ace11a2009-11-05 15:41:27 -0500567 Log.d(TAG, "Adding app '" + item + "' at index " + index + " mRollo=" + mRollo);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700568 mAllAppsList.add(index, item);
569 if (mRollo != null) {
570 mRollo.addApp(index, item);
571 mRollo.mState.iconCount++;
572 }
573 }
574
575 if (mRollo != null) {
576 mRollo.saveAppsList();
577 }
Joe Onoratoc567acb2009-08-31 14:34:43 -0700578 }
579
Joe Onoratoa8138d52009-10-06 19:25:30 -0700580 public void removeApps(ArrayList<ApplicationInfo> list) {
581 final int N = list.size();
582 for (int i=0; i<N; i++) {
583 final ApplicationInfo item = list.get(i);
Joe Onoratocb9f7982009-10-31 16:32:02 -0400584 int index = findAppByComponent(mAllAppsList, item);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700585 if (index >= 0) {
586 mAllAppsList.remove(index);
587 if (mRollo != null) {
588 mRollo.removeApp(index);
589 mRollo.mState.iconCount--;
590 }
591 } else {
592 Log.e(TAG, "couldn't find a match for item \"" + item + "\"");
593 // Try to recover. This should keep us from crashing for now.
594 }
595 }
596
597 if (mRollo != null) {
598 mRollo.saveAppsList();
599 }
600 }
601
602 public void updateApps(String packageName, ArrayList<ApplicationInfo> list) {
603 // Just remove and add, because they may need to be re-sorted.
604 removeApps(list);
605 addApps(list);
606 }
607
608 private Comparator<ApplicationInfo> mAppNameComp = new Comparator<ApplicationInfo>() {
609 public int compare(ApplicationInfo a, ApplicationInfo b) {
610 int result = a.title.toString().compareTo(b.toString());
611 if (result != 0) {
612 return result;
613 }
614 return a.intent.getComponent().compareTo(b.intent.getComponent());
615 }
616 };
617
Joe Onoratocb9f7982009-10-31 16:32:02 -0400618 private static int findAppByComponent(ArrayList<ApplicationInfo> list, ApplicationInfo item) {
619 ComponentName component = item.intent.getComponent();
620 final int N = list.size();
621 for (int i=0; i<N; i++) {
622 ApplicationInfo x = list.get(i);
623 if (x.intent.getComponent().equals(component)) {
624 return i;
625 }
Joe Onoratoa8138d52009-10-06 19:25:30 -0700626 }
Joe Onoratocb9f7982009-10-31 16:32:02 -0400627 return -1;
628 }
Joe Onoratoa8138d52009-10-06 19:25:30 -0700629
Joe Onoratoc567acb2009-08-31 14:34:43 -0700630 private static int countPages(int iconCount) {
631 int iconsPerPage = Defines.COLUMNS_PER_PAGE * Defines.ROWS_PER_PAGE;
632 int pages = iconCount / iconsPerPage;
633 if (pages*iconsPerPage != iconCount) {
634 pages++;
635 }
636 return pages;
Joe Onorato9c1289c2009-08-17 11:03:03 -0400637 }
638
Joe Onorato93839052009-08-06 20:34:32 -0700639 public class RolloRS {
Joe Onoratobf15cb42009-08-07 14:33:40 -0700640
Joe Onorato1feb3a82009-08-08 22:32:00 -0700641 // Allocations ======
Joe Onorato93839052009-08-06 20:34:32 -0700642 private int mWidth;
643 private int mHeight;
644
645 private Resources mRes;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700646 private Script mScript;
647 private Script.Invokable mInvokeMove;
Jason Samsc1c521e2009-10-19 14:45:45 -0700648 private Script.Invokable mInvokeMoveTo;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700649 private Script.Invokable mInvokeFling;
650 private Script.Invokable mInvokeResetWAR;
Jason Sams86c87ed2009-09-18 13:55:55 -0700651
Jason Samsc1c521e2009-10-19 14:45:45 -0700652
Jason Samscd689e12009-09-29 15:28:22 -0700653 private ProgramStore mPSIcons;
Joe Onorato93839052009-08-06 20:34:32 -0700654 private ProgramStore mPSText;
Jason Samscd689e12009-09-29 15:28:22 -0700655 private ProgramFragment mPFColor;
Jason Samsc8514792009-10-29 14:27:29 -0700656 private ProgramFragment mPFTexMip;
657 private ProgramFragment mPFTexNearest;
Joe Onorato93839052009-08-06 20:34:32 -0700658 private ProgramVertex mPV;
Joe Onorato93839052009-08-06 20:34:32 -0700659 private ProgramVertex mPVOrtho;
Jason Sams0aa71662009-10-02 18:43:18 -0700660 private SimpleMesh mMesh;
Jason Samsd8152b92009-10-13 17:19:10 -0700661 private SimpleMesh mMesh2;
Joe Onorato93839052009-08-06 20:34:32 -0700662
Joe Onoratod63458b2009-10-15 21:19:09 -0700663 private Allocation mHomeButtonNormal;
664 private Allocation mHomeButtonPressed;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700665
Joe Onoratobf15cb42009-08-07 14:33:40 -0700666 private Allocation[] mIcons;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700667 private int[] mIconIds;
Joe Onoratoa8138d52009-10-06 19:25:30 -0700668 private Allocation mAllocIconIds;
Joe Onorato93839052009-08-06 20:34:32 -0700669
Joe Onoratobf15cb42009-08-07 14:33:40 -0700670 private Allocation[] mLabels;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700671 private int[] mLabelIds;
Joe Onoratoa8138d52009-10-06 19:25:30 -0700672 private Allocation mAllocLabelIds;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700673 private Allocation mSelectedIcon;
Joe Onorato93839052009-08-06 20:34:32 -0700674
Joe Onorato6665c0f2009-09-02 15:27:24 -0700675 private int[] mTouchYBorders;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700676 private int[] mTouchXBorders;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700677
678 private Bitmap mSelectionBitmap;
Joe Onorato1291a8c2009-09-15 15:07:25 -0400679 private Canvas mSelectionCanvas;
Joe Onorato93839052009-08-06 20:34:32 -0700680
Jason Sams20df7c72009-11-05 12:30:24 -0800681 boolean mHasSurface = false;
682 private boolean mAppsDirty = false;
Jason Samsd8152b92009-10-13 17:19:10 -0700683
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700684 Params mParams;
Joe Onorato1feb3a82009-08-08 22:32:00 -0700685 State mState;
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700686
Jason Sams78aebd82009-09-15 13:06:59 -0700687 class BaseAlloc {
688 Allocation mAlloc;
689 Type mType;
690
691 void save() {
692 mAlloc.data(this);
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700693 }
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700694 }
695
Jason Sams12c14a82009-10-06 14:33:15 -0700696 class AAMessage extends RenderScript.RSMessage {
697 public void run() {
698 mPosX = ((float)mData[0]) / (1 << 16);
699 mVelocity = ((float)mData[1]) / (1 << 16);
700 mZoom = ((float)mData[2]) / (1 << 16);
701 //Log.d("rs", "new msg " + mPosX + " " + mVelocity + " " + mZoom);
702 }
703 float mZoom;
704 float mPosX;
705 float mVelocity;
706 }
707 AAMessage mMessageProc;
708
Jason Sams476339d2009-09-29 18:14:38 -0700709 private boolean checkClickOK() {
710 //android.util.Log.e("rs", "check click " + Float.toString(mReadback.velocity) + ", " + Float.toString(mReadback.posX));
Jason Sams2e19c052009-10-20 18:19:55 -0700711 return (Math.abs(mMessageProc.mVelocity) < 0.4f) &&
712 (Math.abs(mMessageProc.mPosX - Math.round(mMessageProc.mPosX)) < 0.4f);
Jason Sams476339d2009-09-29 18:14:38 -0700713 }
714
Jason Sams78aebd82009-09-15 13:06:59 -0700715 class Params extends BaseAlloc {
716 Params() {
717 mType = Type.createFromClass(mRS, Params.class, 1, "ParamsClass");
718 mAlloc = Allocation.createTyped(mRS, mType);
719 save();
Joe Onorato1feb3a82009-08-08 22:32:00 -0700720 }
Jason Sams78aebd82009-09-15 13:06:59 -0700721 public int bubbleWidth;
722 public int bubbleHeight;
723 public int bubbleBitmapWidth;
724 public int bubbleBitmapHeight;
Joe Onoratobcbeab82009-10-01 21:45:43 -0700725
Joe Onoratobcbeab82009-10-01 21:45:43 -0700726 public int homeButtonWidth;
727 public int homeButtonHeight;
728 public int homeButtonTextureWidth;
729 public int homeButtonTextureHeight;
Jason Sams78aebd82009-09-15 13:06:59 -0700730 }
731
732 class State extends BaseAlloc {
Jason Sams86c87ed2009-09-18 13:55:55 -0700733 public float newPositionX;
734 public int newTouchDown;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700735 public float flingVelocity;
Jason Sams78aebd82009-09-15 13:06:59 -0700736 public int iconCount;
Jason Sams78aebd82009-09-15 13:06:59 -0700737 public int selectedIconIndex = -1;
738 public int selectedIconTexture;
Joe Onorato7bb17492009-09-24 17:51:01 -0700739 public float zoomTarget;
Joe Onoratod63458b2009-10-15 21:19:09 -0700740 public int homeButtonId;
Jason Samsc1c521e2009-10-19 14:45:45 -0700741 public float targetPos;
Jason Sams78aebd82009-09-15 13:06:59 -0700742
743 State() {
744 mType = Type.createFromClass(mRS, State.class, 1, "StateClass");
745 mAlloc = Allocation.createTyped(mRS, mType);
746 save();
747 }
Joe Onorato1feb3a82009-08-08 22:32:00 -0700748 }
749
750 public RolloRS() {
751 }
752
753 public void init(Resources res, int width, int height) {
754 mRes = res;
755 mWidth = width;
756 mHeight = height;
Joe Onoratobcbeab82009-10-01 21:45:43 -0700757 mDefines.recompute(width, height);
Jason Samscd689e12009-09-29 15:28:22 -0700758 initProgramVertex();
759 initProgramFragment();
760 initProgramStore();
Jason Sams0aa71662009-10-02 18:43:18 -0700761 initMesh();
Joe Onorato1feb3a82009-08-08 22:32:00 -0700762 initGl();
763 initData();
Joe Onorato6665c0f2009-09-02 15:27:24 -0700764 initTouchState();
Joe Onorato1feb3a82009-08-08 22:32:00 -0700765 initRs();
766 }
767
Jason Sams0aa71662009-10-02 18:43:18 -0700768 public void initMesh() {
769 SimpleMesh.TriangleMeshBuilder tm = new SimpleMesh.TriangleMeshBuilder(mRS, 3,
770 SimpleMesh.TriangleMeshBuilder.TEXTURE_0 | SimpleMesh.TriangleMeshBuilder.COLOR);
771
Jason Samsd8152b92009-10-13 17:19:10 -0700772 float y = 0;
773 float z = 0;
774 for (int ct=0; ct < 200; ct++) {
775 float angle = 0;
776 float maxAngle = 3.14f * 0.16f;
777 float l = 1.f;
778
779 l = 1 - ((ct-5) * 0.10f);
780 if (ct > 7) {
781 angle = maxAngle * (ct - 7) * 0.2f;
782 angle = Math.min(angle, maxAngle);
783 }
Jason Samsc8514792009-10-29 14:27:29 -0700784 l = Math.max(0.4f, l);
Jason Samsd8152b92009-10-13 17:19:10 -0700785 l = Math.min(1.0f, l);
786
787 y += 0.1f * Math.cos(angle);
788 z += 0.1f * Math.sin(angle);
789
790 float t = 0.1f * ct;
791 float ds = 0.08f;
792 tm.setColor(l, l, l, 0.99f);
793 tm.setTexture(ds, t);
794 tm.addVertex(-0.5f, y, z);
795 tm.setTexture(1 - ds, t);
796 tm.addVertex(0.5f, y, z);
797 }
798 for (int ct=0; ct < (200 * 2 - 2); ct+= 2) {
799 tm.addTriangle(ct, ct+1, ct+2);
800 tm.addTriangle(ct+1, ct+3, ct+2);
801 }
802 mMesh2 = tm.create();
Jason Sams37e7c2b2009-10-19 12:55:43 -0700803 mMesh2.setName("SMMesh");
Jason Samsd8152b92009-10-13 17:19:10 -0700804 }
805
Jason Samscd689e12009-09-29 15:28:22 -0700806 private void initProgramVertex() {
807 ProgramVertex.MatrixAllocation pva = new ProgramVertex.MatrixAllocation(mRS);
808 pva.setupProjectionNormalized(mWidth, mHeight);
Joe Onorato93839052009-08-06 20:34:32 -0700809
810 ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS, null, null);
Jason Sams0aa71662009-10-02 18:43:18 -0700811 pvb.setTextureMatrixEnable(true);
Joe Onorato93839052009-08-06 20:34:32 -0700812 mPV = pvb.create();
813 mPV.setName("PV");
Jason Samscd689e12009-09-29 15:28:22 -0700814 mPV.bindAllocation(pva);
Joe Onorato93839052009-08-06 20:34:32 -0700815
Jason Sams37e7c2b2009-10-19 12:55:43 -0700816 //pva = new ProgramVertex.MatrixAllocation(mRS);
817 //pva.setupOrthoWindow(mWidth, mHeight);
818 //pvb.setTextureMatrixEnable(true);
819 //mPVOrtho = pvb.create();
820 //mPVOrtho.setName("PVOrtho");
821 //mPVOrtho.bindAllocation(pva);
Joe Onorato93839052009-08-06 20:34:32 -0700822
823 mRS.contextBindProgramVertex(mPV);
Jason Samscd689e12009-09-29 15:28:22 -0700824 }
Joe Onorato93839052009-08-06 20:34:32 -0700825
Jason Samscd689e12009-09-29 15:28:22 -0700826 private void initProgramFragment() {
827 Sampler.Builder sb = new Sampler.Builder(mRS);
Jason Samsc8514792009-10-29 14:27:29 -0700828 sb.setMin(Sampler.Value.LINEAR_MIP_LINEAR);
Jason Samscd689e12009-09-29 15:28:22 -0700829 sb.setMag(Sampler.Value.LINEAR);
830 sb.setWrapS(Sampler.Value.CLAMP);
831 sb.setWrapT(Sampler.Value.CLAMP);
832 Sampler linear = sb.create();
833
834 sb.setMin(Sampler.Value.NEAREST);
835 sb.setMag(Sampler.Value.NEAREST);
836 Sampler nearest = sb.create();
837
838 ProgramFragment.Builder bf = new ProgramFragment.Builder(mRS, null, null);
Jason Sams37e7c2b2009-10-19 12:55:43 -0700839 //mPFColor = bf.create();
840 //mPFColor.setName("PFColor");
Jason Samscd689e12009-09-29 15:28:22 -0700841
842 bf.setTexEnable(true, 0);
843 bf.setTexEnvMode(ProgramFragment.EnvMode.MODULATE, 0);
Jason Samsc8514792009-10-29 14:27:29 -0700844 mPFTexMip = bf.create();
845 mPFTexMip.setName("PFTexMip");
846 mPFTexMip.bindSampler(linear, 0);
847
848 mPFTexNearest = bf.create();
849 mPFTexNearest.setName("PFTexNearest");
850 mPFTexNearest.bindSampler(nearest, 0);
Jason Samscd689e12009-09-29 15:28:22 -0700851 }
852
853 private void initProgramStore() {
854 ProgramStore.Builder bs = new ProgramStore.Builder(mRS, null, null);
855 bs.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
Jason Sams12c14a82009-10-06 14:33:15 -0700856 bs.setColorMask(true,true,true,false);
Jason Samscd689e12009-09-29 15:28:22 -0700857 bs.setDitherEnable(true);
858 bs.setBlendFunc(ProgramStore.BlendSrcFunc.SRC_ALPHA,
859 ProgramStore.BlendDstFunc.ONE_MINUS_SRC_ALPHA);
860 mPSIcons = bs.create();
861 mPSIcons.setName("PSIcons");
862
863 //bs.setDitherEnable(false);
864 //mPSText = bs.create();
865 //mPSText.setName("PSText");
866 }
867
868 private void initGl() {
Joe Onorato6665c0f2009-09-02 15:27:24 -0700869 mTouchXBorders = new int[Defines.COLUMNS_PER_PAGE+1];
Joe Onorato6665c0f2009-09-02 15:27:24 -0700870 mTouchYBorders = new int[Defines.ROWS_PER_PAGE+1];
Joe Onoratobf15cb42009-08-07 14:33:40 -0700871 }
Jason Sams78aebd82009-09-15 13:06:59 -0700872
Joe Onorato1feb3a82009-08-08 22:32:00 -0700873 private void initData() {
Jason Sams78aebd82009-09-15 13:06:59 -0700874 mParams = new Params();
875 mState = new State();
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700876
Joe Onoratobf15cb42009-08-07 14:33:40 -0700877 final Utilities.BubbleText bubble = new Utilities.BubbleText(getContext());
Joe Onorato93839052009-08-06 20:34:32 -0700878
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700879 mParams.bubbleWidth = bubble.getBubbleWidth();
880 mParams.bubbleHeight = bubble.getMaxBubbleHeight();
881 mParams.bubbleBitmapWidth = bubble.getBitmapWidth();
882 mParams.bubbleBitmapHeight = bubble.getBitmapHeight();
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700883
Joe Onoratod63458b2009-10-15 21:19:09 -0700884 mHomeButtonNormal = Allocation.createFromBitmapResource(mRS, mRes,
885 R.drawable.home_button_normal, Element.RGBA_8888(mRS), false);
886 mHomeButtonNormal.uploadToTexture(0);
887 mHomeButtonPressed = Allocation.createFromBitmapResource(mRS, mRes,
888 R.drawable.home_button_pressed, Element.RGBA_8888(mRS), false);
889 mHomeButtonPressed.uploadToTexture(0);
Joe Onoratobcbeab82009-10-01 21:45:43 -0700890 mParams.homeButtonWidth = 76;
891 mParams.homeButtonHeight = 68;
892 mParams.homeButtonTextureWidth = 128;
893 mParams.homeButtonTextureHeight = 128;
Joe Onoratoc567acb2009-08-31 14:34:43 -0700894
Joe Onoratod63458b2009-10-15 21:19:09 -0700895 mState.homeButtonId = mHomeButtonNormal.getID();
896
Joe Onorato1feb3a82009-08-08 22:32:00 -0700897 mParams.save();
898 mState.save();
Joe Onorato9c1289c2009-08-17 11:03:03 -0400899
Joe Onorato1291a8c2009-09-15 15:07:25 -0400900 mSelectionBitmap = Bitmap.createBitmap(Defines.ICON_TEXTURE_WIDTH_PX,
901 Defines.ICON_TEXTURE_HEIGHT_PX, Bitmap.Config.ARGB_8888);
902 mSelectionCanvas = new Canvas(mSelectionBitmap);
Joe Onorato6665c0f2009-09-02 15:27:24 -0700903
Joe Onorato9c1289c2009-08-17 11:03:03 -0400904 setApps(null);
Joe Onorato93839052009-08-06 20:34:32 -0700905 }
906
Jason Sams37e7c2b2009-10-19 12:55:43 -0700907 private void initScript(int id) {
908 }
909
910 private void initRs() {
Joe Onorato93839052009-08-06 20:34:32 -0700911 ScriptC.Builder sb = new ScriptC.Builder(mRS);
Jason Sams37e7c2b2009-10-19 12:55:43 -0700912 sb.setScript(mRes, R.raw.rollo3);
Joe Onorato93839052009-08-06 20:34:32 -0700913 sb.setRoot(true);
Joe Onoratobcbeab82009-10-01 21:45:43 -0700914 sb.addDefines(mDefines);
Jason Sams78aebd82009-09-15 13:06:59 -0700915 sb.setType(mParams.mType, "params", Defines.ALLOC_PARAMS);
916 sb.setType(mState.mType, "state", Defines.ALLOC_STATE);
Jason Sams37e7c2b2009-10-19 12:55:43 -0700917 mInvokeMove = sb.addInvokable("move");
918 mInvokeFling = sb.addInvokable("fling");
Jason Samsc1c521e2009-10-19 14:45:45 -0700919 mInvokeMoveTo = sb.addInvokable("moveTo");
Jason Sams37e7c2b2009-10-19 12:55:43 -0700920 mInvokeResetWAR = sb.addInvokable("resetHWWar");
921 mScript = sb.create();
922 mScript.setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
923 mScript.bindAllocation(mParams.mAlloc, Defines.ALLOC_PARAMS);
924 mScript.bindAllocation(mState.mAlloc, Defines.ALLOC_STATE);
925 mScript.bindAllocation(mAllocIconIds, Defines.ALLOC_ICON_IDS);
926 mScript.bindAllocation(mAllocLabelIds, Defines.ALLOC_LABEL_IDS);
Joe Onorato93839052009-08-06 20:34:32 -0700927
Jason Sams12c14a82009-10-06 14:33:15 -0700928 mMessageProc = new AAMessage();
929 mRS.mMessageCallback = mMessageProc;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700930 mRS.contextBindRootScript(mScript);
Joe Onorato93839052009-08-06 20:34:32 -0700931 }
Joe Onorato93839052009-08-06 20:34:32 -0700932
Jason Sams20df7c72009-11-05 12:30:24 -0800933 private void uploadApps(ArrayList<ApplicationInfo> list) {
934 for (int i=0; i < mState.iconCount; i++) {
935 uploadAppIcon(i, list.get(i));
936 }
937 }
938
939 void dirtyCheck() {
940 if (mAppsDirty && mHasSurface) {
941 uploadApps(mAllAppsList);
942 saveAppsList();
943 mAppsDirty = false;
944 }
945 }
946
Joe Onorato9c1289c2009-08-17 11:03:03 -0400947 private void setApps(ArrayList<ApplicationInfo> list) {
948 final int count = list != null ? list.size() : 0;
Jason Sams0a8dc2c2009-09-27 17:51:44 -0700949 int allocCount = count;
Joe Onoratoa8138d52009-10-06 19:25:30 -0700950 if (allocCount < 1) {
Jason Sams0a8dc2c2009-09-27 17:51:44 -0700951 allocCount = 1;
952 }
953
Joe Onorato9c1289c2009-08-17 11:03:03 -0400954 mIcons = new Allocation[count];
Jason Sams0a8dc2c2009-09-27 17:51:44 -0700955 mIconIds = new int[allocCount];
Joe Onoratoa8138d52009-10-06 19:25:30 -0700956 mAllocIconIds = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount);
Joe Onorato9c1289c2009-08-17 11:03:03 -0400957
958 mLabels = new Allocation[count];
Jason Sams0a8dc2c2009-09-27 17:51:44 -0700959 mLabelIds = new int[allocCount];
Joe Onoratoa8138d52009-10-06 19:25:30 -0700960 mAllocLabelIds = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount);
Joe Onorato9c1289c2009-08-17 11:03:03 -0400961
Jason Sams0a8dc2c2009-09-27 17:51:44 -0700962 Element ie8888 = Element.RGBA_8888(mRS);
Joe Onorato9c1289c2009-08-17 11:03:03 -0400963
964 Utilities.BubbleText bubble = new Utilities.BubbleText(getContext());
965
Joe Onorato9c1289c2009-08-17 11:03:03 -0400966 mState.iconCount = count;
Jason Sams20df7c72009-11-05 12:30:24 -0800967 uploadApps(list);
Joe Onoratoa8138d52009-10-06 19:25:30 -0700968 saveAppsList();
969 }
970
Jason Samsc8514792009-10-29 14:27:29 -0700971 private void frameBitmapAllocMips(Allocation alloc, int w, int h) {
972 int black[] = new int[w > h ? w : h];
973 Allocation.Adapter2D a = alloc.createAdapter2D();
974 int mip = 0;
975 while (w > 1 || h > 1) {
976 a.subData(0, 0, 1, h, black);
977 a.subData(w-1, 0, 1, h, black);
978 a.subData(0, 0, w, 1, black);
979 a.subData(0, h-1, w, 1, black);
980 mip++;
981 w = (w + 1) >> 1;
982 h = (h + 1) >> 1;
983 a.setConstraint(Dimension.LOD, mip);
984 }
985 a.subData(0, 0, 1, 1, black);
986 }
987
Joe Onoratoa8138d52009-10-06 19:25:30 -0700988 private void uploadAppIcon(int index, ApplicationInfo item) {
989 mIcons[index] = Allocation.createFromBitmap(mRS, item.iconBitmap,
Jason Samsc8514792009-10-29 14:27:29 -0700990 Element.RGBA_8888(mRS), true);
991 frameBitmapAllocMips(mIcons[index], item.iconBitmap.getWidth(), item.iconBitmap.getHeight());
992
Joe Onoratoa8138d52009-10-06 19:25:30 -0700993 mLabels[index] = Allocation.createFromBitmap(mRS, item.titleBitmap,
Jason Samsc8514792009-10-29 14:27:29 -0700994 Element.RGBA_8888(mRS), true);
995 frameBitmapAllocMips(mLabels[index], item.titleBitmap.getWidth(), item.titleBitmap.getHeight());
Joe Onoratoa8138d52009-10-06 19:25:30 -0700996
997 mIcons[index].uploadToTexture(0);
998 mLabels[index].uploadToTexture(0);
999
1000 mIconIds[index] = mIcons[index].getID();
1001 mLabelIds[index] = mLabels[index].getID();
1002 }
1003
1004 /**
1005 * Puts the empty spaces at the end. Updates mState.iconCount. You must
1006 * fill in the values and call saveAppsList().
1007 */
1008 private void reallocAppsList(int count) {
1009 Allocation[] icons = new Allocation[count];
1010 int[] iconIds = new int[count];
1011 mAllocIconIds = Allocation.createSized(mRS, Element.USER_I32(mRS), count);
1012
1013 Allocation[] labels = new Allocation[count];
1014 int[] labelIds = new int[count];
1015 mAllocLabelIds = Allocation.createSized(mRS, Element.USER_I32(mRS), count);
1016
1017 final int oldCount = mIcons.length;
1018
1019 System.arraycopy(mIcons, 0, icons, 0, oldCount);
1020 System.arraycopy(mIconIds, 0, iconIds, 0, oldCount);
1021 System.arraycopy(mLabels, 0, labels, 0, oldCount);
1022 System.arraycopy(mLabelIds, 0, labelIds, 0, oldCount);
1023
1024 mIcons = icons;
1025 mIconIds = iconIds;
1026 mLabels = labels;
1027 mLabelIds = labelIds;
1028 }
1029
1030 /**
1031 * Handle the allocations for the new app. Make sure you call saveAppsList when done.
1032 */
1033 private void addApp(int index, ApplicationInfo item) {
1034 final int count = mState.iconCount - index;
1035 final int dest = index + 1;
1036
1037 System.arraycopy(mIcons, index, mIcons, dest, count);
1038 System.arraycopy(mIconIds, index, mIconIds, dest, count);
1039 System.arraycopy(mLabels, index, mLabels, dest, count);
1040 System.arraycopy(mLabelIds, index, mLabelIds, dest, count);
1041
Jason Sams20df7c72009-11-05 12:30:24 -08001042 if (mHasSurface ) {
1043 uploadAppIcon(index, item);
1044 } else {
1045 mAppsDirty = true;
1046 }
Joe Onoratoa8138d52009-10-06 19:25:30 -07001047 }
1048
1049 /**
1050 * Handle the allocations for the removed app. Make sure you call saveAppsList when done.
1051 */
1052 private void removeApp(int index) {
1053 final int count = mState.iconCount - index - 1;
1054 final int src = index + 1;
1055
1056 System.arraycopy(mIcons, src, mIcons, index, count);
1057 System.arraycopy(mIconIds, src, mIconIds, index, count);
1058 System.arraycopy(mLabels, src, mLabels, index, count);
1059 System.arraycopy(mLabelIds, src, mLabelIds, index, count);
1060
1061 final int last = mState.iconCount - 1;
1062 mIcons[last] = null;
1063 mIconIds[last] = 0;
1064 mLabels[last] = null;
1065 mLabelIds[last] = 0;
1066 }
1067
1068 /**
1069 * Send the apps list structures to RS.
1070 */
1071 private void saveAppsList() {
1072 mRS.contextBindRootScript(null);
Jason Samsd8152b92009-10-13 17:19:10 -07001073
Joe Onoratoa8138d52009-10-06 19:25:30 -07001074 mAllocIconIds.data(mIconIds);
1075 mAllocLabelIds.data(mLabelIds);
1076
Jason Sams37e7c2b2009-10-19 12:55:43 -07001077 if (mScript != null) { // this happens when we init it
1078 mScript.bindAllocation(mAllocIconIds, Defines.ALLOC_ICON_IDS);
1079 mScript.bindAllocation(mAllocLabelIds, Defines.ALLOC_LABEL_IDS);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001080 }
1081
1082 mState.save();
Joe Onoratoa8138d52009-10-06 19:25:30 -07001083
1084 // Note: mScript may be null if we haven't initialized it yet.
1085 // In that case, this is a no-op.
Jason Sams37e7c2b2009-10-19 12:55:43 -07001086 if (mInvokeResetWAR != null) {
1087 mInvokeResetWAR.execute();
Jason Sams41b61c82009-10-15 15:40:54 -07001088 }
Jason Sams37e7c2b2009-10-19 12:55:43 -07001089 mRS.contextBindRootScript(mScript);
Joe Onorato9c1289c2009-08-17 11:03:03 -04001090 }
Joe Onorato6665c0f2009-09-02 15:27:24 -07001091
1092 void initTouchState() {
1093 int width = getWidth();
1094 int height = getHeight();
Jason Sams37e7c2b2009-10-19 12:55:43 -07001095 int cellHeight = 145;//iconsSize / Defines.ROWS_PER_PAGE;
1096 int cellWidth = width / Defines.COLUMNS_PER_PAGE;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001097
Jason Sams37e7c2b2009-10-19 12:55:43 -07001098 int centerY = (height / 2);
1099 mTouchYBorders[0] = centerY - (cellHeight * 2);
1100 mTouchYBorders[1] = centerY - cellHeight;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001101 mTouchYBorders[2] = centerY;
Jason Sams37e7c2b2009-10-19 12:55:43 -07001102 mTouchYBorders[3] = centerY + cellHeight;
1103 mTouchYBorders[4] = centerY + (cellHeight * 2);
Jason Sams78aebd82009-09-15 13:06:59 -07001104
Joe Onorato6665c0f2009-09-02 15:27:24 -07001105 int centerX = (width / 2);
Jason Sams37e7c2b2009-10-19 12:55:43 -07001106 mTouchXBorders[0] = 0;
1107 mTouchXBorders[1] = centerX - (width / 4);
Joe Onorato6665c0f2009-09-02 15:27:24 -07001108 mTouchXBorders[2] = centerX;
Jason Sams37e7c2b2009-10-19 12:55:43 -07001109 mTouchXBorders[3] = centerX + (width / 4);
1110 mTouchXBorders[4] = width;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001111 }
1112
Joe Onorato664457d2009-10-28 16:30:34 -04001113 void fling() {
1114 mInvokeFling.execute();
1115 }
1116
1117 void move() {
1118 mInvokeMove.execute();
1119 }
1120
1121 void moveTo(float row) {
1122 mState.targetPos = row;
1123 mState.save();
1124 mInvokeMoveTo.execute();
1125 }
1126
Jason Sams37e7c2b2009-10-19 12:55:43 -07001127 int chooseTappedIcon(int x, int y, float pos) {
1128 // Adjust for scroll position if not zero.
1129 y += (pos - ((int)pos)) * (mTouchYBorders[1] - mTouchYBorders[0]);
Jason Sams86c87ed2009-09-18 13:55:55 -07001130
Joe Onorato6665c0f2009-09-02 15:27:24 -07001131 int col = -1;
1132 int row = -1;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001133 for (int i=0; i<Defines.COLUMNS_PER_PAGE; i++) {
1134 if (x >= mTouchXBorders[i] && x < mTouchXBorders[i+1]) {
1135 col = i;
1136 break;
1137 }
1138 }
1139 for (int i=0; i<Defines.ROWS_PER_PAGE; i++) {
1140 if (y >= mTouchYBorders[i] && y < mTouchYBorders[i+1]) {
1141 row = i;
1142 break;
1143 }
1144 }
1145
1146 if (row < 0 || col < 0) {
1147 return -1;
1148 }
1149
Joe Onorato664457d2009-10-28 16:30:34 -04001150 int index = (((int)pos) * Defines.COLUMNS_PER_PAGE)
Joe Onorato6665c0f2009-09-02 15:27:24 -07001151 + (row * Defines.ROWS_PER_PAGE) + col;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001152
Joe Onorato664457d2009-10-28 16:30:34 -04001153 if (index >= mState.iconCount) {
1154 return -1;
1155 } else {
1156 return index;
1157 }
Jason Samsc1c521e2009-10-19 14:45:45 -07001158 }
1159
Joe Onorato6665c0f2009-09-02 15:27:24 -07001160 /**
1161 * You need to call save() on mState on your own after calling this.
Joe Onorato82ca5502009-10-15 16:59:23 -07001162 *
1163 * @return the index of the icon that was selected.
Joe Onorato6665c0f2009-09-02 15:27:24 -07001164 */
Joe Onorato82ca5502009-10-15 16:59:23 -07001165 int selectIcon(int x, int y, float pos) {
1166 final int index = chooseTappedIcon(x, y, pos);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001167 selectIcon(index);
Joe Onorato82ca5502009-10-15 16:59:23 -07001168 return index;
Joe Onorato1291a8c2009-09-15 15:07:25 -04001169 }
1170
1171 void selectIcon(int index) {
Jason Samsc8514792009-10-29 14:27:29 -07001172 if (index < 0 || index >= mAllAppsList.size()) {
Joe Onorato6665c0f2009-09-02 15:27:24 -07001173 mState.selectedIconIndex = -1;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001174 } else {
1175 mState.selectedIconIndex = index;
Joe Onorato1291a8c2009-09-15 15:07:25 -04001176
1177 Bitmap selectionBitmap = mSelectionBitmap;
1178
1179 Utilities.drawSelectedAllAppsBitmap(mSelectionCanvas,
1180 selectionBitmap.getWidth(), selectionBitmap.getHeight(),
1181 mAllAppsList.get(index).iconBitmap);
1182
1183 mSelectedIcon = Allocation.createFromBitmap(mRS, selectionBitmap,
Jason Sams0a8dc2c2009-09-27 17:51:44 -07001184 Element.RGBA_8888(mRS), false);
Joe Onorato1291a8c2009-09-15 15:07:25 -04001185 mSelectedIcon.uploadToTexture(0);
1186 mState.selectedIconTexture = mSelectedIcon.getID();
Joe Onorato6665c0f2009-09-02 15:27:24 -07001187 }
1188 }
1189
1190 /**
1191 * You need to call save() on mState on your own after calling this.
1192 */
1193 void clearSelectedIcon() {
Joe Onorato2ca51dc2009-09-16 11:44:14 -04001194 mState.selectedIconIndex = -1;
Joe Onorato6665c0f2009-09-02 15:27:24 -07001195 }
Joe Onoratoa8138d52009-10-06 19:25:30 -07001196
Joe Onoratod63458b2009-10-15 21:19:09 -07001197 void setHomeSelected(boolean pressed) {
1198 if (pressed) {
1199 mState.homeButtonId = mHomeButtonPressed.getID();
1200 } else {
1201 mState.homeButtonId = mHomeButtonNormal.getID();
1202 }
1203 }
Joe Onorato9c1289c2009-08-17 11:03:03 -04001204 }
Joe Onorato93839052009-08-06 20:34:32 -07001205}
1206
1207