Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.launcher2; |
| 18 | |
Joe Onorato | cb9f798 | 2009-10-31 16:32:02 -0400 | [diff] [blame] | 19 | import android.content.ComponentName; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 20 | import android.content.Context; |
| 21 | import android.content.res.Resources; |
| 22 | import android.graphics.Bitmap; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 23 | import android.graphics.Canvas; |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 24 | import android.graphics.PixelFormat; |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 25 | import android.graphics.Rect; |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame] | 26 | import android.os.SystemClock; |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 27 | import android.renderscript.Allocation; |
| 28 | import android.renderscript.Dimension; |
| 29 | import android.renderscript.Element; |
| 30 | import android.renderscript.ProgramFragment; |
| 31 | import android.renderscript.ProgramStore; |
| 32 | import android.renderscript.ProgramVertex; |
| 33 | import android.renderscript.RSSurfaceView; |
| 34 | import android.renderscript.RenderScript; |
| 35 | import android.renderscript.Sampler; |
| 36 | import android.renderscript.Script; |
| 37 | import android.renderscript.ScriptC; |
| 38 | import android.renderscript.SimpleMesh; |
| 39 | import android.renderscript.Type; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 40 | import android.util.AttributeSet; |
| 41 | import android.util.Log; |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame] | 42 | import android.view.KeyEvent; |
| 43 | import android.view.MotionEvent; |
Joe Onorato | b39e51a | 2009-10-28 15:47:49 -0400 | [diff] [blame] | 44 | import android.view.SoundEffectConstants; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 45 | import android.view.SurfaceHolder; |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame] | 46 | import android.view.VelocityTracker; |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 47 | import android.view.View; |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame] | 48 | import android.view.ViewConfiguration; |
Joe Onorato | 52a653f | 2009-11-11 14:52:11 -0800 | [diff] [blame] | 49 | import android.view.accessibility.AccessibilityEvent; |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 50 | |
| 51 | import java.util.ArrayList; |
Joe Onorato | be38609 | 2009-11-17 17:32:16 -0800 | [diff] [blame^] | 52 | import java.util.Arrays; |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 53 | import java.util.Collections; |
| 54 | import java.util.Comparator; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 55 | |
| 56 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 57 | public class AllAppsView extends RSSurfaceView |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 58 | implements View.OnClickListener, View.OnLongClickListener, DragSource { |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 59 | private static final String TAG = "Launcher.AllAppsView"; |
| 60 | |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 61 | /** Bit for mLocks for when there are icons being loaded. */ |
| 62 | private static final int LOCK_ICONS_PENDING = 1; |
| 63 | |
Joe Onorato | 68ffd10 | 2009-10-15 17:59:43 -0700 | [diff] [blame] | 64 | private static final int TRACKING_NONE = 0; |
| 65 | private static final int TRACKING_FLING = 1; |
| 66 | private static final int TRACKING_HOME = 2; |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 67 | |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 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 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 76 | private Launcher mLauncher; |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 77 | private DragController mDragController; |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 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; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 82 | |
Joe Onorato | 82ca550 | 2009-10-15 16:59:23 -0700 | [diff] [blame] | 83 | private int mSlop; |
Joe Onorato | f7b0e01 | 2009-10-01 14:09:15 -0700 | [diff] [blame] | 84 | private int mMaxFlingVelocity; |
| 85 | |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 86 | private Defines mDefines = new Defines(); |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 87 | private RenderScript mRS; |
| 88 | private RolloRS mRollo; |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 89 | private ArrayList<ApplicationInfo> mAllAppsList; |
Jason Sams | 2e19c05 | 2009-10-20 18:19:55 -0700 | [diff] [blame] | 90 | |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 91 | /** |
| 92 | * True when we are using arrow keys or trackball to drive navigation |
| 93 | */ |
| 94 | private boolean mArrowNavigation = false; |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 95 | private boolean mStartedScrolling; |
| 96 | |
| 97 | /** |
| 98 | * Used to keep track of the selection when AllAppsView loses window focus. |
| 99 | * One of the SELECTION_ constants. |
| 100 | */ |
| 101 | private int mLastSelection; |
Jason Sams | 2e19c05 | 2009-10-20 18:19:55 -0700 | [diff] [blame] | 102 | |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 103 | /** |
| 104 | * Used to keep track of the selection when AllAppsView loses window focus |
| 105 | */ |
| 106 | private int mLastSelectedIcon; |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 107 | |
Joe Onorato | 68ba5ca | 2009-11-12 14:23:43 -0800 | [diff] [blame] | 108 | private VelocityTracker mVelocityTracker; |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 109 | private int mTouchTracking; |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 110 | private int mMotionDownRawX; |
| 111 | private int mMotionDownRawY; |
Joe Onorato | 82ca550 | 2009-10-15 16:59:23 -0700 | [diff] [blame] | 112 | private int mDownIconIndex = -1; |
| 113 | private int mCurrentIconIndex = -1; |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 114 | |
Mike Cleron | b64b67a | 2009-11-08 14:56:25 -0800 | [diff] [blame] | 115 | private boolean mShouldGainFocus; |
| 116 | |
Joe Onorato | 3a8820b | 2009-11-10 15:06:42 -0800 | [diff] [blame] | 117 | private boolean mZoomDirty = false; |
Joe Onorato | 68ba5ca | 2009-11-12 14:23:43 -0800 | [diff] [blame] | 118 | private boolean mAnimateNextZoom; |
| 119 | private float mZoom; |
| 120 | private float mPosX; |
| 121 | private float mVelocity; |
| 122 | private AAMessage mMessageProc; |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 123 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 124 | static class Defines { |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 125 | public static final int ALLOC_PARAMS = 0; |
| 126 | public static final int ALLOC_STATE = 1; |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 127 | public static final int ALLOC_ICON_IDS = 3; |
| 128 | public static final int ALLOC_LABEL_IDS = 4; |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 129 | |
| 130 | public static final int COLUMNS_PER_PAGE = 4; |
| 131 | public static final int ROWS_PER_PAGE = 4; |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 132 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 133 | public static final int ICON_WIDTH_PX = 64; |
| 134 | public static final int ICON_TEXTURE_WIDTH_PX = 128; |
| 135 | |
| 136 | public static final int ICON_HEIGHT_PX = 64; |
| 137 | public static final int ICON_TEXTURE_HEIGHT_PX = 128; |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 138 | |
| 139 | public int SCREEN_WIDTH_PX; |
| 140 | public int SCREEN_HEIGHT_PX; |
| 141 | |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 142 | public void recompute(int w, int h) { |
| 143 | SCREEN_WIDTH_PX = 480; |
| 144 | SCREEN_HEIGHT_PX = 800; |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 145 | } |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 146 | } |
Joe Onorato | 7c312c1 | 2009-08-13 21:36:53 -0700 | [diff] [blame] | 147 | |
| 148 | public AllAppsView(Context context, AttributeSet attrs) { |
| 149 | super(context, attrs); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 150 | setFocusable(true); |
Joe Onorato | b39e51a | 2009-10-28 15:47:49 -0400 | [diff] [blame] | 151 | setSoundEffectsEnabled(false); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 152 | getHolder().setFormat(PixelFormat.TRANSLUCENT); |
Joe Onorato | f7b0e01 | 2009-10-01 14:09:15 -0700 | [diff] [blame] | 153 | final ViewConfiguration config = ViewConfiguration.get(context); |
Joe Onorato | 82ca550 | 2009-10-15 16:59:23 -0700 | [diff] [blame] | 154 | mSlop = config.getScaledTouchSlop(); |
Joe Onorato | f7b0e01 | 2009-10-01 14:09:15 -0700 | [diff] [blame] | 155 | mMaxFlingVelocity = config.getScaledMaximumFlingVelocity(); |
| 156 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 157 | setOnClickListener(this); |
| 158 | setOnLongClickListener(this); |
Dianne Hackborn | e52a1b5 | 2009-09-30 22:36:20 -0700 | [diff] [blame] | 159 | setZOrderOnTop(true); |
Jason Sams | fd22dac | 2009-09-20 17:24:16 -0700 | [diff] [blame] | 160 | getHolder().setFormat(PixelFormat.TRANSLUCENT); |
Jason Sams | e26d9fc | 2009-11-12 14:00:43 -0800 | [diff] [blame] | 161 | |
| 162 | mRS = createRenderScript(true); |
| 163 | } |
| 164 | |
| 165 | @Override |
| 166 | protected void onDetachedFromWindow() { |
| 167 | destroyRenderScript(); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 168 | } |
| 169 | |
Joe Onorato | b39e51a | 2009-10-28 15:47:49 -0400 | [diff] [blame] | 170 | /** |
| 171 | * If you have an attached click listener, View always plays the click sound!?!? |
| 172 | * Deal with sound effects by hand. |
| 173 | */ |
| 174 | public void reallyPlaySoundEffect(int sound) { |
| 175 | boolean old = isSoundEffectsEnabled(); |
| 176 | setSoundEffectsEnabled(true); |
| 177 | playSoundEffect(sound); |
| 178 | setSoundEffectsEnabled(old); |
| 179 | } |
| 180 | |
Joe Onorato | 7c312c1 | 2009-08-13 21:36:53 -0700 | [diff] [blame] | 181 | public AllAppsView(Context context, AttributeSet attrs, int defStyle) { |
| 182 | this(context, attrs); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 183 | } |
| 184 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 185 | public void setLauncher(Launcher launcher) { |
| 186 | mLauncher = launcher; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 189 | @Override |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 190 | public void surfaceDestroyed(SurfaceHolder holder) { |
| 191 | super.surfaceDestroyed(holder); |
Jason Sams | 20df7c7 | 2009-11-05 12:30:24 -0800 | [diff] [blame] | 192 | mRollo.mHasSurface = false; |
Joe Onorato | fab7440 | 2009-11-11 16:05:23 -0800 | [diff] [blame] | 193 | // Without this, we leak mMessageCallback which leaks the context. |
| 194 | mRS.mMessageCallback = null; |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | @Override |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 198 | public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { |
Joe Onorato | a30ce8e | 2009-11-11 08:16:49 -0800 | [diff] [blame] | 199 | //long startTime = SystemClock.uptimeMillis(); |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 200 | |
Joe Onorato | 080d9b6 | 2009-11-02 12:01:11 -0500 | [diff] [blame] | 201 | super.surfaceChanged(holder, format, w, h); |
| 202 | |
Jason Sams | e26d9fc | 2009-11-12 14:00:43 -0800 | [diff] [blame] | 203 | if (mRollo == null) { |
Jason Sams | 9039667 | 2009-11-03 13:59:34 -0800 | [diff] [blame] | 204 | mRollo = new RolloRS(); |
Jason Sams | 20df7c7 | 2009-11-05 12:30:24 -0800 | [diff] [blame] | 205 | mRollo.mHasSurface = true; |
Jason Sams | 9039667 | 2009-11-03 13:59:34 -0800 | [diff] [blame] | 206 | mRollo.init(getResources(), w, h); |
| 207 | if (mAllAppsList != null) { |
| 208 | mRollo.setApps(mAllAppsList); |
Jason Sams | 9039667 | 2009-11-03 13:59:34 -0800 | [diff] [blame] | 209 | } |
Mike Cleron | b64b67a | 2009-11-08 14:56:25 -0800 | [diff] [blame] | 210 | if (mShouldGainFocus) { |
| 211 | gainFocus(); |
| 212 | mShouldGainFocus = false; |
| 213 | } |
Jason Sams | 20df7c7 | 2009-11-05 12:30:24 -0800 | [diff] [blame] | 214 | } else { |
| 215 | mRollo.mHasSurface = true; |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 216 | } |
Jason Sams | e26d9fc | 2009-11-12 14:00:43 -0800 | [diff] [blame] | 217 | mRollo.dirtyCheck(); |
Jason Sams | 5612e43 | 2009-11-16 14:18:07 -0800 | [diff] [blame] | 218 | mRollo.resize(w, h); |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 219 | |
Joe Onorato | cb75f36 | 2009-11-12 13:04:07 -0800 | [diff] [blame] | 220 | mRS.mMessageCallback = mMessageProc = new AAMessage(); |
| 221 | |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 222 | Resources res = getContext().getResources(); |
| 223 | int barHeight = (int)res.getDimension(R.dimen.button_bar_height); |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 224 | |
Joe Onorato | a30ce8e | 2009-11-11 08:16:49 -0800 | [diff] [blame] | 225 | //long endTime = SystemClock.uptimeMillis(); |
| 226 | //Log.d(TAG, "surfaceChanged took " + (endTime-startTime) + "ms"); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 227 | } |
Jason Sams | 2e19c05 | 2009-10-20 18:19:55 -0700 | [diff] [blame] | 228 | |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 229 | @Override |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 230 | public void onWindowFocusChanged(boolean hasWindowFocus) { |
| 231 | super.onWindowFocusChanged(hasWindowFocus); |
| 232 | if (mArrowNavigation) { |
| 233 | if (!hasWindowFocus) { |
| 234 | // Clear selection when we lose window focus |
| 235 | mLastSelectedIcon = mRollo.mState.selectedIconIndex; |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 236 | mRollo.setHomeSelected(SELECTED_NONE); |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 237 | mRollo.clearSelectedIcon(); |
| 238 | mRollo.mState.save(); |
| 239 | } else if (hasWindowFocus) { |
| 240 | if (mRollo.mState.iconCount > 0) { |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 241 | if (mLastSelection == SELECTION_ICONS) { |
| 242 | int selection = mLastSelectedIcon; |
Joe Onorato | 68ba5ca | 2009-11-12 14:23:43 -0800 | [diff] [blame] | 243 | final int firstIcon = Math.round(mPosX) * |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 244 | Defines.COLUMNS_PER_PAGE; |
| 245 | if (selection < 0 || // No selection |
| 246 | selection < firstIcon || // off the top of the screen |
| 247 | selection >= mRollo.mState.iconCount || // past last icon |
| 248 | selection >= firstIcon + // past last icon on screen |
| 249 | (Defines.COLUMNS_PER_PAGE * Defines.ROWS_PER_PAGE)) { |
| 250 | selection = firstIcon; |
| 251 | } |
| 252 | |
| 253 | // Select the first icon when we gain window focus |
| 254 | mRollo.selectIcon(selection, SELECTED_FOCUSED); |
| 255 | mRollo.mState.save(); |
| 256 | } else if (mLastSelection == SELECTION_HOME) { |
| 257 | mRollo.setHomeSelected(SELECTED_FOCUSED); |
| 258 | mRollo.mState.save(); |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 259 | } |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 260 | } |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | @Override |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 266 | protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) { |
| 267 | super.onFocusChanged(gainFocus, direction, previouslyFocusedRect); |
Joe Onorato | 859b3a7 | 2009-10-28 15:17:01 -0400 | [diff] [blame] | 268 | |
| 269 | if (!isVisible()) { |
| 270 | return; |
| 271 | } |
| 272 | |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 273 | if (gainFocus) { |
Mike Cleron | b64b67a | 2009-11-08 14:56:25 -0800 | [diff] [blame] | 274 | if (mRollo != null) { |
| 275 | gainFocus(); |
| 276 | } else { |
| 277 | mShouldGainFocus = true; |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 278 | } |
| 279 | } else { |
Mike Cleron | b64b67a | 2009-11-08 14:56:25 -0800 | [diff] [blame] | 280 | if (mRollo != null) { |
| 281 | if (mArrowNavigation) { |
| 282 | // Clear selection when we lose focus |
| 283 | mRollo.clearSelectedIcon(); |
| 284 | mRollo.setHomeSelected(SELECTED_NONE); |
| 285 | mRollo.mState.save(); |
| 286 | mArrowNavigation = false; |
| 287 | } |
| 288 | } else { |
| 289 | mShouldGainFocus = false; |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 290 | } |
| 291 | } |
| 292 | } |
| 293 | |
Mike Cleron | b64b67a | 2009-11-08 14:56:25 -0800 | [diff] [blame] | 294 | private void gainFocus() { |
| 295 | if (!mArrowNavigation && mRollo.mState.iconCount > 0) { |
| 296 | // Select the first icon when we gain keyboard focus |
| 297 | mArrowNavigation = true; |
Joe Onorato | 68ba5ca | 2009-11-12 14:23:43 -0800 | [diff] [blame] | 298 | mRollo.selectIcon(Math.round(mPosX) * Defines.COLUMNS_PER_PAGE, |
Mike Cleron | b64b67a | 2009-11-08 14:56:25 -0800 | [diff] [blame] | 299 | SELECTED_FOCUSED); |
| 300 | mRollo.mState.save(); |
| 301 | } |
| 302 | } |
| 303 | |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 304 | @Override |
| 305 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
Jason Sams | 2e19c05 | 2009-10-20 18:19:55 -0700 | [diff] [blame] | 306 | |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 307 | boolean handled = false; |
Jason Sams | e26d9fc | 2009-11-12 14:00:43 -0800 | [diff] [blame] | 308 | |
Joe Onorato | 859b3a7 | 2009-10-28 15:17:01 -0400 | [diff] [blame] | 309 | if (!isVisible()) { |
| 310 | return false; |
| 311 | } |
Joe Onorato | a13f574 | 2009-11-02 17:15:19 -0500 | [diff] [blame] | 312 | final int iconCount = mRollo.mState.iconCount; |
| 313 | |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 314 | if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) { |
| 315 | if (mArrowNavigation) { |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 316 | if (mLastSelection == SELECTION_HOME) { |
| 317 | reallyPlaySoundEffect(SoundEffectConstants.CLICK); |
| 318 | mLauncher.closeAllApps(true); |
| 319 | } else { |
| 320 | int whichApp = mRollo.mState.selectedIconIndex; |
| 321 | if (whichApp >= 0) { |
| 322 | ApplicationInfo app = mAllAppsList.get(whichApp); |
| 323 | mLauncher.startActivitySafely(app.intent); |
| 324 | handled = true; |
| 325 | } |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 326 | } |
| 327 | } |
| 328 | } |
Jason Sams | 2e19c05 | 2009-10-20 18:19:55 -0700 | [diff] [blame] | 329 | |
Joe Onorato | 478730f | 2009-11-16 18:54:43 -0800 | [diff] [blame] | 330 | if (iconCount > 0) { |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 331 | mArrowNavigation = true; |
Jason Sams | 2e19c05 | 2009-10-20 18:19:55 -0700 | [diff] [blame] | 332 | |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 333 | int currentSelection = mRollo.mState.selectedIconIndex; |
Joe Onorato | 68ba5ca | 2009-11-12 14:23:43 -0800 | [diff] [blame] | 334 | int currentTopRow = Math.round(mPosX); |
Jason Sams | 2e19c05 | 2009-10-20 18:19:55 -0700 | [diff] [blame] | 335 | |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 336 | // The column of the current selection, in the range 0..COLUMNS_PER_PAGE-1 |
Joe Onorato | a13f574 | 2009-11-02 17:15:19 -0500 | [diff] [blame] | 337 | final int currentPageCol = currentSelection % Defines.COLUMNS_PER_PAGE; |
Jason Sams | 2e19c05 | 2009-10-20 18:19:55 -0700 | [diff] [blame] | 338 | |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 339 | // The row of the current selection, in the range 0..ROWS_PER_PAGE-1 |
Joe Onorato | a13f574 | 2009-11-02 17:15:19 -0500 | [diff] [blame] | 340 | final int currentPageRow = (currentSelection - (currentTopRow*Defines.COLUMNS_PER_PAGE)) |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 341 | / Defines.ROWS_PER_PAGE; |
Jason Sams | 2e19c05 | 2009-10-20 18:19:55 -0700 | [diff] [blame] | 342 | |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 343 | int newSelection = currentSelection; |
| 344 | |
| 345 | switch (keyCode) { |
| 346 | case KeyEvent.KEYCODE_DPAD_UP: |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 347 | if (mLastSelection == SELECTION_HOME) { |
| 348 | mRollo.setHomeSelected(SELECTED_NONE); |
| 349 | int lastRowCount = iconCount % Defines.COLUMNS_PER_PAGE; |
| 350 | if (lastRowCount == 0) { |
| 351 | lastRowCount = Defines.COLUMNS_PER_PAGE; |
| 352 | } |
| 353 | newSelection = iconCount - lastRowCount + (Defines.COLUMNS_PER_PAGE / 2); |
| 354 | if (newSelection >= iconCount) { |
| 355 | newSelection = iconCount-1; |
| 356 | } |
| 357 | int target = (newSelection / Defines.COLUMNS_PER_PAGE) |
| 358 | - (Defines.ROWS_PER_PAGE - 1); |
| 359 | if (target < 0) { |
| 360 | target = 0; |
| 361 | } |
| 362 | if (currentTopRow != target) { |
| 363 | mRollo.moveTo(target); |
| 364 | } |
| 365 | } else { |
| 366 | if (currentPageRow > 0) { |
| 367 | newSelection = currentSelection - Defines.COLUMNS_PER_PAGE; |
| 368 | } else if (currentTopRow > 0) { |
| 369 | newSelection = currentSelection - Defines.COLUMNS_PER_PAGE; |
| 370 | mRollo.moveTo(newSelection / Defines.COLUMNS_PER_PAGE); |
Joe Onorato | 478730f | 2009-11-16 18:54:43 -0800 | [diff] [blame] | 371 | } else { |
| 372 | newSelection = Defines.COLUMNS_PER_PAGE * (Defines.ROWS_PER_PAGE-1); |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 373 | } |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 374 | } |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 375 | handled = true; |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 376 | break; |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 377 | |
Joe Onorato | a13f574 | 2009-11-02 17:15:19 -0500 | [diff] [blame] | 378 | case KeyEvent.KEYCODE_DPAD_DOWN: { |
| 379 | final int rowCount = iconCount / Defines.COLUMNS_PER_PAGE |
| 380 | + (iconCount % Defines.COLUMNS_PER_PAGE == 0 ? 0 : 1); |
| 381 | final int currentRow = currentSelection / Defines.COLUMNS_PER_PAGE; |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 382 | if (mLastSelection != SELECTION_HOME) { |
| 383 | if (currentRow < rowCount-1) { |
| 384 | mRollo.setHomeSelected(SELECTED_NONE); |
Joe Onorato | 478730f | 2009-11-16 18:54:43 -0800 | [diff] [blame] | 385 | if (currentSelection < 0) { |
| 386 | newSelection = 0; |
| 387 | } else { |
| 388 | newSelection = currentSelection + Defines.COLUMNS_PER_PAGE; |
| 389 | } |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 390 | if (newSelection >= iconCount) { |
| 391 | // Go from D to G in this arrangement: |
| 392 | // A B C D |
| 393 | // E F G |
| 394 | newSelection = iconCount - 1; |
| 395 | } |
| 396 | if (currentPageRow >= Defines.ROWS_PER_PAGE - 1) { |
| 397 | mRollo.moveTo((newSelection / Defines.COLUMNS_PER_PAGE) - |
| 398 | Defines.ROWS_PER_PAGE + 1); |
| 399 | } |
| 400 | } else { |
| 401 | newSelection = -1; |
| 402 | mRollo.setHomeSelected(SELECTED_FOCUSED); |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 403 | } |
| 404 | } |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 405 | handled = true; |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 406 | break; |
Joe Onorato | a13f574 | 2009-11-02 17:15:19 -0500 | [diff] [blame] | 407 | } |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 408 | case KeyEvent.KEYCODE_DPAD_LEFT: |
| 409 | if (currentPageCol > 0) { |
| 410 | newSelection = currentSelection - 1; |
| 411 | } |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 412 | handled = true; |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 413 | break; |
| 414 | case KeyEvent.KEYCODE_DPAD_RIGHT: |
Jason Sams | 2e19c05 | 2009-10-20 18:19:55 -0700 | [diff] [blame] | 415 | if ((currentPageCol < Defines.COLUMNS_PER_PAGE - 1) && |
Joe Onorato | a13f574 | 2009-11-02 17:15:19 -0500 | [diff] [blame] | 416 | (currentSelection < iconCount - 1)) { |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 417 | newSelection = currentSelection + 1; |
| 418 | } |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 419 | handled = true; |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 420 | break; |
| 421 | } |
| 422 | if (newSelection != currentSelection) { |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 423 | mRollo.selectIcon(newSelection, SELECTED_FOCUSED); |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 424 | mRollo.mState.save(); |
| 425 | } |
| 426 | } |
Mike Cleron | 4a5c1e1 | 2009-11-03 10:17:05 -0800 | [diff] [blame] | 427 | return handled; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 428 | } |
| 429 | |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 430 | @Override |
| 431 | public boolean onTouchEvent(MotionEvent ev) |
| 432 | { |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 433 | mArrowNavigation = false; |
Jason Sams | 2e19c05 | 2009-10-20 18:19:55 -0700 | [diff] [blame] | 434 | |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 435 | if (!isVisible()) { |
Joe Onorato | 85a02a8 | 2009-09-08 12:34:22 -0700 | [diff] [blame] | 436 | return true; |
Joe Onorato | e3406a2 | 2009-09-03 14:36:25 -0700 | [diff] [blame] | 437 | } |
| 438 | |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 439 | if (mLocks != 0) { |
Joe Onorato | 85a02a8 | 2009-09-08 12:34:22 -0700 | [diff] [blame] | 440 | return true; |
| 441 | } |
| 442 | |
| 443 | super.onTouchEvent(ev); |
| 444 | |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 445 | int x = (int)ev.getX(); |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 446 | int y = (int)ev.getY(); |
| 447 | |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 448 | int action = ev.getAction(); |
| 449 | switch (action) { |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 450 | case MotionEvent.ACTION_DOWN: |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 451 | if (y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]) { |
| 452 | mTouchTracking = TRACKING_HOME; |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 453 | mRollo.setHomeSelected(SELECTED_PRESSED); |
Joe Onorato | d63458b | 2009-10-15 21:19:09 -0700 | [diff] [blame] | 454 | mRollo.mState.save(); |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 455 | mCurrentIconIndex = -1; |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 456 | } else { |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 457 | mTouchTracking = TRACKING_FLING; |
| 458 | |
| 459 | mMotionDownRawX = (int)ev.getRawX(); |
| 460 | mMotionDownRawY = (int)ev.getRawY(); |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 461 | |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 462 | mRollo.mState.newPositionX = ev.getRawY() / getHeight(); |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 463 | mRollo.mState.newTouchDown = 1; |
| 464 | |
| 465 | if (!mRollo.checkClickOK()) { |
| 466 | mRollo.clearSelectedIcon(); |
| 467 | } else { |
Joe Onorato | 82ca550 | 2009-10-15 16:59:23 -0700 | [diff] [blame] | 468 | mDownIconIndex = mCurrentIconIndex |
Joe Onorato | 68ba5ca | 2009-11-12 14:23:43 -0800 | [diff] [blame] | 469 | = mRollo.selectIcon(x, y, mPosX, SELECTED_PRESSED); |
Joe Onorato | 82ca550 | 2009-10-15 16:59:23 -0700 | [diff] [blame] | 470 | if (mDownIconIndex < 0) { |
| 471 | // if nothing was selected, no long press. |
| 472 | cancelLongPress(); |
| 473 | } |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 474 | } |
| 475 | mRollo.mState.save(); |
Jason Sams | d8152b9 | 2009-10-13 17:19:10 -0700 | [diff] [blame] | 476 | mRollo.move(); |
Joe Onorato | 68ba5ca | 2009-11-12 14:23:43 -0800 | [diff] [blame] | 477 | mVelocityTracker = VelocityTracker.obtain(); |
| 478 | mVelocityTracker.addMovement(ev); |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 479 | mStartedScrolling = false; |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 480 | } |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 481 | break; |
| 482 | case MotionEvent.ACTION_MOVE: |
| 483 | case MotionEvent.ACTION_OUTSIDE: |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 484 | if (mTouchTracking == TRACKING_HOME) { |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 485 | mRollo.setHomeSelected(y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1] |
| 486 | ? SELECTED_PRESSED : SELECTED_NONE); |
Joe Onorato | d63458b | 2009-10-15 21:19:09 -0700 | [diff] [blame] | 487 | mRollo.mState.save(); |
Joe Onorato | 68ffd10 | 2009-10-15 17:59:43 -0700 | [diff] [blame] | 488 | } else if (mTouchTracking == TRACKING_FLING) { |
Joe Onorato | 82ca550 | 2009-10-15 16:59:23 -0700 | [diff] [blame] | 489 | int rawX = (int)ev.getRawX(); |
| 490 | int rawY = (int)ev.getRawY(); |
| 491 | int slop; |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 492 | slop = Math.abs(rawY - mMotionDownRawY); |
Jason Sams | d8152b9 | 2009-10-13 17:19:10 -0700 | [diff] [blame] | 493 | |
Joe Onorato | 82ca550 | 2009-10-15 16:59:23 -0700 | [diff] [blame] | 494 | if (!mStartedScrolling && slop < mSlop) { |
| 495 | // don't update anything so when we do start scrolling |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 496 | // below, we get the right delta. |
Joe Onorato | 68ba5ca | 2009-11-12 14:23:43 -0800 | [diff] [blame] | 497 | mCurrentIconIndex = mRollo.chooseTappedIcon(x, y, mPosX); |
Joe Onorato | 82ca550 | 2009-10-15 16:59:23 -0700 | [diff] [blame] | 498 | if (mDownIconIndex != mCurrentIconIndex) { |
| 499 | // If a different icon is selected, don't allow it to be picked up. |
| 500 | // This handles off-axis dragging. |
| 501 | cancelLongPress(); |
| 502 | mCurrentIconIndex = -1; |
| 503 | } |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 504 | } else { |
Joe Onorato | 82ca550 | 2009-10-15 16:59:23 -0700 | [diff] [blame] | 505 | if (!mStartedScrolling) { |
| 506 | cancelLongPress(); |
| 507 | mCurrentIconIndex = -1; |
| 508 | } |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 509 | mRollo.mState.newPositionX = ev.getRawY() / getHeight(); |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 510 | mRollo.mState.newTouchDown = 1; |
Jason Sams | d8152b9 | 2009-10-13 17:19:10 -0700 | [diff] [blame] | 511 | mRollo.move(); |
Jason Sams | 86c87ed | 2009-09-18 13:55:55 -0700 | [diff] [blame] | 512 | |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 513 | mStartedScrolling = true; |
| 514 | mRollo.clearSelectedIcon(); |
Joe Onorato | 68ba5ca | 2009-11-12 14:23:43 -0800 | [diff] [blame] | 515 | mVelocityTracker.addMovement(ev); |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 516 | mRollo.mState.save(); |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 517 | } |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 518 | } |
| 519 | break; |
| 520 | case MotionEvent.ACTION_UP: |
| 521 | case MotionEvent.ACTION_CANCEL: |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 522 | if (mTouchTracking == TRACKING_HOME) { |
| 523 | if (action == MotionEvent.ACTION_UP) { |
| 524 | if (y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]) { |
Joe Onorato | b39e51a | 2009-10-28 15:47:49 -0400 | [diff] [blame] | 525 | reallyPlaySoundEffect(SoundEffectConstants.CLICK); |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 526 | mLauncher.closeAllApps(true); |
| 527 | } |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 528 | mRollo.setHomeSelected(SELECTED_NONE); |
Joe Onorato | d63458b | 2009-10-15 21:19:09 -0700 | [diff] [blame] | 529 | mRollo.mState.save(); |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 530 | } |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 531 | mCurrentIconIndex = -1; |
Joe Onorato | 68ffd10 | 2009-10-15 17:59:43 -0700 | [diff] [blame] | 532 | } else if (mTouchTracking == TRACKING_FLING) { |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 533 | mRollo.mState.newTouchDown = 0; |
Mike Cleron | 7d5d746 | 2009-10-20 14:06:00 -0700 | [diff] [blame] | 534 | mRollo.mState.newPositionX = ev.getRawY() / getHeight(); |
Jason Sams | 476339d | 2009-09-29 18:14:38 -0700 | [diff] [blame] | 535 | |
Joe Onorato | 68ba5ca | 2009-11-12 14:23:43 -0800 | [diff] [blame] | 536 | mVelocityTracker.computeCurrentVelocity(1000 /* px/sec */, mMaxFlingVelocity); |
| 537 | mRollo.mState.flingVelocity = mVelocityTracker.getYVelocity() / getHeight(); |
Jason Sams | 12c14a8 | 2009-10-06 14:33:15 -0700 | [diff] [blame] | 538 | mRollo.clearSelectedIcon(); |
| 539 | mRollo.mState.save(); |
Jason Sams | d8152b9 | 2009-10-13 17:19:10 -0700 | [diff] [blame] | 540 | mRollo.fling(); |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 541 | |
Joe Onorato | 68ba5ca | 2009-11-12 14:23:43 -0800 | [diff] [blame] | 542 | if (mVelocityTracker != null) { |
| 543 | mVelocityTracker.recycle(); |
| 544 | mVelocityTracker = null; |
Joe Onorato | 539ed9d | 2009-10-02 10:22:14 -0700 | [diff] [blame] | 545 | } |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 546 | } |
Joe Onorato | 68ffd10 | 2009-10-15 17:59:43 -0700 | [diff] [blame] | 547 | mTouchTracking = TRACKING_NONE; |
| 548 | break; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 549 | } |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 550 | |
| 551 | return true; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 552 | } |
| 553 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 554 | public void onClick(View v) { |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 555 | if (mLocks != 0 || !isVisible()) { |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 556 | return; |
| 557 | } |
Joe Onorato | 82ca550 | 2009-10-15 16:59:23 -0700 | [diff] [blame] | 558 | if (mRollo.checkClickOK() && mCurrentIconIndex == mDownIconIndex |
| 559 | && mCurrentIconIndex >= 0 && mCurrentIconIndex < mAllAppsList.size()) { |
Joe Onorato | b39e51a | 2009-10-28 15:47:49 -0400 | [diff] [blame] | 560 | reallyPlaySoundEffect(SoundEffectConstants.CLICK); |
Joe Onorato | 82ca550 | 2009-10-15 16:59:23 -0700 | [diff] [blame] | 561 | ApplicationInfo app = mAllAppsList.get(mCurrentIconIndex); |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 562 | mLauncher.startActivitySafely(app.intent); |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | public boolean onLongClick(View v) { |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 567 | if (mLocks != 0 || !isVisible()) { |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 568 | return true; |
| 569 | } |
Joe Onorato | 82ca550 | 2009-10-15 16:59:23 -0700 | [diff] [blame] | 570 | if (mRollo.checkClickOK() && mCurrentIconIndex == mDownIconIndex |
| 571 | && mCurrentIconIndex >= 0 && mCurrentIconIndex < mAllAppsList.size()) { |
| 572 | ApplicationInfo app = mAllAppsList.get(mCurrentIconIndex); |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 573 | |
| 574 | // We don't really have an accurate location to use. This will do. |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 575 | int screenX = mMotionDownRawX - (mDefines.ICON_WIDTH_PX / 2); |
| 576 | int screenY = mMotionDownRawY - mDefines.ICON_HEIGHT_PX; |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 577 | |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 578 | int left = (mDefines.ICON_TEXTURE_WIDTH_PX - mDefines.ICON_WIDTH_PX) / 2; |
| 579 | int top = (mDefines.ICON_TEXTURE_HEIGHT_PX - mDefines.ICON_HEIGHT_PX) / 2; |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 580 | mDragController.startDrag(app.iconBitmap, screenX, screenY, |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 581 | left, top, mDefines.ICON_WIDTH_PX, mDefines.ICON_HEIGHT_PX, |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 582 | this, app, DragController.DRAG_ACTION_COPY); |
Joe Onorato | e3406a2 | 2009-09-03 14:36:25 -0700 | [diff] [blame] | 583 | |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 584 | mLauncher.closeAllApps(true); |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 585 | } |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 586 | return true; |
| 587 | } |
| 588 | |
Joe Onorato | 52a653f | 2009-11-11 14:52:11 -0800 | [diff] [blame] | 589 | @Override |
| 590 | public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { |
| 591 | if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SELECTED) { |
| 592 | if (!isVisible()) { |
| 593 | return false; |
| 594 | } |
| 595 | String text = null; |
| 596 | int index; |
| 597 | int count = mAllAppsList.size() + 1; // +1 is home |
| 598 | int pos = -1; |
| 599 | switch (mLastSelection) { |
| 600 | case SELECTION_ICONS: |
| 601 | index = mRollo.mState.selectedIconIndex; |
| 602 | if (index >= 0) { |
| 603 | ApplicationInfo info = mAllAppsList.get(index); |
| 604 | if (info.title != null) { |
| 605 | text = info.title.toString(); |
| 606 | pos = index; |
| 607 | } |
| 608 | } |
| 609 | break; |
| 610 | case SELECTION_HOME: |
| 611 | text = getContext().getString(R.string.all_apps_home_button_label); |
| 612 | pos = count; |
| 613 | break; |
| 614 | } |
| 615 | if (text != null) { |
Joe Onorato | 52a653f | 2009-11-11 14:52:11 -0800 | [diff] [blame] | 616 | event.setEnabled(true); |
| 617 | event.getText().add(text); |
| 618 | //event.setContentDescription(text); |
| 619 | event.setItemCount(count); |
| 620 | event.setCurrentItemIndex(pos); |
| 621 | } |
| 622 | } |
| 623 | return false; |
| 624 | } |
| 625 | |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 626 | public void setDragController(DragController dragger) { |
| 627 | mDragController = dragger; |
| 628 | } |
| 629 | |
| 630 | public void onDropCompleted(View target, boolean success) { |
| 631 | } |
| 632 | |
Joe Onorato | 4db5231 | 2009-10-06 11:17:43 -0700 | [diff] [blame] | 633 | /** |
Joe Onorato | 3a8820b | 2009-11-10 15:06:42 -0800 | [diff] [blame] | 634 | * Zoom to the specifed level. |
Joe Onorato | 4db5231 | 2009-10-06 11:17:43 -0700 | [diff] [blame] | 635 | * |
Joe Onorato | 3a8820b | 2009-11-10 15:06:42 -0800 | [diff] [blame] | 636 | * @param zoom [0..1] 0 is hidden, 1 is open |
Joe Onorato | 4db5231 | 2009-10-06 11:17:43 -0700 | [diff] [blame] | 637 | */ |
Joe Onorato | 3a8820b | 2009-11-10 15:06:42 -0800 | [diff] [blame] | 638 | public void zoom(float zoom, boolean animate) { |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 639 | cancelLongPress(); |
Joe Onorato | 3a8820b | 2009-11-10 15:06:42 -0800 | [diff] [blame] | 640 | if (mRollo == null || !mRollo.mHasSurface) { |
| 641 | mZoomDirty = true; |
Joe Onorato | 68ba5ca | 2009-11-12 14:23:43 -0800 | [diff] [blame] | 642 | mZoom = zoom; |
| 643 | mAnimateNextZoom = animate; |
Joe Onorato | 3a8820b | 2009-11-10 15:06:42 -0800 | [diff] [blame] | 644 | return; |
Joe Onorato | 85a02a8 | 2009-09-08 12:34:22 -0700 | [diff] [blame] | 645 | } else { |
Joe Onorato | 3a8820b | 2009-11-10 15:06:42 -0800 | [diff] [blame] | 646 | mRollo.setZoom(zoom, animate); |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 647 | } |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 648 | } |
| 649 | |
| 650 | public boolean isVisible() { |
Joe Onorato | 68ba5ca | 2009-11-12 14:23:43 -0800 | [diff] [blame] | 651 | return mZoom > 0.001f; |
Joe Onorato | 3a8820b | 2009-11-10 15:06:42 -0800 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | public boolean isOpaque() { |
Joe Onorato | 68ba5ca | 2009-11-12 14:23:43 -0800 | [diff] [blame] | 655 | return mZoom > 0.999f; |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 656 | } |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 657 | |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 658 | public void setApps(ArrayList<ApplicationInfo> list) { |
| 659 | mAllAppsList = list; |
| 660 | if (mRollo != null) { |
| 661 | mRollo.setApps(list); |
| 662 | } |
Joe Onorato | fb0ca67 | 2009-09-14 17:55:46 -0400 | [diff] [blame] | 663 | mLocks &= ~LOCK_ICONS_PENDING; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 664 | } |
| 665 | |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 666 | public void addApps(ArrayList<ApplicationInfo> list) { |
Joe Onorato | 2d80476 | 2009-11-05 16:02:32 -0500 | [diff] [blame] | 667 | if (mAllAppsList == null) { |
| 668 | // Not done loading yet. We'll find out about it later. |
| 669 | return; |
| 670 | } |
| 671 | |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 672 | final int N = list.size(); |
| 673 | if (mRollo != null) { |
| 674 | mRollo.reallocAppsList(mRollo.mState.iconCount + N); |
| 675 | } |
| 676 | |
| 677 | for (int i=0; i<N; i++) { |
| 678 | final ApplicationInfo item = list.get(i); |
| 679 | int index = Collections.binarySearch(mAllAppsList, item, mAppNameComp); |
| 680 | if (index < 0) { |
| 681 | index = -(index+1); |
| 682 | } |
| 683 | mAllAppsList.add(index, item); |
| 684 | if (mRollo != null) { |
| 685 | mRollo.addApp(index, item); |
| 686 | mRollo.mState.iconCount++; |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | if (mRollo != null) { |
| 691 | mRollo.saveAppsList(); |
| 692 | } |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 693 | } |
| 694 | |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 695 | public void removeApps(ArrayList<ApplicationInfo> list) { |
Joe Onorato | 2d80476 | 2009-11-05 16:02:32 -0500 | [diff] [blame] | 696 | if (mAllAppsList == null) { |
| 697 | // Not done loading yet. We'll find out about it later. |
| 698 | return; |
| 699 | } |
| 700 | |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 701 | final int N = list.size(); |
| 702 | for (int i=0; i<N; i++) { |
| 703 | final ApplicationInfo item = list.get(i); |
Joe Onorato | cb9f798 | 2009-10-31 16:32:02 -0400 | [diff] [blame] | 704 | int index = findAppByComponent(mAllAppsList, item); |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 705 | if (index >= 0) { |
| 706 | mAllAppsList.remove(index); |
| 707 | if (mRollo != null) { |
| 708 | mRollo.removeApp(index); |
| 709 | mRollo.mState.iconCount--; |
| 710 | } |
| 711 | } else { |
Joe Onorato | a30ce8e | 2009-11-11 08:16:49 -0800 | [diff] [blame] | 712 | Log.w(TAG, "couldn't find a match for item \"" + item + "\""); |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 713 | // Try to recover. This should keep us from crashing for now. |
| 714 | } |
| 715 | } |
| 716 | |
| 717 | if (mRollo != null) { |
| 718 | mRollo.saveAppsList(); |
| 719 | } |
| 720 | } |
| 721 | |
| 722 | public void updateApps(String packageName, ArrayList<ApplicationInfo> list) { |
| 723 | // Just remove and add, because they may need to be re-sorted. |
| 724 | removeApps(list); |
| 725 | addApps(list); |
| 726 | } |
| 727 | |
| 728 | private Comparator<ApplicationInfo> mAppNameComp = new Comparator<ApplicationInfo>() { |
| 729 | public int compare(ApplicationInfo a, ApplicationInfo b) { |
| 730 | int result = a.title.toString().compareTo(b.toString()); |
| 731 | if (result != 0) { |
| 732 | return result; |
| 733 | } |
| 734 | return a.intent.getComponent().compareTo(b.intent.getComponent()); |
| 735 | } |
| 736 | }; |
| 737 | |
Joe Onorato | cb9f798 | 2009-10-31 16:32:02 -0400 | [diff] [blame] | 738 | private static int findAppByComponent(ArrayList<ApplicationInfo> list, ApplicationInfo item) { |
| 739 | ComponentName component = item.intent.getComponent(); |
| 740 | final int N = list.size(); |
| 741 | for (int i=0; i<N; i++) { |
| 742 | ApplicationInfo x = list.get(i); |
| 743 | if (x.intent.getComponent().equals(component)) { |
| 744 | return i; |
| 745 | } |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 746 | } |
Joe Onorato | cb9f798 | 2009-10-31 16:32:02 -0400 | [diff] [blame] | 747 | return -1; |
| 748 | } |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 749 | |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 750 | private static int countPages(int iconCount) { |
| 751 | int iconsPerPage = Defines.COLUMNS_PER_PAGE * Defines.ROWS_PER_PAGE; |
| 752 | int pages = iconCount / iconsPerPage; |
| 753 | if (pages*iconsPerPage != iconCount) { |
| 754 | pages++; |
| 755 | } |
| 756 | return pages; |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 757 | } |
| 758 | |
Joe Onorato | cb75f36 | 2009-11-12 13:04:07 -0800 | [diff] [blame] | 759 | class AAMessage extends RenderScript.RSMessage { |
| 760 | public void run() { |
| 761 | mPosX = ((float)mData[0]) / (1 << 16); |
| 762 | mVelocity = ((float)mData[1]) / (1 << 16); |
| 763 | mZoom = ((float)mData[2]) / (1 << 16); |
| 764 | mZoomDirty = false; |
| 765 | } |
Joe Onorato | cb75f36 | 2009-11-12 13:04:07 -0800 | [diff] [blame] | 766 | } |
| 767 | |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 768 | public class RolloRS { |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 769 | |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 770 | // Allocations ====== |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 771 | private int mWidth; |
| 772 | private int mHeight; |
| 773 | |
| 774 | private Resources mRes; |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 775 | private Script mScript; |
| 776 | private Script.Invokable mInvokeMove; |
Jason Sams | c1c521e | 2009-10-19 14:45:45 -0700 | [diff] [blame] | 777 | private Script.Invokable mInvokeMoveTo; |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 778 | private Script.Invokable mInvokeFling; |
| 779 | private Script.Invokable mInvokeResetWAR; |
Joe Onorato | 3a8820b | 2009-11-10 15:06:42 -0800 | [diff] [blame] | 780 | private Script.Invokable mInvokeSetZoom; |
Jason Sams | c1c521e | 2009-10-19 14:45:45 -0700 | [diff] [blame] | 781 | |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 782 | private ProgramStore mPSIcons; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 783 | private ProgramStore mPSText; |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 784 | private ProgramFragment mPFColor; |
Jason Sams | c851479 | 2009-10-29 14:27:29 -0700 | [diff] [blame] | 785 | private ProgramFragment mPFTexMip; |
| 786 | private ProgramFragment mPFTexNearest; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 787 | private ProgramVertex mPV; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 788 | private ProgramVertex mPVOrtho; |
Jason Sams | 0aa7166 | 2009-10-02 18:43:18 -0700 | [diff] [blame] | 789 | private SimpleMesh mMesh; |
Jason Sams | d8152b9 | 2009-10-13 17:19:10 -0700 | [diff] [blame] | 790 | private SimpleMesh mMesh2; |
Jason Sams | 5612e43 | 2009-11-16 14:18:07 -0800 | [diff] [blame] | 791 | private ProgramVertex.MatrixAllocation mPVA; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 792 | |
Joe Onorato | d63458b | 2009-10-15 21:19:09 -0700 | [diff] [blame] | 793 | private Allocation mHomeButtonNormal; |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 794 | private Allocation mHomeButtonFocused; |
Joe Onorato | d63458b | 2009-10-15 21:19:09 -0700 | [diff] [blame] | 795 | private Allocation mHomeButtonPressed; |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 796 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 797 | private Allocation[] mIcons; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 798 | private int[] mIconIds; |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 799 | private Allocation mAllocIconIds; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 800 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 801 | private Allocation[] mLabels; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 802 | private int[] mLabelIds; |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 803 | private Allocation mAllocLabelIds; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 804 | private Allocation mSelectedIcon; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 805 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 806 | private int[] mTouchYBorders; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 807 | private int[] mTouchXBorders; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 808 | |
| 809 | private Bitmap mSelectionBitmap; |
Joe Onorato | 1291a8c | 2009-09-15 15:07:25 -0400 | [diff] [blame] | 810 | private Canvas mSelectionCanvas; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 811 | |
Jason Sams | 20df7c7 | 2009-11-05 12:30:24 -0800 | [diff] [blame] | 812 | boolean mHasSurface = false; |
| 813 | private boolean mAppsDirty = false; |
Jason Sams | d8152b9 | 2009-10-13 17:19:10 -0700 | [diff] [blame] | 814 | |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 815 | Params mParams; |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 816 | State mState; |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 817 | |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 818 | class BaseAlloc { |
| 819 | Allocation mAlloc; |
| 820 | Type mType; |
| 821 | |
| 822 | void save() { |
| 823 | mAlloc.data(this); |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 824 | } |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 825 | } |
| 826 | |
Jason Sams | 476339d | 2009-09-29 18:14:38 -0700 | [diff] [blame] | 827 | private boolean checkClickOK() { |
Joe Onorato | 68ba5ca | 2009-11-12 14:23:43 -0800 | [diff] [blame] | 828 | return (Math.abs(mVelocity) < 0.4f) && |
| 829 | (Math.abs(mPosX - Math.round(mPosX)) < 0.4f); |
Jason Sams | 476339d | 2009-09-29 18:14:38 -0700 | [diff] [blame] | 830 | } |
| 831 | |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 832 | class Params extends BaseAlloc { |
| 833 | Params() { |
| 834 | mType = Type.createFromClass(mRS, Params.class, 1, "ParamsClass"); |
| 835 | mAlloc = Allocation.createTyped(mRS, mType); |
| 836 | save(); |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 837 | } |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 838 | public int bubbleWidth; |
| 839 | public int bubbleHeight; |
| 840 | public int bubbleBitmapWidth; |
| 841 | public int bubbleBitmapHeight; |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 842 | |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 843 | public int homeButtonWidth; |
| 844 | public int homeButtonHeight; |
| 845 | public int homeButtonTextureWidth; |
| 846 | public int homeButtonTextureHeight; |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 847 | } |
| 848 | |
| 849 | class State extends BaseAlloc { |
Jason Sams | 86c87ed | 2009-09-18 13:55:55 -0700 | [diff] [blame] | 850 | public float newPositionX; |
| 851 | public int newTouchDown; |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 852 | public float flingVelocity; |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 853 | public int iconCount; |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 854 | public int selectedIconIndex = -1; |
| 855 | public int selectedIconTexture; |
Joe Onorato | 7bb1749 | 2009-09-24 17:51:01 -0700 | [diff] [blame] | 856 | public float zoomTarget; |
Joe Onorato | d63458b | 2009-10-15 21:19:09 -0700 | [diff] [blame] | 857 | public int homeButtonId; |
Jason Sams | c1c521e | 2009-10-19 14:45:45 -0700 | [diff] [blame] | 858 | public float targetPos; |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 859 | |
| 860 | State() { |
| 861 | mType = Type.createFromClass(mRS, State.class, 1, "StateClass"); |
| 862 | mAlloc = Allocation.createTyped(mRS, mType); |
| 863 | save(); |
| 864 | } |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 865 | } |
| 866 | |
| 867 | public RolloRS() { |
| 868 | } |
| 869 | |
| 870 | public void init(Resources res, int width, int height) { |
| 871 | mRes = res; |
| 872 | mWidth = width; |
| 873 | mHeight = height; |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 874 | mDefines.recompute(width, height); |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 875 | initProgramVertex(); |
| 876 | initProgramFragment(); |
| 877 | initProgramStore(); |
Jason Sams | 0aa7166 | 2009-10-02 18:43:18 -0700 | [diff] [blame] | 878 | initMesh(); |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 879 | initGl(); |
| 880 | initData(); |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 881 | initTouchState(); |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 882 | initRs(); |
| 883 | } |
| 884 | |
Jason Sams | 0aa7166 | 2009-10-02 18:43:18 -0700 | [diff] [blame] | 885 | public void initMesh() { |
| 886 | SimpleMesh.TriangleMeshBuilder tm = new SimpleMesh.TriangleMeshBuilder(mRS, 3, |
| 887 | SimpleMesh.TriangleMeshBuilder.TEXTURE_0 | SimpleMesh.TriangleMeshBuilder.COLOR); |
| 888 | |
Jason Sams | d8152b9 | 2009-10-13 17:19:10 -0700 | [diff] [blame] | 889 | float y = 0; |
| 890 | float z = 0; |
| 891 | for (int ct=0; ct < 200; ct++) { |
| 892 | float angle = 0; |
| 893 | float maxAngle = 3.14f * 0.16f; |
| 894 | float l = 1.f; |
| 895 | |
| 896 | l = 1 - ((ct-5) * 0.10f); |
| 897 | if (ct > 7) { |
| 898 | angle = maxAngle * (ct - 7) * 0.2f; |
| 899 | angle = Math.min(angle, maxAngle); |
| 900 | } |
Jason Sams | c851479 | 2009-10-29 14:27:29 -0700 | [diff] [blame] | 901 | l = Math.max(0.4f, l); |
Jason Sams | d8152b9 | 2009-10-13 17:19:10 -0700 | [diff] [blame] | 902 | l = Math.min(1.0f, l); |
| 903 | |
| 904 | y += 0.1f * Math.cos(angle); |
| 905 | z += 0.1f * Math.sin(angle); |
| 906 | |
| 907 | float t = 0.1f * ct; |
| 908 | float ds = 0.08f; |
| 909 | tm.setColor(l, l, l, 0.99f); |
| 910 | tm.setTexture(ds, t); |
| 911 | tm.addVertex(-0.5f, y, z); |
| 912 | tm.setTexture(1 - ds, t); |
| 913 | tm.addVertex(0.5f, y, z); |
| 914 | } |
| 915 | for (int ct=0; ct < (200 * 2 - 2); ct+= 2) { |
| 916 | tm.addTriangle(ct, ct+1, ct+2); |
| 917 | tm.addTriangle(ct+1, ct+3, ct+2); |
| 918 | } |
| 919 | mMesh2 = tm.create(); |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 920 | mMesh2.setName("SMMesh"); |
Jason Sams | d8152b9 | 2009-10-13 17:19:10 -0700 | [diff] [blame] | 921 | } |
| 922 | |
Jason Sams | 5612e43 | 2009-11-16 14:18:07 -0800 | [diff] [blame] | 923 | void resize(int w, int h) { |
| 924 | mPVA.setupProjectionNormalized(w, h); |
| 925 | mWidth = w; |
| 926 | mHeight = h; |
| 927 | } |
| 928 | |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 929 | private void initProgramVertex() { |
Jason Sams | 5612e43 | 2009-11-16 14:18:07 -0800 | [diff] [blame] | 930 | mPVA = new ProgramVertex.MatrixAllocation(mRS); |
| 931 | resize(mWidth, mHeight); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 932 | |
| 933 | ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS, null, null); |
Jason Sams | 0aa7166 | 2009-10-02 18:43:18 -0700 | [diff] [blame] | 934 | pvb.setTextureMatrixEnable(true); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 935 | mPV = pvb.create(); |
| 936 | mPV.setName("PV"); |
Jason Sams | 5612e43 | 2009-11-16 14:18:07 -0800 | [diff] [blame] | 937 | mPV.bindAllocation(mPVA); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 938 | |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 939 | //pva = new ProgramVertex.MatrixAllocation(mRS); |
| 940 | //pva.setupOrthoWindow(mWidth, mHeight); |
| 941 | //pvb.setTextureMatrixEnable(true); |
| 942 | //mPVOrtho = pvb.create(); |
| 943 | //mPVOrtho.setName("PVOrtho"); |
| 944 | //mPVOrtho.bindAllocation(pva); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 945 | |
| 946 | mRS.contextBindProgramVertex(mPV); |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 947 | } |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 948 | |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 949 | private void initProgramFragment() { |
| 950 | Sampler.Builder sb = new Sampler.Builder(mRS); |
Jason Sams | c851479 | 2009-10-29 14:27:29 -0700 | [diff] [blame] | 951 | sb.setMin(Sampler.Value.LINEAR_MIP_LINEAR); |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 952 | sb.setMag(Sampler.Value.LINEAR); |
| 953 | sb.setWrapS(Sampler.Value.CLAMP); |
| 954 | sb.setWrapT(Sampler.Value.CLAMP); |
| 955 | Sampler linear = sb.create(); |
| 956 | |
| 957 | sb.setMin(Sampler.Value.NEAREST); |
| 958 | sb.setMag(Sampler.Value.NEAREST); |
| 959 | Sampler nearest = sb.create(); |
| 960 | |
| 961 | ProgramFragment.Builder bf = new ProgramFragment.Builder(mRS, null, null); |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 962 | //mPFColor = bf.create(); |
| 963 | //mPFColor.setName("PFColor"); |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 964 | |
| 965 | bf.setTexEnable(true, 0); |
| 966 | bf.setTexEnvMode(ProgramFragment.EnvMode.MODULATE, 0); |
Jason Sams | c851479 | 2009-10-29 14:27:29 -0700 | [diff] [blame] | 967 | mPFTexMip = bf.create(); |
| 968 | mPFTexMip.setName("PFTexMip"); |
| 969 | mPFTexMip.bindSampler(linear, 0); |
| 970 | |
| 971 | mPFTexNearest = bf.create(); |
| 972 | mPFTexNearest.setName("PFTexNearest"); |
| 973 | mPFTexNearest.bindSampler(nearest, 0); |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 974 | } |
| 975 | |
| 976 | private void initProgramStore() { |
| 977 | ProgramStore.Builder bs = new ProgramStore.Builder(mRS, null, null); |
| 978 | bs.setDepthFunc(ProgramStore.DepthFunc.ALWAYS); |
Jason Sams | 12c14a8 | 2009-10-06 14:33:15 -0700 | [diff] [blame] | 979 | bs.setColorMask(true,true,true,false); |
Jason Sams | cd689e1 | 2009-09-29 15:28:22 -0700 | [diff] [blame] | 980 | bs.setDitherEnable(true); |
| 981 | bs.setBlendFunc(ProgramStore.BlendSrcFunc.SRC_ALPHA, |
| 982 | ProgramStore.BlendDstFunc.ONE_MINUS_SRC_ALPHA); |
| 983 | mPSIcons = bs.create(); |
| 984 | mPSIcons.setName("PSIcons"); |
| 985 | |
| 986 | //bs.setDitherEnable(false); |
| 987 | //mPSText = bs.create(); |
| 988 | //mPSText.setName("PSText"); |
| 989 | } |
| 990 | |
| 991 | private void initGl() { |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 992 | mTouchXBorders = new int[Defines.COLUMNS_PER_PAGE+1]; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 993 | mTouchYBorders = new int[Defines.ROWS_PER_PAGE+1]; |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 994 | } |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 995 | |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 996 | private void initData() { |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 997 | mParams = new Params(); |
| 998 | mState = new State(); |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 999 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 1000 | final Utilities.BubbleText bubble = new Utilities.BubbleText(getContext()); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 1001 | |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 1002 | mParams.bubbleWidth = bubble.getBubbleWidth(); |
| 1003 | mParams.bubbleHeight = bubble.getMaxBubbleHeight(); |
| 1004 | mParams.bubbleBitmapWidth = bubble.getBitmapWidth(); |
| 1005 | mParams.bubbleBitmapHeight = bubble.getBitmapHeight(); |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 1006 | |
Joe Onorato | d63458b | 2009-10-15 21:19:09 -0700 | [diff] [blame] | 1007 | mHomeButtonNormal = Allocation.createFromBitmapResource(mRS, mRes, |
| 1008 | R.drawable.home_button_normal, Element.RGBA_8888(mRS), false); |
| 1009 | mHomeButtonNormal.uploadToTexture(0); |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 1010 | mHomeButtonFocused = Allocation.createFromBitmapResource(mRS, mRes, |
| 1011 | R.drawable.home_button_focused, Element.RGBA_8888(mRS), false); |
| 1012 | mHomeButtonFocused.uploadToTexture(0); |
Joe Onorato | d63458b | 2009-10-15 21:19:09 -0700 | [diff] [blame] | 1013 | mHomeButtonPressed = Allocation.createFromBitmapResource(mRS, mRes, |
| 1014 | R.drawable.home_button_pressed, Element.RGBA_8888(mRS), false); |
| 1015 | mHomeButtonPressed.uploadToTexture(0); |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 1016 | mParams.homeButtonWidth = 76; |
| 1017 | mParams.homeButtonHeight = 68; |
| 1018 | mParams.homeButtonTextureWidth = 128; |
| 1019 | mParams.homeButtonTextureHeight = 128; |
Joe Onorato | c567acb | 2009-08-31 14:34:43 -0700 | [diff] [blame] | 1020 | |
Joe Onorato | d63458b | 2009-10-15 21:19:09 -0700 | [diff] [blame] | 1021 | mState.homeButtonId = mHomeButtonNormal.getID(); |
| 1022 | |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 1023 | mParams.save(); |
| 1024 | mState.save(); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 1025 | |
Joe Onorato | 1291a8c | 2009-09-15 15:07:25 -0400 | [diff] [blame] | 1026 | mSelectionBitmap = Bitmap.createBitmap(Defines.ICON_TEXTURE_WIDTH_PX, |
| 1027 | Defines.ICON_TEXTURE_HEIGHT_PX, Bitmap.Config.ARGB_8888); |
| 1028 | mSelectionCanvas = new Canvas(mSelectionBitmap); |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1029 | |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 1030 | setApps(null); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 1031 | } |
| 1032 | |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 1033 | private void initScript(int id) { |
| 1034 | } |
| 1035 | |
| 1036 | private void initRs() { |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 1037 | ScriptC.Builder sb = new ScriptC.Builder(mRS); |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 1038 | sb.setScript(mRes, R.raw.rollo3); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 1039 | sb.setRoot(true); |
Joe Onorato | bcbeab8 | 2009-10-01 21:45:43 -0700 | [diff] [blame] | 1040 | sb.addDefines(mDefines); |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 1041 | sb.setType(mParams.mType, "params", Defines.ALLOC_PARAMS); |
| 1042 | sb.setType(mState.mType, "state", Defines.ALLOC_STATE); |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 1043 | mInvokeMove = sb.addInvokable("move"); |
| 1044 | mInvokeFling = sb.addInvokable("fling"); |
Jason Sams | c1c521e | 2009-10-19 14:45:45 -0700 | [diff] [blame] | 1045 | mInvokeMoveTo = sb.addInvokable("moveTo"); |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 1046 | mInvokeResetWAR = sb.addInvokable("resetHWWar"); |
Joe Onorato | 3a8820b | 2009-11-10 15:06:42 -0800 | [diff] [blame] | 1047 | mInvokeSetZoom = sb.addInvokable("setZoom"); |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 1048 | mScript = sb.create(); |
| 1049 | mScript.setClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
| 1050 | mScript.bindAllocation(mParams.mAlloc, Defines.ALLOC_PARAMS); |
| 1051 | mScript.bindAllocation(mState.mAlloc, Defines.ALLOC_STATE); |
| 1052 | mScript.bindAllocation(mAllocIconIds, Defines.ALLOC_ICON_IDS); |
| 1053 | mScript.bindAllocation(mAllocLabelIds, Defines.ALLOC_LABEL_IDS); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 1054 | |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 1055 | mRS.contextBindRootScript(mScript); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 1056 | } |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 1057 | |
Jason Sams | 20df7c7 | 2009-11-05 12:30:24 -0800 | [diff] [blame] | 1058 | private void uploadApps(ArrayList<ApplicationInfo> list) { |
| 1059 | for (int i=0; i < mState.iconCount; i++) { |
| 1060 | uploadAppIcon(i, list.get(i)); |
| 1061 | } |
| 1062 | } |
| 1063 | |
| 1064 | void dirtyCheck() { |
Joe Onorato | 3a8820b | 2009-11-10 15:06:42 -0800 | [diff] [blame] | 1065 | if (mHasSurface) { |
| 1066 | if (mAppsDirty) { |
| 1067 | uploadApps(mAllAppsList); |
| 1068 | saveAppsList(); |
| 1069 | mAppsDirty = false; |
| 1070 | } |
| 1071 | if (mZoomDirty) { |
Joe Onorato | 68ba5ca | 2009-11-12 14:23:43 -0800 | [diff] [blame] | 1072 | setZoom(mZoom, mAnimateNextZoom); |
Joe Onorato | 3a8820b | 2009-11-10 15:06:42 -0800 | [diff] [blame] | 1073 | } |
Jason Sams | 20df7c7 | 2009-11-05 12:30:24 -0800 | [diff] [blame] | 1074 | } |
| 1075 | } |
| 1076 | |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 1077 | private void setApps(ArrayList<ApplicationInfo> list) { |
| 1078 | final int count = list != null ? list.size() : 0; |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 1079 | int allocCount = count; |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 1080 | if (allocCount < 1) { |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 1081 | allocCount = 1; |
| 1082 | } |
| 1083 | |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 1084 | mIcons = new Allocation[count]; |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 1085 | mIconIds = new int[allocCount]; |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 1086 | mAllocIconIds = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 1087 | |
| 1088 | mLabels = new Allocation[count]; |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 1089 | mLabelIds = new int[allocCount]; |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 1090 | mAllocLabelIds = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 1091 | |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 1092 | Element ie8888 = Element.RGBA_8888(mRS); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 1093 | |
| 1094 | Utilities.BubbleText bubble = new Utilities.BubbleText(getContext()); |
| 1095 | |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 1096 | mState.iconCount = count; |
Jason Sams | 20df7c7 | 2009-11-05 12:30:24 -0800 | [diff] [blame] | 1097 | uploadApps(list); |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 1098 | saveAppsList(); |
| 1099 | } |
| 1100 | |
Joe Onorato | 3a8820b | 2009-11-10 15:06:42 -0800 | [diff] [blame] | 1101 | private void setZoom(float zoom, boolean animate) { |
| 1102 | mRollo.clearSelectedIcon(); |
| 1103 | mRollo.setHomeSelected(SELECTED_NONE); |
| 1104 | if (zoom > 0.001f) { |
| 1105 | mRollo.mState.zoomTarget = zoom; |
| 1106 | } else { |
| 1107 | mRollo.mState.zoomTarget = 0; |
| 1108 | } |
| 1109 | mRollo.mState.save(); |
| 1110 | if (!animate) { |
| 1111 | mRollo.mInvokeSetZoom.execute(); |
| 1112 | } |
| 1113 | } |
| 1114 | |
Jason Sams | c851479 | 2009-10-29 14:27:29 -0700 | [diff] [blame] | 1115 | private void frameBitmapAllocMips(Allocation alloc, int w, int h) { |
| 1116 | int black[] = new int[w > h ? w : h]; |
| 1117 | Allocation.Adapter2D a = alloc.createAdapter2D(); |
| 1118 | int mip = 0; |
| 1119 | while (w > 1 || h > 1) { |
| 1120 | a.subData(0, 0, 1, h, black); |
| 1121 | a.subData(w-1, 0, 1, h, black); |
| 1122 | a.subData(0, 0, w, 1, black); |
| 1123 | a.subData(0, h-1, w, 1, black); |
| 1124 | mip++; |
| 1125 | w = (w + 1) >> 1; |
| 1126 | h = (h + 1) >> 1; |
| 1127 | a.setConstraint(Dimension.LOD, mip); |
| 1128 | } |
| 1129 | a.subData(0, 0, 1, 1, black); |
| 1130 | } |
| 1131 | |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 1132 | private void uploadAppIcon(int index, ApplicationInfo item) { |
| 1133 | mIcons[index] = Allocation.createFromBitmap(mRS, item.iconBitmap, |
Jason Sams | c851479 | 2009-10-29 14:27:29 -0700 | [diff] [blame] | 1134 | Element.RGBA_8888(mRS), true); |
| 1135 | frameBitmapAllocMips(mIcons[index], item.iconBitmap.getWidth(), item.iconBitmap.getHeight()); |
| 1136 | |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 1137 | mLabels[index] = Allocation.createFromBitmap(mRS, item.titleBitmap, |
Jason Sams | c851479 | 2009-10-29 14:27:29 -0700 | [diff] [blame] | 1138 | Element.RGBA_8888(mRS), true); |
| 1139 | frameBitmapAllocMips(mLabels[index], item.titleBitmap.getWidth(), item.titleBitmap.getHeight()); |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 1140 | |
| 1141 | mIcons[index].uploadToTexture(0); |
| 1142 | mLabels[index].uploadToTexture(0); |
| 1143 | |
| 1144 | mIconIds[index] = mIcons[index].getID(); |
| 1145 | mLabelIds[index] = mLabels[index].getID(); |
| 1146 | } |
| 1147 | |
| 1148 | /** |
| 1149 | * Puts the empty spaces at the end. Updates mState.iconCount. You must |
| 1150 | * fill in the values and call saveAppsList(). |
| 1151 | */ |
| 1152 | private void reallocAppsList(int count) { |
| 1153 | Allocation[] icons = new Allocation[count]; |
| 1154 | int[] iconIds = new int[count]; |
| 1155 | mAllocIconIds = Allocation.createSized(mRS, Element.USER_I32(mRS), count); |
| 1156 | |
| 1157 | Allocation[] labels = new Allocation[count]; |
| 1158 | int[] labelIds = new int[count]; |
| 1159 | mAllocLabelIds = Allocation.createSized(mRS, Element.USER_I32(mRS), count); |
| 1160 | |
| 1161 | final int oldCount = mIcons.length; |
| 1162 | |
| 1163 | System.arraycopy(mIcons, 0, icons, 0, oldCount); |
| 1164 | System.arraycopy(mIconIds, 0, iconIds, 0, oldCount); |
| 1165 | System.arraycopy(mLabels, 0, labels, 0, oldCount); |
| 1166 | System.arraycopy(mLabelIds, 0, labelIds, 0, oldCount); |
| 1167 | |
| 1168 | mIcons = icons; |
| 1169 | mIconIds = iconIds; |
| 1170 | mLabels = labels; |
| 1171 | mLabelIds = labelIds; |
| 1172 | } |
| 1173 | |
| 1174 | /** |
| 1175 | * Handle the allocations for the new app. Make sure you call saveAppsList when done. |
| 1176 | */ |
| 1177 | private void addApp(int index, ApplicationInfo item) { |
| 1178 | final int count = mState.iconCount - index; |
| 1179 | final int dest = index + 1; |
| 1180 | |
| 1181 | System.arraycopy(mIcons, index, mIcons, dest, count); |
| 1182 | System.arraycopy(mIconIds, index, mIconIds, dest, count); |
| 1183 | System.arraycopy(mLabels, index, mLabels, dest, count); |
| 1184 | System.arraycopy(mLabelIds, index, mLabelIds, dest, count); |
| 1185 | |
Jason Sams | 20df7c7 | 2009-11-05 12:30:24 -0800 | [diff] [blame] | 1186 | if (mHasSurface ) { |
| 1187 | uploadAppIcon(index, item); |
| 1188 | } else { |
| 1189 | mAppsDirty = true; |
| 1190 | } |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 1191 | } |
| 1192 | |
| 1193 | /** |
| 1194 | * Handle the allocations for the removed app. Make sure you call saveAppsList when done. |
| 1195 | */ |
| 1196 | private void removeApp(int index) { |
| 1197 | final int count = mState.iconCount - index - 1; |
| 1198 | final int src = index + 1; |
| 1199 | |
| 1200 | System.arraycopy(mIcons, src, mIcons, index, count); |
| 1201 | System.arraycopy(mIconIds, src, mIconIds, index, count); |
| 1202 | System.arraycopy(mLabels, src, mLabels, index, count); |
| 1203 | System.arraycopy(mLabelIds, src, mLabelIds, index, count); |
| 1204 | |
| 1205 | final int last = mState.iconCount - 1; |
| 1206 | mIcons[last] = null; |
| 1207 | mIconIds[last] = 0; |
| 1208 | mLabels[last] = null; |
| 1209 | mLabelIds[last] = 0; |
| 1210 | } |
| 1211 | |
| 1212 | /** |
| 1213 | * Send the apps list structures to RS. |
| 1214 | */ |
| 1215 | private void saveAppsList() { |
| 1216 | mRS.contextBindRootScript(null); |
Jason Sams | d8152b9 | 2009-10-13 17:19:10 -0700 | [diff] [blame] | 1217 | |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 1218 | mAllocIconIds.data(mIconIds); |
| 1219 | mAllocLabelIds.data(mLabelIds); |
| 1220 | |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 1221 | if (mScript != null) { // this happens when we init it |
| 1222 | mScript.bindAllocation(mAllocIconIds, Defines.ALLOC_ICON_IDS); |
| 1223 | mScript.bindAllocation(mAllocLabelIds, Defines.ALLOC_LABEL_IDS); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 1224 | } |
| 1225 | |
| 1226 | mState.save(); |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 1227 | |
| 1228 | // Note: mScript may be null if we haven't initialized it yet. |
| 1229 | // In that case, this is a no-op. |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 1230 | if (mInvokeResetWAR != null) { |
| 1231 | mInvokeResetWAR.execute(); |
Jason Sams | 41b61c8 | 2009-10-15 15:40:54 -0700 | [diff] [blame] | 1232 | } |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 1233 | mRS.contextBindRootScript(mScript); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 1234 | } |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1235 | |
| 1236 | void initTouchState() { |
| 1237 | int width = getWidth(); |
| 1238 | int height = getHeight(); |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 1239 | int cellHeight = 145;//iconsSize / Defines.ROWS_PER_PAGE; |
| 1240 | int cellWidth = width / Defines.COLUMNS_PER_PAGE; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1241 | |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 1242 | int centerY = (height / 2); |
| 1243 | mTouchYBorders[0] = centerY - (cellHeight * 2); |
| 1244 | mTouchYBorders[1] = centerY - cellHeight; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1245 | mTouchYBorders[2] = centerY; |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 1246 | mTouchYBorders[3] = centerY + cellHeight; |
| 1247 | mTouchYBorders[4] = centerY + (cellHeight * 2); |
Jason Sams | 78aebd8 | 2009-09-15 13:06:59 -0700 | [diff] [blame] | 1248 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1249 | int centerX = (width / 2); |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 1250 | mTouchXBorders[0] = 0; |
| 1251 | mTouchXBorders[1] = centerX - (width / 4); |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1252 | mTouchXBorders[2] = centerX; |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 1253 | mTouchXBorders[3] = centerX + (width / 4); |
| 1254 | mTouchXBorders[4] = width; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1255 | } |
| 1256 | |
Joe Onorato | 664457d | 2009-10-28 16:30:34 -0400 | [diff] [blame] | 1257 | void fling() { |
| 1258 | mInvokeFling.execute(); |
| 1259 | } |
| 1260 | |
| 1261 | void move() { |
| 1262 | mInvokeMove.execute(); |
| 1263 | } |
| 1264 | |
| 1265 | void moveTo(float row) { |
| 1266 | mState.targetPos = row; |
| 1267 | mState.save(); |
| 1268 | mInvokeMoveTo.execute(); |
| 1269 | } |
| 1270 | |
Jason Sams | 37e7c2b | 2009-10-19 12:55:43 -0700 | [diff] [blame] | 1271 | int chooseTappedIcon(int x, int y, float pos) { |
| 1272 | // Adjust for scroll position if not zero. |
| 1273 | y += (pos - ((int)pos)) * (mTouchYBorders[1] - mTouchYBorders[0]); |
Jason Sams | 86c87ed | 2009-09-18 13:55:55 -0700 | [diff] [blame] | 1274 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1275 | int col = -1; |
| 1276 | int row = -1; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1277 | for (int i=0; i<Defines.COLUMNS_PER_PAGE; i++) { |
| 1278 | if (x >= mTouchXBorders[i] && x < mTouchXBorders[i+1]) { |
| 1279 | col = i; |
| 1280 | break; |
| 1281 | } |
| 1282 | } |
| 1283 | for (int i=0; i<Defines.ROWS_PER_PAGE; i++) { |
| 1284 | if (y >= mTouchYBorders[i] && y < mTouchYBorders[i+1]) { |
| 1285 | row = i; |
| 1286 | break; |
| 1287 | } |
| 1288 | } |
| 1289 | |
| 1290 | if (row < 0 || col < 0) { |
| 1291 | return -1; |
| 1292 | } |
| 1293 | |
Joe Onorato | 664457d | 2009-10-28 16:30:34 -0400 | [diff] [blame] | 1294 | int index = (((int)pos) * Defines.COLUMNS_PER_PAGE) |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1295 | + (row * Defines.ROWS_PER_PAGE) + col; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1296 | |
Joe Onorato | 664457d | 2009-10-28 16:30:34 -0400 | [diff] [blame] | 1297 | if (index >= mState.iconCount) { |
| 1298 | return -1; |
| 1299 | } else { |
| 1300 | return index; |
| 1301 | } |
Jason Sams | c1c521e | 2009-10-19 14:45:45 -0700 | [diff] [blame] | 1302 | } |
| 1303 | |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1304 | /** |
| 1305 | * You need to call save() on mState on your own after calling this. |
Joe Onorato | 82ca550 | 2009-10-15 16:59:23 -0700 | [diff] [blame] | 1306 | * |
| 1307 | * @return the index of the icon that was selected. |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1308 | */ |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 1309 | int selectIcon(int x, int y, float pos, int pressed) { |
Joe Onorato | 82ca550 | 2009-10-15 16:59:23 -0700 | [diff] [blame] | 1310 | final int index = chooseTappedIcon(x, y, pos); |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 1311 | selectIcon(index, pressed); |
Joe Onorato | 82ca550 | 2009-10-15 16:59:23 -0700 | [diff] [blame] | 1312 | return index; |
Joe Onorato | 1291a8c | 2009-09-15 15:07:25 -0400 | [diff] [blame] | 1313 | } |
| 1314 | |
Joe Onorato | c61cff9 | 2009-11-08 11:54:39 -0500 | [diff] [blame] | 1315 | /** |
| 1316 | * Select the icon at the given index. |
| 1317 | * |
| 1318 | * @param index The index. |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 1319 | * @param pressed one of SELECTED_PRESSED or SELECTED_FOCUSED |
Joe Onorato | c61cff9 | 2009-11-08 11:54:39 -0500 | [diff] [blame] | 1320 | */ |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 1321 | void selectIcon(int index, int pressed) { |
Joe Onorato | 2d80476 | 2009-11-05 16:02:32 -0500 | [diff] [blame] | 1322 | if (mAllAppsList == null || index < 0 || index >= mAllAppsList.size()) { |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1323 | mState.selectedIconIndex = -1; |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 1324 | if (mLastSelection == SELECTION_ICONS) { |
| 1325 | mLastSelection = SELECTION_NONE; |
| 1326 | } |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1327 | } else { |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 1328 | if (pressed == SELECTED_FOCUSED) { |
| 1329 | mLastSelection = SELECTION_ICONS; |
| 1330 | } |
| 1331 | |
Joe Onorato | 52a653f | 2009-11-11 14:52:11 -0800 | [diff] [blame] | 1332 | int prev = mState.selectedIconIndex; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1333 | mState.selectedIconIndex = index; |
Joe Onorato | 1291a8c | 2009-09-15 15:07:25 -0400 | [diff] [blame] | 1334 | |
Joe Onorato | 52a653f | 2009-11-11 14:52:11 -0800 | [diff] [blame] | 1335 | ApplicationInfo info = mAllAppsList.get(index); |
Joe Onorato | 1291a8c | 2009-09-15 15:07:25 -0400 | [diff] [blame] | 1336 | Bitmap selectionBitmap = mSelectionBitmap; |
| 1337 | |
| 1338 | Utilities.drawSelectedAllAppsBitmap(mSelectionCanvas, |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 1339 | selectionBitmap.getWidth(), selectionBitmap.getHeight(), |
Joe Onorato | 52a653f | 2009-11-11 14:52:11 -0800 | [diff] [blame] | 1340 | pressed == SELECTED_PRESSED, info.iconBitmap); |
Joe Onorato | 1291a8c | 2009-09-15 15:07:25 -0400 | [diff] [blame] | 1341 | |
| 1342 | mSelectedIcon = Allocation.createFromBitmap(mRS, selectionBitmap, |
Jason Sams | 0a8dc2c | 2009-09-27 17:51:44 -0700 | [diff] [blame] | 1343 | Element.RGBA_8888(mRS), false); |
Joe Onorato | 1291a8c | 2009-09-15 15:07:25 -0400 | [diff] [blame] | 1344 | mSelectedIcon.uploadToTexture(0); |
| 1345 | mState.selectedIconTexture = mSelectedIcon.getID(); |
Joe Onorato | 52a653f | 2009-11-11 14:52:11 -0800 | [diff] [blame] | 1346 | |
| 1347 | if (prev != index) { |
| 1348 | if (info.title != null && info.title.length() > 0) { |
Joe Onorato | 52a653f | 2009-11-11 14:52:11 -0800 | [diff] [blame] | 1349 | //setContentDescription(info.title); |
| 1350 | sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); |
| 1351 | } |
| 1352 | } |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1353 | } |
| 1354 | } |
| 1355 | |
| 1356 | /** |
| 1357 | * You need to call save() on mState on your own after calling this. |
| 1358 | */ |
| 1359 | void clearSelectedIcon() { |
Joe Onorato | 2ca51dc | 2009-09-16 11:44:14 -0400 | [diff] [blame] | 1360 | mState.selectedIconIndex = -1; |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 1361 | } |
Joe Onorato | a8138d5 | 2009-10-06 19:25:30 -0700 | [diff] [blame] | 1362 | |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 1363 | void setHomeSelected(int mode) { |
Joe Onorato | 52a653f | 2009-11-11 14:52:11 -0800 | [diff] [blame] | 1364 | final int prev = mLastSelection; |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 1365 | switch (mode) { |
| 1366 | case SELECTED_NONE: |
Joe Onorato | d63458b | 2009-10-15 21:19:09 -0700 | [diff] [blame] | 1367 | mState.homeButtonId = mHomeButtonNormal.getID(); |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 1368 | break; |
| 1369 | case SELECTED_FOCUSED: |
| 1370 | mLastSelection = SELECTION_HOME; |
| 1371 | mState.homeButtonId = mHomeButtonFocused.getID(); |
Joe Onorato | 52a653f | 2009-11-11 14:52:11 -0800 | [diff] [blame] | 1372 | if (prev != SELECTION_HOME) { |
Joe Onorato | 52a653f | 2009-11-11 14:52:11 -0800 | [diff] [blame] | 1373 | sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); |
| 1374 | } |
Joe Onorato | eb8325a | 2009-11-08 13:20:30 -0500 | [diff] [blame] | 1375 | break; |
| 1376 | case SELECTED_PRESSED: |
| 1377 | mState.homeButtonId = mHomeButtonPressed.getID(); |
| 1378 | break; |
Joe Onorato | d63458b | 2009-10-15 21:19:09 -0700 | [diff] [blame] | 1379 | } |
| 1380 | } |
Joe Onorato | be38609 | 2009-11-17 17:32:16 -0800 | [diff] [blame^] | 1381 | |
| 1382 | public void dumpState() { |
| 1383 | Log.d(TAG, "mRollo.mWidth=" + mWidth); |
| 1384 | Log.d(TAG, "mRollo.mHeight=" + mHeight); |
| 1385 | Log.d(TAG, "mRollo.mIcons=" + mIcons); |
| 1386 | if (mIcons != null) { |
| 1387 | Log.d(TAG, "mRollo.mIcons.length=" + mIcons.length); |
| 1388 | } |
| 1389 | if (mIconIds != null) { |
| 1390 | Log.d(TAG, "mRollo.mIconIds.length=" + mIconIds.length); |
| 1391 | } |
| 1392 | Log.d(TAG, "mRollo.mIconIds=" + Arrays.toString(mIconIds)); |
| 1393 | if (mLabelIds != null) { |
| 1394 | Log.d(TAG, "mRollo.mLabelIds.length=" + mLabelIds.length); |
| 1395 | } |
| 1396 | Log.d(TAG, "mRollo.mLabelIds=" + Arrays.toString(mLabelIds)); |
| 1397 | Log.d(TAG, "mRollo.mTouchXBorders=" + Arrays.toString(mTouchXBorders)); |
| 1398 | Log.d(TAG, "mRollo.mTouchYBorders=" + Arrays.toString(mTouchYBorders)); |
| 1399 | Log.d(TAG, "mRollo.mHasSurface=" + mHasSurface); |
| 1400 | Log.d(TAG, "mRollo.mAppsDirty=" + mAppsDirty); |
| 1401 | Log.d(TAG, "mRollo.mState.newPositionX=" + mState.newPositionX); |
| 1402 | Log.d(TAG, "mRollo.mState.newTouchDown=" + mState.newTouchDown); |
| 1403 | Log.d(TAG, "mRollo.mState.flingVelocity=" + mState.flingVelocity); |
| 1404 | Log.d(TAG, "mRollo.mState.iconCount=" + mState.iconCount); |
| 1405 | Log.d(TAG, "mRollo.mState.selectedIconIndex=" + mState.selectedIconIndex); |
| 1406 | Log.d(TAG, "mRollo.mState.selectedIconTexture=" + mState.selectedIconTexture); |
| 1407 | Log.d(TAG, "mRollo.mState.zoomTarget=" + mState.zoomTarget); |
| 1408 | Log.d(TAG, "mRollo.mState.homeButtonId=" + mState.homeButtonId); |
| 1409 | Log.d(TAG, "mRollo.mState.targetPos=" + mState.targetPos); |
| 1410 | Log.d(TAG, "mRollo.mParams.bubbleWidth=" + mParams.bubbleWidth); |
| 1411 | Log.d(TAG, "mRollo.mParams.bubbleHeight=" + mParams.bubbleHeight); |
| 1412 | Log.d(TAG, "mRollo.mParams.bubbleBitmapWidth=" + mParams.bubbleBitmapWidth); |
| 1413 | Log.d(TAG, "mRollo.mParams.bubbleBitmapHeight=" + mParams.bubbleBitmapHeight); |
| 1414 | Log.d(TAG, "mRollo.mParams.homeButtonWidth=" + mParams.homeButtonWidth); |
| 1415 | Log.d(TAG, "mRollo.mParams.homeButtonHeight=" + mParams.homeButtonHeight); |
| 1416 | Log.d(TAG, "mRollo.mParams.homeButtonTextureWidth=" + mParams.homeButtonTextureWidth); |
| 1417 | Log.d(TAG, "mRollo.mParams.homeButtonTextureHeight=" + mParams.homeButtonTextureHeight); |
| 1418 | } |
| 1419 | } |
| 1420 | |
| 1421 | public void dumpState() { |
| 1422 | Log.d(TAG, "mRS=" + mRS); |
| 1423 | Log.d(TAG, "mRollo=" + mRollo); |
| 1424 | ApplicationInfo.dumpApplicationInfoList(TAG, "mAllAppsList", mAllAppsList); |
| 1425 | Log.d(TAG, "mArrowNavigation=" + mArrowNavigation); |
| 1426 | Log.d(TAG, "mStartedScrolling=" + mStartedScrolling); |
| 1427 | Log.d(TAG, "mLastSelection=" + mLastSelection); |
| 1428 | Log.d(TAG, "mLastSelectedIcon=" + mLastSelectedIcon); |
| 1429 | Log.d(TAG, "mVelocityTracker=" + mVelocityTracker); |
| 1430 | Log.d(TAG, "mTouchTracking=" + mTouchTracking); |
| 1431 | Log.d(TAG, "mShouldGainFocus=" + mShouldGainFocus); |
| 1432 | Log.d(TAG, "mZoomDirty=" + mZoomDirty); |
| 1433 | Log.d(TAG, "mAnimateNextZoom=" + mAnimateNextZoom); |
| 1434 | Log.d(TAG, "mZoom=" + mZoom); |
| 1435 | Log.d(TAG, "mPosX=" + mPosX); |
| 1436 | Log.d(TAG, "mVelocity=" + mVelocity); |
| 1437 | Log.d(TAG, "mMessageProc=" + mMessageProc); |
| 1438 | if (mRollo != null) { |
| 1439 | mRollo.dumpState(); |
| 1440 | } |
| 1441 | if (mRS != null) { |
| 1442 | mRS.contextDump(0); |
| 1443 | } |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 1444 | } |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 1445 | } |
| 1446 | |
| 1447 | |