blob: 4a2dc49e4e5a5fa4f97635344ca3a0dda744cfec [file] [log] [blame]
Daniel Sandler388f6792010-03-02 14:08:08 -05001/*
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
19import android.content.ComponentName;
20import android.content.Context;
21import android.content.res.Resources;
22import android.graphics.Bitmap;
23import android.graphics.Canvas;
24import android.graphics.PixelFormat;
25import android.graphics.Rect;
Daniel Sandler388f6792010-03-02 14:08:08 -050026import android.renderscript.Allocation;
Daniel Sandler388f6792010-03-02 14:08:08 -050027import android.renderscript.Element;
28import android.renderscript.ProgramFragment;
29import android.renderscript.ProgramStore;
30import android.renderscript.ProgramVertex;
31import android.renderscript.RSSurfaceView;
32import android.renderscript.RenderScriptGL;
33import android.renderscript.RenderScript;
34import android.renderscript.Sampler;
35import android.renderscript.Script;
36import android.renderscript.ScriptC;
37import android.renderscript.SimpleMesh;
38import android.renderscript.Type;
39import android.util.AttributeSet;
Romain Guy060b5c82010-03-04 10:07:38 -080040import android.util.DisplayMetrics;
Daniel Sandler388f6792010-03-02 14:08:08 -050041import android.util.Log;
42import android.view.KeyEvent;
43import android.view.MotionEvent;
44import android.view.SoundEffectConstants;
45import android.view.SurfaceHolder;
46import android.view.VelocityTracker;
47import android.view.View;
48import android.view.ViewConfiguration;
49import android.view.accessibility.AccessibilityEvent;
50
51import java.util.ArrayList;
52import java.util.Arrays;
53import java.util.Collections;
Daniel Sandler388f6792010-03-02 14:08:08 -050054
Romain Guyedcce092010-03-04 13:03:17 -080055import com.android.launcher.R;
56
Daniel Sandler388f6792010-03-02 14:08:08 -050057public class AllApps3D extends RSSurfaceView
58 implements AllAppsView, View.OnClickListener, View.OnLongClickListener, DragSource {
59 private static final String TAG = "Launcher.AllApps3D";
60
61 /** Bit for mLocks for when there are icons being loaded. */
62 private static final int LOCK_ICONS_PENDING = 1;
63
64 private static final int TRACKING_NONE = 0;
65 private static final int TRACKING_FLING = 1;
66 private static final int TRACKING_HOME = 2;
67
68 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
76 private Launcher mLauncher;
77 private DragController mDragController;
78
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;
82
83 private int mSlop;
84 private int mMaxFlingVelocity;
85
86 private Defines mDefines = new Defines();
Daniel Sandler388f6792010-03-02 14:08:08 -050087 private ArrayList<ApplicationInfo> mAllAppsList;
88
Joe Onorato2cc62e82010-03-17 20:23:53 -070089 private static RenderScriptGL sRS;
90 private static RolloRS sRollo;
Jason Samsdd8cd8b2010-03-11 12:38:48 -080091
Joe Onoratoeffc4a82010-04-15 11:48:13 -070092 private static boolean sZoomDirty = false;
93 private static boolean sAnimateNextZoom;
94 private static float sNextZoom;
95
Daniel Sandler388f6792010-03-02 14:08:08 -050096 /**
97 * True when we are using arrow keys or trackball to drive navigation
98 */
99 private boolean mArrowNavigation = false;
100 private boolean mStartedScrolling;
101
102 /**
103 * Used to keep track of the selection when AllAppsView loses window focus.
104 * One of the SELECTION_ constants.
105 */
106 private int mLastSelection;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800107
Daniel Sandler388f6792010-03-02 14:08:08 -0500108 /**
109 * Used to keep track of the selection when AllAppsView loses window focus
110 */
111 private int mLastSelectedIcon;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800112
Daniel Sandler388f6792010-03-02 14:08:08 -0500113 private VelocityTracker mVelocityTracker;
114 private int mTouchTracking;
115 private int mMotionDownRawX;
116 private int mMotionDownRawY;
117 private int mDownIconIndex = -1;
118 private int mCurrentIconIndex = -1;
Joe Onoratocfc4c7b2010-03-18 15:15:10 -0700119 private int[] mTouchYBorders;
120 private int[] mTouchXBorders;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800121
Daniel Sandler388f6792010-03-02 14:08:08 -0500122 private boolean mShouldGainFocus;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800123
Daniel Sandler388f6792010-03-02 14:08:08 -0500124 private boolean mHaveSurface = false;
Daniel Sandler388f6792010-03-02 14:08:08 -0500125 private float mZoom;
Daniel Sandler388f6792010-03-02 14:08:08 -0500126 private float mVelocity;
127 private AAMessage mMessageProc;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800128
Romain Guy060b5c82010-03-04 10:07:38 -0800129 private int mColumnsPerPage;
130 private int mRowsPerPage;
Romain Guy13c2e7b2010-03-10 19:45:00 -0800131 private boolean mSurrendered;
132
Romain Guyc16fea72010-03-12 17:17:56 -0800133 private int mRestoreFocusIndex = -1;
Jason Sams14f67ed2010-05-11 14:02:43 -0700134
Romain Guy060b5c82010-03-04 10:07:38 -0800135 @SuppressWarnings({"UnusedDeclaration"})
Daniel Sandler388f6792010-03-02 14:08:08 -0500136 static class Defines {
Romain Guy060b5c82010-03-04 10:07:38 -0800137 public static final int COLUMNS_PER_PAGE_PORTRAIT = 4;
138 public static final int ROWS_PER_PAGE_PORTRAIT = 4;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800139
Romain Guy060b5c82010-03-04 10:07:38 -0800140 public static final int COLUMNS_PER_PAGE_LANDSCAPE = 6;
141 public static final int ROWS_PER_PAGE_LANDSCAPE = 3;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800142
Daniel Sandler388f6792010-03-02 14:08:08 -0500143 public static final int SELECTION_TEXTURE_WIDTH_PX = 74 + 20;
Daniel Sandler388f6792010-03-02 14:08:08 -0500144 public static final int SELECTION_TEXTURE_HEIGHT_PX = 74 + 20;
145 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800146
Daniel Sandler388f6792010-03-02 14:08:08 -0500147 public AllApps3D(Context context, AttributeSet attrs) {
148 super(context, attrs);
149 setFocusable(true);
150 setSoundEffectsEnabled(false);
Daniel Sandler388f6792010-03-02 14:08:08 -0500151 final ViewConfiguration config = ViewConfiguration.get(context);
152 mSlop = config.getScaledTouchSlop();
153 mMaxFlingVelocity = config.getScaledMaximumFlingVelocity();
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800154
Daniel Sandler388f6792010-03-02 14:08:08 -0500155 setOnClickListener(this);
156 setOnLongClickListener(this);
157 setZOrderOnTop(true);
158 getHolder().setFormat(PixelFormat.TRANSLUCENT);
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800159
Joe Onorato2cc62e82010-03-17 20:23:53 -0700160 if (sRS == null) {
161 sRS = createRenderScript(true);
Romain Guy13c2e7b2010-03-10 19:45:00 -0800162 } else {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700163 createRenderScript(sRS);
Romain Guy13c2e7b2010-03-10 19:45:00 -0800164 }
165
Romain Guy060b5c82010-03-04 10:07:38 -0800166 final DisplayMetrics metrics = getResources().getDisplayMetrics();
167 final boolean isPortrait = metrics.widthPixels < metrics.heightPixels;
168 mColumnsPerPage = isPortrait ? Defines.COLUMNS_PER_PAGE_PORTRAIT :
169 Defines.COLUMNS_PER_PAGE_LANDSCAPE;
170 mRowsPerPage = isPortrait ? Defines.ROWS_PER_PAGE_PORTRAIT :
171 Defines.ROWS_PER_PAGE_LANDSCAPE;
Romain Guy13c2e7b2010-03-10 19:45:00 -0800172
Joe Onorato2cc62e82010-03-17 20:23:53 -0700173 if (sRollo != null) {
174 sRollo.mAllApps = this;
175 sRollo.mRes = getResources();
176 sRollo.mInitialize = true;
Romain Guy13c2e7b2010-03-10 19:45:00 -0800177 }
Daniel Sandler388f6792010-03-02 14:08:08 -0500178 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800179
Romain Guy060b5c82010-03-04 10:07:38 -0800180 @SuppressWarnings({"UnusedDeclaration"})
181 public AllApps3D(Context context, AttributeSet attrs, int defStyle) {
182 this(context, attrs);
183 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800184
Romain Guy13c2e7b2010-03-10 19:45:00 -0800185 public void surrender() {
Joe Onoratoc5210eb2010-03-23 11:26:28 -0400186 if (sRS != null) {
187 sRS.contextSetSurface(0, 0, null);
188 sRS.mMessageCallback = null;
189 }
Romain Guy13c2e7b2010-03-10 19:45:00 -0800190 mSurrendered = true;
191 }
192
Daniel Sandler388f6792010-03-02 14:08:08 -0500193 /**
194 * Note that this implementation prohibits this view from ever being reattached.
195 */
196 @Override
197 protected void onDetachedFromWindow() {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700198 sRS.mMessageCallback = null;
Romain Guy13c2e7b2010-03-10 19:45:00 -0800199 if (!mSurrendered) {
Joe Onorato96da4012010-03-17 20:03:24 -0700200 Log.i(TAG, "onDetachedFromWindow");
Romain Guy13c2e7b2010-03-10 19:45:00 -0800201 destroyRenderScript();
Joe Onorato2cc62e82010-03-17 20:23:53 -0700202 sRS = null;
203 sRollo = null;
Romain Guy13c2e7b2010-03-10 19:45:00 -0800204 }
Daniel Sandler388f6792010-03-02 14:08:08 -0500205 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800206
Daniel Sandler388f6792010-03-02 14:08:08 -0500207 /**
208 * If you have an attached click listener, View always plays the click sound!?!?
209 * Deal with sound effects by hand.
210 */
211 public void reallyPlaySoundEffect(int sound) {
212 boolean old = isSoundEffectsEnabled();
213 setSoundEffectsEnabled(true);
214 playSoundEffect(sound);
215 setSoundEffectsEnabled(old);
216 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800217
Daniel Sandler388f6792010-03-02 14:08:08 -0500218 public void setLauncher(Launcher launcher) {
219 mLauncher = launcher;
220 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800221
Daniel Sandler388f6792010-03-02 14:08:08 -0500222 @Override
223 public void surfaceDestroyed(SurfaceHolder holder) {
224 super.surfaceDestroyed(holder);
225 // Without this, we leak mMessageCallback which leaks the context.
Romain Guy13c2e7b2010-03-10 19:45:00 -0800226 if (!mSurrendered) {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700227 sRS.mMessageCallback = null;
Romain Guy13c2e7b2010-03-10 19:45:00 -0800228 }
Daniel Sandler388f6792010-03-02 14:08:08 -0500229 // We may lose any callbacks that are pending, so make sure that we re-sync that
230 // on the next surfaceChanged.
Joe Onoratoeffc4a82010-04-15 11:48:13 -0700231 sZoomDirty = true;
Daniel Sandler388f6792010-03-02 14:08:08 -0500232 mHaveSurface = false;
233 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800234
Daniel Sandler388f6792010-03-02 14:08:08 -0500235 @Override
236 public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
237 //long startTime = SystemClock.uptimeMillis();
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800238
Daniel Sandler388f6792010-03-02 14:08:08 -0500239 super.surfaceChanged(holder, format, w, h);
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800240
Romain Guy13c2e7b2010-03-10 19:45:00 -0800241 if (mSurrendered) return;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800242
Daniel Sandler388f6792010-03-02 14:08:08 -0500243 mHaveSurface = true;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800244
Joe Onorato2cc62e82010-03-17 20:23:53 -0700245 if (sRollo == null) {
246 sRollo = new RolloRS(this);
247 sRollo.init(getResources(), w, h);
Daniel Sandler388f6792010-03-02 14:08:08 -0500248 if (mAllAppsList != null) {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700249 sRollo.setApps(mAllAppsList);
Daniel Sandler388f6792010-03-02 14:08:08 -0500250 }
251 if (mShouldGainFocus) {
252 gainFocus();
253 mShouldGainFocus = false;
254 }
Joe Onorato2cc62e82010-03-17 20:23:53 -0700255 } else if (sRollo.mInitialize) {
256 sRollo.initGl();
Joe Onorato2cc62e82010-03-17 20:23:53 -0700257 sRollo.mInitialize = false;
Daniel Sandler388f6792010-03-02 14:08:08 -0500258 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800259
Joe Onoratocfc4c7b2010-03-18 15:15:10 -0700260 initTouchState(w, h);
261
Joe Onorato2cc62e82010-03-17 20:23:53 -0700262 sRollo.dirtyCheck();
263 sRollo.resize(w, h);
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800264
Jason Sams14f67ed2010-05-11 14:02:43 -0700265 Log.d(TAG, "sc " + sRS);
Joe Onorato2cc62e82010-03-17 20:23:53 -0700266 if (sRS != null) {
267 sRS.mMessageCallback = mMessageProc = new AAMessage();
Daniel Sandler388f6792010-03-02 14:08:08 -0500268 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800269
Joe Onorato2cc62e82010-03-17 20:23:53 -0700270 if (sRollo.mUniformAlloc != null) {
Jason Sams60a55bb2010-06-18 15:11:19 -0700271 ScriptField_VpConsts.Item i = new ScriptField_VpConsts.Item();
272 i.ScaleOffset.x = (2.f / 480.f);
273 i.ScaleOffset.y = 0;
274 i.ScaleOffset.z = -((float)w / 2) - 0.25f;
275 i.ScaleOffset.w = -380.25f;
276 i.BendPos.x = 120.f;
277 i.BendPos.y = 680.f;
Daniel Sandler388f6792010-03-02 14:08:08 -0500278 if (w > h) {
Jason Sams60a55bb2010-06-18 15:11:19 -0700279 i.ScaleOffset.z = 40.f;
280 i.ScaleOffset.w = h - 40.f;
281 i.BendPos.y = 1.f;
Daniel Sandler388f6792010-03-02 14:08:08 -0500282 }
Jason Sams60a55bb2010-06-18 15:11:19 -0700283 sRollo.mUniformAlloc.set(i, 0, true);
Daniel Sandler388f6792010-03-02 14:08:08 -0500284 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800285
Daniel Sandler388f6792010-03-02 14:08:08 -0500286 //long endTime = SystemClock.uptimeMillis();
287 //Log.d(TAG, "surfaceChanged took " + (endTime-startTime) + "ms");
288 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800289
Daniel Sandler388f6792010-03-02 14:08:08 -0500290 @Override
291 public void onWindowFocusChanged(boolean hasWindowFocus) {
292 super.onWindowFocusChanged(hasWindowFocus);
Romain Guy13c2e7b2010-03-10 19:45:00 -0800293
294 if (mSurrendered) return;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800295
Daniel Sandler388f6792010-03-02 14:08:08 -0500296 if (mArrowNavigation) {
297 if (!hasWindowFocus) {
298 // Clear selection when we lose window focus
Jason Sams14f67ed2010-05-11 14:02:43 -0700299 mLastSelectedIcon = sRollo.mScript.get_gSelectedIconIndex();
Joe Onorato2cc62e82010-03-17 20:23:53 -0700300 sRollo.setHomeSelected(SELECTED_NONE);
301 sRollo.clearSelectedIcon();
Romain Guy060b5c82010-03-04 10:07:38 -0800302 } else {
Jason Sams14f67ed2010-05-11 14:02:43 -0700303 if (sRollo.mScript.get_gIconCount() > 0) {
Daniel Sandler388f6792010-03-02 14:08:08 -0500304 if (mLastSelection == SELECTION_ICONS) {
305 int selection = mLastSelectedIcon;
Joe Onorato2cc62e82010-03-17 20:23:53 -0700306 final int firstIcon = Math.round(sRollo.mScrollPos) * mColumnsPerPage;
Daniel Sandler388f6792010-03-02 14:08:08 -0500307 if (selection < 0 || // No selection
308 selection < firstIcon || // off the top of the screen
Jason Sams14f67ed2010-05-11 14:02:43 -0700309 selection >= sRollo.mScript.get_gIconCount() || // past last icon
Daniel Sandler388f6792010-03-02 14:08:08 -0500310 selection >= firstIcon + // past last icon on screen
Romain Guy060b5c82010-03-04 10:07:38 -0800311 (mColumnsPerPage * mRowsPerPage)) {
Daniel Sandler388f6792010-03-02 14:08:08 -0500312 selection = firstIcon;
313 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800314
Daniel Sandler388f6792010-03-02 14:08:08 -0500315 // Select the first icon when we gain window focus
Joe Onorato2cc62e82010-03-17 20:23:53 -0700316 sRollo.selectIcon(selection, SELECTED_FOCUSED);
Daniel Sandler388f6792010-03-02 14:08:08 -0500317 } else if (mLastSelection == SELECTION_HOME) {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700318 sRollo.setHomeSelected(SELECTED_FOCUSED);
Daniel Sandler388f6792010-03-02 14:08:08 -0500319 }
320 }
321 }
322 }
323 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800324
Daniel Sandler388f6792010-03-02 14:08:08 -0500325 @Override
326 protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
327 super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800328
Romain Guy13c2e7b2010-03-10 19:45:00 -0800329 if (!isVisible() || mSurrendered) {
Daniel Sandler388f6792010-03-02 14:08:08 -0500330 return;
331 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800332
Daniel Sandler388f6792010-03-02 14:08:08 -0500333 if (gainFocus) {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700334 if (sRollo != null) {
Daniel Sandler388f6792010-03-02 14:08:08 -0500335 gainFocus();
336 } else {
337 mShouldGainFocus = true;
338 }
339 } else {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700340 if (sRollo != null) {
Daniel Sandler388f6792010-03-02 14:08:08 -0500341 if (mArrowNavigation) {
342 // Clear selection when we lose focus
Joe Onorato2cc62e82010-03-17 20:23:53 -0700343 sRollo.clearSelectedIcon();
344 sRollo.setHomeSelected(SELECTED_NONE);
Daniel Sandler388f6792010-03-02 14:08:08 -0500345 mArrowNavigation = false;
346 }
347 } else {
348 mShouldGainFocus = false;
349 }
350 }
351 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800352
Daniel Sandler388f6792010-03-02 14:08:08 -0500353 private void gainFocus() {
Jason Sams14f67ed2010-05-11 14:02:43 -0700354 if (!mArrowNavigation && sRollo.mScript.get_gIconCount() > 0) {
Daniel Sandler388f6792010-03-02 14:08:08 -0500355 // Select the first icon when we gain keyboard focus
356 mArrowNavigation = true;
Joe Onorato2cc62e82010-03-17 20:23:53 -0700357 sRollo.selectIcon(Math.round(sRollo.mScrollPos) * mColumnsPerPage, SELECTED_FOCUSED);
Daniel Sandler388f6792010-03-02 14:08:08 -0500358 }
359 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800360
Daniel Sandler388f6792010-03-02 14:08:08 -0500361 @Override
362 public boolean onKeyDown(int keyCode, KeyEvent event) {
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800363
Daniel Sandler388f6792010-03-02 14:08:08 -0500364 boolean handled = false;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800365
Daniel Sandler388f6792010-03-02 14:08:08 -0500366 if (!isVisible()) {
367 return false;
368 }
Jason Sams14f67ed2010-05-11 14:02:43 -0700369 final int iconCount = sRollo.mScript.get_gIconCount();
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800370
Daniel Sandler388f6792010-03-02 14:08:08 -0500371 if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
372 if (mArrowNavigation) {
373 if (mLastSelection == SELECTION_HOME) {
374 reallyPlaySoundEffect(SoundEffectConstants.CLICK);
375 mLauncher.closeAllApps(true);
376 } else {
Jason Sams14f67ed2010-05-11 14:02:43 -0700377 int whichApp = sRollo.mScript.get_gSelectedIconIndex();
Daniel Sandler388f6792010-03-02 14:08:08 -0500378 if (whichApp >= 0) {
379 ApplicationInfo app = mAllAppsList.get(whichApp);
Joe Onoratof984e852010-03-25 09:47:45 -0700380 mLauncher.startActivitySafely(app.intent, app);
Daniel Sandler388f6792010-03-02 14:08:08 -0500381 handled = true;
382 }
383 }
384 }
385 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800386
Daniel Sandler388f6792010-03-02 14:08:08 -0500387 if (iconCount > 0) {
Romain Guy6a42cf32010-03-12 16:03:52 -0800388 final boolean isPortrait = getWidth() < getHeight();
Jason Sams14f67ed2010-05-11 14:02:43 -0700389
Daniel Sandler388f6792010-03-02 14:08:08 -0500390 mArrowNavigation = true;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800391
Jason Sams14f67ed2010-05-11 14:02:43 -0700392 int currentSelection = sRollo.mScript.get_gSelectedIconIndex();
Joe Onorato2cc62e82010-03-17 20:23:53 -0700393 int currentTopRow = Math.round(sRollo.mScrollPos);
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800394
Romain Guy060b5c82010-03-04 10:07:38 -0800395 // The column of the current selection, in the range 0..COLUMNS_PER_PAGE_PORTRAIT-1
396 final int currentPageCol = currentSelection % mColumnsPerPage;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800397
Romain Guy060b5c82010-03-04 10:07:38 -0800398 // The row of the current selection, in the range 0..ROWS_PER_PAGE_PORTRAIT-1
Romain Guy6a42cf32010-03-12 16:03:52 -0800399 final int currentPageRow = (currentSelection - (currentTopRow * mColumnsPerPage))
Romain Guy060b5c82010-03-04 10:07:38 -0800400 / mRowsPerPage;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800401
Daniel Sandler388f6792010-03-02 14:08:08 -0500402 int newSelection = currentSelection;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800403
Daniel Sandler388f6792010-03-02 14:08:08 -0500404 switch (keyCode) {
405 case KeyEvent.KEYCODE_DPAD_UP:
406 if (mLastSelection == SELECTION_HOME) {
Romain Guy6a42cf32010-03-12 16:03:52 -0800407 if (isPortrait) {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700408 sRollo.setHomeSelected(SELECTED_NONE);
Romain Guy6a42cf32010-03-12 16:03:52 -0800409 int lastRowCount = iconCount % mColumnsPerPage;
410 if (lastRowCount == 0) {
411 lastRowCount = mColumnsPerPage;
412 }
413 newSelection = iconCount - lastRowCount + (mColumnsPerPage / 2);
414 if (newSelection >= iconCount) {
415 newSelection = iconCount-1;
416 }
417 int target = (newSelection / mColumnsPerPage) - (mRowsPerPage - 1);
418 if (target < 0) {
419 target = 0;
420 }
421 if (currentTopRow != target) {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700422 sRollo.moveTo(target);
Romain Guy6a42cf32010-03-12 16:03:52 -0800423 }
Daniel Sandler388f6792010-03-02 14:08:08 -0500424 }
425 } else {
426 if (currentPageRow > 0) {
Romain Guy060b5c82010-03-04 10:07:38 -0800427 newSelection = currentSelection - mColumnsPerPage;
Romain Guy6a42cf32010-03-12 16:03:52 -0800428 if (currentTopRow > newSelection / mColumnsPerPage) {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700429 sRollo.moveTo(newSelection / mColumnsPerPage);
Romain Guy6a42cf32010-03-12 16:03:52 -0800430 }
Daniel Sandler388f6792010-03-02 14:08:08 -0500431 } else if (currentTopRow > 0) {
Romain Guy060b5c82010-03-04 10:07:38 -0800432 newSelection = currentSelection - mColumnsPerPage;
Joe Onorato2cc62e82010-03-17 20:23:53 -0700433 sRollo.moveTo(newSelection / mColumnsPerPage);
Daniel Sandler388f6792010-03-02 14:08:08 -0500434 } else if (currentPageRow != 0) {
Romain Guy060b5c82010-03-04 10:07:38 -0800435 newSelection = currentTopRow * mRowsPerPage;
Daniel Sandler388f6792010-03-02 14:08:08 -0500436 }
437 }
438 handled = true;
439 break;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800440
Daniel Sandler388f6792010-03-02 14:08:08 -0500441 case KeyEvent.KEYCODE_DPAD_DOWN: {
Romain Guy060b5c82010-03-04 10:07:38 -0800442 final int rowCount = iconCount / mColumnsPerPage
443 + (iconCount % mColumnsPerPage == 0 ? 0 : 1);
444 final int currentRow = currentSelection / mColumnsPerPage;
Daniel Sandler388f6792010-03-02 14:08:08 -0500445 if (mLastSelection != SELECTION_HOME) {
446 if (currentRow < rowCount-1) {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700447 sRollo.setHomeSelected(SELECTED_NONE);
Daniel Sandler388f6792010-03-02 14:08:08 -0500448 if (currentSelection < 0) {
449 newSelection = 0;
450 } else {
Romain Guy060b5c82010-03-04 10:07:38 -0800451 newSelection = currentSelection + mColumnsPerPage;
Daniel Sandler388f6792010-03-02 14:08:08 -0500452 }
453 if (newSelection >= iconCount) {
454 // Go from D to G in this arrangement:
455 // A B C D
456 // E F G
457 newSelection = iconCount - 1;
458 }
Romain Guy060b5c82010-03-04 10:07:38 -0800459 if (currentPageRow >= mRowsPerPage - 1) {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700460 sRollo.moveTo((newSelection / mColumnsPerPage) - mRowsPerPage + 1);
Daniel Sandler388f6792010-03-02 14:08:08 -0500461 }
Romain Guy6a42cf32010-03-12 16:03:52 -0800462 } else if (isPortrait) {
Daniel Sandler388f6792010-03-02 14:08:08 -0500463 newSelection = -1;
Joe Onorato2cc62e82010-03-17 20:23:53 -0700464 sRollo.setHomeSelected(SELECTED_FOCUSED);
Daniel Sandler388f6792010-03-02 14:08:08 -0500465 }
466 }
467 handled = true;
468 break;
469 }
470 case KeyEvent.KEYCODE_DPAD_LEFT:
471 if (mLastSelection != SELECTION_HOME) {
472 if (currentPageCol > 0) {
473 newSelection = currentSelection - 1;
474 }
Romain Guy6a42cf32010-03-12 16:03:52 -0800475 } else if (!isPortrait) {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700476 newSelection = ((int) (sRollo.mScrollPos) * mColumnsPerPage) +
Romain Guy6a42cf32010-03-12 16:03:52 -0800477 (mRowsPerPage / 2 * mColumnsPerPage) + mColumnsPerPage - 1;
Joe Onorato2cc62e82010-03-17 20:23:53 -0700478 sRollo.setHomeSelected(SELECTED_NONE);
Daniel Sandler388f6792010-03-02 14:08:08 -0500479 }
480 handled = true;
481 break;
482 case KeyEvent.KEYCODE_DPAD_RIGHT:
483 if (mLastSelection != SELECTION_HOME) {
Romain Guy6a42cf32010-03-12 16:03:52 -0800484 if (!isPortrait && (currentPageCol == mColumnsPerPage - 1 ||
485 currentSelection == iconCount - 1)) {
486 newSelection = -1;
Joe Onorato2cc62e82010-03-17 20:23:53 -0700487 sRollo.setHomeSelected(SELECTED_FOCUSED);
Romain Guy6a42cf32010-03-12 16:03:52 -0800488 } else if ((currentPageCol < mColumnsPerPage - 1) &&
Daniel Sandler388f6792010-03-02 14:08:08 -0500489 (currentSelection < iconCount - 1)) {
490 newSelection = currentSelection + 1;
491 }
492 }
493 handled = true;
494 break;
495 }
496 if (newSelection != currentSelection) {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700497 sRollo.selectIcon(newSelection, SELECTED_FOCUSED);
Daniel Sandler388f6792010-03-02 14:08:08 -0500498 }
499 }
500 return handled;
501 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800502
Joe Onoratocfc4c7b2010-03-18 15:15:10 -0700503 void initTouchState(int width, int height) {
504 boolean isPortrait = width < height;
505
506 int[] viewPos = new int[2];
507 getLocationOnScreen(viewPos);
508
509 mTouchXBorders = new int[mColumnsPerPage + 1];
510 mTouchYBorders = new int[mRowsPerPage + 1];
511
512 // TODO: Put this in a config file/define
513 int cellHeight = 145;//iconsSize / Defines.ROWS_PER_PAGE_PORTRAIT;
514 if (!isPortrait) cellHeight -= 12;
515 int centerY = (int) (height * (isPortrait ? 0.5f : 0.47f));
516 if (!isPortrait) centerY += cellHeight / 2;
517 int half = (int) Math.floor((mRowsPerPage + 1) / 2);
518 int end = mTouchYBorders.length - (half + 1);
519
520 for (int i = -half; i <= end; i++) {
521 mTouchYBorders[i + half] = centerY + (i * cellHeight) - viewPos[1];
522 }
523
524 int x = 0;
525 // TODO: Put this in a config file/define
526 int columnWidth = 120;
527 for (int i = 0; i < mColumnsPerPage + 1; i++) {
528 mTouchXBorders[i] = x - viewPos[0];
529 x += columnWidth;
530 }
531 }
532
533 int chooseTappedIcon(int x, int y) {
534 float pos = sRollo != null ? sRollo.mScrollPos : 0;
535
536 int oldY = y;
537
538 // Adjust for scroll position if not zero.
539 y += (pos - ((int)pos)) * (mTouchYBorders[1] - mTouchYBorders[0]);
540
541 int col = -1;
542 int row = -1;
543 final int columnsCount = mColumnsPerPage;
544 for (int i=0; i< columnsCount; i++) {
545 if (x >= mTouchXBorders[i] && x < mTouchXBorders[i+1]) {
546 col = i;
547 break;
548 }
549 }
550 final int rowsCount = mRowsPerPage;
551 for (int i=0; i< rowsCount; i++) {
552 if (y >= mTouchYBorders[i] && y < mTouchYBorders[i+1]) {
553 row = i;
554 break;
555 }
556 }
557
558 if (row < 0 || col < 0) {
559 return -1;
560 }
561
562 int index = (((int) pos) * columnsCount) + (row * columnsCount) + col;
563
564 if (index >= mAllAppsList.size()) {
565 return -1;
566 } else {
567 return index;
568 }
569 }
570
Daniel Sandler388f6792010-03-02 14:08:08 -0500571 @Override
572 public boolean onTouchEvent(MotionEvent ev)
573 {
574 mArrowNavigation = false;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800575
Daniel Sandler388f6792010-03-02 14:08:08 -0500576 if (!isVisible()) {
577 return true;
578 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800579
Daniel Sandler388f6792010-03-02 14:08:08 -0500580 if (mLocks != 0) {
581 return true;
582 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800583
Daniel Sandler388f6792010-03-02 14:08:08 -0500584 super.onTouchEvent(ev);
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800585
Daniel Sandler388f6792010-03-02 14:08:08 -0500586 int x = (int)ev.getX();
587 int y = (int)ev.getY();
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800588
Romain Guyce115852010-03-04 12:15:37 -0800589 final boolean isPortrait = getWidth() < getHeight();
Daniel Sandler388f6792010-03-02 14:08:08 -0500590 int action = ev.getAction();
591 switch (action) {
592 case MotionEvent.ACTION_DOWN:
Joe Onoratocfc4c7b2010-03-18 15:15:10 -0700593 if ((isPortrait && y > mTouchYBorders[mTouchYBorders.length-1]) ||
594 (!isPortrait && x > mTouchXBorders[mTouchXBorders.length-1])) {
Daniel Sandler388f6792010-03-02 14:08:08 -0500595 mTouchTracking = TRACKING_HOME;
Joe Onorato2cc62e82010-03-17 20:23:53 -0700596 sRollo.setHomeSelected(SELECTED_PRESSED);
Daniel Sandler388f6792010-03-02 14:08:08 -0500597 mCurrentIconIndex = -1;
598 } else {
599 mTouchTracking = TRACKING_FLING;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800600
Daniel Sandler388f6792010-03-02 14:08:08 -0500601 mMotionDownRawX = (int)ev.getRawX();
602 mMotionDownRawY = (int)ev.getRawY();
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800603
Joe Onorato2cc62e82010-03-17 20:23:53 -0700604 if (!sRollo.checkClickOK()) {
605 sRollo.clearSelectedIcon();
Daniel Sandler388f6792010-03-02 14:08:08 -0500606 } else {
607 mDownIconIndex = mCurrentIconIndex
Joe Onorato2cc62e82010-03-17 20:23:53 -0700608 = sRollo.selectIcon(x, y, SELECTED_PRESSED);
Daniel Sandler388f6792010-03-02 14:08:08 -0500609 if (mDownIconIndex < 0) {
610 // if nothing was selected, no long press.
611 cancelLongPress();
612 }
613 }
Jason Sams60a55bb2010-06-18 15:11:19 -0700614 sRollo.move(ev.getRawY() / getHeight());
Daniel Sandler388f6792010-03-02 14:08:08 -0500615 mVelocityTracker = VelocityTracker.obtain();
616 mVelocityTracker.addMovement(ev);
617 mStartedScrolling = false;
618 }
619 break;
620 case MotionEvent.ACTION_MOVE:
621 case MotionEvent.ACTION_OUTSIDE:
622 if (mTouchTracking == TRACKING_HOME) {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700623 sRollo.setHomeSelected((isPortrait &&
Joe Onoratocfc4c7b2010-03-18 15:15:10 -0700624 y > mTouchYBorders[mTouchYBorders.length-1]) || (!isPortrait
625 && x > mTouchXBorders[mTouchXBorders.length-1])
Daniel Sandler388f6792010-03-02 14:08:08 -0500626 ? SELECTED_PRESSED : SELECTED_NONE);
Daniel Sandler388f6792010-03-02 14:08:08 -0500627 } else if (mTouchTracking == TRACKING_FLING) {
Daniel Sandler388f6792010-03-02 14:08:08 -0500628 int rawY = (int)ev.getRawY();
629 int slop;
630 slop = Math.abs(rawY - mMotionDownRawY);
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800631
Daniel Sandler388f6792010-03-02 14:08:08 -0500632 if (!mStartedScrolling && slop < mSlop) {
633 // don't update anything so when we do start scrolling
634 // below, we get the right delta.
Joe Onoratocfc4c7b2010-03-18 15:15:10 -0700635 mCurrentIconIndex = chooseTappedIcon(x, y);
Daniel Sandler388f6792010-03-02 14:08:08 -0500636 if (mDownIconIndex != mCurrentIconIndex) {
637 // If a different icon is selected, don't allow it to be picked up.
638 // This handles off-axis dragging.
639 cancelLongPress();
640 mCurrentIconIndex = -1;
641 }
642 } else {
643 if (!mStartedScrolling) {
644 cancelLongPress();
645 mCurrentIconIndex = -1;
646 }
Jason Sams60a55bb2010-06-18 15:11:19 -0700647 sRollo.move(ev.getRawY() / getHeight());
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800648
Daniel Sandler388f6792010-03-02 14:08:08 -0500649 mStartedScrolling = true;
Joe Onorato2cc62e82010-03-17 20:23:53 -0700650 sRollo.clearSelectedIcon();
Daniel Sandler388f6792010-03-02 14:08:08 -0500651 mVelocityTracker.addMovement(ev);
Daniel Sandler388f6792010-03-02 14:08:08 -0500652 }
653 }
654 break;
655 case MotionEvent.ACTION_UP:
656 case MotionEvent.ACTION_CANCEL:
657 if (mTouchTracking == TRACKING_HOME) {
658 if (action == MotionEvent.ACTION_UP) {
Joe Onoratocfc4c7b2010-03-18 15:15:10 -0700659 if ((isPortrait && y > mTouchYBorders[mTouchYBorders.length-1]) ||
660 (!isPortrait && x > mTouchXBorders[mTouchXBorders.length-1])) {
Daniel Sandler388f6792010-03-02 14:08:08 -0500661 reallyPlaySoundEffect(SoundEffectConstants.CLICK);
662 mLauncher.closeAllApps(true);
663 }
Joe Onorato2cc62e82010-03-17 20:23:53 -0700664 sRollo.setHomeSelected(SELECTED_NONE);
Daniel Sandler388f6792010-03-02 14:08:08 -0500665 }
666 mCurrentIconIndex = -1;
667 } else if (mTouchTracking == TRACKING_FLING) {
Daniel Sandler388f6792010-03-02 14:08:08 -0500668 mVelocityTracker.computeCurrentVelocity(1000 /* px/sec */, mMaxFlingVelocity);
Joe Onorato2cc62e82010-03-17 20:23:53 -0700669 sRollo.clearSelectedIcon();
Jason Sams60a55bb2010-06-18 15:11:19 -0700670 sRollo.fling(ev.getRawY() / getHeight(),
671 mVelocityTracker.getYVelocity() / getHeight());
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800672
Daniel Sandler388f6792010-03-02 14:08:08 -0500673 if (mVelocityTracker != null) {
674 mVelocityTracker.recycle();
675 mVelocityTracker = null;
676 }
677 }
678 mTouchTracking = TRACKING_NONE;
679 break;
680 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800681
Daniel Sandler388f6792010-03-02 14:08:08 -0500682 return true;
683 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800684
Daniel Sandler388f6792010-03-02 14:08:08 -0500685 public void onClick(View v) {
686 if (mLocks != 0 || !isVisible()) {
687 return;
688 }
Joe Onorato2cc62e82010-03-17 20:23:53 -0700689 if (sRollo.checkClickOK() && mCurrentIconIndex == mDownIconIndex
Daniel Sandler388f6792010-03-02 14:08:08 -0500690 && mCurrentIconIndex >= 0 && mCurrentIconIndex < mAllAppsList.size()) {
691 reallyPlaySoundEffect(SoundEffectConstants.CLICK);
692 ApplicationInfo app = mAllAppsList.get(mCurrentIconIndex);
Joe Onoratof984e852010-03-25 09:47:45 -0700693 mLauncher.startActivitySafely(app.intent, app);
Daniel Sandler388f6792010-03-02 14:08:08 -0500694 }
695 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800696
Daniel Sandler388f6792010-03-02 14:08:08 -0500697 public boolean onLongClick(View v) {
698 if (mLocks != 0 || !isVisible()) {
699 return true;
700 }
Joe Onorato2cc62e82010-03-17 20:23:53 -0700701 if (sRollo.checkClickOK() && mCurrentIconIndex == mDownIconIndex
Daniel Sandler388f6792010-03-02 14:08:08 -0500702 && mCurrentIconIndex >= 0 && mCurrentIconIndex < mAllAppsList.size()) {
703 ApplicationInfo app = mAllAppsList.get(mCurrentIconIndex);
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800704
Daniel Sandler388f6792010-03-02 14:08:08 -0500705 Bitmap bmp = app.iconBitmap;
706 final int w = bmp.getWidth();
707 final int h = bmp.getHeight();
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800708
Daniel Sandler388f6792010-03-02 14:08:08 -0500709 // We don't really have an accurate location to use. This will do.
710 int screenX = mMotionDownRawX - (w / 2);
711 int screenY = mMotionDownRawY - h;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800712
Daniel Sandler388f6792010-03-02 14:08:08 -0500713 mDragController.startDrag(bmp, screenX, screenY,
714 0, 0, w, h, this, app, DragController.DRAG_ACTION_COPY);
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800715
Daniel Sandler388f6792010-03-02 14:08:08 -0500716 mLauncher.closeAllApps(true);
717 }
718 return true;
719 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800720
Daniel Sandler388f6792010-03-02 14:08:08 -0500721 @Override
722 public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
723 if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SELECTED) {
724 if (!isVisible()) {
725 return false;
726 }
727 String text = null;
728 int index;
729 int count = mAllAppsList.size() + 1; // +1 is home
730 int pos = -1;
731 switch (mLastSelection) {
732 case SELECTION_ICONS:
Jason Sams14f67ed2010-05-11 14:02:43 -0700733 index = sRollo.mScript.get_gSelectedIconIndex();
Daniel Sandler388f6792010-03-02 14:08:08 -0500734 if (index >= 0) {
735 ApplicationInfo info = mAllAppsList.get(index);
736 if (info.title != null) {
737 text = info.title.toString();
738 pos = index;
739 }
740 }
741 break;
742 case SELECTION_HOME:
743 text = getContext().getString(R.string.all_apps_home_button_label);
744 pos = count;
745 break;
746 }
747 if (text != null) {
748 event.setEnabled(true);
749 event.getText().add(text);
750 //event.setContentDescription(text);
751 event.setItemCount(count);
752 event.setCurrentItemIndex(pos);
753 }
754 }
755 return false;
756 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800757
Daniel Sandler388f6792010-03-02 14:08:08 -0500758 public void setDragController(DragController dragger) {
759 mDragController = dragger;
760 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800761
Daniel Sandler388f6792010-03-02 14:08:08 -0500762 public void onDropCompleted(View target, boolean success) {
763 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800764
Daniel Sandler388f6792010-03-02 14:08:08 -0500765 /**
766 * Zoom to the specifed level.
767 *
768 * @param zoom [0..1] 0 is hidden, 1 is open
769 */
770 public void zoom(float zoom, boolean animate) {
771 cancelLongPress();
Joe Onoratoeffc4a82010-04-15 11:48:13 -0700772 sNextZoom = zoom;
773 sAnimateNextZoom = animate;
Daniel Sandler388f6792010-03-02 14:08:08 -0500774 // if we do setZoom while we don't have a surface, we won't
775 // get the callbacks that actually set mZoom.
Joe Onorato2cc62e82010-03-17 20:23:53 -0700776 if (sRollo == null || !mHaveSurface) {
Joe Onoratoeffc4a82010-04-15 11:48:13 -0700777 sZoomDirty = true;
Daniel Sandler388f6792010-03-02 14:08:08 -0500778 mZoom = zoom;
Daniel Sandler388f6792010-03-02 14:08:08 -0500779 } else {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700780 sRollo.setZoom(zoom, animate);
Daniel Sandler388f6792010-03-02 14:08:08 -0500781 }
782 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800783
Joe Onorato878f0862010-03-22 12:22:22 -0400784 /**
785 * If sRollo is null, then we're not visible. This is also used to guard against
786 * sRollo being null.
787 */
Daniel Sandler388f6792010-03-02 14:08:08 -0500788 public boolean isVisible() {
Joe Onorato878f0862010-03-22 12:22:22 -0400789 return sRollo != null && mZoom > 0.001f;
Daniel Sandler388f6792010-03-02 14:08:08 -0500790 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800791
Daniel Sandler388f6792010-03-02 14:08:08 -0500792 public boolean isOpaque() {
793 return mZoom > 0.999f;
794 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800795
Daniel Sandler388f6792010-03-02 14:08:08 -0500796 public void setApps(ArrayList<ApplicationInfo> list) {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700797 if (sRS == null) {
Daniel Sandler388f6792010-03-02 14:08:08 -0500798 // We've been removed from the window. Don't bother with all this.
799 return;
800 }
Romain Guy13c2e7b2010-03-10 19:45:00 -0800801
Daniel Sandler707b0f72010-04-15 16:41:31 -0400802 if (list != null) {
803 Collections.sort(list, LauncherModel.APP_NAME_COMPARATOR);
804 }
805
Romain Guy13c2e7b2010-03-10 19:45:00 -0800806 boolean reload = false;
807 if (mAllAppsList == null) {
808 reload = true;
809 } else if (list.size() != mAllAppsList.size()) {
810 reload = true;
811 } else {
812 final int count = list.size();
813 for (int i = 0; i < count; i++) {
814 if (list.get(i) != mAllAppsList.get(i)) {
815 reload = true;
816 break;
817 }
818 }
819 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800820
Daniel Sandler388f6792010-03-02 14:08:08 -0500821 mAllAppsList = list;
Joe Onorato2cc62e82010-03-17 20:23:53 -0700822 if (sRollo != null && reload) {
823 sRollo.setApps(list);
Daniel Sandler388f6792010-03-02 14:08:08 -0500824 }
Jason Sams14f67ed2010-05-11 14:02:43 -0700825
Romain Guyc16fea72010-03-12 17:17:56 -0800826 if (hasFocus() && mRestoreFocusIndex != -1) {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700827 sRollo.selectIcon(mRestoreFocusIndex, SELECTED_FOCUSED);
Romain Guyc16fea72010-03-12 17:17:56 -0800828 mRestoreFocusIndex = -1;
829 }
Jason Sams14f67ed2010-05-11 14:02:43 -0700830
Daniel Sandler388f6792010-03-02 14:08:08 -0500831 mLocks &= ~LOCK_ICONS_PENDING;
832 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800833
Daniel Sandler388f6792010-03-02 14:08:08 -0500834 public void addApps(ArrayList<ApplicationInfo> list) {
835 if (mAllAppsList == null) {
836 // Not done loading yet. We'll find out about it later.
837 return;
838 }
Joe Onorato2cc62e82010-03-17 20:23:53 -0700839 if (sRS == null) {
Daniel Sandler388f6792010-03-02 14:08:08 -0500840 // We've been removed from the window. Don't bother with all this.
841 return;
842 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800843
Daniel Sandler388f6792010-03-02 14:08:08 -0500844 final int N = list.size();
Joe Onorato2cc62e82010-03-17 20:23:53 -0700845 if (sRollo != null) {
846 sRollo.pause();
Jason Sams14f67ed2010-05-11 14:02:43 -0700847 sRollo.reallocAppsList(sRollo.mScript.get_gIconCount() + N);
Daniel Sandler388f6792010-03-02 14:08:08 -0500848 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800849
Daniel Sandler388f6792010-03-02 14:08:08 -0500850 for (int i=0; i<N; i++) {
851 final ApplicationInfo item = list.get(i);
852 int index = Collections.binarySearch(mAllAppsList, item,
853 LauncherModel.APP_NAME_COMPARATOR);
854 if (index < 0) {
855 index = -(index+1);
856 }
857 mAllAppsList.add(index, item);
Joe Onorato2cc62e82010-03-17 20:23:53 -0700858 if (sRollo != null) {
859 sRollo.addApp(index, item);
Daniel Sandler388f6792010-03-02 14:08:08 -0500860 }
861 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800862
Joe Onorato2cc62e82010-03-17 20:23:53 -0700863 if (sRollo != null) {
864 sRollo.saveAppsList();
865 sRollo.resume();
Daniel Sandler388f6792010-03-02 14:08:08 -0500866 }
867 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800868
Daniel Sandler388f6792010-03-02 14:08:08 -0500869 public void removeApps(ArrayList<ApplicationInfo> list) {
870 if (mAllAppsList == null) {
871 // Not done loading yet. We'll find out about it later.
872 return;
873 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800874
Joe Onorato2cc62e82010-03-17 20:23:53 -0700875 if (sRollo != null) {
876 sRollo.pause();
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800877 }
Daniel Sandler388f6792010-03-02 14:08:08 -0500878 final int N = list.size();
879 for (int i=0; i<N; i++) {
880 final ApplicationInfo item = list.get(i);
881 int index = findAppByComponent(mAllAppsList, item);
882 if (index >= 0) {
Daniel Sandler388f6792010-03-02 14:08:08 -0500883 mAllAppsList.remove(index);
Joe Onorato2cc62e82010-03-17 20:23:53 -0700884 if (sRollo != null) {
885 sRollo.removeApp(index);
Daniel Sandler388f6792010-03-02 14:08:08 -0500886 }
887 } else {
888 Log.w(TAG, "couldn't find a match for item \"" + item + "\"");
889 // Try to recover. This should keep us from crashing for now.
890 }
891 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800892
Joe Onorato2cc62e82010-03-17 20:23:53 -0700893 if (sRollo != null) {
894 sRollo.saveAppsList();
895 sRollo.resume();
Daniel Sandler388f6792010-03-02 14:08:08 -0500896 }
897 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800898
Joe Onorato64e6be72010-03-05 15:05:52 -0500899 public void updateApps(ArrayList<ApplicationInfo> list) {
Daniel Sandler388f6792010-03-02 14:08:08 -0500900 // Just remove and add, because they may need to be re-sorted.
901 removeApps(list);
902 addApps(list);
903 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800904
Daniel Sandler388f6792010-03-02 14:08:08 -0500905 private static int findAppByComponent(ArrayList<ApplicationInfo> list, ApplicationInfo item) {
906 ComponentName component = item.intent.getComponent();
907 final int N = list.size();
908 for (int i=0; i<N; i++) {
909 ApplicationInfo x = list.get(i);
910 if (x.intent.getComponent().equals(component)) {
911 return i;
912 }
913 }
914 return -1;
915 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800916
Daniel Sandler388f6792010-03-02 14:08:08 -0500917 class AAMessage extends RenderScript.RSMessage {
918 public void run() {
Joe Onorato2cc62e82010-03-17 20:23:53 -0700919 sRollo.mScrollPos = ((float)mData[0]) / (1 << 16);
Daniel Sandler388f6792010-03-02 14:08:08 -0500920 mVelocity = ((float)mData[1]) / (1 << 16);
Romain Guy8783a052010-06-07 17:08:34 -0700921
922 boolean lastVisible = isVisible();
Daniel Sandler388f6792010-03-02 14:08:08 -0500923 mZoom = ((float)mData[2]) / (1 << 16);
Romain Guy8783a052010-06-07 17:08:34 -0700924
925 final boolean visible = isVisible();
926 if (visible != lastVisible) {
927 post(new Runnable() {
928 public void run() {
929 if (visible) {
930 showSurface();
931 } else {
932 hideSurface();
933 }
934 }
935 });
936 }
937
Joe Onoratoeffc4a82010-04-15 11:48:13 -0700938 sZoomDirty = false;
Daniel Sandler388f6792010-03-02 14:08:08 -0500939 }
940 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800941
Romain Guy13c2e7b2010-03-10 19:45:00 -0800942 public static class RolloRS {
Daniel Sandler388f6792010-03-02 14:08:08 -0500943 // Allocations ======
944 private int mWidth;
945 private int mHeight;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800946
Daniel Sandler388f6792010-03-02 14:08:08 -0500947 private Resources mRes;
Jason Sams1aa4ff02010-06-15 14:59:57 -0700948 ScriptC_Allapps mScript;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800949
Daniel Sandler388f6792010-03-02 14:08:08 -0500950 private SimpleMesh mMesh;
951 private ProgramVertex.MatrixAllocation mPVA;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800952
Jason Sams14f67ed2010-05-11 14:02:43 -0700953 private ScriptField_VpConsts mUniformAlloc;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800954
Daniel Sandler388f6792010-03-02 14:08:08 -0500955 private Allocation mHomeButtonNormal;
956 private Allocation mHomeButtonFocused;
957 private Allocation mHomeButtonPressed;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800958
Daniel Sandler388f6792010-03-02 14:08:08 -0500959 private Allocation[] mIcons;
960 private int[] mIconIds;
961 private Allocation mAllocIconIds;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800962
Daniel Sandler388f6792010-03-02 14:08:08 -0500963 private Allocation[] mLabels;
964 private int[] mLabelIds;
965 private Allocation mAllocLabelIds;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800966
Daniel Sandler388f6792010-03-02 14:08:08 -0500967 private Bitmap mSelectionBitmap;
968 private Canvas mSelectionCanvas;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800969
Jason Sams14f67ed2010-05-11 14:02:43 -0700970 private float mScrollPos;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800971
Romain Guy13c2e7b2010-03-10 19:45:00 -0800972 AllApps3D mAllApps;
973 boolean mInitialize;
974
Daniel Sandler388f6792010-03-02 14:08:08 -0500975 class BaseAlloc {
976 Allocation mAlloc;
977 Type mType;
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800978
Daniel Sandler388f6792010-03-02 14:08:08 -0500979 void save() {
980 mAlloc.data(this);
981 }
982 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800983
Daniel Sandler388f6792010-03-02 14:08:08 -0500984 private boolean checkClickOK() {
Romain Guy13c2e7b2010-03-10 19:45:00 -0800985 return (Math.abs(mAllApps.mVelocity) < 0.4f) &&
Romain Guy6a42cf32010-03-12 16:03:52 -0800986 (Math.abs(mScrollPos - Math.round(mScrollPos)) < 0.4f);
Daniel Sandler388f6792010-03-02 14:08:08 -0500987 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800988
989 void pause() {
Joe Onoratoc5210eb2010-03-23 11:26:28 -0400990 if (sRS != null) {
991 sRS.contextBindRootScript(null);
992 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800993 }
994
995 void resume() {
Joe Onoratoc5210eb2010-03-23 11:26:28 -0400996 if (sRS != null) {
997 sRS.contextBindRootScript(mScript);
998 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -0800999 }
1000
Romain Guy13c2e7b2010-03-10 19:45:00 -08001001 public RolloRS(AllApps3D allApps) {
1002 mAllApps = allApps;
Daniel Sandler388f6792010-03-02 14:08:08 -05001003 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001004
Daniel Sandler388f6792010-03-02 14:08:08 -05001005 public void init(Resources res, int width, int height) {
1006 mRes = res;
1007 mWidth = width;
1008 mHeight = height;
Jason Sams1aa4ff02010-06-15 14:59:57 -07001009 mScript = new ScriptC_Allapps(sRS, mRes, R.raw.allapps_bc, true);
Jason Sams14f67ed2010-05-11 14:02:43 -07001010
Daniel Sandler388f6792010-03-02 14:08:08 -05001011 initProgramVertex();
1012 initProgramFragment();
1013 initProgramStore();
1014 initGl();
1015 initData();
Jason Sams14f67ed2010-05-11 14:02:43 -07001016
1017 mScript.bind_gIconIDs(mAllocIconIds);
1018 mScript.bind_gLabelIDs(mAllocLabelIds);
Jason Sams14f67ed2010-05-11 14:02:43 -07001019 sRS.contextBindRootScript(mScript);
Daniel Sandler388f6792010-03-02 14:08:08 -05001020 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001021
Daniel Sandler388f6792010-03-02 14:08:08 -05001022 public void initMesh() {
Joe Onorato2cc62e82010-03-17 20:23:53 -07001023 SimpleMesh.TriangleMeshBuilder tm = new SimpleMesh.TriangleMeshBuilder(sRS, 2, 0);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001024
Daniel Sandler388f6792010-03-02 14:08:08 -05001025 for (int ct=0; ct < 16; ct++) {
1026 float pos = (1.f / (16.f - 1)) * ct;
1027 tm.addVertex(0.0f, pos);
1028 tm.addVertex(1.0f, pos);
1029 }
1030 for (int ct=0; ct < (16 * 2 - 2); ct+= 2) {
1031 tm.addTriangle(ct, ct+1, ct+2);
1032 tm.addTriangle(ct+1, ct+3, ct+2);
1033 }
1034 mMesh = tm.create();
Jason Sams14f67ed2010-05-11 14:02:43 -07001035 mScript.set_gSMCell(mMesh);
Daniel Sandler388f6792010-03-02 14:08:08 -05001036 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001037
Daniel Sandler388f6792010-03-02 14:08:08 -05001038 void resize(int w, int h) {
1039 mPVA.setupProjectionNormalized(w, h);
1040 mWidth = w;
1041 mHeight = h;
1042 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001043
Daniel Sandler388f6792010-03-02 14:08:08 -05001044 private void initProgramVertex() {
Joe Onorato2cc62e82010-03-17 20:23:53 -07001045 mPVA = new ProgramVertex.MatrixAllocation(sRS);
Daniel Sandler388f6792010-03-02 14:08:08 -05001046 resize(mWidth, mHeight);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001047
Joe Onorato2cc62e82010-03-17 20:23:53 -07001048 ProgramVertex.Builder pvb = new ProgramVertex.Builder(sRS, null, null);
Daniel Sandler388f6792010-03-02 14:08:08 -05001049 pvb.setTextureMatrixEnable(true);
Jason Sams60a55bb2010-06-18 15:11:19 -07001050 ProgramVertex pv = pvb.create();
1051 pv.bindAllocation(mPVA);
1052 sRS.contextBindProgramVertex(pv);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001053
Jason Sams14f67ed2010-05-11 14:02:43 -07001054 mUniformAlloc = new ScriptField_VpConsts(sRS, 1);
1055 mScript.bind_vpConstants(mUniformAlloc);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001056
Daniel Sandler388f6792010-03-02 14:08:08 -05001057 initMesh();
Joe Onorato2cc62e82010-03-17 20:23:53 -07001058 ProgramVertex.ShaderBuilder sb = new ProgramVertex.ShaderBuilder(sRS);
Romain Guy060b5c82010-03-04 10:07:38 -08001059 String t = "void main() {\n" +
1060 // Animation
1061 " float ani = UNI_Position.z;\n" +
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001062
Romain Guy060b5c82010-03-04 10:07:38 -08001063 " float bendY1 = UNI_BendPos.x;\n" +
1064 " float bendY2 = UNI_BendPos.y;\n" +
1065 " float bendAngle = 47.0 * (3.14 / 180.0);\n" +
1066 " float bendDistance = bendY1 * 0.4;\n" +
1067 " float distanceDimLevel = 0.6;\n" +
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001068
Romain Guy060b5c82010-03-04 10:07:38 -08001069 " float bendStep = (bendAngle / bendDistance) * (bendAngle * 0.5);\n" +
1070 " float aDy = cos(bendAngle);\n" +
1071 " float aDz = sin(bendAngle);\n" +
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001072
Romain Guy060b5c82010-03-04 10:07:38 -08001073 " float scale = (2.0 / 480.0);\n" +
1074 " float x = UNI_Position.x + UNI_ImgSize.x * (1.0 - ani) * (ATTRIB_position.x - 0.5);\n" +
1075 " float ys= UNI_Position.y + UNI_ImgSize.y * (1.0 - ani) * ATTRIB_position.y;\n" +
1076 " float y = 0.0;\n" +
1077 " float z = 0.0;\n" +
1078 " float lum = 1.0;\n" +
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001079
Romain Guy060b5c82010-03-04 10:07:38 -08001080 " float cv = min(ys, bendY1 - bendDistance) - (bendY1 - bendDistance);\n" +
1081 " y += cv * aDy;\n" +
1082 " z += -cv * aDz;\n" +
1083 " cv = clamp(ys, bendY1 - bendDistance, bendY1) - bendY1;\n" + // curve range
1084 " lum += cv / bendDistance * distanceDimLevel;\n" +
1085 " y += cv * cos(cv * bendStep);\n" +
1086 " z += cv * sin(cv * bendStep);\n" +
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001087
Romain Guy060b5c82010-03-04 10:07:38 -08001088 " cv = max(ys, bendY2 + bendDistance) - (bendY2 + bendDistance);\n" +
1089 " y += cv * aDy;\n" +
1090 " z += cv * aDz;\n" +
1091 " cv = clamp(ys, bendY2, bendY2 + bendDistance) - bendY2;\n" +
1092 " lum -= cv / bendDistance * distanceDimLevel;\n" +
1093 " y += cv * cos(cv * bendStep);\n" +
1094 " z += cv * sin(cv * bendStep);\n" +
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001095
Romain Guy060b5c82010-03-04 10:07:38 -08001096 " y += clamp(ys, bendY1, bendY2);\n" +
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001097
Romain Guy060b5c82010-03-04 10:07:38 -08001098 " vec4 pos;\n" +
1099 " pos.x = (x + UNI_ScaleOffset.z) * UNI_ScaleOffset.x;\n" +
1100 " pos.y = (y + UNI_ScaleOffset.w) * UNI_ScaleOffset.x;\n" +
1101 " pos.z = z * UNI_ScaleOffset.x;\n" +
1102 " pos.w = 1.0;\n" +
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001103
Romain Guy060b5c82010-03-04 10:07:38 -08001104 " pos.x *= 1.0 + ani * 4.0;\n" +
1105 " pos.y *= 1.0 + ani * 4.0;\n" +
1106 " pos.z -= ani * 1.5;\n" +
1107 " lum *= 1.0 - ani;\n" +
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001108
Romain Guy060b5c82010-03-04 10:07:38 -08001109 " gl_Position = UNI_MVP * pos;\n" +
1110 " varColor.rgba = vec4(lum, lum, lum, 1.0);\n" +
1111 " varTex0.xy = ATTRIB_position;\n" +
1112 " varTex0.y = 1.0 - varTex0.y;\n" +
1113 " varTex0.zw = vec2(0.0, 0.0);\n" +
1114 "}\n";
Daniel Sandler388f6792010-03-02 14:08:08 -05001115 sb.setShader(t);
1116 sb.addConstant(mUniformAlloc.getType());
1117 sb.addInput(mMesh.getVertexType(0).getElement());
Jason Sams60a55bb2010-06-18 15:11:19 -07001118 ProgramVertex pvc = sb.create();
1119 pvc.bindAllocation(mPVA);
1120 pvc.bindConstants(mUniformAlloc.getAllocation(), 1);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001121
Jason Sams60a55bb2010-06-18 15:11:19 -07001122 mScript.set_gPVCurve(pvc);
Daniel Sandler388f6792010-03-02 14:08:08 -05001123 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001124
Daniel Sandler388f6792010-03-02 14:08:08 -05001125 private void initProgramFragment() {
Joe Onorato2cc62e82010-03-17 20:23:53 -07001126 Sampler.Builder sb = new Sampler.Builder(sRS);
Daniel Sandler388f6792010-03-02 14:08:08 -05001127 sb.setMin(Sampler.Value.LINEAR_MIP_LINEAR);
1128 sb.setMag(Sampler.Value.NEAREST);
1129 sb.setWrapS(Sampler.Value.CLAMP);
1130 sb.setWrapT(Sampler.Value.CLAMP);
1131 Sampler linear = sb.create();
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001132
Daniel Sandler388f6792010-03-02 14:08:08 -05001133 sb.setMin(Sampler.Value.NEAREST);
1134 sb.setMag(Sampler.Value.NEAREST);
1135 Sampler nearest = sb.create();
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001136
Joe Onorato2cc62e82010-03-17 20:23:53 -07001137 ProgramFragment.Builder bf = new ProgramFragment.Builder(sRS);
Daniel Sandler388f6792010-03-02 14:08:08 -05001138 bf.setTexture(ProgramFragment.Builder.EnvMode.MODULATE,
1139 ProgramFragment.Builder.Format.RGBA, 0);
Jason Sams60a55bb2010-06-18 15:11:19 -07001140 ProgramFragment pfTexMip = bf.create();
1141 pfTexMip.bindSampler(linear, 0);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001142
Jason Sams60a55bb2010-06-18 15:11:19 -07001143 ProgramFragment pfTexNearest = bf.create();
1144 pfTexNearest.bindSampler(nearest, 0);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001145
Daniel Sandler388f6792010-03-02 14:08:08 -05001146 bf.setTexture(ProgramFragment.Builder.EnvMode.MODULATE,
1147 ProgramFragment.Builder.Format.ALPHA, 0);
Jason Sams60a55bb2010-06-18 15:11:19 -07001148 ProgramFragment pfTexMipAlpha = bf.create();
1149 pfTexMipAlpha.bindSampler(linear, 0);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001150
Jason Sams60a55bb2010-06-18 15:11:19 -07001151 mScript.set_gPFTexNearest(pfTexNearest);
1152 mScript.set_gPFTexMip(pfTexMip);
1153 mScript.set_gPFTexMipAlpha(pfTexMipAlpha);
Daniel Sandler388f6792010-03-02 14:08:08 -05001154 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001155
Daniel Sandler388f6792010-03-02 14:08:08 -05001156 private void initProgramStore() {
Joe Onorato2cc62e82010-03-17 20:23:53 -07001157 ProgramStore.Builder bs = new ProgramStore.Builder(sRS, null, null);
Daniel Sandler388f6792010-03-02 14:08:08 -05001158 bs.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
1159 bs.setColorMask(true,true,true,false);
1160 bs.setDitherEnable(true);
1161 bs.setBlendFunc(ProgramStore.BlendSrcFunc.SRC_ALPHA,
1162 ProgramStore.BlendDstFunc.ONE_MINUS_SRC_ALPHA);
Jason Sams14f67ed2010-05-11 14:02:43 -07001163 mScript.set_gPS(bs.create());
Daniel Sandler388f6792010-03-02 14:08:08 -05001164 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001165
Daniel Sandler388f6792010-03-02 14:08:08 -05001166 private void initGl() {
Daniel Sandler388f6792010-03-02 14:08:08 -05001167 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001168
Daniel Sandler388f6792010-03-02 14:08:08 -05001169 private void initData() {
Jason Sams14f67ed2010-05-11 14:02:43 -07001170 mScript.set_COLUMNS_PER_PAGE_PORTRAIT(Defines.COLUMNS_PER_PAGE_PORTRAIT);
1171 mScript.set_ROWS_PER_PAGE_PORTRAIT(Defines.ROWS_PER_PAGE_PORTRAIT);
1172 mScript.set_COLUMNS_PER_PAGE_LANDSCAPE(Defines.COLUMNS_PER_PAGE_LANDSCAPE);
1173 mScript.set_ROWS_PER_PAGE_LANDSCAPE(Defines.ROWS_PER_PAGE_LANDSCAPE);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001174
Joe Onorato2cc62e82010-03-17 20:23:53 -07001175 mHomeButtonNormal = Allocation.createFromBitmapResource(sRS, mRes,
1176 R.drawable.home_button_normal, Element.RGBA_8888(sRS), false);
Daniel Sandler388f6792010-03-02 14:08:08 -05001177 mHomeButtonNormal.uploadToTexture(0);
Joe Onorato2cc62e82010-03-17 20:23:53 -07001178 mHomeButtonFocused = Allocation.createFromBitmapResource(sRS, mRes,
1179 R.drawable.home_button_focused, Element.RGBA_8888(sRS), false);
Daniel Sandler388f6792010-03-02 14:08:08 -05001180 mHomeButtonFocused.uploadToTexture(0);
Joe Onorato2cc62e82010-03-17 20:23:53 -07001181 mHomeButtonPressed = Allocation.createFromBitmapResource(sRS, mRes,
1182 R.drawable.home_button_pressed, Element.RGBA_8888(sRS), false);
Daniel Sandler388f6792010-03-02 14:08:08 -05001183 mHomeButtonPressed.uploadToTexture(0);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001184
Jason Sams14f67ed2010-05-11 14:02:43 -07001185 mScript.set_gHomeButton(mHomeButtonNormal);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001186
Daniel Sandler388f6792010-03-02 14:08:08 -05001187 mSelectionBitmap = Bitmap.createBitmap(Defines.SELECTION_TEXTURE_WIDTH_PX,
1188 Defines.SELECTION_TEXTURE_HEIGHT_PX, Bitmap.Config.ARGB_8888);
1189 mSelectionCanvas = new Canvas(mSelectionBitmap);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001190
Daniel Sandler388f6792010-03-02 14:08:08 -05001191 setApps(null);
1192 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001193
Daniel Sandler388f6792010-03-02 14:08:08 -05001194 void dirtyCheck() {
Joe Onoratoeffc4a82010-04-15 11:48:13 -07001195 if (sZoomDirty) {
1196 setZoom(mAllApps.sNextZoom, mAllApps.sAnimateNextZoom);
Daniel Sandler388f6792010-03-02 14:08:08 -05001197 }
1198 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001199
Romain Guy060b5c82010-03-04 10:07:38 -08001200 @SuppressWarnings({"ConstantConditions"})
Daniel Sandler388f6792010-03-02 14:08:08 -05001201 private void setApps(ArrayList<ApplicationInfo> list) {
Joe Onorato2cc62e82010-03-17 20:23:53 -07001202 sRollo.pause();
Daniel Sandler388f6792010-03-02 14:08:08 -05001203 final int count = list != null ? list.size() : 0;
1204 int allocCount = count;
1205 if (allocCount < 1) {
1206 allocCount = 1;
1207 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001208
Daniel Sandler388f6792010-03-02 14:08:08 -05001209 mIcons = new Allocation[count];
1210 mIconIds = new int[allocCount];
Jason Sams98994c42010-06-01 15:54:10 -07001211 mAllocIconIds = Allocation.createSized(sRS, Element.I32(sRS), allocCount);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001212
Daniel Sandler388f6792010-03-02 14:08:08 -05001213 mLabels = new Allocation[count];
1214 mLabelIds = new int[allocCount];
Jason Sams98994c42010-06-01 15:54:10 -07001215 mAllocLabelIds = Allocation.createSized(sRS, Element.I32(sRS), allocCount);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001216
Jason Sams14f67ed2010-05-11 14:02:43 -07001217 mScript.set_gIconCount(count);
1218 for (int i=0; i < count; i++) {
Daniel Sandler388f6792010-03-02 14:08:08 -05001219 createAppIconAllocations(i, list.get(i));
1220 }
Jason Sams14f67ed2010-05-11 14:02:43 -07001221 for (int i=0; i < count; i++) {
Daniel Sandler388f6792010-03-02 14:08:08 -05001222 uploadAppIcon(i, list.get(i));
1223 }
1224 saveAppsList();
Jason Sams14f67ed2010-05-11 14:02:43 -07001225 android.util.Log.e("rs", "setApps");
Joe Onorato2cc62e82010-03-17 20:23:53 -07001226 sRollo.resume();
Daniel Sandler388f6792010-03-02 14:08:08 -05001227 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001228
Daniel Sandler388f6792010-03-02 14:08:08 -05001229 private void setZoom(float zoom, boolean animate) {
Romain Guyc16fea72010-03-12 17:17:56 -08001230 if (animate) {
Joe Onorato2cc62e82010-03-17 20:23:53 -07001231 sRollo.clearSelectedIcon();
1232 sRollo.setHomeSelected(SELECTED_NONE);
Romain Guyc16fea72010-03-12 17:17:56 -08001233 }
Jason Sams60a55bb2010-06-18 15:11:19 -07001234 sRollo.mScript.invoke_setZoom(zoom, animate ? 1 : 0);
Daniel Sandler388f6792010-03-02 14:08:08 -05001235 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001236
Daniel Sandler388f6792010-03-02 14:08:08 -05001237 private void createAppIconAllocations(int index, ApplicationInfo item) {
Joe Onorato2cc62e82010-03-17 20:23:53 -07001238 mIcons[index] = Allocation.createFromBitmap(sRS, item.iconBitmap,
1239 Element.RGBA_8888(sRS), false);
1240 mLabels[index] = Allocation.createFromBitmap(sRS, item.titleBitmap,
1241 Element.A_8(sRS), false);
Daniel Sandler388f6792010-03-02 14:08:08 -05001242 mIconIds[index] = mIcons[index].getID();
1243 mLabelIds[index] = mLabels[index].getID();
1244 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001245
Daniel Sandler388f6792010-03-02 14:08:08 -05001246 private void uploadAppIcon(int index, ApplicationInfo item) {
1247 if (mIconIds[index] != mIcons[index].getID()) {
1248 throw new IllegalStateException("uploadAppIcon index=" + index
1249 + " mIcons[index].getID=" + mIcons[index].getID()
1250 + " mIconsIds[index]=" + mIconIds[index]
1251 + " item=" + item);
1252 }
Jason Samsd1e2e1d2010-03-05 13:24:31 -08001253 mIcons[index].uploadToTexture(true, 0);
1254 mLabels[index].uploadToTexture(true, 0);
Daniel Sandler388f6792010-03-02 14:08:08 -05001255 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001256
Daniel Sandler388f6792010-03-02 14:08:08 -05001257 /**
1258 * Puts the empty spaces at the end. Updates mState.iconCount. You must
1259 * fill in the values and call saveAppsList().
1260 */
1261 private void reallocAppsList(int count) {
1262 Allocation[] icons = new Allocation[count];
1263 int[] iconIds = new int[count];
Jason Sams98994c42010-06-01 15:54:10 -07001264 mAllocIconIds = Allocation.createSized(sRS, Element.I32(sRS), count);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001265
Daniel Sandler388f6792010-03-02 14:08:08 -05001266 Allocation[] labels = new Allocation[count];
1267 int[] labelIds = new int[count];
Jason Sams98994c42010-06-01 15:54:10 -07001268 mAllocLabelIds = Allocation.createSized(sRS, Element.I32(sRS), count);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001269
Jason Sams14f67ed2010-05-11 14:02:43 -07001270 final int oldCount = sRollo.mScript.get_gIconCount();
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001271
Daniel Sandler388f6792010-03-02 14:08:08 -05001272 System.arraycopy(mIcons, 0, icons, 0, oldCount);
1273 System.arraycopy(mIconIds, 0, iconIds, 0, oldCount);
1274 System.arraycopy(mLabels, 0, labels, 0, oldCount);
1275 System.arraycopy(mLabelIds, 0, labelIds, 0, oldCount);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001276
Daniel Sandler388f6792010-03-02 14:08:08 -05001277 mIcons = icons;
1278 mIconIds = iconIds;
1279 mLabels = labels;
1280 mLabelIds = labelIds;
1281 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001282
Daniel Sandler388f6792010-03-02 14:08:08 -05001283 /**
1284 * Handle the allocations for the new app. Make sure you call saveAppsList when done.
1285 */
1286 private void addApp(int index, ApplicationInfo item) {
Jason Sams14f67ed2010-05-11 14:02:43 -07001287 final int count = mScript.get_gIconCount() - index;
Daniel Sandler388f6792010-03-02 14:08:08 -05001288 final int dest = index + 1;
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001289
Daniel Sandler388f6792010-03-02 14:08:08 -05001290 System.arraycopy(mIcons, index, mIcons, dest, count);
1291 System.arraycopy(mIconIds, index, mIconIds, dest, count);
1292 System.arraycopy(mLabels, index, mLabels, dest, count);
1293 System.arraycopy(mLabelIds, index, mLabelIds, dest, count);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001294
Daniel Sandler388f6792010-03-02 14:08:08 -05001295 createAppIconAllocations(index, item);
1296 uploadAppIcon(index, item);
Jason Sams14f67ed2010-05-11 14:02:43 -07001297
1298 mScript.set_gIconCount(mScript.get_gIconCount() + 1);
Daniel Sandler388f6792010-03-02 14:08:08 -05001299 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001300
Daniel Sandler388f6792010-03-02 14:08:08 -05001301 /**
1302 * Handle the allocations for the removed app. Make sure you call saveAppsList when done.
1303 */
1304 private void removeApp(int index) {
Jason Sams14f67ed2010-05-11 14:02:43 -07001305 final int count = mScript.get_gIconCount() - index - 1;
Daniel Sandler388f6792010-03-02 14:08:08 -05001306 final int src = index + 1;
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001307
Daniel Sandler388f6792010-03-02 14:08:08 -05001308 System.arraycopy(mIcons, src, mIcons, index, count);
1309 System.arraycopy(mIconIds, src, mIconIds, index, count);
1310 System.arraycopy(mLabels, src, mLabels, index, count);
1311 System.arraycopy(mLabelIds, src, mLabelIds, index, count);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001312
Jason Sams14f67ed2010-05-11 14:02:43 -07001313 mScript.set_gIconCount(mScript.get_gIconCount() - 1);
1314 final int last = mScript.get_gIconCount();
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001315
Daniel Sandler388f6792010-03-02 14:08:08 -05001316 mIcons[last] = null;
1317 mIconIds[last] = 0;
1318 mLabels[last] = null;
1319 mLabelIds[last] = 0;
1320 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001321
Daniel Sandler388f6792010-03-02 14:08:08 -05001322 /**
1323 * Send the apps list structures to RS.
1324 */
1325 private void saveAppsList() {
1326 // WTF: how could mScript be not null but mAllocIconIds null b/2460740.
1327 if (mScript != null && mAllocIconIds != null) {
Daniel Sandler388f6792010-03-02 14:08:08 -05001328 mAllocIconIds.data(mIconIds);
1329 mAllocLabelIds.data(mLabelIds);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001330
Jason Sams14f67ed2010-05-11 14:02:43 -07001331 mScript.bind_gIconIDs(mAllocIconIds);
1332 mScript.bind_gLabelIDs(mAllocLabelIds);
Daniel Sandler388f6792010-03-02 14:08:08 -05001333 }
1334 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001335
Jason Sams60a55bb2010-06-18 15:11:19 -07001336 void fling(float pos, float v) {
1337 mScript.invoke_fling(pos, v);
Daniel Sandler388f6792010-03-02 14:08:08 -05001338 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001339
Jason Sams60a55bb2010-06-18 15:11:19 -07001340 void move(float pos) {
1341 mScript.invoke_move(pos);
Daniel Sandler388f6792010-03-02 14:08:08 -05001342 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001343
Daniel Sandler388f6792010-03-02 14:08:08 -05001344 void moveTo(float row) {
Jason Sams60a55bb2010-06-18 15:11:19 -07001345 mScript.invoke_moveTo(row);
Daniel Sandler388f6792010-03-02 14:08:08 -05001346 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001347
Daniel Sandler388f6792010-03-02 14:08:08 -05001348 /**
1349 * You need to call save() on mState on your own after calling this.
1350 *
1351 * @return the index of the icon that was selected.
1352 */
Romain Guy6a42cf32010-03-12 16:03:52 -08001353 int selectIcon(int x, int y, int pressed) {
Joe Onoratocfc4c7b2010-03-18 15:15:10 -07001354 if (mAllApps != null) {
1355 final int index = mAllApps.chooseTappedIcon(x, y);
1356 selectIcon(index, pressed);
1357 return index;
1358 } else {
1359 return -1;
1360 }
Daniel Sandler388f6792010-03-02 14:08:08 -05001361 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001362
Daniel Sandler388f6792010-03-02 14:08:08 -05001363 /**
1364 * Select the icon at the given index.
1365 *
1366 * @param index The index.
1367 * @param pressed one of SELECTED_PRESSED or SELECTED_FOCUSED
1368 */
1369 void selectIcon(int index, int pressed) {
Romain Guy13c2e7b2010-03-10 19:45:00 -08001370 final ArrayList<ApplicationInfo> appsList = mAllApps.mAllAppsList;
1371 if (appsList == null || index < 0 || index >= appsList.size()) {
Romain Guyc16fea72010-03-12 17:17:56 -08001372 if (mAllApps != null) {
1373 mAllApps.mRestoreFocusIndex = index;
1374 }
Jason Sams14f67ed2010-05-11 14:02:43 -07001375 mScript.set_gSelectedIconIndex(-1);
Romain Guy13c2e7b2010-03-10 19:45:00 -08001376 if (mAllApps.mLastSelection == SELECTION_ICONS) {
1377 mAllApps.mLastSelection = SELECTION_NONE;
Daniel Sandler388f6792010-03-02 14:08:08 -05001378 }
1379 } else {
1380 if (pressed == SELECTED_FOCUSED) {
Romain Guy13c2e7b2010-03-10 19:45:00 -08001381 mAllApps.mLastSelection = SELECTION_ICONS;
Daniel Sandler388f6792010-03-02 14:08:08 -05001382 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001383
Jason Sams14f67ed2010-05-11 14:02:43 -07001384 int prev = mScript.get_gSelectedIconIndex();
1385 mScript.set_gSelectedIconIndex(index);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001386
Romain Guy13c2e7b2010-03-10 19:45:00 -08001387 ApplicationInfo info = appsList.get(index);
Daniel Sandler388f6792010-03-02 14:08:08 -05001388 Bitmap selectionBitmap = mSelectionBitmap;
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001389
Daniel Sandler388f6792010-03-02 14:08:08 -05001390 Utilities.drawSelectedAllAppsBitmap(mSelectionCanvas,
1391 selectionBitmap.getWidth(), selectionBitmap.getHeight(),
1392 pressed == SELECTED_PRESSED, info.iconBitmap);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001393
Jason Sams60a55bb2010-06-18 15:11:19 -07001394 Allocation si = Allocation.createFromBitmap(sRS, selectionBitmap,
Joe Onorato2cc62e82010-03-17 20:23:53 -07001395 Element.RGBA_8888(sRS), false);
Jason Sams60a55bb2010-06-18 15:11:19 -07001396 si.uploadToTexture(0);
1397 mScript.set_gSelectedIconTexture(si);
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001398
Daniel Sandler388f6792010-03-02 14:08:08 -05001399 if (prev != index) {
1400 if (info.title != null && info.title.length() > 0) {
1401 //setContentDescription(info.title);
Romain Guy13c2e7b2010-03-10 19:45:00 -08001402 mAllApps.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
Daniel Sandler388f6792010-03-02 14:08:08 -05001403 }
1404 }
1405 }
1406 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001407
Daniel Sandler388f6792010-03-02 14:08:08 -05001408 /**
1409 * You need to call save() on mState on your own after calling this.
1410 */
1411 void clearSelectedIcon() {
Jason Sams14f67ed2010-05-11 14:02:43 -07001412 mScript.set_gSelectedIconIndex(-1);
Daniel Sandler388f6792010-03-02 14:08:08 -05001413 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001414
Daniel Sandler388f6792010-03-02 14:08:08 -05001415 void setHomeSelected(int mode) {
Romain Guy13c2e7b2010-03-10 19:45:00 -08001416 final int prev = mAllApps.mLastSelection;
Daniel Sandler388f6792010-03-02 14:08:08 -05001417 switch (mode) {
1418 case SELECTED_NONE:
Jason Sams14f67ed2010-05-11 14:02:43 -07001419 mScript.set_gHomeButton(mHomeButtonNormal);
Daniel Sandler388f6792010-03-02 14:08:08 -05001420 break;
1421 case SELECTED_FOCUSED:
Romain Guy13c2e7b2010-03-10 19:45:00 -08001422 mAllApps.mLastSelection = SELECTION_HOME;
Jason Sams14f67ed2010-05-11 14:02:43 -07001423 mScript.set_gHomeButton(mHomeButtonFocused);
Daniel Sandler388f6792010-03-02 14:08:08 -05001424 if (prev != SELECTION_HOME) {
Romain Guy13c2e7b2010-03-10 19:45:00 -08001425 mAllApps.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
Daniel Sandler388f6792010-03-02 14:08:08 -05001426 }
1427 break;
1428 case SELECTED_PRESSED:
Jason Sams14f67ed2010-05-11 14:02:43 -07001429 mScript.set_gHomeButton(mHomeButtonPressed);
Daniel Sandler388f6792010-03-02 14:08:08 -05001430 break;
1431 }
1432 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001433
Daniel Sandler388f6792010-03-02 14:08:08 -05001434 public void dumpState() {
Joe Onorato2cc62e82010-03-17 20:23:53 -07001435 Log.d(TAG, "sRollo.mWidth=" + mWidth);
1436 Log.d(TAG, "sRollo.mHeight=" + mHeight);
1437 Log.d(TAG, "sRollo.mIcons=" + Arrays.toString(mIcons));
Daniel Sandler388f6792010-03-02 14:08:08 -05001438 if (mIcons != null) {
Joe Onorato2cc62e82010-03-17 20:23:53 -07001439 Log.d(TAG, "sRollo.mIcons.length=" + mIcons.length);
Daniel Sandler388f6792010-03-02 14:08:08 -05001440 }
1441 if (mIconIds != null) {
Joe Onorato2cc62e82010-03-17 20:23:53 -07001442 Log.d(TAG, "sRollo.mIconIds.length=" + mIconIds.length);
Daniel Sandler388f6792010-03-02 14:08:08 -05001443 }
Joe Onorato2cc62e82010-03-17 20:23:53 -07001444 Log.d(TAG, "sRollo.mIconIds=" + Arrays.toString(mIconIds));
Daniel Sandler388f6792010-03-02 14:08:08 -05001445 if (mLabelIds != null) {
Joe Onorato2cc62e82010-03-17 20:23:53 -07001446 Log.d(TAG, "sRollo.mLabelIds.length=" + mLabelIds.length);
Daniel Sandler388f6792010-03-02 14:08:08 -05001447 }
Joe Onorato2cc62e82010-03-17 20:23:53 -07001448 Log.d(TAG, "sRollo.mLabelIds=" + Arrays.toString(mLabelIds));
Jason Sams14f67ed2010-05-11 14:02:43 -07001449 //Log.d(TAG, "sRollo.mState.newPositionX=" + mState.newPositionX);
1450 //Log.d(TAG, "sRollo.mState.newTouchDown=" + mState.newTouchDown);
1451 //Log.d(TAG, "sRollo.mState.flingVelocity=" + mState.flingVelocity);
1452 //Log.d(TAG, "sRollo.mState.iconCount=" + mState.iconCount);
1453 //Log.d(TAG, "sRollo.mState.selectedIconIndex=" + mState.selectedIconIndex);
1454 //Log.d(TAG, "sRollo.mState.selectedIconTexture=" + mState.selectedIconTexture);
1455 //Log.d(TAG, "sRollo.mState.zoomTarget=" + mState.zoomTarget);
1456 //Log.d(TAG, "sRollo.mState.homeButtonId=" + mState.homeButtonId);
1457 //Log.d(TAG, "sRollo.mState.targetPos=" + mState.targetPos);
Daniel Sandler388f6792010-03-02 14:08:08 -05001458 }
1459 }
Jason Samsdd8cd8b2010-03-11 12:38:48 -08001460
Daniel Sandler388f6792010-03-02 14:08:08 -05001461 public void dumpState() {
Joe Onorato2cc62e82010-03-17 20:23:53 -07001462 Log.d(TAG, "sRS=" + sRS);
1463 Log.d(TAG, "sRollo=" + sRollo);
Daniel Sandler388f6792010-03-02 14:08:08 -05001464 ApplicationInfo.dumpApplicationInfoList(TAG, "mAllAppsList", mAllAppsList);
Joe Onoratocfc4c7b2010-03-18 15:15:10 -07001465 Log.d(TAG, "mTouchXBorders=" + Arrays.toString(mTouchXBorders));
1466 Log.d(TAG, "mTouchYBorders=" + Arrays.toString(mTouchYBorders));
Daniel Sandler388f6792010-03-02 14:08:08 -05001467 Log.d(TAG, "mArrowNavigation=" + mArrowNavigation);
1468 Log.d(TAG, "mStartedScrolling=" + mStartedScrolling);
1469 Log.d(TAG, "mLastSelection=" + mLastSelection);
1470 Log.d(TAG, "mLastSelectedIcon=" + mLastSelectedIcon);
1471 Log.d(TAG, "mVelocityTracker=" + mVelocityTracker);
1472 Log.d(TAG, "mTouchTracking=" + mTouchTracking);
1473 Log.d(TAG, "mShouldGainFocus=" + mShouldGainFocus);
Joe Onoratoeffc4a82010-04-15 11:48:13 -07001474 Log.d(TAG, "sZoomDirty=" + sZoomDirty);
1475 Log.d(TAG, "sAnimateNextZoom=" + sAnimateNextZoom);
Daniel Sandler388f6792010-03-02 14:08:08 -05001476 Log.d(TAG, "mZoom=" + mZoom);
Joe Onorato2cc62e82010-03-17 20:23:53 -07001477 Log.d(TAG, "mScrollPos=" + sRollo.mScrollPos);
Daniel Sandler388f6792010-03-02 14:08:08 -05001478 Log.d(TAG, "mVelocity=" + mVelocity);
1479 Log.d(TAG, "mMessageProc=" + mMessageProc);
Joe Onorato2cc62e82010-03-17 20:23:53 -07001480 if (sRollo != null) {
1481 sRollo.dumpState();
Daniel Sandler388f6792010-03-02 14:08:08 -05001482 }
Joe Onorato2cc62e82010-03-17 20:23:53 -07001483 if (sRS != null) {
1484 sRS.contextDump(0);
Daniel Sandler388f6792010-03-02 14:08:08 -05001485 }
1486 }
1487}