diff options
Diffstat (limited to 'src/com/android/launcher3/DeleteDropTarget.java')
-rw-r--r-- | src/com/android/launcher3/DeleteDropTarget.java | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java index 150d958a8..94a335f5d 100644 --- a/src/com/android/launcher3/DeleteDropTarget.java +++ b/src/com/android/launcher3/DeleteDropTarget.java @@ -29,6 +29,7 @@ import android.content.res.Resources; import android.graphics.PointF; import android.graphics.Rect; import android.graphics.drawable.TransitionDrawable; +import android.os.AsyncTask; import android.util.AttributeSet; import android.view.View; import android.view.ViewConfiguration; @@ -95,7 +96,7 @@ public class DeleteDropTarget extends ButtonDropTarget { } private boolean isAllAppsApplication(DragSource source, Object info) { - return (source instanceof AppsCustomizePagedView) && (info instanceof AppInfo); + return source.supportsAppInfoDropTarget() && (info instanceof AppInfo); } private boolean isAllAppsWidget(DragSource source, Object info) { if (source instanceof AppsCustomizePagedView) { @@ -151,12 +152,12 @@ public class DeleteDropTarget extends ButtonDropTarget { return true; } - if (!AppsCustomizePagedView.DISABLE_ALL_APPS && + if (!LauncherAppState.isDisableAllApps() && item.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) { return true; } - if (!AppsCustomizePagedView.DISABLE_ALL_APPS && + if (!LauncherAppState.isDisableAllApps() && item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION && item instanceof AppInfo) { AppInfo appInfo = (AppInfo) info; @@ -165,7 +166,7 @@ public class DeleteDropTarget extends ButtonDropTarget { if (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION && item instanceof ShortcutInfo) { - if (AppsCustomizePagedView.DISABLE_ALL_APPS) { + if (LauncherAppState.isDisableAllApps()) { ShortcutInfo shortcutInfo = (ShortcutInfo) info; return (shortcutInfo.flags & AppInfo.DOWNLOADED_FLAG) != 0; } else { @@ -179,8 +180,9 @@ public class DeleteDropTarget extends ButtonDropTarget { @Override public void onDragStart(DragSource source, Object info, int dragAction) { boolean isVisible = true; - boolean useUninstallLabel = !AppsCustomizePagedView.DISABLE_ALL_APPS && + boolean useUninstallLabel = !LauncherAppState.isDisableAllApps() && isAllAppsApplication(source, info); + boolean useDeleteLabel = !useUninstallLabel && source.supportsDeleteDropTarget(); // If we are dragging an application from AppsCustomize, only show the control if we can // delete the app (it was downloaded), and rename the string to "uninstall" in such a case. @@ -191,15 +193,17 @@ public class DeleteDropTarget extends ButtonDropTarget { if (useUninstallLabel) { setCompoundDrawablesRelativeWithIntrinsicBounds(mUninstallDrawable, null, null, null); - } else { + } else if (useDeleteLabel) { setCompoundDrawablesRelativeWithIntrinsicBounds(mRemoveDrawable, null, null, null); + } else { + isVisible = false; } mCurrentDrawable = (TransitionDrawable) getCurrentDrawable(); mActive = isVisible; resetHoverColor(); ((ViewGroup) getParent()).setVisibility(isVisible ? View.VISIBLE : View.GONE); - if (getText().length() > 0) { + if (isVisible && getText().length() > 0) { setText(useUninstallLabel ? R.string.delete_target_uninstall_label : R.string.delete_target_label); } @@ -266,21 +270,10 @@ public class DeleteDropTarget extends ButtonDropTarget { } private boolean isUninstallFromWorkspace(DragObject d) { - if (AppsCustomizePagedView.DISABLE_ALL_APPS && isWorkspaceOrFolderApplication(d)) { + if (LauncherAppState.isDisableAllApps() && isWorkspaceOrFolderApplication(d)) { ShortcutInfo shortcut = (ShortcutInfo) d.dragInfo; - if (shortcut.intent != null && shortcut.intent.getComponent() != null) { - Set<String> categories = shortcut.intent.getCategories(); - boolean includesLauncherCategory = false; - if (categories != null) { - for (String category : categories) { - if (category.equals(Intent.CATEGORY_LAUNCHER)) { - includesLauncherCategory = true; - break; - } - } - } - return includesLauncherCategory; - } + // Only allow manifest shortcuts to initiate an un-install. + return !InstallShortcutReceiver.isValidShortcutLaunchIntent(shortcut.intent); } return false; } @@ -340,11 +333,12 @@ public class DeleteDropTarget extends ButtonDropTarget { if (appWidgetHost != null) { // Deleting an app widget ID is a void call but writes to disk before returning // to the caller... - new Thread("deleteAppWidgetId") { - public void run() { + new AsyncTask<Void, Void, Void>() { + public Void doInBackground(Void ... args) { appWidgetHost.deleteAppWidgetId(launcherAppWidgetInfo.appWidgetId); + return null; } - }.start(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null); } } if (wasWaitingForUninstall && !mWaitingForUninstall) { |