Caching the uninstall disabled state for each userHandle
> Removing static access to varios drop targets
> Creating a cache at UI level with 5sec timeout
Bug: 67104426
Change-Id: Ide6e2e0c01606f9b5fb9281f95dc009873c18fb9
diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java
index fdd4f34..c12ea57 100644
--- a/src/com/android/launcher3/DeleteDropTarget.java
+++ b/src/com/android/launcher3/DeleteDropTarget.java
@@ -21,6 +21,7 @@
import android.util.AttributeSet;
import android.view.View;
+import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.folder.Folder;
@@ -49,14 +50,22 @@
setTextBasedOnDragSource(dragObject.dragInfo);
}
- /** @return true for items that should have a "Remove" action in accessibility. */
- public static boolean supportsAccessibleDrop(ItemInfo info) {
+ /**
+ * @return true for items that should have a "Remove" action in accessibility.
+ */
+ @Override
+ public boolean supportsAccessibilityDrop(ItemInfo info) {
return (info instanceof ShortcutInfo)
|| (info instanceof LauncherAppWidgetInfo)
|| (info instanceof FolderInfo);
}
@Override
+ public int getAccessibilityAction() {
+ return LauncherAccessibilityDelegate.REMOVE;
+ }
+
+ @Override
protected boolean supportsDrop(ItemInfo info) {
return true;
}
@@ -77,19 +86,21 @@
public void completeDrop(DragObject d) {
ItemInfo item = d.dragInfo;
if ((d.dragSource instanceof Workspace) || (d.dragSource instanceof Folder)) {
- removeWorkspaceOrFolderItem(mLauncher, item, null);
+ onAccessibilityDrop(null, item);
}
}
/**
* Removes the item from the workspace. If the view is not null, it also removes the view.
*/
- public static void removeWorkspaceOrFolderItem(Launcher launcher, ItemInfo item, View view) {
+ @Override
+ public void onAccessibilityDrop(View view, ItemInfo item) {
// Remove the item from launcher and the db, we can ignore the containerInfo in this call
// because we already remove the drag view from the folder (if the drag originated from
// a folder) in Folder.beginDrag()
- launcher.removeItem(view, item, true /* deleteFromDb */);
- launcher.getWorkspace().stripEmptyScreens();
- launcher.getDragLayer().announceForAccessibility(launcher.getString(R.string.item_removed));
+ mLauncher.removeItem(view, item, true /* deleteFromDb */);
+ mLauncher.getWorkspace().stripEmptyScreens();
+ mLauncher.getDragLayer()
+ .announceForAccessibility(getContext().getString(R.string.item_removed));
}
}