blob: 4be9b811aa809ce9358738351fb55d7c677c9dcb [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
Winson Chung61fa4192011-06-12 15:15:29 -070037public class DeleteDropTarget extends ButtonDropTarget {
Winson Chung043f2af2012-03-01 16:09:54 -080038 private static int DELETE_ANIMATION_DURATION = 285;
Winson Chung6e1bdaf2012-05-29 17:03:45 -070039 private static int FLING_DELETE_ANIMATION_DURATION = 350;
40 private static float FLING_TO_DELETE_FRICTION = 0.035f;
Winson Chung043f2af2012-03-01 16:09:54 -080041 private static int MODE_FLING_DELETE_TO_TRASH = 0;
42 private static int MODE_FLING_DELETE_ALONG_VECTOR = 1;
Winson Chung4c98d922011-05-31 16:50:48 -070043
Winson Chung043f2af2012-03-01 16:09:54 -080044 private final int mFlingDeleteMode = MODE_FLING_DELETE_ALONG_VECTOR;
45
Winson Chunga62e9fd2011-07-11 15:20:48 -070046 private ColorStateList mOriginalTextColor;
Adam Cohenebea84d2011-11-09 17:20:41 -080047 private TransitionDrawable mUninstallDrawable;
48 private TransitionDrawable mRemoveDrawable;
49 private TransitionDrawable mCurrentDrawable;
Winson Chung4c98d922011-05-31 16:50:48 -070050
51 public DeleteDropTarget(Context context, AttributeSet attrs) {
52 this(context, attrs, 0);
53 }
54
55 public DeleteDropTarget(Context context, AttributeSet attrs, int defStyle) {
56 super(context, attrs, defStyle);
57 }
58
59 @Override
60 protected void onFinishInflate() {
61 super.onFinishInflate();
62
63 // Get the drawable
Winson Chunga6427b12011-07-27 10:53:39 -070064 mOriginalTextColor = getTextColors();
Winson Chung4c98d922011-05-31 16:50:48 -070065
66 // Get the hover color
67 Resources r = getResources();
Winson Chung4c98d922011-05-31 16:50:48 -070068 mHoverColor = r.getColor(R.color.delete_target_hover_tint);
Adam Cohenebea84d2011-11-09 17:20:41 -080069 mUninstallDrawable = (TransitionDrawable)
70 r.getDrawable(R.drawable.uninstall_target_selector);
71 mRemoveDrawable = (TransitionDrawable) r.getDrawable(R.drawable.remove_target_selector);
72
73 mRemoveDrawable.setCrossFadeEnabled(true);
74 mUninstallDrawable.setCrossFadeEnabled(true);
75
76 // The current drawable is set to either the remove drawable or the uninstall drawable
77 // and is initially set to the remove drawable, as set in the layout xml.
Winson Chung947245b2012-05-15 16:34:19 -070078 mCurrentDrawable = (TransitionDrawable) getCurrentDrawable();
Winson Chung201bc822011-06-20 15:41:53 -070079
80 // Remove the text in the Phone UI in landscape
81 int orientation = getResources().getConfiguration().orientation;
82 if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
Daniel Sandlere4f98912013-06-25 15:13:26 -040083 if (!LauncherAppState.getInstance().isScreenLarge()) {
Winson Chunga6427b12011-07-27 10:53:39 -070084 setText("");
Winson Chung201bc822011-06-20 15:41:53 -070085 }
86 }
Winson Chung4c98d922011-05-31 16:50:48 -070087 }
88
89 private boolean isAllAppsApplication(DragSource source, Object info) {
90 return (source instanceof AppsCustomizePagedView) && (info instanceof ApplicationInfo);
91 }
92 private boolean isAllAppsWidget(DragSource source, Object info) {
Winson Chung11a49372012-04-27 15:12:38 -070093 if (source instanceof AppsCustomizePagedView) {
94 if (info instanceof PendingAddItemInfo) {
95 PendingAddItemInfo addInfo = (PendingAddItemInfo) info;
96 switch (addInfo.itemType) {
97 case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
98 case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
99 return true;
100 }
101 }
102 }
103 return false;
Winson Chung4c98d922011-05-31 16:50:48 -0700104 }
Michael Jurka0b4870d2011-07-10 13:39:08 -0700105 private boolean isDragSourceWorkspaceOrFolder(DragObject d) {
106 return (d.dragSource instanceof Workspace) || (d.dragSource instanceof Folder);
Winson Chung4c98d922011-05-31 16:50:48 -0700107 }
Michael Jurka0b4870d2011-07-10 13:39:08 -0700108 private boolean isWorkspaceOrFolderApplication(DragObject d) {
109 return isDragSourceWorkspaceOrFolder(d) && (d.dragInfo instanceof ShortcutInfo);
110 }
111 private boolean isWorkspaceOrFolderWidget(DragObject d) {
112 return isDragSourceWorkspaceOrFolder(d) && (d.dragInfo instanceof LauncherAppWidgetInfo);
Winson Chung4c98d922011-05-31 16:50:48 -0700113 }
114 private boolean isWorkspaceFolder(DragObject d) {
115 return (d.dragSource instanceof Workspace) && (d.dragInfo instanceof FolderInfo);
116 }
117
Winson Chunga48487a2012-03-20 16:19:37 -0700118 private void setHoverColor() {
119 mCurrentDrawable.startTransition(mTransitionDuration);
120 setTextColor(mHoverColor);
121 }
122 private void resetHoverColor() {
123 mCurrentDrawable.resetTransition();
124 setTextColor(mOriginalTextColor);
125 }
126
Winson Chung4c98d922011-05-31 16:50:48 -0700127 @Override
128 public boolean acceptDrop(DragObject d) {
Adam Cohen7c4c5102013-06-14 17:42:35 -0700129 return willAcceptDrop(d.dragInfo);
130 }
131
132 public static boolean willAcceptDrop(Object info) {
133 if (info instanceof ItemInfo) {
134 ItemInfo item = (ItemInfo) info;
135 if (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET ||
136 item.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
137 return true;
138 }
Adam Cohen947dc542013-06-06 22:43:33 -0700139 }
Adam Cohen7c4c5102013-06-14 17:42:35 -0700140 return false;
Winson Chung4c98d922011-05-31 16:50:48 -0700141 }
142
143 @Override
144 public void onDragStart(DragSource source, Object info, int dragAction) {
Winson Chung4c98d922011-05-31 16:50:48 -0700145 boolean isVisible = true;
146 boolean isUninstall = false;
147
Winson Chungf0ea4d32011-06-06 14:27:16 -0700148 // If we are dragging a widget from AppsCustomize, hide the delete target
Winson Chung4c98d922011-05-31 16:50:48 -0700149 if (isAllAppsWidget(source, info)) {
150 isVisible = false;
151 }
152
153 // If we are dragging an application from AppsCustomize, only show the control if we can
154 // delete the app (it was downloaded), and rename the string to "uninstall" in such a case
Adam Cohen7c4c5102013-06-14 17:42:35 -0700155 if (willAcceptDrop(info)) {
Adam Cohen947dc542013-06-06 22:43:33 -0700156 isVisible = true;
157 } else {
158 isVisible = false;
Winson Chung4c98d922011-05-31 16:50:48 -0700159 }
160
Adam Cohenebea84d2011-11-09 17:20:41 -0800161 if (isUninstall) {
Fabrice Di Megliod6a33c62013-02-06 15:40:46 -0800162 setCompoundDrawablesRelativeWithIntrinsicBounds(mUninstallDrawable, null, null, null);
Adam Cohenebea84d2011-11-09 17:20:41 -0800163 } else {
Fabrice Di Megliod6a33c62013-02-06 15:40:46 -0800164 setCompoundDrawablesRelativeWithIntrinsicBounds(mRemoveDrawable, null, null, null);
Adam Cohenebea84d2011-11-09 17:20:41 -0800165 }
Winson Chung947245b2012-05-15 16:34:19 -0700166 mCurrentDrawable = (TransitionDrawable) getCurrentDrawable();
Adam Cohenebea84d2011-11-09 17:20:41 -0800167
Winson Chung4c98d922011-05-31 16:50:48 -0700168 mActive = isVisible;
Winson Chunga48487a2012-03-20 16:19:37 -0700169 resetHoverColor();
Winson Chunga6427b12011-07-27 10:53:39 -0700170 ((ViewGroup) getParent()).setVisibility(isVisible ? View.VISIBLE : View.GONE);
171 if (getText().length() > 0) {
172 setText(isUninstall ? R.string.delete_target_uninstall_label
Winson Chung4c98d922011-05-31 16:50:48 -0700173 : R.string.delete_target_label);
174 }
175 }
176
177 @Override
178 public void onDragEnd() {
179 super.onDragEnd();
180 mActive = false;
181 }
182
183 public void onDragEnter(DragObject d) {
184 super.onDragEnter(d);
185
Winson Chunga48487a2012-03-20 16:19:37 -0700186 setHoverColor();
Winson Chung4c98d922011-05-31 16:50:48 -0700187 }
188
189 public void onDragExit(DragObject d) {
190 super.onDragExit(d);
191
Winson Chungaaa530a2011-07-11 21:06:30 -0700192 if (!d.dragComplete) {
Winson Chunga48487a2012-03-20 16:19:37 -0700193 resetHoverColor();
Winson Chung61967cb2012-02-28 18:11:33 -0800194 } else {
195 // Restore the hover color if we are deleting
196 d.dragView.setColor(mHoverColor);
Winson Chungaaa530a2011-07-11 21:06:30 -0700197 }
Winson Chung4c98d922011-05-31 16:50:48 -0700198 }
199
Adam Cohened66b2b2012-01-23 17:28:51 -0800200 private void animateToTrashAndCompleteDrop(final DragObject d) {
201 DragLayer dragLayer = mLauncher.getDragLayer();
202 Rect from = new Rect();
203 dragLayer.getViewRectRelativeToSelf(d.dragView, from);
Winson Chung61967cb2012-02-28 18:11:33 -0800204 Rect to = getIconRect(d.dragView.getMeasuredWidth(), d.dragView.getMeasuredHeight(),
205 mCurrentDrawable.getIntrinsicWidth(), mCurrentDrawable.getIntrinsicHeight());
206 float scale = (float) to.width() / from.width();
Adam Cohened66b2b2012-01-23 17:28:51 -0800207
Adam Cohend4d7aa52011-07-19 21:47:37 -0700208 mSearchDropTargetBar.deferOnDragEnd();
209 Runnable onAnimationEndRunnable = new Runnable() {
210 @Override
211 public void run() {
212 mSearchDropTargetBar.onDragEnd();
213 mLauncher.exitSpringLoadedDragMode();
214 completeDrop(d);
215 }
216 };
Winson Chung61967cb2012-02-28 18:11:33 -0800217 dragLayer.animateView(d.dragView, from, to, scale, 1f, 1f, 0.1f, 0.1f,
Adam Cohend4d7aa52011-07-19 21:47:37 -0700218 DELETE_ANIMATION_DURATION, new DecelerateInterpolator(2),
Winson Chung61967cb2012-02-28 18:11:33 -0800219 new LinearInterpolator(), onAnimationEndRunnable,
Adam Cohened66b2b2012-01-23 17:28:51 -0800220 DragLayer.ANIMATION_END_DISAPPEAR, null);
Adam Cohend4d7aa52011-07-19 21:47:37 -0700221 }
222
223 private void completeDrop(DragObject d) {
Winson Chung4c98d922011-05-31 16:50:48 -0700224 ItemInfo item = (ItemInfo) d.dragInfo;
225
226 if (isAllAppsApplication(d.dragSource, item)) {
227 // Uninstall the application if it is being dragged from AppsCustomize
228 mLauncher.startApplicationUninstallActivity((ApplicationInfo) item);
Michael Jurka0b4870d2011-07-10 13:39:08 -0700229 } else if (isWorkspaceOrFolderApplication(d)) {
Winson Chung4c98d922011-05-31 16:50:48 -0700230 LauncherModel.deleteItemFromDatabase(mLauncher, item);
231 } else if (isWorkspaceFolder(d)) {
232 // Remove the folder from the workspace and delete the contents from launcher model
233 FolderInfo folderInfo = (FolderInfo) item;
234 mLauncher.removeFolder(folderInfo);
235 LauncherModel.deleteFolderContentsFromDatabase(mLauncher, folderInfo);
Michael Jurka0b4870d2011-07-10 13:39:08 -0700236 } else if (isWorkspaceOrFolderWidget(d)) {
Winson Chung4c98d922011-05-31 16:50:48 -0700237 // Remove the widget from the workspace
238 mLauncher.removeAppWidget((LauncherAppWidgetInfo) item);
239 LauncherModel.deleteItemFromDatabase(mLauncher, item);
240
241 final LauncherAppWidgetInfo launcherAppWidgetInfo = (LauncherAppWidgetInfo) item;
242 final LauncherAppWidgetHost appWidgetHost = mLauncher.getAppWidgetHost();
243 if (appWidgetHost != null) {
244 // Deleting an app widget ID is a void call but writes to disk before returning
245 // to the caller...
246 new Thread("deleteAppWidgetId") {
247 public void run() {
248 appWidgetHost.deleteAppWidgetId(launcherAppWidgetInfo.appWidgetId);
249 }
250 }.start();
251 }
252 }
253 }
Adam Cohend4d7aa52011-07-19 21:47:37 -0700254
255 public void onDrop(DragObject d) {
256 animateToTrashAndCompleteDrop(d);
257 }
Winson Chung043f2af2012-03-01 16:09:54 -0800258
259 /**
260 * Creates an animation from the current drag view to the delete trash icon.
261 */
262 private AnimatorUpdateListener createFlingToTrashAnimatorListener(final DragLayer dragLayer,
263 DragObject d, PointF vel, ViewConfiguration config) {
264 final Rect to = getIconRect(d.dragView.getMeasuredWidth(), d.dragView.getMeasuredHeight(),
265 mCurrentDrawable.getIntrinsicWidth(), mCurrentDrawable.getIntrinsicHeight());
266 final Rect from = new Rect();
267 dragLayer.getViewRectRelativeToSelf(d.dragView, from);
268
269 // Calculate how far along the velocity vector we should put the intermediate point on
270 // the bezier curve
271 float velocity = Math.abs(vel.length());
272 float vp = Math.min(1f, velocity / (config.getScaledMaximumFlingVelocity() / 2f));
273 int offsetY = (int) (-from.top * vp);
274 int offsetX = (int) (offsetY / (vel.y / vel.x));
275 final float y2 = from.top + offsetY; // intermediate t/l
276 final float x2 = from.left + offsetX;
277 final float x1 = from.left; // drag view t/l
278 final float y1 = from.top;
279 final float x3 = to.left; // delete target t/l
280 final float y3 = to.top;
281
282 final TimeInterpolator scaleAlphaInterpolator = new TimeInterpolator() {
283 @Override
284 public float getInterpolation(float t) {
285 return t * t * t * t * t * t * t * t;
286 }
287 };
288 return new AnimatorUpdateListener() {
289 @Override
290 public void onAnimationUpdate(ValueAnimator animation) {
291 final DragView dragView = (DragView) dragLayer.getAnimatedView();
292 float t = ((Float) animation.getAnimatedValue()).floatValue();
293 float tp = scaleAlphaInterpolator.getInterpolation(t);
294 float initialScale = dragView.getInitialScale();
295 float finalAlpha = 0.5f;
296 float scale = dragView.getScaleX();
297 float x1o = ((1f - scale) * dragView.getMeasuredWidth()) / 2f;
298 float y1o = ((1f - scale) * dragView.getMeasuredHeight()) / 2f;
299 float x = (1f - t) * (1f - t) * (x1 - x1o) + 2 * (1f - t) * t * (x2 - x1o) +
300 (t * t) * x3;
301 float y = (1f - t) * (1f - t) * (y1 - y1o) + 2 * (1f - t) * t * (y2 - x1o) +
302 (t * t) * y3;
303
304 dragView.setTranslationX(x);
305 dragView.setTranslationY(y);
306 dragView.setScaleX(initialScale * (1f - tp));
307 dragView.setScaleY(initialScale * (1f - tp));
308 dragView.setAlpha(finalAlpha + (1f - finalAlpha) * (1f - tp));
309 }
310 };
311 }
312
313 /**
314 * Creates an animation from the current drag view along its current velocity vector.
315 * For this animation, the alpha runs for a fixed duration and we update the position
316 * progressively.
317 */
318 private static class FlingAlongVectorAnimatorUpdateListener implements AnimatorUpdateListener {
Winson Chung043f2af2012-03-01 16:09:54 -0800319 private DragLayer mDragLayer;
320 private PointF mVelocity;
321 private Rect mFrom;
322 private long mPrevTime;
323 private boolean mHasOffsetForScale;
Winson Chung6e1bdaf2012-05-29 17:03:45 -0700324 private float mFriction;
Winson Chung043f2af2012-03-01 16:09:54 -0800325
Winson Chung9658b1e2012-04-09 18:30:07 -0700326 private final TimeInterpolator mAlphaInterpolator = new DecelerateInterpolator(0.75f);
Winson Chung043f2af2012-03-01 16:09:54 -0800327
328 public FlingAlongVectorAnimatorUpdateListener(DragLayer dragLayer, PointF vel, Rect from,
Winson Chung6e1bdaf2012-05-29 17:03:45 -0700329 long startTime, float friction) {
Winson Chung043f2af2012-03-01 16:09:54 -0800330 mDragLayer = dragLayer;
331 mVelocity = vel;
332 mFrom = from;
333 mPrevTime = startTime;
Winson Chung6e1bdaf2012-05-29 17:03:45 -0700334 mFriction = 1f - (dragLayer.getResources().getDisplayMetrics().density * friction);
Winson Chung043f2af2012-03-01 16:09:54 -0800335 }
336
337 @Override
338 public void onAnimationUpdate(ValueAnimator animation) {
339 final DragView dragView = (DragView) mDragLayer.getAnimatedView();
340 float t = ((Float) animation.getAnimatedValue()).floatValue();
341 long curTime = AnimationUtils.currentAnimationTimeMillis();
342
343 if (!mHasOffsetForScale) {
344 mHasOffsetForScale = true;
345 float scale = dragView.getScaleX();
346 float xOffset = ((scale - 1f) * dragView.getMeasuredWidth()) / 2f;
347 float yOffset = ((scale - 1f) * dragView.getMeasuredHeight()) / 2f;
348
349 mFrom.left += xOffset;
350 mFrom.top += yOffset;
351 }
352
353 mFrom.left += (mVelocity.x * (curTime - mPrevTime) / 1000f);
354 mFrom.top += (mVelocity.y * (curTime - mPrevTime) / 1000f);
355
356 dragView.setTranslationX(mFrom.left);
357 dragView.setTranslationY(mFrom.top);
358 dragView.setAlpha(1f - mAlphaInterpolator.getInterpolation(t));
359
Winson Chung6e1bdaf2012-05-29 17:03:45 -0700360 mVelocity.x *= mFriction;
361 mVelocity.y *= mFriction;
Winson Chung043f2af2012-03-01 16:09:54 -0800362 mPrevTime = curTime;
363 }
364 };
365 private AnimatorUpdateListener createFlingAlongVectorAnimatorListener(final DragLayer dragLayer,
366 DragObject d, PointF vel, final long startTime, final int duration,
367 ViewConfiguration config) {
368 final Rect from = new Rect();
369 dragLayer.getViewRectRelativeToSelf(d.dragView, from);
370
Winson Chung6e1bdaf2012-05-29 17:03:45 -0700371 return new FlingAlongVectorAnimatorUpdateListener(dragLayer, vel, from, startTime,
372 FLING_TO_DELETE_FRICTION);
Winson Chung043f2af2012-03-01 16:09:54 -0800373 }
374
375 public void onFlingToDelete(final DragObject d, int x, int y, PointF vel) {
Winson Chunga48487a2012-03-20 16:19:37 -0700376 final boolean isAllApps = d.dragSource instanceof AppsCustomizePagedView;
377
Winson Chung043f2af2012-03-01 16:09:54 -0800378 // Don't highlight the icon as it's animating
379 d.dragView.setColor(0);
380 d.dragView.updateInitialScaleToCurrentScale();
Winson Chunga48487a2012-03-20 16:19:37 -0700381 // Don't highlight the target if we are flinging from AllApps
382 if (isAllApps) {
383 resetHoverColor();
384 }
Winson Chung043f2af2012-03-01 16:09:54 -0800385
386 if (mFlingDeleteMode == MODE_FLING_DELETE_TO_TRASH) {
387 // Defer animating out the drop target if we are animating to it
388 mSearchDropTargetBar.deferOnDragEnd();
389 mSearchDropTargetBar.finishAnimations();
390 }
391
392 final ViewConfiguration config = ViewConfiguration.get(mLauncher);
393 final DragLayer dragLayer = mLauncher.getDragLayer();
Winson Chung6e1bdaf2012-05-29 17:03:45 -0700394 final int duration = FLING_DELETE_ANIMATION_DURATION;
Winson Chung043f2af2012-03-01 16:09:54 -0800395 final long startTime = AnimationUtils.currentAnimationTimeMillis();
396
397 // NOTE: Because it takes time for the first frame of animation to actually be
398 // called and we expect the animation to be a continuation of the fling, we have
399 // to account for the time that has elapsed since the fling finished. And since
400 // we don't have a startDelay, we will always get call to update when we call
401 // start() (which we want to ignore).
402 final TimeInterpolator tInterpolator = new TimeInterpolator() {
403 private int mCount = -1;
404 private float mOffset = 0f;
405
406 @Override
407 public float getInterpolation(float t) {
408 if (mCount < 0) {
409 mCount++;
410 } else if (mCount == 0) {
411 mOffset = Math.min(0.5f, (float) (AnimationUtils.currentAnimationTimeMillis() -
412 startTime) / duration);
413 mCount++;
414 }
415 return Math.min(1f, mOffset + t);
416 }
417 };
418 AnimatorUpdateListener updateCb = null;
419 if (mFlingDeleteMode == MODE_FLING_DELETE_TO_TRASH) {
420 updateCb = createFlingToTrashAnimatorListener(dragLayer, d, vel, config);
421 } else if (mFlingDeleteMode == MODE_FLING_DELETE_ALONG_VECTOR) {
422 updateCb = createFlingAlongVectorAnimatorListener(dragLayer, d, vel, startTime,
423 duration, config);
424 }
425 Runnable onAnimationEndRunnable = new Runnable() {
426 @Override
427 public void run() {
428 mSearchDropTargetBar.onDragEnd();
Winson Chunga48487a2012-03-20 16:19:37 -0700429
430 // If we are dragging from AllApps, then we allow AppsCustomizePagedView to clean up
431 // itself, otherwise, complete the drop to initiate the deletion process
432 if (!isAllApps) {
433 mLauncher.exitSpringLoadedDragMode();
434 completeDrop(d);
435 }
436 mLauncher.getDragController().onDeferredEndFling(d);
Winson Chung043f2af2012-03-01 16:09:54 -0800437 }
438 };
439 dragLayer.animateView(d.dragView, updateCb, duration, tInterpolator, onAnimationEndRunnable,
440 DragLayer.ANIMATION_END_DISAPPEAR, null);
441 }
Winson Chung4c98d922011-05-31 16:50:48 -0700442}