blob: 0ccdae1a7d19e21cebcd3b804bd654223680548c [file] [log] [blame]
Winson Chung4c98d922011-05-31 16:50:48 -07001/*
2 * Copyright (C) 2011 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
Daniel Sandler325dc232013-06-05 22:57:57 -040017package com.android.launcher3;
Winson Chung4c98d922011-05-31 16:50:48 -070018
Winson Chung043f2af2012-03-01 16:09:54 -080019import android.animation.TimeInterpolator;
20import android.animation.ValueAnimator;
21import android.animation.ValueAnimator.AnimatorUpdateListener;
Winson Chung4c98d922011-05-31 16:50:48 -070022import android.content.Context;
Winson Chunga62e9fd2011-07-11 15:20:48 -070023import android.content.res.ColorStateList;
Winson Chung201bc822011-06-20 15:41:53 -070024import android.content.res.Configuration;
Winson Chung4c98d922011-05-31 16:50:48 -070025import android.content.res.Resources;
Winson Chung043f2af2012-03-01 16:09:54 -080026import android.graphics.PointF;
Adam Cohend4d7aa52011-07-19 21:47:37 -070027import android.graphics.Rect;
Winson Chung967289b2011-06-30 18:09:30 -070028import android.graphics.drawable.TransitionDrawable;
Winson Chung4c98d922011-05-31 16:50:48 -070029import android.util.AttributeSet;
30import android.view.View;
Winson Chung043f2af2012-03-01 16:09:54 -080031import android.view.ViewConfiguration;
Winson Chunga6427b12011-07-27 10:53:39 -070032import android.view.ViewGroup;
Winson Chung043f2af2012-03-01 16:09:54 -080033import android.view.animation.AnimationUtils;
Adam Cohend4d7aa52011-07-19 21:47:37 -070034import android.view.animation.DecelerateInterpolator;
Winson Chung61967cb2012-02-28 18:11:33 -080035import android.view.animation.LinearInterpolator;
Winson Chung4c98d922011-05-31 16:50:48 -070036
Daniel Sandler325dc232013-06-05 22:57:57 -040037import com.android.launcher3.R;
Winson Chung4c98d922011-05-31 16:50:48 -070038
Winson Chung61fa4192011-06-12 15:15:29 -070039public class DeleteDropTarget extends ButtonDropTarget {
Winson Chung043f2af2012-03-01 16:09:54 -080040 private static int DELETE_ANIMATION_DURATION = 285;
Winson Chung6e1bdaf2012-05-29 17:03:45 -070041 private static int FLING_DELETE_ANIMATION_DURATION = 350;
42 private static float FLING_TO_DELETE_FRICTION = 0.035f;
Winson Chung043f2af2012-03-01 16:09:54 -080043 private static int MODE_FLING_DELETE_TO_TRASH = 0;
44 private static int MODE_FLING_DELETE_ALONG_VECTOR = 1;
Winson Chung4c98d922011-05-31 16:50:48 -070045
Winson Chung043f2af2012-03-01 16:09:54 -080046 private final int mFlingDeleteMode = MODE_FLING_DELETE_ALONG_VECTOR;
47
Winson Chunga62e9fd2011-07-11 15:20:48 -070048 private ColorStateList mOriginalTextColor;
Adam Cohenebea84d2011-11-09 17:20:41 -080049 private TransitionDrawable mUninstallDrawable;
50 private TransitionDrawable mRemoveDrawable;
51 private TransitionDrawable mCurrentDrawable;
Winson Chung4c98d922011-05-31 16:50:48 -070052
53 public DeleteDropTarget(Context context, AttributeSet attrs) {
54 this(context, attrs, 0);
55 }
56
57 public DeleteDropTarget(Context context, AttributeSet attrs, int defStyle) {
58 super(context, attrs, defStyle);
59 }
60
61 @Override
62 protected void onFinishInflate() {
63 super.onFinishInflate();
64
65 // Get the drawable
Winson Chunga6427b12011-07-27 10:53:39 -070066 mOriginalTextColor = getTextColors();
Winson Chung4c98d922011-05-31 16:50:48 -070067
68 // Get the hover color
69 Resources r = getResources();
Winson Chung4c98d922011-05-31 16:50:48 -070070 mHoverColor = r.getColor(R.color.delete_target_hover_tint);
Adam Cohenebea84d2011-11-09 17:20:41 -080071 mUninstallDrawable = (TransitionDrawable)
72 r.getDrawable(R.drawable.uninstall_target_selector);
73 mRemoveDrawable = (TransitionDrawable) r.getDrawable(R.drawable.remove_target_selector);
74
75 mRemoveDrawable.setCrossFadeEnabled(true);
76 mUninstallDrawable.setCrossFadeEnabled(true);
77
78 // The current drawable is set to either the remove drawable or the uninstall drawable
79 // and is initially set to the remove drawable, as set in the layout xml.
Winson Chung947245b2012-05-15 16:34:19 -070080 mCurrentDrawable = (TransitionDrawable) getCurrentDrawable();
Winson Chung201bc822011-06-20 15:41:53 -070081
82 // Remove the text in the Phone UI in landscape
83 int orientation = getResources().getConfiguration().orientation;
84 if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
Daniel Sandlercc8befa2013-06-11 14:45:48 -040085 if (!LauncherAppState.isScreenLarge()) {
Winson Chunga6427b12011-07-27 10:53:39 -070086 setText("");
Winson Chung201bc822011-06-20 15:41:53 -070087 }
88 }
Winson Chung4c98d922011-05-31 16:50:48 -070089 }
90
91 private boolean isAllAppsApplication(DragSource source, Object info) {
92 return (source instanceof AppsCustomizePagedView) && (info instanceof ApplicationInfo);
93 }
94 private boolean isAllAppsWidget(DragSource source, Object info) {
Winson Chung11a49372012-04-27 15:12:38 -070095 if (source instanceof AppsCustomizePagedView) {
96 if (info instanceof PendingAddItemInfo) {
97 PendingAddItemInfo addInfo = (PendingAddItemInfo) info;
98 switch (addInfo.itemType) {
99 case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
100 case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
101 return true;
102 }
103 }
104 }
105 return false;
Winson Chung4c98d922011-05-31 16:50:48 -0700106 }
Michael Jurka0b4870d2011-07-10 13:39:08 -0700107 private boolean isDragSourceWorkspaceOrFolder(DragObject d) {
108 return (d.dragSource instanceof Workspace) || (d.dragSource instanceof Folder);
Winson Chung4c98d922011-05-31 16:50:48 -0700109 }
Michael Jurka0b4870d2011-07-10 13:39:08 -0700110 private boolean isWorkspaceOrFolderApplication(DragObject d) {
111 return isDragSourceWorkspaceOrFolder(d) && (d.dragInfo instanceof ShortcutInfo);
112 }
113 private boolean isWorkspaceOrFolderWidget(DragObject d) {
114 return isDragSourceWorkspaceOrFolder(d) && (d.dragInfo instanceof LauncherAppWidgetInfo);
Winson Chung4c98d922011-05-31 16:50:48 -0700115 }
116 private boolean isWorkspaceFolder(DragObject d) {
117 return (d.dragSource instanceof Workspace) && (d.dragInfo instanceof FolderInfo);
118 }
119
Winson Chunga48487a2012-03-20 16:19:37 -0700120 private void setHoverColor() {
121 mCurrentDrawable.startTransition(mTransitionDuration);
122 setTextColor(mHoverColor);
123 }
124 private void resetHoverColor() {
125 mCurrentDrawable.resetTransition();
126 setTextColor(mOriginalTextColor);
127 }
128
Winson Chung4c98d922011-05-31 16:50:48 -0700129 @Override
130 public boolean acceptDrop(DragObject d) {
Adam Cohen7c4c5102013-06-14 17:42:35 -0700131 return willAcceptDrop(d.dragInfo);
132 }
133
134 public static boolean willAcceptDrop(Object info) {
135 if (info instanceof ItemInfo) {
136 ItemInfo item = (ItemInfo) info;
137 if (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET ||
138 item.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
139 return true;
140 }
Adam Cohen947dc542013-06-06 22:43:33 -0700141 }
Adam Cohen7c4c5102013-06-14 17:42:35 -0700142 return false;
Winson Chung4c98d922011-05-31 16:50:48 -0700143 }
144
145 @Override
146 public void onDragStart(DragSource source, Object info, int dragAction) {
Winson Chung4c98d922011-05-31 16:50:48 -0700147 boolean isVisible = true;
148 boolean isUninstall = false;
149
Winson Chungf0ea4d32011-06-06 14:27:16 -0700150 // If we are dragging a widget from AppsCustomize, hide the delete target
Winson Chung4c98d922011-05-31 16:50:48 -0700151 if (isAllAppsWidget(source, info)) {
152 isVisible = false;
153 }
154
155 // If we are dragging an application from AppsCustomize, only show the control if we can
156 // delete the app (it was downloaded), and rename the string to "uninstall" in such a case
Adam Cohen7c4c5102013-06-14 17:42:35 -0700157 if (willAcceptDrop(info)) {
Adam Cohen947dc542013-06-06 22:43:33 -0700158 isVisible = true;
159 } else {
160 isVisible = false;
Winson Chung4c98d922011-05-31 16:50:48 -0700161 }
162
Adam Cohenebea84d2011-11-09 17:20:41 -0800163 if (isUninstall) {
Fabrice Di Megliod6a33c62013-02-06 15:40:46 -0800164 setCompoundDrawablesRelativeWithIntrinsicBounds(mUninstallDrawable, null, null, null);
Adam Cohenebea84d2011-11-09 17:20:41 -0800165 } else {
Fabrice Di Megliod6a33c62013-02-06 15:40:46 -0800166 setCompoundDrawablesRelativeWithIntrinsicBounds(mRemoveDrawable, null, null, null);
Adam Cohenebea84d2011-11-09 17:20:41 -0800167 }
Winson Chung947245b2012-05-15 16:34:19 -0700168 mCurrentDrawable = (TransitionDrawable) getCurrentDrawable();
Adam Cohenebea84d2011-11-09 17:20:41 -0800169
Winson Chung4c98d922011-05-31 16:50:48 -0700170 mActive = isVisible;
Winson Chunga48487a2012-03-20 16:19:37 -0700171 resetHoverColor();
Winson Chunga6427b12011-07-27 10:53:39 -0700172 ((ViewGroup) getParent()).setVisibility(isVisible ? View.VISIBLE : View.GONE);
173 if (getText().length() > 0) {
174 setText(isUninstall ? R.string.delete_target_uninstall_label
Winson Chung4c98d922011-05-31 16:50:48 -0700175 : R.string.delete_target_label);
176 }
177 }
178
179 @Override
180 public void onDragEnd() {
181 super.onDragEnd();
182 mActive = false;
183 }
184
185 public void onDragEnter(DragObject d) {
186 super.onDragEnter(d);
187
Winson Chunga48487a2012-03-20 16:19:37 -0700188 setHoverColor();
Winson Chung4c98d922011-05-31 16:50:48 -0700189 }
190
191 public void onDragExit(DragObject d) {
192 super.onDragExit(d);
193
Winson Chungaaa530a2011-07-11 21:06:30 -0700194 if (!d.dragComplete) {
Winson Chunga48487a2012-03-20 16:19:37 -0700195 resetHoverColor();
Winson Chung61967cb2012-02-28 18:11:33 -0800196 } else {
197 // Restore the hover color if we are deleting
198 d.dragView.setColor(mHoverColor);
Winson Chungaaa530a2011-07-11 21:06:30 -0700199 }
Winson Chung4c98d922011-05-31 16:50:48 -0700200 }
201
Adam Cohened66b2b2012-01-23 17:28:51 -0800202 private void animateToTrashAndCompleteDrop(final DragObject d) {
203 DragLayer dragLayer = mLauncher.getDragLayer();
204 Rect from = new Rect();
205 dragLayer.getViewRectRelativeToSelf(d.dragView, from);
Winson Chung61967cb2012-02-28 18:11:33 -0800206 Rect to = getIconRect(d.dragView.getMeasuredWidth(), d.dragView.getMeasuredHeight(),
207 mCurrentDrawable.getIntrinsicWidth(), mCurrentDrawable.getIntrinsicHeight());
208 float scale = (float) to.width() / from.width();
Adam Cohened66b2b2012-01-23 17:28:51 -0800209
Adam Cohend4d7aa52011-07-19 21:47:37 -0700210 mSearchDropTargetBar.deferOnDragEnd();
211 Runnable onAnimationEndRunnable = new Runnable() {
212 @Override
213 public void run() {
214 mSearchDropTargetBar.onDragEnd();
215 mLauncher.exitSpringLoadedDragMode();
216 completeDrop(d);
217 }
218 };
Winson Chung61967cb2012-02-28 18:11:33 -0800219 dragLayer.animateView(d.dragView, from, to, scale, 1f, 1f, 0.1f, 0.1f,
Adam Cohend4d7aa52011-07-19 21:47:37 -0700220 DELETE_ANIMATION_DURATION, new DecelerateInterpolator(2),
Winson Chung61967cb2012-02-28 18:11:33 -0800221 new LinearInterpolator(), onAnimationEndRunnable,
Adam Cohened66b2b2012-01-23 17:28:51 -0800222 DragLayer.ANIMATION_END_DISAPPEAR, null);
Adam Cohend4d7aa52011-07-19 21:47:37 -0700223 }
224
225 private void completeDrop(DragObject d) {
Winson Chung4c98d922011-05-31 16:50:48 -0700226 ItemInfo item = (ItemInfo) d.dragInfo;
227
228 if (isAllAppsApplication(d.dragSource, item)) {
229 // Uninstall the application if it is being dragged from AppsCustomize
230 mLauncher.startApplicationUninstallActivity((ApplicationInfo) item);
Michael Jurka0b4870d2011-07-10 13:39:08 -0700231 } else if (isWorkspaceOrFolderApplication(d)) {
Winson Chung4c98d922011-05-31 16:50:48 -0700232 LauncherModel.deleteItemFromDatabase(mLauncher, item);
233 } else if (isWorkspaceFolder(d)) {
234 // Remove the folder from the workspace and delete the contents from launcher model
235 FolderInfo folderInfo = (FolderInfo) item;
236 mLauncher.removeFolder(folderInfo);
237 LauncherModel.deleteFolderContentsFromDatabase(mLauncher, folderInfo);
Michael Jurka0b4870d2011-07-10 13:39:08 -0700238 } else if (isWorkspaceOrFolderWidget(d)) {
Winson Chung4c98d922011-05-31 16:50:48 -0700239 // Remove the widget from the workspace
240 mLauncher.removeAppWidget((LauncherAppWidgetInfo) item);
241 LauncherModel.deleteItemFromDatabase(mLauncher, item);
242
243 final LauncherAppWidgetInfo launcherAppWidgetInfo = (LauncherAppWidgetInfo) item;
244 final LauncherAppWidgetHost appWidgetHost = mLauncher.getAppWidgetHost();
245 if (appWidgetHost != null) {
246 // Deleting an app widget ID is a void call but writes to disk before returning
247 // to the caller...
248 new Thread("deleteAppWidgetId") {
249 public void run() {
250 appWidgetHost.deleteAppWidgetId(launcherAppWidgetInfo.appWidgetId);
251 }
252 }.start();
253 }
254 }
255 }
Adam Cohend4d7aa52011-07-19 21:47:37 -0700256
257 public void onDrop(DragObject d) {
258 animateToTrashAndCompleteDrop(d);
259 }
Winson Chung043f2af2012-03-01 16:09:54 -0800260
261 /**
262 * Creates an animation from the current drag view to the delete trash icon.
263 */
264 private AnimatorUpdateListener createFlingToTrashAnimatorListener(final DragLayer dragLayer,
265 DragObject d, PointF vel, ViewConfiguration config) {
266 final Rect to = getIconRect(d.dragView.getMeasuredWidth(), d.dragView.getMeasuredHeight(),
267 mCurrentDrawable.getIntrinsicWidth(), mCurrentDrawable.getIntrinsicHeight());
268 final Rect from = new Rect();
269 dragLayer.getViewRectRelativeToSelf(d.dragView, from);
270
271 // Calculate how far along the velocity vector we should put the intermediate point on
272 // the bezier curve
273 float velocity = Math.abs(vel.length());
274 float vp = Math.min(1f, velocity / (config.getScaledMaximumFlingVelocity() / 2f));
275 int offsetY = (int) (-from.top * vp);
276 int offsetX = (int) (offsetY / (vel.y / vel.x));
277 final float y2 = from.top + offsetY; // intermediate t/l
278 final float x2 = from.left + offsetX;
279 final float x1 = from.left; // drag view t/l
280 final float y1 = from.top;
281 final float x3 = to.left; // delete target t/l
282 final float y3 = to.top;
283
284 final TimeInterpolator scaleAlphaInterpolator = new TimeInterpolator() {
285 @Override
286 public float getInterpolation(float t) {
287 return t * t * t * t * t * t * t * t;
288 }
289 };
290 return new AnimatorUpdateListener() {
291 @Override
292 public void onAnimationUpdate(ValueAnimator animation) {
293 final DragView dragView = (DragView) dragLayer.getAnimatedView();
294 float t = ((Float) animation.getAnimatedValue()).floatValue();
295 float tp = scaleAlphaInterpolator.getInterpolation(t);
296 float initialScale = dragView.getInitialScale();
297 float finalAlpha = 0.5f;
298 float scale = dragView.getScaleX();
299 float x1o = ((1f - scale) * dragView.getMeasuredWidth()) / 2f;
300 float y1o = ((1f - scale) * dragView.getMeasuredHeight()) / 2f;
301 float x = (1f - t) * (1f - t) * (x1 - x1o) + 2 * (1f - t) * t * (x2 - x1o) +
302 (t * t) * x3;
303 float y = (1f - t) * (1f - t) * (y1 - y1o) + 2 * (1f - t) * t * (y2 - x1o) +
304 (t * t) * y3;
305
306 dragView.setTranslationX(x);
307 dragView.setTranslationY(y);
308 dragView.setScaleX(initialScale * (1f - tp));
309 dragView.setScaleY(initialScale * (1f - tp));
310 dragView.setAlpha(finalAlpha + (1f - finalAlpha) * (1f - tp));
311 }
312 };
313 }
314
315 /**
316 * Creates an animation from the current drag view along its current velocity vector.
317 * For this animation, the alpha runs for a fixed duration and we update the position
318 * progressively.
319 */
320 private static class FlingAlongVectorAnimatorUpdateListener implements AnimatorUpdateListener {
Winson Chung043f2af2012-03-01 16:09:54 -0800321 private DragLayer mDragLayer;
322 private PointF mVelocity;
323 private Rect mFrom;
324 private long mPrevTime;
325 private boolean mHasOffsetForScale;
Winson Chung6e1bdaf2012-05-29 17:03:45 -0700326 private float mFriction;
Winson Chung043f2af2012-03-01 16:09:54 -0800327
Winson Chung9658b1e2012-04-09 18:30:07 -0700328 private final TimeInterpolator mAlphaInterpolator = new DecelerateInterpolator(0.75f);
Winson Chung043f2af2012-03-01 16:09:54 -0800329
330 public FlingAlongVectorAnimatorUpdateListener(DragLayer dragLayer, PointF vel, Rect from,
Winson Chung6e1bdaf2012-05-29 17:03:45 -0700331 long startTime, float friction) {
Winson Chung043f2af2012-03-01 16:09:54 -0800332 mDragLayer = dragLayer;
333 mVelocity = vel;
334 mFrom = from;
335 mPrevTime = startTime;
Winson Chung6e1bdaf2012-05-29 17:03:45 -0700336 mFriction = 1f - (dragLayer.getResources().getDisplayMetrics().density * friction);
Winson Chung043f2af2012-03-01 16:09:54 -0800337 }
338
339 @Override
340 public void onAnimationUpdate(ValueAnimator animation) {
341 final DragView dragView = (DragView) mDragLayer.getAnimatedView();
342 float t = ((Float) animation.getAnimatedValue()).floatValue();
343 long curTime = AnimationUtils.currentAnimationTimeMillis();
344
345 if (!mHasOffsetForScale) {
346 mHasOffsetForScale = true;
347 float scale = dragView.getScaleX();
348 float xOffset = ((scale - 1f) * dragView.getMeasuredWidth()) / 2f;
349 float yOffset = ((scale - 1f) * dragView.getMeasuredHeight()) / 2f;
350
351 mFrom.left += xOffset;
352 mFrom.top += yOffset;
353 }
354
355 mFrom.left += (mVelocity.x * (curTime - mPrevTime) / 1000f);
356 mFrom.top += (mVelocity.y * (curTime - mPrevTime) / 1000f);
357
358 dragView.setTranslationX(mFrom.left);
359 dragView.setTranslationY(mFrom.top);
360 dragView.setAlpha(1f - mAlphaInterpolator.getInterpolation(t));
361
Winson Chung6e1bdaf2012-05-29 17:03:45 -0700362 mVelocity.x *= mFriction;
363 mVelocity.y *= mFriction;
Winson Chung043f2af2012-03-01 16:09:54 -0800364 mPrevTime = curTime;
365 }
366 };
367 private AnimatorUpdateListener createFlingAlongVectorAnimatorListener(final DragLayer dragLayer,
368 DragObject d, PointF vel, final long startTime, final int duration,
369 ViewConfiguration config) {
370 final Rect from = new Rect();
371 dragLayer.getViewRectRelativeToSelf(d.dragView, from);
372
Winson Chung6e1bdaf2012-05-29 17:03:45 -0700373 return new FlingAlongVectorAnimatorUpdateListener(dragLayer, vel, from, startTime,
374 FLING_TO_DELETE_FRICTION);
Winson Chung043f2af2012-03-01 16:09:54 -0800375 }
376
377 public void onFlingToDelete(final DragObject d, int x, int y, PointF vel) {
Winson Chunga48487a2012-03-20 16:19:37 -0700378 final boolean isAllApps = d.dragSource instanceof AppsCustomizePagedView;
379
Winson Chung043f2af2012-03-01 16:09:54 -0800380 // Don't highlight the icon as it's animating
381 d.dragView.setColor(0);
382 d.dragView.updateInitialScaleToCurrentScale();
Winson Chunga48487a2012-03-20 16:19:37 -0700383 // Don't highlight the target if we are flinging from AllApps
384 if (isAllApps) {
385 resetHoverColor();
386 }
Winson Chung043f2af2012-03-01 16:09:54 -0800387
388 if (mFlingDeleteMode == MODE_FLING_DELETE_TO_TRASH) {
389 // Defer animating out the drop target if we are animating to it
390 mSearchDropTargetBar.deferOnDragEnd();
391 mSearchDropTargetBar.finishAnimations();
392 }
393
394 final ViewConfiguration config = ViewConfiguration.get(mLauncher);
395 final DragLayer dragLayer = mLauncher.getDragLayer();
Winson Chung6e1bdaf2012-05-29 17:03:45 -0700396 final int duration = FLING_DELETE_ANIMATION_DURATION;
Winson Chung043f2af2012-03-01 16:09:54 -0800397 final long startTime = AnimationUtils.currentAnimationTimeMillis();
398
399 // NOTE: Because it takes time for the first frame of animation to actually be
400 // called and we expect the animation to be a continuation of the fling, we have
401 // to account for the time that has elapsed since the fling finished. And since
402 // we don't have a startDelay, we will always get call to update when we call
403 // start() (which we want to ignore).
404 final TimeInterpolator tInterpolator = new TimeInterpolator() {
405 private int mCount = -1;
406 private float mOffset = 0f;
407
408 @Override
409 public float getInterpolation(float t) {
410 if (mCount < 0) {
411 mCount++;
412 } else if (mCount == 0) {
413 mOffset = Math.min(0.5f, (float) (AnimationUtils.currentAnimationTimeMillis() -
414 startTime) / duration);
415 mCount++;
416 }
417 return Math.min(1f, mOffset + t);
418 }
419 };
420 AnimatorUpdateListener updateCb = null;
421 if (mFlingDeleteMode == MODE_FLING_DELETE_TO_TRASH) {
422 updateCb = createFlingToTrashAnimatorListener(dragLayer, d, vel, config);
423 } else if (mFlingDeleteMode == MODE_FLING_DELETE_ALONG_VECTOR) {
424 updateCb = createFlingAlongVectorAnimatorListener(dragLayer, d, vel, startTime,
425 duration, config);
426 }
427 Runnable onAnimationEndRunnable = new Runnable() {
428 @Override
429 public void run() {
430 mSearchDropTargetBar.onDragEnd();
Winson Chunga48487a2012-03-20 16:19:37 -0700431
432 // If we are dragging from AllApps, then we allow AppsCustomizePagedView to clean up
433 // itself, otherwise, complete the drop to initiate the deletion process
434 if (!isAllApps) {
435 mLauncher.exitSpringLoadedDragMode();
436 completeDrop(d);
437 }
438 mLauncher.getDragController().onDeferredEndFling(d);
Winson Chung043f2af2012-03-01 16:09:54 -0800439 }
440 };
441 dragLayer.animateView(d.dragView, updateCb, duration, tInterpolator, onAnimationEndRunnable,
442 DragLayer.ANIMATION_END_DISAPPEAR, null);
443 }
Winson Chung4c98d922011-05-31 16:50:48 -0700444}