blob: c1580b168981eefdc3285de6936b63976c1b63f5 [file] [log] [blame]
The Android Open Source Project31dd5032009-03-03 19:32:27 -08001/*
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
Joe Onoratoa5902522009-07-30 13:37:37 -070017package com.android.launcher2;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080018
Adam Cohendf2cc412011-04-27 16:56:57 -070019import android.animation.Animator;
20import android.animation.AnimatorListenerAdapter;
Adam Cohendf2cc412011-04-27 16:56:57 -070021import android.animation.ObjectAnimator;
22import android.animation.PropertyValuesHolder;
23import android.animation.ValueAnimator;
24import android.animation.ValueAnimator.AnimatorUpdateListener;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080025import android.content.Context;
Adam Cohen76fc0852011-06-17 13:26:23 -070026import android.content.res.Resources;
Romain Guyfb5411e2010-02-24 10:04:17 -080027import android.graphics.Rect;
Adam Cohenbadf71e2011-05-26 19:08:29 -070028import android.graphics.drawable.Drawable;
Adam Cohen7a14d0b2011-06-24 11:36:35 -070029import android.text.InputType;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080030import android.util.AttributeSet;
Adam Cohen76fc0852011-06-17 13:26:23 -070031import android.view.ActionMode;
32import android.view.KeyEvent;
Adam Cohendf2cc412011-04-27 16:56:57 -070033import android.view.LayoutInflater;
Adam Cohen76fc0852011-06-17 13:26:23 -070034import android.view.Menu;
35import android.view.MenuItem;
Adam Cohen0c872ba2011-05-05 10:34:16 -070036import android.view.MotionEvent;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080037import android.view.View;
38import android.view.View.OnClickListener;
Adam Cohen2801caf2011-05-13 20:57:39 -070039import android.view.animation.AccelerateInterpolator;
40import android.view.animation.DecelerateInterpolator;
Adam Cohen76fc0852011-06-17 13:26:23 -070041import android.view.inputmethod.EditorInfo;
42import android.view.inputmethod.InputMethodManager;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080043import android.widget.AdapterView;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080044import android.widget.LinearLayout;
Adam Cohendf2cc412011-04-27 16:56:57 -070045import android.widget.TextView;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080046import android.widget.AdapterView.OnItemClickListener;
47import android.widget.AdapterView.OnItemLongClickListener;
48
Romain Guyedcce092010-03-04 13:03:17 -080049import com.android.launcher.R;
Adam Cohena9cf38f2011-05-02 15:36:58 -070050import com.android.launcher2.FolderInfo.FolderListener;
Romain Guyedcce092010-03-04 13:03:17 -080051
Adam Cohenc0dcf592011-06-01 15:30:43 -070052import java.util.ArrayList;
53
The Android Open Source Project31dd5032009-03-03 19:32:27 -080054/**
55 * Represents a set of icons chosen by the user or generated by the system.
56 */
57public class Folder extends LinearLayout implements DragSource, OnItemLongClickListener,
Adam Cohen76fc0852011-06-17 13:26:23 -070058 OnItemClickListener, OnClickListener, View.OnLongClickListener, DropTarget, FolderListener,
59 TextView.OnEditorActionListener {
The Android Open Source Project31dd5032009-03-03 19:32:27 -080060
Joe Onorato00acb122009-08-04 16:04:30 -040061 protected DragController mDragController;
Adam Cohendf2cc412011-04-27 16:56:57 -070062
The Android Open Source Project31dd5032009-03-03 19:32:27 -080063 protected Launcher mLauncher;
64
The Android Open Source Project31dd5032009-03-03 19:32:27 -080065 protected FolderInfo mInfo;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080066
Adam Cohendf2cc412011-04-27 16:56:57 -070067 private static final String TAG = "Launcher.Folder";
68
69 static final int STATE_NONE = -1;
70 static final int STATE_SMALL = 0;
71 static final int STATE_ANIMATING = 1;
72 static final int STATE_OPEN = 2;
73
74 private int mExpandDuration;
75 protected CellLayout mContent;
76 private final LayoutInflater mInflater;
77 private final IconCache mIconCache;
78 private int mState = STATE_NONE;
Adam Cohen2801caf2011-05-13 20:57:39 -070079 private static final int FULL_GROW = 0;
80 private static final int PARTIAL_GROW = 1;
Adam Cohenbfbfd262011-06-13 16:55:12 -070081 private static final int REORDER_ANIMATION_DURATION = 230;
82 private static final int ON_EXIT_CLOSE_DELAY = 800;
Adam Cohen2801caf2011-05-13 20:57:39 -070083 private int mMode = PARTIAL_GROW;
84 private boolean mRearrangeOnClose = false;
85 private FolderIcon mFolderIcon;
86 private int mMaxCountX;
87 private int mMaxCountY;
88 private Rect mNewSize = new Rect();
Adam Cohen7c693212011-05-18 15:26:57 -070089 private ArrayList<View> mItemsInReadingOrder = new ArrayList<View>();
Adam Cohenbadf71e2011-05-26 19:08:29 -070090 private Drawable mIconDrawable;
Adam Cohen7c693212011-05-18 15:26:57 -070091 boolean mItemsInvalidated = false;
Adam Cohenbfbfd262011-06-13 16:55:12 -070092 private ShortcutInfo mCurrentDragInfo;
93 private View mCurrentDragView;
94 boolean mSuppressOnAdd = false;
95 private int[] mTargetCell = new int[2];
96 private int[] mPreviousTargetCell = new int[2];
97 private int[] mEmptyCell = new int[2];
98 private Alarm mReorderAlarm = new Alarm();
99 private Alarm mOnExitAlarm = new Alarm();
Adam Cohen76fc0852011-06-17 13:26:23 -0700100 private TextView mFolderName;
101 private int mFolderNameHeight;
Adam Cohen4ef610f2011-06-21 22:37:36 -0700102 private Rect mHitRect = new Rect();
Adam Cohen76fc0852011-06-17 13:26:23 -0700103
104 private boolean mIsEditingName = false;
105 private InputMethodManager mInputMethodManager;
Adam Cohendf2cc412011-04-27 16:56:57 -0700106
Adam Cohena65beee2011-06-27 21:32:23 -0700107 private static String sDefaultFolderName;
108 private static String sHintText;
109
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800110 /**
111 * Used to inflate the Workspace from XML.
112 *
113 * @param context The application's context.
114 * @param attrs The attribtues set containing the Workspace's customization values.
115 */
116 public Folder(Context context, AttributeSet attrs) {
117 super(context, attrs);
118 setAlwaysDrawnWithCacheEnabled(false);
Adam Cohendf2cc412011-04-27 16:56:57 -0700119 mInflater = LayoutInflater.from(context);
120 mIconCache = ((LauncherApplication)context.getApplicationContext()).getIconCache();
Adam Cohen2801caf2011-05-13 20:57:39 -0700121 mMaxCountX = LauncherModel.getCellCountX() - 1;
122 mMaxCountY = LauncherModel.getCellCountY() - 1;
Adam Cohen76fc0852011-06-17 13:26:23 -0700123
124 mInputMethodManager = (InputMethodManager)
125 mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
126
127 Resources res = getResources();
128 mExpandDuration = res.getInteger(R.integer.config_folderAnimDuration);
Adam Cohen4ef610f2011-06-21 22:37:36 -0700129
130 if (sDefaultFolderName == null) {
131 sDefaultFolderName = res.getString(R.string.folder_name);
132 }
Adam Cohena65beee2011-06-27 21:32:23 -0700133 if (sHintText == null) {
134 sHintText = res.getString(R.string.folder_hint_text);
135 }
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800136 }
137
138 @Override
139 protected void onFinishInflate() {
140 super.onFinishInflate();
Adam Cohendf2cc412011-04-27 16:56:57 -0700141 mContent = (CellLayout) findViewById(R.id.folder_content);
Adam Cohen2801caf2011-05-13 20:57:39 -0700142 mContent.setGridSize(0, 0);
143 mContent.enableHardwareLayers();
Adam Cohen76fc0852011-06-17 13:26:23 -0700144 mFolderName = (TextView) findViewById(R.id.folder_name);
145
146 // We find out how tall the text view wants to be (it is set to wrap_content), so that
147 // we can allocate the appropriate amount of space for it.
148 int measureSpec = MeasureSpec.UNSPECIFIED;
149 mFolderName.measure(measureSpec, measureSpec);
150 mFolderNameHeight = mFolderName.getMeasuredHeight();
151
152 // We disable action mode for now since it messes up the view on phones
153 mFolderName.setCustomSelectionActionModeCallback(mActionModeCallback);
154 mFolderName.setCursorVisible(false);
155 mFolderName.setOnEditorActionListener(this);
Adam Cohen4ef610f2011-06-21 22:37:36 -0700156 mFolderName.setSelectAllOnFocus(true);
Adam Cohen7a14d0b2011-06-24 11:36:35 -0700157 mFolderName.setInputType(mFolderName.getInputType() |
158 InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800159 }
Adam Cohen2801caf2011-05-13 20:57:39 -0700160
Adam Cohen76fc0852011-06-17 13:26:23 -0700161 private ActionMode.Callback mActionModeCallback = new ActionMode.Callback() {
162 public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
163 return false;
164 }
165
166 public boolean onCreateActionMode(ActionMode mode, Menu menu) {
167 return false;
168 }
169
170 public void onDestroyActionMode(ActionMode mode) {
171 }
172
173 public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
174 return false;
175 }
176 };
177
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800178 public void onItemClick(AdapterView parent, View v, int position, long id) {
Joe Onorato0589f0f2010-02-08 13:44:00 -0800179 ShortcutInfo app = (ShortcutInfo) parent.getItemAtPosition(position);
Romain Guyfb5411e2010-02-24 10:04:17 -0800180 int[] pos = new int[2];
181 v.getLocationOnScreen(pos);
182 app.intent.setSourceBounds(new Rect(pos[0], pos[1],
183 pos[0] + v.getWidth(), pos[1] + v.getHeight()));
Joe Onoratof984e852010-03-25 09:47:45 -0700184 mLauncher.startActivitySafely(app.intent, app);
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800185 }
186
187 public void onClick(View v) {
Adam Cohendf2cc412011-04-27 16:56:57 -0700188 Object tag = v.getTag();
189 if (tag instanceof ShortcutInfo) {
190 // refactor this code from Folder
191 ShortcutInfo item = (ShortcutInfo) tag;
192 int[] pos = new int[2];
193 v.getLocationOnScreen(pos);
194 item.intent.setSourceBounds(new Rect(pos[0], pos[1],
195 pos[0] + v.getWidth(), pos[1] + v.getHeight()));
196 mLauncher.startActivitySafely(item.intent, item);
Adam Cohendf2cc412011-04-27 16:56:57 -0700197 }
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800198 }
199
Adam Cohen76fc0852011-06-17 13:26:23 -0700200 public boolean onInterceptTouchEvent(MotionEvent ev) {
201 if (ev.getAction() == MotionEvent.ACTION_DOWN) {
202 mFolderName.getHitRect(mHitRect);
203 if (mHitRect.contains((int) ev.getX(), (int) ev.getY()) && !mIsEditingName) {
204 startEditingFolderName();
205 }
206 }
207 return false;
208 }
209
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800210 public boolean onLongClick(View v) {
Adam Cohendf2cc412011-04-27 16:56:57 -0700211 Object tag = v.getTag();
212 if (tag instanceof ShortcutInfo) {
Adam Cohendf2cc412011-04-27 16:56:57 -0700213 ShortcutInfo item = (ShortcutInfo) tag;
214 if (!v.isInTouchMode()) {
215 return false;
216 }
217
218 mLauncher.getWorkspace().onDragStartedWithItem(v);
219 mDragController.startDrag(v, this, item, DragController.DRAG_ACTION_COPY);
Adam Cohenbadf71e2011-05-26 19:08:29 -0700220 mIconDrawable = ((TextView) v).getCompoundDrawables()[1];
Adam Cohen76078c42011-06-09 15:06:52 -0700221
222 mCurrentDragInfo = item;
Adam Cohenbfbfd262011-06-13 16:55:12 -0700223 mEmptyCell[0] = item.cellX;
224 mEmptyCell[1] = item.cellY;
225 mCurrentDragView = v;
226 mContent.removeView(mCurrentDragView);
227 mInfo.remove(item);
Adam Cohendf2cc412011-04-27 16:56:57 -0700228 }
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800229 return true;
230 }
231
Adam Cohen76fc0852011-06-17 13:26:23 -0700232 public boolean isEditingName() {
233 return mIsEditingName;
234 }
235
236 public void startEditingFolderName() {
Adam Cohena65beee2011-06-27 21:32:23 -0700237 mFolderName.setHint("");
Adam Cohen76fc0852011-06-17 13:26:23 -0700238 mFolderName.setCursorVisible(true);
239 mIsEditingName = true;
240 }
241
242 public void dismissEditingName() {
243 mInputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0);
244 doneEditingFolderName(true);
245 }
246
247 public void doneEditingFolderName(boolean commit) {
Adam Cohena65beee2011-06-27 21:32:23 -0700248 mFolderName.setHint(sHintText);
Adam Cohen76fc0852011-06-17 13:26:23 -0700249 mInfo.setTitle(mFolderName.getText());
250 LauncherModel.updateItemInDatabase(mLauncher, mInfo);
251 mFolderName.setCursorVisible(false);
252 mFolderName.clearFocus();
253 mIsEditingName = false;
254 }
255
256 public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
257 if (actionId == EditorInfo.IME_ACTION_DONE) {
258 dismissEditingName();
259 return true;
260 }
261 return false;
262 }
263
264 public View getEditTextRegion() {
265 return mFolderName;
266 }
267
Adam Cohenbadf71e2011-05-26 19:08:29 -0700268 public Drawable getDragDrawable() {
269 return mIconDrawable;
270 }
271
Adam Cohen0c872ba2011-05-05 10:34:16 -0700272 /**
273 * We need to handle touch events to prevent them from falling through to the workspace below.
274 */
275 @Override
276 public boolean onTouchEvent(MotionEvent ev) {
277 return true;
278 }
279
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800280 public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
281 if (!view.isInTouchMode()) {
282 return false;
283 }
284
Joe Onorato0589f0f2010-02-08 13:44:00 -0800285 ShortcutInfo app = (ShortcutInfo) parent.getItemAtPosition(position);
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800286
Joe Onorato00acb122009-08-04 16:04:30 -0400287 mDragController.startDrag(view, this, app, DragController.DRAG_ACTION_COPY);
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800288 mLauncher.closeFolder(this);
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800289 return true;
290 }
291
Joe Onorato00acb122009-08-04 16:04:30 -0400292 public void setDragController(DragController dragController) {
293 mDragController = dragController;
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800294 }
295
Patrick Dubroya669d792010-11-23 14:40:33 -0800296 public void onDragViewVisible() {
297 }
298
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800299 void setLauncher(Launcher launcher) {
300 mLauncher = launcher;
301 }
Adam Cohen2801caf2011-05-13 20:57:39 -0700302
303 void setFolderIcon(FolderIcon icon) {
304 mFolderIcon = icon;
305 }
306
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800307 /**
308 * @return the FolderInfo object associated with this folder
309 */
310 FolderInfo getInfo() {
311 return mInfo;
312 }
313
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800314 void onOpen() {
Adam Cohendf2cc412011-04-27 16:56:57 -0700315 // When the folder opens, we need to refresh the GridView's selection by
316 // forcing a layout
317 // TODO: find out if this is still necessary
318 mContent.requestLayout();
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800319 }
320
321 void onClose() {
Adam Cohen76fc0852011-06-17 13:26:23 -0700322 CellLayoutChildren clc = (CellLayoutChildren) getParent();
323 final CellLayout cellLayout = (CellLayout) clc.getParent();
324 cellLayout.removeViewWithoutMarkingCells(Folder.this);
325 clearFocus();
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800326 }
327
328 void bind(FolderInfo info) {
329 mInfo = info;
Adam Cohendf2cc412011-04-27 16:56:57 -0700330 ArrayList<ShortcutInfo> children = info.contents;
Adam Cohen7c693212011-05-18 15:26:57 -0700331 setupContentForNumItems(children.size());
Adam Cohendf2cc412011-04-27 16:56:57 -0700332 for (int i = 0; i < children.size(); i++) {
333 ShortcutInfo child = (ShortcutInfo) children.get(i);
Adam Cohen7c693212011-05-18 15:26:57 -0700334 createAndAddShortcut(child);
Adam Cohendf2cc412011-04-27 16:56:57 -0700335 }
Adam Cohen4dbe6d92011-05-18 17:14:15 -0700336 mItemsInvalidated = true;
Adam Cohena9cf38f2011-05-02 15:36:58 -0700337 mInfo.addListener(this);
Adam Cohen4ef610f2011-06-21 22:37:36 -0700338
Adam Cohenafb01ee2011-06-23 15:38:03 -0700339 if (!sDefaultFolderName.contentEquals(mInfo.title)) {
Adam Cohen4ef610f2011-06-21 22:37:36 -0700340 mFolderName.setText(mInfo.title);
341 } else {
342 mFolderName.setText("");
343 }
Adam Cohendf2cc412011-04-27 16:56:57 -0700344 }
345
346 /**
347 * Creates a new UserFolder, inflated from R.layout.user_folder.
348 *
349 * @param context The application's context.
350 *
351 * @return A new UserFolder.
352 */
353 static Folder fromXml(Context context) {
354 return (Folder) LayoutInflater.from(context).inflate(R.layout.user_folder, null);
355 }
356
357 /**
358 * This method is intended to make the UserFolder to be visually identical in size and position
359 * to its associated FolderIcon. This allows for a seamless transition into the expanded state.
360 */
361 private void positionAndSizeAsIcon() {
362 if (!(getParent() instanceof CellLayoutChildren)) return;
363
Adam Cohen2801caf2011-05-13 20:57:39 -0700364 CellLayout.LayoutParams iconLp = (CellLayout.LayoutParams) mFolderIcon.getLayoutParams();
Adam Cohendf2cc412011-04-27 16:56:57 -0700365 CellLayout.LayoutParams lp = (CellLayout.LayoutParams) getLayoutParams();
366
Adam Cohen2801caf2011-05-13 20:57:39 -0700367 if (mMode == PARTIAL_GROW) {
368 setScaleX(0.8f);
369 setScaleY(0.8f);
370 setAlpha(0f);
371 } else {
372 lp.width = iconLp.width;
373 lp.height = iconLp.height;
374 lp.x = iconLp.x;
375 lp.y = iconLp.y;
376 mContent.setAlpha(0);
377 }
Adam Cohendf2cc412011-04-27 16:56:57 -0700378 mState = STATE_SMALL;
379 }
380
381 public void animateOpen() {
382 if (mState != STATE_SMALL) {
383 positionAndSizeAsIcon();
384 }
385 if (!(getParent() instanceof CellLayoutChildren)) return;
386
Adam Cohen2801caf2011-05-13 20:57:39 -0700387 ObjectAnimator oa;
Adam Cohendf2cc412011-04-27 16:56:57 -0700388 CellLayout.LayoutParams lp = (CellLayout.LayoutParams) getLayoutParams();
389
Adam Cohen2801caf2011-05-13 20:57:39 -0700390 centerAboutIcon();
391 if (mMode == PARTIAL_GROW) {
392 PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1);
393 PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f);
394 PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f);
395 oa = ObjectAnimator.ofPropertyValuesHolder(this, alpha, scaleX, scaleY);
396 } else {
397 PropertyValuesHolder width = PropertyValuesHolder.ofInt("width", mNewSize.width());
398 PropertyValuesHolder height = PropertyValuesHolder.ofInt("height", mNewSize.height());
399 PropertyValuesHolder x = PropertyValuesHolder.ofInt("x", mNewSize.left);
400 PropertyValuesHolder y = PropertyValuesHolder.ofInt("y", mNewSize.top);
401 oa = ObjectAnimator.ofPropertyValuesHolder(lp, width, height, x, y);
402 oa.addUpdateListener(new AnimatorUpdateListener() {
403 public void onAnimationUpdate(ValueAnimator animation) {
404 requestLayout();
405 }
406 });
Adam Cohendf2cc412011-04-27 16:56:57 -0700407
Adam Cohen2801caf2011-05-13 20:57:39 -0700408 PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f);
409 ObjectAnimator alphaOa = ObjectAnimator.ofPropertyValuesHolder(mContent, alpha);
410 alphaOa.setDuration(mExpandDuration);
411 alphaOa.setInterpolator(new AccelerateInterpolator(2.0f));
412 alphaOa.start();
413 }
Adam Cohendf2cc412011-04-27 16:56:57 -0700414
Adam Cohen2801caf2011-05-13 20:57:39 -0700415 oa.addListener(new AnimatorListenerAdapter() {
Adam Cohendf2cc412011-04-27 16:56:57 -0700416 @Override
417 public void onAnimationStart(Animator animation) {
418 mState = STATE_ANIMATING;
419 }
420 @Override
421 public void onAnimationEnd(Animator animation) {
Adam Cohen2801caf2011-05-13 20:57:39 -0700422 mState = STATE_OPEN;
Adam Cohendf2cc412011-04-27 16:56:57 -0700423 }
424 });
Adam Cohen2801caf2011-05-13 20:57:39 -0700425 oa.setDuration(mExpandDuration);
426 oa.start();
Adam Cohendf2cc412011-04-27 16:56:57 -0700427 }
428
429 public void animateClosed() {
430 if (!(getParent() instanceof CellLayoutChildren)) return;
431
Adam Cohen2801caf2011-05-13 20:57:39 -0700432 ObjectAnimator oa;
Adam Cohen2801caf2011-05-13 20:57:39 -0700433 if (mMode == PARTIAL_GROW) {
434 PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0);
435 PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.9f);
436 PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.9f);
437 oa = ObjectAnimator.ofPropertyValuesHolder(this, alpha, scaleX, scaleY);
438 } else {
439 CellLayout.LayoutParams iconLp = (CellLayout.LayoutParams) mFolderIcon.getLayoutParams();
440 CellLayout.LayoutParams lp = (CellLayout.LayoutParams) getLayoutParams();
Adam Cohendf2cc412011-04-27 16:56:57 -0700441
Adam Cohen2801caf2011-05-13 20:57:39 -0700442 PropertyValuesHolder width = PropertyValuesHolder.ofInt("width", iconLp.width);
443 PropertyValuesHolder height = PropertyValuesHolder.ofInt("height", iconLp.height);
444 PropertyValuesHolder x = PropertyValuesHolder.ofInt("x",iconLp.x);
445 PropertyValuesHolder y = PropertyValuesHolder.ofInt("y", iconLp.y);
446 oa = ObjectAnimator.ofPropertyValuesHolder(lp, width, height, x, y);
447 oa.addUpdateListener(new AnimatorUpdateListener() {
448 public void onAnimationUpdate(ValueAnimator animation) {
449 requestLayout();
450 }
451 });
Adam Cohendf2cc412011-04-27 16:56:57 -0700452
Adam Cohen2801caf2011-05-13 20:57:39 -0700453 PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f);
454 ObjectAnimator alphaOa = ObjectAnimator.ofPropertyValuesHolder(mContent, alpha);
455 alphaOa.setDuration(mExpandDuration);
456 alphaOa.setInterpolator(new DecelerateInterpolator(2.0f));
457 alphaOa.start();
458 }
Adam Cohendf2cc412011-04-27 16:56:57 -0700459
Adam Cohen2801caf2011-05-13 20:57:39 -0700460 oa.addListener(new AnimatorListenerAdapter() {
Adam Cohendf2cc412011-04-27 16:56:57 -0700461 @Override
462 public void onAnimationEnd(Animator animation) {
Adam Cohen76fc0852011-06-17 13:26:23 -0700463 onClose();
Adam Cohen2801caf2011-05-13 20:57:39 -0700464 onCloseComplete();
Adam Cohen2801caf2011-05-13 20:57:39 -0700465 mState = STATE_SMALL;
Adam Cohendf2cc412011-04-27 16:56:57 -0700466 }
467 @Override
468 public void onAnimationStart(Animator animation) {
469 mState = STATE_ANIMATING;
470 }
471 });
Adam Cohen2801caf2011-05-13 20:57:39 -0700472 oa.setDuration(mExpandDuration);
473 oa.start();
Adam Cohendf2cc412011-04-27 16:56:57 -0700474 }
475
476 void notifyDataSetChanged() {
477 // recreate all the children if the data set changes under us. We may want to do this more
478 // intelligently (ie just removing the views that should no longer exist)
479 mContent.removeAllViewsInLayout();
480 bind(mInfo);
481 }
482
Adam Cohencb3382b2011-05-24 14:07:08 -0700483 public boolean acceptDrop(DragObject d) {
484 final ItemInfo item = (ItemInfo) d.dragInfo;
Adam Cohendf2cc412011-04-27 16:56:57 -0700485 final int itemType = item.itemType;
Adam Cohen2801caf2011-05-13 20:57:39 -0700486 return ((itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION ||
487 itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) &&
488 !isFull());
Adam Cohendf2cc412011-04-27 16:56:57 -0700489 }
490
Adam Cohendf2cc412011-04-27 16:56:57 -0700491 protected boolean findAndSetEmptyCells(ShortcutInfo item) {
492 int[] emptyCell = new int[2];
493 if (mContent.findCellForSpan(emptyCell, item.spanX, item.spanY)) {
494 item.cellX = emptyCell[0];
495 item.cellY = emptyCell[1];
Adam Cohendf2cc412011-04-27 16:56:57 -0700496 return true;
497 } else {
498 return false;
499 }
500 }
501
502 protected void createAndAddShortcut(ShortcutInfo item) {
503 final TextView textView =
504 (TextView) mInflater.inflate(R.layout.application_boxed, this, false);
505 textView.setCompoundDrawablesWithIntrinsicBounds(null,
506 new FastBitmapDrawable(item.getIcon(mIconCache)), null, null);
507 textView.setText(item.title);
508 textView.setTag(item);
509
510 textView.setOnClickListener(this);
511 textView.setOnLongClickListener(this);
512
513 CellLayout.LayoutParams lp =
514 new CellLayout.LayoutParams(item.cellX, item.cellY, item.spanX, item.spanY);
515 boolean insert = false;
516 mContent.addViewToCellLayout(textView, insert ? 0 : -1, (int)item.id, lp, true);
517 }
518
Adam Cohencb3382b2011-05-24 14:07:08 -0700519 public void onDragEnter(DragObject d) {
Adam Cohenbfbfd262011-06-13 16:55:12 -0700520 mPreviousTargetCell[0] = -1;
521 mPreviousTargetCell[1] = -1;
Adam Cohen2801caf2011-05-13 20:57:39 -0700522 mContent.onDragEnter();
Adam Cohenbfbfd262011-06-13 16:55:12 -0700523 mOnExitAlarm.cancelAlarm();
524 }
525
526 OnAlarmListener mReorderAlarmListener = new OnAlarmListener() {
527 public void onAlarm(Alarm alarm) {
528 realTimeReorder(mEmptyCell, mTargetCell);
529 }
530 };
531
532 boolean readingOrderGreaterThan(int[] v1, int[] v2) {
533 if (v1[1] > v2[1] || (v1[1] == v2[1] && v1[0] > v2[0])) {
534 return true;
535 } else {
536 return false;
537 }
538 }
539
540 private void realTimeReorder(int[] empty, int[] target) {
541 boolean wrap;
542 int startX;
543 int endX;
544 int startY;
Adam Cohen76fc0852011-06-17 13:26:23 -0700545 int delay = 0;
546 float delayAmount = 30;
Adam Cohenbfbfd262011-06-13 16:55:12 -0700547 if (readingOrderGreaterThan(target, empty)) {
548 wrap = empty[0] >= mContent.getCountX() - 1;
549 startY = wrap ? empty[1] + 1 : empty[1];
550 for (int y = startY; y <= target[1]; y++) {
551 startX = y == empty[1] ? empty[0] + 1 : 0;
552 endX = y < target[1] ? mContent.getCountX() - 1 : target[0];
553 for (int x = startX; x <= endX; x++) {
554 View v = mContent.getChildAt(x,y);
555 if (mContent.animateChildToPosition(v, empty[0], empty[1],
Adam Cohen76fc0852011-06-17 13:26:23 -0700556 REORDER_ANIMATION_DURATION, delay)) {
Adam Cohenbfbfd262011-06-13 16:55:12 -0700557 empty[0] = x;
558 empty[1] = y;
Adam Cohen76fc0852011-06-17 13:26:23 -0700559 delay += delayAmount;
560 delayAmount *= 0.9;
Adam Cohenbfbfd262011-06-13 16:55:12 -0700561 }
562 }
563 }
564 } else {
565 wrap = empty[0] == 0;
566 startY = wrap ? empty[1] - 1 : empty[1];
567 for (int y = startY; y >= target[1]; y--) {
568 startX = y == empty[1] ? empty[0] - 1 : mContent.getCountX() - 1;
569 endX = y > target[1] ? 0 : target[0];
570 for (int x = startX; x >= endX; x--) {
571 View v = mContent.getChildAt(x,y);
572 if (mContent.animateChildToPosition(v, empty[0], empty[1],
Adam Cohen76fc0852011-06-17 13:26:23 -0700573 REORDER_ANIMATION_DURATION, delay)) {
Adam Cohenbfbfd262011-06-13 16:55:12 -0700574 empty[0] = x;
575 empty[1] = y;
Adam Cohen76fc0852011-06-17 13:26:23 -0700576 delay += delayAmount;
577 delayAmount *= 0.9;
Adam Cohenbfbfd262011-06-13 16:55:12 -0700578 }
579 }
580 }
581 }
Adam Cohendf2cc412011-04-27 16:56:57 -0700582 }
583
Adam Cohencb3382b2011-05-24 14:07:08 -0700584 public void onDragOver(DragObject d) {
Adam Cohenbfbfd262011-06-13 16:55:12 -0700585 float[] r = getDragViewVisualCenter(d.x, d.y, d.xOffset, d.yOffset, d.dragView, null);
586 mTargetCell = mContent.findNearestArea((int) r[0], (int) r[1], 1, 1, mTargetCell);
587
588 if (mTargetCell[0] != mPreviousTargetCell[0] || mTargetCell[1] != mPreviousTargetCell[1]) {
589 mReorderAlarm.cancelAlarm();
590 mReorderAlarm.setOnAlarmListener(mReorderAlarmListener);
591 mReorderAlarm.setAlarm(150);
592 mPreviousTargetCell[0] = mTargetCell[0];
593 mPreviousTargetCell[1] = mTargetCell[1];
594 }
Adam Cohendf2cc412011-04-27 16:56:57 -0700595 }
596
Adam Cohenbfbfd262011-06-13 16:55:12 -0700597 // This is used to compute the visual center of the dragView. The idea is that
598 // the visual center represents the user's interpretation of where the item is, and hence
599 // is the appropriate point to use when determining drop location.
600 private float[] getDragViewVisualCenter(int x, int y, int xOffset, int yOffset,
601 DragView dragView, float[] recycle) {
602 float res[];
603 if (recycle == null) {
604 res = new float[2];
605 } else {
606 res = recycle;
607 }
608
609 // These represent the visual top and left of drag view if a dragRect was provided.
610 // If a dragRect was not provided, then they correspond to the actual view left and
611 // top, as the dragRect is in that case taken to be the entire dragView.
612 // R.dimen.dragViewOffsetY.
613 int left = x - xOffset;
614 int top = y - yOffset;
615
616 // In order to find the visual center, we shift by half the dragRect
617 res[0] = left + dragView.getDragRegion().width() / 2;
618 res[1] = top + dragView.getDragRegion().height() / 2;
619
620 return res;
621 }
622
623 OnAlarmListener mOnExitAlarmListener = new OnAlarmListener() {
624 public void onAlarm(Alarm alarm) {
Adam Cohen1d9af7d2011-06-22 15:26:58 -0700625 mLauncher.closeFolder();
Adam Cohenbfbfd262011-06-13 16:55:12 -0700626 mCurrentDragInfo = null;
627 mCurrentDragView = null;
628 mSuppressOnAdd = false;
629 mRearrangeOnClose = true;
630 }
631 };
632
Adam Cohencb3382b2011-05-24 14:07:08 -0700633 public void onDragExit(DragObject d) {
Adam Cohenbfbfd262011-06-13 16:55:12 -0700634 // We only close the folder if this is a true drag exit, ie. not because a drop
635 // has occurred above the folder.
636 if (!d.dragComplete) {
637 mOnExitAlarm.setOnAlarmListener(mOnExitAlarmListener);
638 mOnExitAlarm.setAlarm(ON_EXIT_CLOSE_DELAY);
639 }
640 mReorderAlarm.cancelAlarm();
Adam Cohen2801caf2011-05-13 20:57:39 -0700641 mContent.onDragExit();
642 }
643
Adam Cohenc0dcf592011-06-01 15:30:43 -0700644 public void onDropCompleted(View target, DragObject d, boolean success) {
Adam Cohenbfbfd262011-06-13 16:55:12 -0700645 mCurrentDragInfo = null;
646 mCurrentDragView = null;
647 mSuppressOnAdd = false;
Adam Cohen76078c42011-06-09 15:06:52 -0700648 if (!success) {
649 if (d.dragView != null) {
650 if (target instanceof CellLayout) {
651 // TODO: we should animate the item back to the folder in this case
652 }
653 }
Adam Cohenbfbfd262011-06-13 16:55:12 -0700654 // TODO: if the drag fails, we need to re-add the item
Adam Cohen76078c42011-06-09 15:06:52 -0700655 }
Adam Cohendf2cc412011-04-27 16:56:57 -0700656 }
657
658 public boolean isDropEnabled() {
659 return true;
660 }
661
Adam Cohencb3382b2011-05-24 14:07:08 -0700662 public DropTarget getDropTargetDelegate(DragObject d) {
Adam Cohendf2cc412011-04-27 16:56:57 -0700663 return null;
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800664 }
Adam Cohena9cf38f2011-05-02 15:36:58 -0700665
Adam Cohen2801caf2011-05-13 20:57:39 -0700666 private void setupContentDimension(int count) {
667 ArrayList<View> list = getItemsInReadingOrder();
668
669 int countX = mContent.getCountX();
670 int countY = mContent.getCountY();
Adam Cohen7c693212011-05-18 15:26:57 -0700671 boolean done = false;
Adam Cohen2801caf2011-05-13 20:57:39 -0700672
Adam Cohen7c693212011-05-18 15:26:57 -0700673 while (!done) {
674 int oldCountX = countX;
675 int oldCountY = countY;
676 if (countX * countY < count) {
677 // Current grid is too small, expand it
678 if (countX <= countY && countX < mMaxCountX) {
679 countX++;
680 } else if (countY < mMaxCountY) {
681 countY++;
682 }
683 if (countY == 0) countY++;
684 } else if ((countY - 1) * countX >= count && countY >= countX) {
685 countY = Math.max(0, countY - 1);
686 } else if ((countX - 1) * countY >= count) {
687 countX = Math.max(0, countX - 1);
Adam Cohen2801caf2011-05-13 20:57:39 -0700688 }
Adam Cohen7c693212011-05-18 15:26:57 -0700689 done = countX == oldCountX && countY == oldCountY;
Adam Cohen2801caf2011-05-13 20:57:39 -0700690 }
Adam Cohen7c693212011-05-18 15:26:57 -0700691 mContent.setGridSize(countX, countY);
Adam Cohen2801caf2011-05-13 20:57:39 -0700692 arrangeChildren(list);
693 }
694
695 public boolean isFull() {
696 return getItemCount() >= mMaxCountX * mMaxCountY;
697 }
698
699 private void centerAboutIcon() {
700 CellLayout.LayoutParams iconLp = (CellLayout.LayoutParams) mFolderIcon.getLayoutParams();
701 CellLayout.LayoutParams lp = (CellLayout.LayoutParams) getLayoutParams();
702
703 int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth();
Adam Cohen76fc0852011-06-17 13:26:23 -0700704 // Technically there is no padding at the bottom, but we add space equal to the padding
705 // and have to account for that here.
706 int height = getPaddingTop() + mContent.getDesiredHeight() + mFolderNameHeight;
Adam Cohen2801caf2011-05-13 20:57:39 -0700707
708 int centerX = iconLp.x + iconLp.width / 2;
709 int centerY = iconLp.y + iconLp.height / 2;
710 int centeredLeft = centerX - width / 2;
711 int centeredTop = centerY - height / 2;
712
713 CellLayoutChildren clc = (CellLayoutChildren) getParent();
714 int parentWidth = 0;
715 int parentHeight = 0;
716 if (clc != null) {
717 parentWidth = clc.getMeasuredWidth();
718 parentHeight = clc.getMeasuredHeight();
719 }
720
721 int left = Math.min(Math.max(0, centeredLeft), parentWidth - width);
722 int top = Math.min(Math.max(0, centeredTop), parentHeight - height);
723
724 int folderPivotX = width / 2 + (centeredLeft - left);
725 int folderPivotY = height / 2 + (centeredTop - top);
726 setPivotX(folderPivotX);
727 setPivotY(folderPivotY);
728 int folderIconPivotX = (int) (mFolderIcon.getMeasuredWidth() *
729 (1.0f * folderPivotX / width));
730 int folderIconPivotY = (int) (mFolderIcon.getMeasuredHeight() *
731 (1.0f * folderPivotY / height));
732 mFolderIcon.setPivotX(folderIconPivotX);
733 mFolderIcon.setPivotY(folderIconPivotY);
734
735 if (mMode == PARTIAL_GROW) {
736 lp.width = width;
737 lp.height = height;
738 lp.x = left;
739 lp.y = top;
740 } else {
741 mNewSize.set(left, top, left + width, top + height);
742 }
743 }
744
745 private void setupContentForNumItems(int count) {
Adam Cohen2801caf2011-05-13 20:57:39 -0700746 setupContentDimension(count);
747
748 CellLayout.LayoutParams lp = (CellLayout.LayoutParams) getLayoutParams();
749 if (lp == null) {
750 lp = new CellLayout.LayoutParams(0, 0, -1, -1);
751 lp.isLockedToGrid = false;
752 setLayoutParams(lp);
753 }
754 centerAboutIcon();
755 }
756
757 private void arrangeChildren(ArrayList<View> list) {
758 int[] vacant = new int[2];
759 if (list == null) {
760 list = getItemsInReadingOrder();
761 }
762 mContent.removeAllViews();
763
764 for (int i = 0; i < list.size(); i++) {
765 View v = list.get(i);
766 mContent.getVacantCell(vacant, 1, 1);
767 CellLayout.LayoutParams lp = (CellLayout.LayoutParams) v.getLayoutParams();
768 lp.cellX = vacant[0];
769 lp.cellY = vacant[1];
770 ItemInfo info = (ItemInfo) v.getTag();
771 info.cellX = vacant[0];
772 info.cellY = vacant[1];
773 boolean insert = false;
774 mContent.addViewToCellLayout(v, insert ? 0 : -1, (int)info.id, lp, true);
Adam Cohen7c693212011-05-18 15:26:57 -0700775 LauncherModel.addOrMoveItemInDatabase(mLauncher, info, mInfo.id, 0,
776 info.cellX, info.cellY);
Adam Cohen2801caf2011-05-13 20:57:39 -0700777 }
Adam Cohen7c693212011-05-18 15:26:57 -0700778 mItemsInvalidated = true;
Adam Cohen2801caf2011-05-13 20:57:39 -0700779 }
780
Adam Cohena9cf38f2011-05-02 15:36:58 -0700781 public int getItemCount() {
782 return mContent.getChildrenLayout().getChildCount();
783 }
784
785 public View getItemAt(int index) {
786 return mContent.getChildrenLayout().getChildAt(index);
787 }
788
Adam Cohen2801caf2011-05-13 20:57:39 -0700789 private void onCloseComplete() {
790 if (mRearrangeOnClose) {
791 setupContentForNumItems(getItemCount());
792 mRearrangeOnClose = false;
793 }
Adam Cohenafb01ee2011-06-23 15:38:03 -0700794 if (getItemCount() <= 1) {
795 replaceFolderWithFinalItem();
796 }
797 }
798
799 private void replaceFolderWithFinalItem() {
800 ItemInfo finalItem = null;
801
802 if (getItemCount() == 1) {
803 finalItem = mInfo.contents.get(0);
804 }
805
806 // Remove the folder completely
807 final CellLayout cellLayout = (CellLayout)
808 mLauncher.getWorkspace().getChildAt(mInfo.screen);
809 cellLayout.removeView(mFolderIcon);
810 if (mFolderIcon instanceof DropTarget) {
811 mDragController.removeDropTarget((DropTarget) mFolderIcon);
812 }
813 mLauncher.removeFolder(mInfo);
814
815 if (finalItem != null) {
816 LauncherModel.addOrMoveItemInDatabase(mLauncher, finalItem,
817 LauncherSettings.Favorites.CONTAINER_DESKTOP, mInfo.screen,
818 mInfo.cellX, mInfo.cellY);
819 }
820 LauncherModel.deleteFolderContentsFromDatabase(mLauncher, mInfo, true);
821
822 // Add the last remaining child to the workspace in place of the folder
823 if (finalItem != null) {
824 View child = mLauncher.createShortcut(R.layout.application, cellLayout,
825 (ShortcutInfo) finalItem);
826
827 mLauncher.getWorkspace().addInScreen(child, mInfo.screen, mInfo.cellX, mInfo.cellY,
828 mInfo.spanX, mInfo.spanY);
829 }
Adam Cohen2801caf2011-05-13 20:57:39 -0700830 }
831
Adam Cohenbfbfd262011-06-13 16:55:12 -0700832 public void onDrop(DragObject d) {
833 ShortcutInfo item;
834 if (d.dragInfo instanceof ApplicationInfo) {
835 // Came from all apps -- make a copy
836 item = ((ApplicationInfo) d.dragInfo).makeShortcut();
837 item.spanX = 1;
838 item.spanY = 1;
839 } else {
840 item = (ShortcutInfo) d.dragInfo;
841 }
842 // Dragged from self onto self
843 if (item == mCurrentDragInfo) {
844 ShortcutInfo si = (ShortcutInfo) mCurrentDragView.getTag();
845 CellLayout.LayoutParams lp = (CellLayout.LayoutParams) mCurrentDragView.getLayoutParams();
846 si.cellX = lp.cellX = mEmptyCell[0];
847 si.cellX = lp.cellY = mEmptyCell[1];
848 mContent.addViewToCellLayout(mCurrentDragView, -1, (int)item.id, lp, true);
849 mSuppressOnAdd = true;
850 mItemsInvalidated = true;
851 setupContentDimension(getItemCount());
852 }
853 mInfo.add(item);
854 }
855
856 public void onAdd(ShortcutInfo item) {
857 mItemsInvalidated = true;
858 if (mSuppressOnAdd) return;
859 if (!findAndSetEmptyCells(item)) {
860 // The current layout is full, can we expand it?
861 setupContentForNumItems(getItemCount() + 1);
862 findAndSetEmptyCells(item);
863 }
864 createAndAddShortcut(item);
865 LauncherModel.addOrMoveItemInDatabase(
866 mLauncher, item, mInfo.id, 0, item.cellX, item.cellY);
867 }
868
Adam Cohena9cf38f2011-05-02 15:36:58 -0700869 public void onRemove(ShortcutInfo item) {
Adam Cohen7c693212011-05-18 15:26:57 -0700870 mItemsInvalidated = true;
Adam Cohenbfbfd262011-06-13 16:55:12 -0700871 if (item == mCurrentDragInfo) return;
Adam Cohendf1e4e82011-06-24 15:57:39 -0700872 View v = getViewForInfo(item);
Adam Cohena9cf38f2011-05-02 15:36:58 -0700873 mContent.removeView(v);
Adam Cohen2801caf2011-05-13 20:57:39 -0700874 if (mState == STATE_ANIMATING) {
875 mRearrangeOnClose = true;
876 } else {
877 setupContentForNumItems(getItemCount());
878 }
Adam Cohenafb01ee2011-06-23 15:38:03 -0700879 if (getItemCount() <= 1) {
880 replaceFolderWithFinalItem();
881 }
Adam Cohena9cf38f2011-05-02 15:36:58 -0700882 }
Adam Cohen7c693212011-05-18 15:26:57 -0700883
Adam Cohendf1e4e82011-06-24 15:57:39 -0700884 private View getViewForInfo(ShortcutInfo item) {
885 for (int j = 0; j < mContent.getCountY(); j++) {
886 for (int i = 0; i < mContent.getCountX(); i++) {
887 View v = mContent.getChildAt(i, j);
888 if (v.getTag() == item) {
889 return v;
890 }
891 }
892 }
893 return null;
894 }
895
Adam Cohen76078c42011-06-09 15:06:52 -0700896 public void onItemsChanged() {
897 }
Adam Cohen76fc0852011-06-17 13:26:23 -0700898 public void onTitleChanged(CharSequence title) {
899 }
Adam Cohen76078c42011-06-09 15:06:52 -0700900
Adam Cohen7c693212011-05-18 15:26:57 -0700901 public ArrayList<View> getItemsInReadingOrder() {
Adam Cohen76078c42011-06-09 15:06:52 -0700902 return getItemsInReadingOrder(true);
903 }
904
905 public ArrayList<View> getItemsInReadingOrder(boolean includeCurrentDragItem) {
Adam Cohen7c693212011-05-18 15:26:57 -0700906 if (mItemsInvalidated) {
907 mItemsInReadingOrder.clear();
908 for (int j = 0; j < mContent.getCountY(); j++) {
909 for (int i = 0; i < mContent.getCountX(); i++) {
910 View v = mContent.getChildAt(i, j);
911 if (v != null) {
Adam Cohen76078c42011-06-09 15:06:52 -0700912 ShortcutInfo info = (ShortcutInfo) v.getTag();
913 if (info != mCurrentDragInfo || includeCurrentDragItem) {
914 mItemsInReadingOrder.add(v);
915 }
Adam Cohen7c693212011-05-18 15:26:57 -0700916 }
917 }
918 }
919 mItemsInvalidated = false;
920 }
921 return mItemsInReadingOrder;
922 }
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800923}