Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 1 | /* |
| 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 Sandler | 325dc23 | 2013-06-05 22:57:57 -0400 | [diff] [blame] | 17 | package com.android.launcher3; |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 18 | |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 19 | import android.animation.TimeInterpolator; |
| 20 | import android.animation.ValueAnimator; |
| 21 | import android.animation.ValueAnimator.AnimatorUpdateListener; |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 22 | import android.content.ComponentName; |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 23 | import android.content.Context; |
Michael Jurka | 5e7af5d | 2013-09-14 18:35:38 +0200 | [diff] [blame] | 24 | import android.content.Intent; |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 25 | import android.content.pm.ResolveInfo; |
Winson Chung | a62e9fd | 2011-07-11 15:20:48 -0700 | [diff] [blame] | 26 | import android.content.res.ColorStateList; |
Winson Chung | 201bc82 | 2011-06-20 15:41:53 -0700 | [diff] [blame] | 27 | import android.content.res.Configuration; |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 28 | import android.content.res.Resources; |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 29 | import android.graphics.PointF; |
Adam Cohen | d4d7aa5 | 2011-07-19 21:47:37 -0700 | [diff] [blame] | 30 | import android.graphics.Rect; |
Winson Chung | 967289b | 2011-06-30 18:09:30 -0700 | [diff] [blame] | 31 | import android.graphics.drawable.TransitionDrawable; |
Michael Jurka | 4346746 | 2013-11-14 12:03:58 +0100 | [diff] [blame] | 32 | import android.os.AsyncTask; |
Jason Monk | 6a2c778 | 2014-09-02 13:13:24 -0400 | [diff] [blame] | 33 | import android.os.Build; |
| 34 | import android.os.Bundle; |
Jason Monk | 950a467 | 2014-07-15 09:22:36 -0400 | [diff] [blame] | 35 | import android.os.UserManager; |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 36 | import android.util.AttributeSet; |
| 37 | import android.view.View; |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 38 | import android.view.ViewConfiguration; |
Winson Chung | a6427b1 | 2011-07-27 10:53:39 -0700 | [diff] [blame] | 39 | import android.view.ViewGroup; |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 40 | import android.view.animation.AnimationUtils; |
Adam Cohen | d4d7aa5 | 2011-07-19 21:47:37 -0700 | [diff] [blame] | 41 | import android.view.animation.DecelerateInterpolator; |
Winson Chung | 61967cb | 2012-02-28 18:11:33 -0800 | [diff] [blame] | 42 | import android.view.animation.LinearInterpolator; |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 43 | |
Kenny Guy | ed13187 | 2014-04-30 03:02:21 +0100 | [diff] [blame] | 44 | import com.android.launcher3.compat.LauncherAppsCompat; |
| 45 | import com.android.launcher3.compat.UserHandleCompat; |
| 46 | |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 47 | import java.util.List; |
Michael Jurka | 5e7af5d | 2013-09-14 18:35:38 +0200 | [diff] [blame] | 48 | import java.util.Set; |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 49 | |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 50 | public class DeleteDropTarget extends ButtonDropTarget { |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 51 | private static int DELETE_ANIMATION_DURATION = 285; |
Winson Chung | 6e1bdaf | 2012-05-29 17:03:45 -0700 | [diff] [blame] | 52 | private static int FLING_DELETE_ANIMATION_DURATION = 350; |
| 53 | private static float FLING_TO_DELETE_FRICTION = 0.035f; |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 54 | private static int MODE_FLING_DELETE_TO_TRASH = 0; |
| 55 | private static int MODE_FLING_DELETE_ALONG_VECTOR = 1; |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 56 | |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 57 | private final int mFlingDeleteMode = MODE_FLING_DELETE_ALONG_VECTOR; |
| 58 | |
Winson Chung | a62e9fd | 2011-07-11 15:20:48 -0700 | [diff] [blame] | 59 | private ColorStateList mOriginalTextColor; |
Adam Cohen | ebea84d | 2011-11-09 17:20:41 -0800 | [diff] [blame] | 60 | private TransitionDrawable mUninstallDrawable; |
| 61 | private TransitionDrawable mRemoveDrawable; |
| 62 | private TransitionDrawable mCurrentDrawable; |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 63 | |
Michael Jurka | 24715c7 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 64 | private boolean mWaitingForUninstall = false; |
| 65 | |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 66 | public DeleteDropTarget(Context context, AttributeSet attrs) { |
| 67 | this(context, attrs, 0); |
| 68 | } |
| 69 | |
| 70 | public DeleteDropTarget(Context context, AttributeSet attrs, int defStyle) { |
| 71 | super(context, attrs, defStyle); |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | protected void onFinishInflate() { |
| 76 | super.onFinishInflate(); |
| 77 | |
| 78 | // Get the drawable |
Winson Chung | a6427b1 | 2011-07-27 10:53:39 -0700 | [diff] [blame] | 79 | mOriginalTextColor = getTextColors(); |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 80 | |
| 81 | // Get the hover color |
| 82 | Resources r = getResources(); |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 83 | mHoverColor = r.getColor(R.color.delete_target_hover_tint); |
Adam Cohen | ebea84d | 2011-11-09 17:20:41 -0800 | [diff] [blame] | 84 | mUninstallDrawable = (TransitionDrawable) |
| 85 | r.getDrawable(R.drawable.uninstall_target_selector); |
| 86 | mRemoveDrawable = (TransitionDrawable) r.getDrawable(R.drawable.remove_target_selector); |
| 87 | |
| 88 | mRemoveDrawable.setCrossFadeEnabled(true); |
| 89 | mUninstallDrawable.setCrossFadeEnabled(true); |
| 90 | |
| 91 | // The current drawable is set to either the remove drawable or the uninstall drawable |
| 92 | // and is initially set to the remove drawable, as set in the layout xml. |
Winson Chung | 947245b | 2012-05-15 16:34:19 -0700 | [diff] [blame] | 93 | mCurrentDrawable = (TransitionDrawable) getCurrentDrawable(); |
Winson Chung | 201bc82 | 2011-06-20 15:41:53 -0700 | [diff] [blame] | 94 | |
| 95 | // Remove the text in the Phone UI in landscape |
| 96 | int orientation = getResources().getConfiguration().orientation; |
| 97 | if (orientation == Configuration.ORIENTATION_LANDSCAPE) { |
Daniel Sandler | e4f9891 | 2013-06-25 15:13:26 -0400 | [diff] [blame] | 98 | if (!LauncherAppState.getInstance().isScreenLarge()) { |
Winson Chung | a6427b1 | 2011-07-27 10:53:39 -0700 | [diff] [blame] | 99 | setText(""); |
Winson Chung | 201bc82 | 2011-06-20 15:41:53 -0700 | [diff] [blame] | 100 | } |
| 101 | } |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | private boolean isAllAppsApplication(DragSource source, Object info) { |
Mathew Inwood | 1eeb3fc | 2013-11-25 17:01:34 +0000 | [diff] [blame] | 105 | return source.supportsAppInfoDropTarget() && (info instanceof AppInfo); |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 106 | } |
| 107 | private boolean isAllAppsWidget(DragSource source, Object info) { |
Winson Chung | 11a4937 | 2012-04-27 15:12:38 -0700 | [diff] [blame] | 108 | if (source instanceof AppsCustomizePagedView) { |
| 109 | if (info instanceof PendingAddItemInfo) { |
| 110 | PendingAddItemInfo addInfo = (PendingAddItemInfo) info; |
| 111 | switch (addInfo.itemType) { |
| 112 | case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT: |
| 113 | case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET: |
| 114 | return true; |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | return false; |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 119 | } |
Michael Jurka | 0b4870d | 2011-07-10 13:39:08 -0700 | [diff] [blame] | 120 | private boolean isDragSourceWorkspaceOrFolder(DragObject d) { |
| 121 | return (d.dragSource instanceof Workspace) || (d.dragSource instanceof Folder); |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 122 | } |
Michael Jurka | 0b4870d | 2011-07-10 13:39:08 -0700 | [diff] [blame] | 123 | private boolean isWorkspaceOrFolderApplication(DragObject d) { |
| 124 | return isDragSourceWorkspaceOrFolder(d) && (d.dragInfo instanceof ShortcutInfo); |
| 125 | } |
| 126 | private boolean isWorkspaceOrFolderWidget(DragObject d) { |
| 127 | return isDragSourceWorkspaceOrFolder(d) && (d.dragInfo instanceof LauncherAppWidgetInfo); |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 128 | } |
| 129 | private boolean isWorkspaceFolder(DragObject d) { |
| 130 | return (d.dragSource instanceof Workspace) && (d.dragInfo instanceof FolderInfo); |
| 131 | } |
| 132 | |
Winson Chung | a48487a | 2012-03-20 16:19:37 -0700 | [diff] [blame] | 133 | private void setHoverColor() { |
Adam Cohen | fe9da81 | 2014-08-04 17:08:01 -0700 | [diff] [blame] | 134 | if (mCurrentDrawable != null) { |
| 135 | mCurrentDrawable.startTransition(mTransitionDuration); |
| 136 | } |
Winson Chung | a48487a | 2012-03-20 16:19:37 -0700 | [diff] [blame] | 137 | setTextColor(mHoverColor); |
| 138 | } |
| 139 | private void resetHoverColor() { |
Adam Cohen | fe9da81 | 2014-08-04 17:08:01 -0700 | [diff] [blame] | 140 | if (mCurrentDrawable != null) { |
| 141 | mCurrentDrawable.resetTransition(); |
| 142 | } |
Winson Chung | a48487a | 2012-03-20 16:19:37 -0700 | [diff] [blame] | 143 | setTextColor(mOriginalTextColor); |
| 144 | } |
| 145 | |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 146 | @Override |
| 147 | public boolean acceptDrop(DragObject d) { |
Adam Cohen | 7c4c510 | 2013-06-14 17:42:35 -0700 | [diff] [blame] | 148 | return willAcceptDrop(d.dragInfo); |
| 149 | } |
| 150 | |
| 151 | public static boolean willAcceptDrop(Object info) { |
| 152 | if (info instanceof ItemInfo) { |
| 153 | ItemInfo item = (ItemInfo) info; |
| 154 | if (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET || |
| 155 | item.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) { |
| 156 | return true; |
| 157 | } |
Michael Jurka | ed3d4df | 2013-09-12 18:09:24 +0200 | [diff] [blame] | 158 | |
Nilesh Agrawal | 16f3ea8 | 2014-01-09 17:14:01 -0800 | [diff] [blame] | 159 | if (!LauncherAppState.isDisableAllApps() && |
Michael Jurka | 5e7af5d | 2013-09-14 18:35:38 +0200 | [diff] [blame] | 160 | item.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) { |
Michael Jurka | ed3d4df | 2013-09-12 18:09:24 +0200 | [diff] [blame] | 161 | return true; |
| 162 | } |
| 163 | |
Nilesh Agrawal | 16f3ea8 | 2014-01-09 17:14:01 -0800 | [diff] [blame] | 164 | if (!LauncherAppState.isDisableAllApps() && |
Michael Jurka | 5e7af5d | 2013-09-14 18:35:38 +0200 | [diff] [blame] | 165 | item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION && |
| 166 | item instanceof AppInfo) { |
| 167 | AppInfo appInfo = (AppInfo) info; |
| 168 | return (appInfo.flags & AppInfo.DOWNLOADED_FLAG) != 0; |
| 169 | } |
| 170 | |
Michael Jurka | 9bd4d28 | 2013-09-05 19:21:31 +0200 | [diff] [blame] | 171 | if (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION && |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 172 | item instanceof ShortcutInfo) { |
Nilesh Agrawal | 16f3ea8 | 2014-01-09 17:14:01 -0800 | [diff] [blame] | 173 | if (LauncherAppState.isDisableAllApps()) { |
Michael Jurka | 9bd4d28 | 2013-09-05 19:21:31 +0200 | [diff] [blame] | 174 | ShortcutInfo shortcutInfo = (ShortcutInfo) info; |
| 175 | return (shortcutInfo.flags & AppInfo.DOWNLOADED_FLAG) != 0; |
| 176 | } else { |
| 177 | return true; |
| 178 | } |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 179 | } |
Adam Cohen | 947dc54 | 2013-06-06 22:43:33 -0700 | [diff] [blame] | 180 | } |
Adam Cohen | 7c4c510 | 2013-06-14 17:42:35 -0700 | [diff] [blame] | 181 | return false; |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | @Override |
| 185 | public void onDragStart(DragSource source, Object info, int dragAction) { |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 186 | boolean isVisible = true; |
Nilesh Agrawal | 16f3ea8 | 2014-01-09 17:14:01 -0800 | [diff] [blame] | 187 | boolean useUninstallLabel = !LauncherAppState.isDisableAllApps() && |
Michael Jurka | addcba6 | 2013-10-09 19:04:13 -0700 | [diff] [blame] | 188 | isAllAppsApplication(source, info); |
Mathew Inwood | 1eeb3fc | 2013-11-25 17:01:34 +0000 | [diff] [blame] | 189 | boolean useDeleteLabel = !useUninstallLabel && source.supportsDeleteDropTarget(); |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 190 | |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 191 | // If we are dragging an application from AppsCustomize, only show the control if we can |
Winson Chung | e01af63 | 2013-09-26 10:43:20 -0700 | [diff] [blame] | 192 | // delete the app (it was downloaded), and rename the string to "uninstall" in such a case. |
| 193 | // Hide the delete target if it is a widget from AppsCustomize. |
| 194 | if (!willAcceptDrop(info) || isAllAppsWidget(source, info)) { |
Adam Cohen | 947dc54 | 2013-06-06 22:43:33 -0700 | [diff] [blame] | 195 | isVisible = false; |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 196 | } |
Jason Monk | 950a467 | 2014-07-15 09:22:36 -0400 | [diff] [blame] | 197 | if (useUninstallLabel) { |
Jason Monk | 6a2c778 | 2014-09-02 13:13:24 -0400 | [diff] [blame] | 198 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { |
| 199 | UserManager userManager = (UserManager) |
| 200 | getContext().getSystemService(Context.USER_SERVICE); |
| 201 | Bundle restrictions = userManager.getUserRestrictions(); |
| 202 | if (restrictions.getBoolean(UserManager.DISALLOW_APPS_CONTROL, false) |
| 203 | || restrictions.getBoolean(UserManager.DISALLOW_UNINSTALL_APPS, false)) { |
| 204 | isVisible = false; |
| 205 | } |
Jason Monk | 950a467 | 2014-07-15 09:22:36 -0400 | [diff] [blame] | 206 | } |
| 207 | } |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 208 | |
Michael Jurka | addcba6 | 2013-10-09 19:04:13 -0700 | [diff] [blame] | 209 | if (useUninstallLabel) { |
Fabrice Di Meglio | d6a33c6 | 2013-02-06 15:40:46 -0800 | [diff] [blame] | 210 | setCompoundDrawablesRelativeWithIntrinsicBounds(mUninstallDrawable, null, null, null); |
Mathew Inwood | 1eeb3fc | 2013-11-25 17:01:34 +0000 | [diff] [blame] | 211 | } else if (useDeleteLabel) { |
Fabrice Di Meglio | d6a33c6 | 2013-02-06 15:40:46 -0800 | [diff] [blame] | 212 | setCompoundDrawablesRelativeWithIntrinsicBounds(mRemoveDrawable, null, null, null); |
Mathew Inwood | 1eeb3fc | 2013-11-25 17:01:34 +0000 | [diff] [blame] | 213 | } else { |
| 214 | isVisible = false; |
Adam Cohen | ebea84d | 2011-11-09 17:20:41 -0800 | [diff] [blame] | 215 | } |
Winson Chung | 947245b | 2012-05-15 16:34:19 -0700 | [diff] [blame] | 216 | mCurrentDrawable = (TransitionDrawable) getCurrentDrawable(); |
Adam Cohen | ebea84d | 2011-11-09 17:20:41 -0800 | [diff] [blame] | 217 | |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 218 | mActive = isVisible; |
Winson Chung | a48487a | 2012-03-20 16:19:37 -0700 | [diff] [blame] | 219 | resetHoverColor(); |
Winson Chung | a6427b1 | 2011-07-27 10:53:39 -0700 | [diff] [blame] | 220 | ((ViewGroup) getParent()).setVisibility(isVisible ? View.VISIBLE : View.GONE); |
Mathew Inwood | 1eeb3fc | 2013-11-25 17:01:34 +0000 | [diff] [blame] | 221 | if (isVisible && getText().length() > 0) { |
Michael Jurka | addcba6 | 2013-10-09 19:04:13 -0700 | [diff] [blame] | 222 | setText(useUninstallLabel ? R.string.delete_target_uninstall_label |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 223 | : R.string.delete_target_label); |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | @Override |
| 228 | public void onDragEnd() { |
| 229 | super.onDragEnd(); |
| 230 | mActive = false; |
| 231 | } |
| 232 | |
| 233 | public void onDragEnter(DragObject d) { |
| 234 | super.onDragEnter(d); |
| 235 | |
Winson Chung | a48487a | 2012-03-20 16:19:37 -0700 | [diff] [blame] | 236 | setHoverColor(); |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | public void onDragExit(DragObject d) { |
| 240 | super.onDragExit(d); |
| 241 | |
Winson Chung | aaa530a | 2011-07-11 21:06:30 -0700 | [diff] [blame] | 242 | if (!d.dragComplete) { |
Winson Chung | a48487a | 2012-03-20 16:19:37 -0700 | [diff] [blame] | 243 | resetHoverColor(); |
Winson Chung | 61967cb | 2012-02-28 18:11:33 -0800 | [diff] [blame] | 244 | } else { |
| 245 | // Restore the hover color if we are deleting |
| 246 | d.dragView.setColor(mHoverColor); |
Winson Chung | aaa530a | 2011-07-11 21:06:30 -0700 | [diff] [blame] | 247 | } |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 248 | } |
| 249 | |
Adam Cohen | ed66b2b | 2012-01-23 17:28:51 -0800 | [diff] [blame] | 250 | private void animateToTrashAndCompleteDrop(final DragObject d) { |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 251 | final DragLayer dragLayer = mLauncher.getDragLayer(); |
| 252 | final Rect from = new Rect(); |
Adam Cohen | ed66b2b | 2012-01-23 17:28:51 -0800 | [diff] [blame] | 253 | dragLayer.getViewRectRelativeToSelf(d.dragView, from); |
Adam Cohen | fe9da81 | 2014-08-04 17:08:01 -0700 | [diff] [blame] | 254 | |
| 255 | int width = mCurrentDrawable == null ? 0 : mCurrentDrawable.getIntrinsicWidth(); |
| 256 | int height = mCurrentDrawable == null ? 0 : mCurrentDrawable.getIntrinsicHeight(); |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 257 | final Rect to = getIconRect(d.dragView.getMeasuredWidth(), d.dragView.getMeasuredHeight(), |
Adam Cohen | fe9da81 | 2014-08-04 17:08:01 -0700 | [diff] [blame] | 258 | width, height); |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 259 | final float scale = (float) to.width() / from.width(); |
Adam Cohen | ed66b2b | 2012-01-23 17:28:51 -0800 | [diff] [blame] | 260 | |
Adam Cohen | d4d7aa5 | 2011-07-19 21:47:37 -0700 | [diff] [blame] | 261 | mSearchDropTargetBar.deferOnDragEnd(); |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 262 | deferCompleteDropIfUninstalling(d); |
| 263 | |
Adam Cohen | d4d7aa5 | 2011-07-19 21:47:37 -0700 | [diff] [blame] | 264 | Runnable onAnimationEndRunnable = new Runnable() { |
| 265 | @Override |
| 266 | public void run() { |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 267 | completeDrop(d); |
Adam Cohen | d4d7aa5 | 2011-07-19 21:47:37 -0700 | [diff] [blame] | 268 | mSearchDropTargetBar.onDragEnd(); |
| 269 | mLauncher.exitSpringLoadedDragMode(); |
Adam Cohen | d4d7aa5 | 2011-07-19 21:47:37 -0700 | [diff] [blame] | 270 | } |
| 271 | }; |
Winson Chung | 61967cb | 2012-02-28 18:11:33 -0800 | [diff] [blame] | 272 | dragLayer.animateView(d.dragView, from, to, scale, 1f, 1f, 0.1f, 0.1f, |
Adam Cohen | d4d7aa5 | 2011-07-19 21:47:37 -0700 | [diff] [blame] | 273 | DELETE_ANIMATION_DURATION, new DecelerateInterpolator(2), |
Winson Chung | 61967cb | 2012-02-28 18:11:33 -0800 | [diff] [blame] | 274 | new LinearInterpolator(), onAnimationEndRunnable, |
Adam Cohen | ed66b2b | 2012-01-23 17:28:51 -0800 | [diff] [blame] | 275 | DragLayer.ANIMATION_END_DISAPPEAR, null); |
Adam Cohen | d4d7aa5 | 2011-07-19 21:47:37 -0700 | [diff] [blame] | 276 | } |
| 277 | |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 278 | private void deferCompleteDropIfUninstalling(DragObject d) { |
| 279 | mWaitingForUninstall = false; |
Michael Jurka | 5e7af5d | 2013-09-14 18:35:38 +0200 | [diff] [blame] | 280 | if (isUninstallFromWorkspace(d)) { |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 281 | if (d.dragSource instanceof Folder) { |
| 282 | ((Folder) d.dragSource).deferCompleteDropAfterUninstallActivity(); |
| 283 | } else if (d.dragSource instanceof Workspace) { |
| 284 | ((Workspace) d.dragSource).deferCompleteDropAfterUninstallActivity(); |
| 285 | } |
| 286 | mWaitingForUninstall = true; |
| 287 | } |
| 288 | } |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 289 | |
Michael Jurka | 5e7af5d | 2013-09-14 18:35:38 +0200 | [diff] [blame] | 290 | private boolean isUninstallFromWorkspace(DragObject d) { |
Nilesh Agrawal | 16f3ea8 | 2014-01-09 17:14:01 -0800 | [diff] [blame] | 291 | if (LauncherAppState.isDisableAllApps() && isWorkspaceOrFolderApplication(d)) { |
Michael Jurka | 5e7af5d | 2013-09-14 18:35:38 +0200 | [diff] [blame] | 292 | ShortcutInfo shortcut = (ShortcutInfo) d.dragInfo; |
Nilesh Agrawal | dff0bfe | 2013-12-17 15:20:50 -0800 | [diff] [blame] | 293 | // Only allow manifest shortcuts to initiate an un-install. |
| 294 | return !InstallShortcutReceiver.isValidShortcutLaunchIntent(shortcut.intent); |
Michael Jurka | 5e7af5d | 2013-09-14 18:35:38 +0200 | [diff] [blame] | 295 | } |
| 296 | return false; |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 297 | } |
| 298 | |
Michael Jurka | f300758 | 2013-08-21 14:33:57 +0200 | [diff] [blame] | 299 | private void completeDrop(DragObject d) { |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 300 | ItemInfo item = (ItemInfo) d.dragInfo; |
| 301 | boolean wasWaitingForUninstall = mWaitingForUninstall; |
| 302 | mWaitingForUninstall = false; |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 303 | if (isAllAppsApplication(d.dragSource, item)) { |
| 304 | // Uninstall the application if it is being dragged from AppsCustomize |
Michael Jurka | eadbfc5 | 2013-09-04 00:45:37 +0200 | [diff] [blame] | 305 | AppInfo appInfo = (AppInfo) item; |
Kenny Guy | d31df54 | 2014-06-30 15:12:11 +0100 | [diff] [blame] | 306 | mLauncher.startApplicationUninstallActivity(appInfo.componentName, appInfo.flags, |
| 307 | appInfo.user); |
Michael Jurka | 5e7af5d | 2013-09-14 18:35:38 +0200 | [diff] [blame] | 308 | } else if (isUninstallFromWorkspace(d)) { |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 309 | ShortcutInfo shortcut = (ShortcutInfo) item; |
Kenny Guy | d31df54 | 2014-06-30 15:12:11 +0100 | [diff] [blame] | 310 | if (shortcut.intent != null && shortcut.intent.getComponent() != null) { |
Michael Jurka | f300758 | 2013-08-21 14:33:57 +0200 | [diff] [blame] | 311 | final ComponentName componentName = shortcut.intent.getComponent(); |
| 312 | final DragSource dragSource = d.dragSource; |
Kenny Guy | d31df54 | 2014-06-30 15:12:11 +0100 | [diff] [blame] | 313 | final UserHandleCompat user = shortcut.user; |
| 314 | mWaitingForUninstall = mLauncher.startApplicationUninstallActivity( |
| 315 | componentName, shortcut.flags, user); |
Michael Jurka | f300758 | 2013-08-21 14:33:57 +0200 | [diff] [blame] | 316 | if (mWaitingForUninstall) { |
| 317 | final Runnable checkIfUninstallWasSuccess = new Runnable() { |
| 318 | @Override |
| 319 | public void run() { |
| 320 | mWaitingForUninstall = false; |
| 321 | String packageName = componentName.getPackageName(); |
Kenny Guy | ed13187 | 2014-04-30 03:02:21 +0100 | [diff] [blame] | 322 | boolean uninstallSuccessful = !AllAppsList.packageHasActivities( |
Kenny Guy | d31df54 | 2014-06-30 15:12:11 +0100 | [diff] [blame] | 323 | getContext(), packageName, user); |
Michael Jurka | f300758 | 2013-08-21 14:33:57 +0200 | [diff] [blame] | 324 | if (dragSource instanceof Folder) { |
| 325 | ((Folder) dragSource). |
| 326 | onUninstallActivityReturned(uninstallSuccessful); |
| 327 | } else if (dragSource instanceof Workspace) { |
| 328 | ((Workspace) dragSource). |
| 329 | onUninstallActivityReturned(uninstallSuccessful); |
| 330 | } |
| 331 | } |
| 332 | }; |
| 333 | mLauncher.addOnResumeCallback(checkIfUninstallWasSuccess); |
| 334 | } |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 335 | } |
Michael Jurka | 0b4870d | 2011-07-10 13:39:08 -0700 | [diff] [blame] | 336 | } else if (isWorkspaceOrFolderApplication(d)) { |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 337 | LauncherModel.deleteItemFromDatabase(mLauncher, item); |
| 338 | } else if (isWorkspaceFolder(d)) { |
| 339 | // Remove the folder from the workspace and delete the contents from launcher model |
| 340 | FolderInfo folderInfo = (FolderInfo) item; |
| 341 | mLauncher.removeFolder(folderInfo); |
| 342 | LauncherModel.deleteFolderContentsFromDatabase(mLauncher, folderInfo); |
Michael Jurka | 0b4870d | 2011-07-10 13:39:08 -0700 | [diff] [blame] | 343 | } else if (isWorkspaceOrFolderWidget(d)) { |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 344 | // Remove the widget from the workspace |
| 345 | mLauncher.removeAppWidget((LauncherAppWidgetInfo) item); |
| 346 | LauncherModel.deleteItemFromDatabase(mLauncher, item); |
| 347 | |
| 348 | final LauncherAppWidgetInfo launcherAppWidgetInfo = (LauncherAppWidgetInfo) item; |
| 349 | final LauncherAppWidgetHost appWidgetHost = mLauncher.getAppWidgetHost(); |
Sunny Goyal | 651077b | 2014-06-30 14:15:31 -0700 | [diff] [blame] | 350 | if ((appWidgetHost != null) && launcherAppWidgetInfo.isWidgetIdValid()) { |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 351 | // Deleting an app widget ID is a void call but writes to disk before returning |
| 352 | // to the caller... |
Michael Jurka | 4346746 | 2013-11-14 12:03:58 +0100 | [diff] [blame] | 353 | new AsyncTask<Void, Void, Void>() { |
| 354 | public Void doInBackground(Void ... args) { |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 355 | appWidgetHost.deleteAppWidgetId(launcherAppWidgetInfo.appWidgetId); |
Michael Jurka | 4346746 | 2013-11-14 12:03:58 +0100 | [diff] [blame] | 356 | return null; |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 357 | } |
Michael Jurka | 4346746 | 2013-11-14 12:03:58 +0100 | [diff] [blame] | 358 | }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null); |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 359 | } |
| 360 | } |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 361 | if (wasWaitingForUninstall && !mWaitingForUninstall) { |
| 362 | if (d.dragSource instanceof Folder) { |
| 363 | ((Folder) d.dragSource).onUninstallActivityReturned(false); |
| 364 | } else if (d.dragSource instanceof Workspace) { |
| 365 | ((Workspace) d.dragSource).onUninstallActivityReturned(false); |
| 366 | } |
| 367 | } |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 368 | } |
Adam Cohen | d4d7aa5 | 2011-07-19 21:47:37 -0700 | [diff] [blame] | 369 | |
| 370 | public void onDrop(DragObject d) { |
| 371 | animateToTrashAndCompleteDrop(d); |
| 372 | } |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 373 | |
| 374 | /** |
| 375 | * Creates an animation from the current drag view to the delete trash icon. |
| 376 | */ |
| 377 | private AnimatorUpdateListener createFlingToTrashAnimatorListener(final DragLayer dragLayer, |
| 378 | DragObject d, PointF vel, ViewConfiguration config) { |
Adam Cohen | fe9da81 | 2014-08-04 17:08:01 -0700 | [diff] [blame] | 379 | |
| 380 | int width = mCurrentDrawable == null ? 0 : mCurrentDrawable.getIntrinsicWidth(); |
| 381 | int height = mCurrentDrawable == null ? 0 : mCurrentDrawable.getIntrinsicHeight(); |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 382 | final Rect to = getIconRect(d.dragView.getMeasuredWidth(), d.dragView.getMeasuredHeight(), |
Adam Cohen | fe9da81 | 2014-08-04 17:08:01 -0700 | [diff] [blame] | 383 | width, height); |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 384 | final Rect from = new Rect(); |
| 385 | dragLayer.getViewRectRelativeToSelf(d.dragView, from); |
| 386 | |
| 387 | // Calculate how far along the velocity vector we should put the intermediate point on |
| 388 | // the bezier curve |
| 389 | float velocity = Math.abs(vel.length()); |
| 390 | float vp = Math.min(1f, velocity / (config.getScaledMaximumFlingVelocity() / 2f)); |
| 391 | int offsetY = (int) (-from.top * vp); |
| 392 | int offsetX = (int) (offsetY / (vel.y / vel.x)); |
| 393 | final float y2 = from.top + offsetY; // intermediate t/l |
| 394 | final float x2 = from.left + offsetX; |
| 395 | final float x1 = from.left; // drag view t/l |
| 396 | final float y1 = from.top; |
| 397 | final float x3 = to.left; // delete target t/l |
| 398 | final float y3 = to.top; |
| 399 | |
| 400 | final TimeInterpolator scaleAlphaInterpolator = new TimeInterpolator() { |
| 401 | @Override |
| 402 | public float getInterpolation(float t) { |
| 403 | return t * t * t * t * t * t * t * t; |
| 404 | } |
| 405 | }; |
| 406 | return new AnimatorUpdateListener() { |
| 407 | @Override |
| 408 | public void onAnimationUpdate(ValueAnimator animation) { |
| 409 | final DragView dragView = (DragView) dragLayer.getAnimatedView(); |
| 410 | float t = ((Float) animation.getAnimatedValue()).floatValue(); |
| 411 | float tp = scaleAlphaInterpolator.getInterpolation(t); |
| 412 | float initialScale = dragView.getInitialScale(); |
| 413 | float finalAlpha = 0.5f; |
| 414 | float scale = dragView.getScaleX(); |
| 415 | float x1o = ((1f - scale) * dragView.getMeasuredWidth()) / 2f; |
| 416 | float y1o = ((1f - scale) * dragView.getMeasuredHeight()) / 2f; |
| 417 | float x = (1f - t) * (1f - t) * (x1 - x1o) + 2 * (1f - t) * t * (x2 - x1o) + |
| 418 | (t * t) * x3; |
| 419 | float y = (1f - t) * (1f - t) * (y1 - y1o) + 2 * (1f - t) * t * (y2 - x1o) + |
| 420 | (t * t) * y3; |
| 421 | |
| 422 | dragView.setTranslationX(x); |
| 423 | dragView.setTranslationY(y); |
| 424 | dragView.setScaleX(initialScale * (1f - tp)); |
| 425 | dragView.setScaleY(initialScale * (1f - tp)); |
| 426 | dragView.setAlpha(finalAlpha + (1f - finalAlpha) * (1f - tp)); |
| 427 | } |
| 428 | }; |
| 429 | } |
| 430 | |
| 431 | /** |
| 432 | * Creates an animation from the current drag view along its current velocity vector. |
| 433 | * For this animation, the alpha runs for a fixed duration and we update the position |
| 434 | * progressively. |
| 435 | */ |
| 436 | private static class FlingAlongVectorAnimatorUpdateListener implements AnimatorUpdateListener { |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 437 | private DragLayer mDragLayer; |
| 438 | private PointF mVelocity; |
| 439 | private Rect mFrom; |
| 440 | private long mPrevTime; |
| 441 | private boolean mHasOffsetForScale; |
Winson Chung | 6e1bdaf | 2012-05-29 17:03:45 -0700 | [diff] [blame] | 442 | private float mFriction; |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 443 | |
Winson Chung | 9658b1e | 2012-04-09 18:30:07 -0700 | [diff] [blame] | 444 | private final TimeInterpolator mAlphaInterpolator = new DecelerateInterpolator(0.75f); |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 445 | |
| 446 | public FlingAlongVectorAnimatorUpdateListener(DragLayer dragLayer, PointF vel, Rect from, |
Winson Chung | 6e1bdaf | 2012-05-29 17:03:45 -0700 | [diff] [blame] | 447 | long startTime, float friction) { |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 448 | mDragLayer = dragLayer; |
| 449 | mVelocity = vel; |
| 450 | mFrom = from; |
| 451 | mPrevTime = startTime; |
Winson Chung | 6e1bdaf | 2012-05-29 17:03:45 -0700 | [diff] [blame] | 452 | mFriction = 1f - (dragLayer.getResources().getDisplayMetrics().density * friction); |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | @Override |
| 456 | public void onAnimationUpdate(ValueAnimator animation) { |
| 457 | final DragView dragView = (DragView) mDragLayer.getAnimatedView(); |
| 458 | float t = ((Float) animation.getAnimatedValue()).floatValue(); |
| 459 | long curTime = AnimationUtils.currentAnimationTimeMillis(); |
| 460 | |
| 461 | if (!mHasOffsetForScale) { |
| 462 | mHasOffsetForScale = true; |
| 463 | float scale = dragView.getScaleX(); |
| 464 | float xOffset = ((scale - 1f) * dragView.getMeasuredWidth()) / 2f; |
| 465 | float yOffset = ((scale - 1f) * dragView.getMeasuredHeight()) / 2f; |
| 466 | |
| 467 | mFrom.left += xOffset; |
| 468 | mFrom.top += yOffset; |
| 469 | } |
| 470 | |
| 471 | mFrom.left += (mVelocity.x * (curTime - mPrevTime) / 1000f); |
| 472 | mFrom.top += (mVelocity.y * (curTime - mPrevTime) / 1000f); |
| 473 | |
| 474 | dragView.setTranslationX(mFrom.left); |
| 475 | dragView.setTranslationY(mFrom.top); |
| 476 | dragView.setAlpha(1f - mAlphaInterpolator.getInterpolation(t)); |
| 477 | |
Winson Chung | 6e1bdaf | 2012-05-29 17:03:45 -0700 | [diff] [blame] | 478 | mVelocity.x *= mFriction; |
| 479 | mVelocity.y *= mFriction; |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 480 | mPrevTime = curTime; |
| 481 | } |
| 482 | }; |
| 483 | private AnimatorUpdateListener createFlingAlongVectorAnimatorListener(final DragLayer dragLayer, |
| 484 | DragObject d, PointF vel, final long startTime, final int duration, |
| 485 | ViewConfiguration config) { |
| 486 | final Rect from = new Rect(); |
| 487 | dragLayer.getViewRectRelativeToSelf(d.dragView, from); |
| 488 | |
Winson Chung | 6e1bdaf | 2012-05-29 17:03:45 -0700 | [diff] [blame] | 489 | return new FlingAlongVectorAnimatorUpdateListener(dragLayer, vel, from, startTime, |
| 490 | FLING_TO_DELETE_FRICTION); |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 491 | } |
| 492 | |
| 493 | public void onFlingToDelete(final DragObject d, int x, int y, PointF vel) { |
Winson Chung | a48487a | 2012-03-20 16:19:37 -0700 | [diff] [blame] | 494 | final boolean isAllApps = d.dragSource instanceof AppsCustomizePagedView; |
| 495 | |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 496 | // Don't highlight the icon as it's animating |
| 497 | d.dragView.setColor(0); |
| 498 | d.dragView.updateInitialScaleToCurrentScale(); |
Winson Chung | a48487a | 2012-03-20 16:19:37 -0700 | [diff] [blame] | 499 | // Don't highlight the target if we are flinging from AllApps |
| 500 | if (isAllApps) { |
| 501 | resetHoverColor(); |
| 502 | } |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 503 | |
| 504 | if (mFlingDeleteMode == MODE_FLING_DELETE_TO_TRASH) { |
| 505 | // Defer animating out the drop target if we are animating to it |
| 506 | mSearchDropTargetBar.deferOnDragEnd(); |
| 507 | mSearchDropTargetBar.finishAnimations(); |
| 508 | } |
| 509 | |
| 510 | final ViewConfiguration config = ViewConfiguration.get(mLauncher); |
| 511 | final DragLayer dragLayer = mLauncher.getDragLayer(); |
Winson Chung | 6e1bdaf | 2012-05-29 17:03:45 -0700 | [diff] [blame] | 512 | final int duration = FLING_DELETE_ANIMATION_DURATION; |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 513 | final long startTime = AnimationUtils.currentAnimationTimeMillis(); |
| 514 | |
| 515 | // NOTE: Because it takes time for the first frame of animation to actually be |
| 516 | // called and we expect the animation to be a continuation of the fling, we have |
| 517 | // to account for the time that has elapsed since the fling finished. And since |
| 518 | // we don't have a startDelay, we will always get call to update when we call |
| 519 | // start() (which we want to ignore). |
| 520 | final TimeInterpolator tInterpolator = new TimeInterpolator() { |
| 521 | private int mCount = -1; |
| 522 | private float mOffset = 0f; |
| 523 | |
| 524 | @Override |
| 525 | public float getInterpolation(float t) { |
| 526 | if (mCount < 0) { |
| 527 | mCount++; |
| 528 | } else if (mCount == 0) { |
| 529 | mOffset = Math.min(0.5f, (float) (AnimationUtils.currentAnimationTimeMillis() - |
| 530 | startTime) / duration); |
| 531 | mCount++; |
| 532 | } |
| 533 | return Math.min(1f, mOffset + t); |
| 534 | } |
| 535 | }; |
| 536 | AnimatorUpdateListener updateCb = null; |
| 537 | if (mFlingDeleteMode == MODE_FLING_DELETE_TO_TRASH) { |
| 538 | updateCb = createFlingToTrashAnimatorListener(dragLayer, d, vel, config); |
| 539 | } else if (mFlingDeleteMode == MODE_FLING_DELETE_ALONG_VECTOR) { |
| 540 | updateCb = createFlingAlongVectorAnimatorListener(dragLayer, d, vel, startTime, |
| 541 | duration, config); |
| 542 | } |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 543 | deferCompleteDropIfUninstalling(d); |
| 544 | |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 545 | Runnable onAnimationEndRunnable = new Runnable() { |
| 546 | @Override |
| 547 | public void run() { |
Winson Chung | a48487a | 2012-03-20 16:19:37 -0700 | [diff] [blame] | 548 | // If we are dragging from AllApps, then we allow AppsCustomizePagedView to clean up |
| 549 | // itself, otherwise, complete the drop to initiate the deletion process |
| 550 | if (!isAllApps) { |
| 551 | mLauncher.exitSpringLoadedDragMode(); |
| 552 | completeDrop(d); |
| 553 | } |
| 554 | mLauncher.getDragController().onDeferredEndFling(d); |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 555 | } |
| 556 | }; |
| 557 | dragLayer.animateView(d.dragView, updateCb, duration, tInterpolator, onAnimationEndRunnable, |
| 558 | DragLayer.ANIMATION_END_DISAPPEAR, null); |
| 559 | } |
Winson Chung | 4c98d92 | 2011-05-31 16:50:48 -0700 | [diff] [blame] | 560 | } |