From c0b52fefbc11531d560359c093484099f9d1298e Mon Sep 17 00:00:00 2001 From: Winson Date: Wed, 9 Sep 2015 16:38:15 -0700 Subject: Refactoring to ensure item deletion always removes from the DB. - Routing the various places where we call through to delete from LauncherModel through Launcher, which will delegate the removal of the icon from the workspace, and properly handle the removal of all items and their contents from the db. Bug: 23944119 Change-Id: I022fe2b3e79da16b5af87505c4362490b8422686 --- src/com/android/launcher3/FocusHelper.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/com/android/launcher3/FocusHelper.java') diff --git a/src/com/android/launcher3/FocusHelper.java b/src/com/android/launcher3/FocusHelper.java index 57aec3280..eca5eec2a 100644 --- a/src/com/android/launcher3/FocusHelper.java +++ b/src/com/android/launcher3/FocusHelper.java @@ -185,7 +185,8 @@ public class FocusHelper { return consume; } - DeviceProfile profile = ((Launcher) v.getContext()).getDeviceProfile(); + final Launcher launcher = (Launcher) v.getContext(); + final DeviceProfile profile = launcher.getDeviceProfile(); if (DEBUG) { Log.v(TAG, String.format( @@ -196,7 +197,6 @@ public class FocusHelper { // Initialize the variables. final ShortcutAndWidgetContainer hotseatParent = (ShortcutAndWidgetContainer) v.getParent(); final CellLayout hotseatLayout = (CellLayout) hotseatParent.getParent(); - Hotseat hotseat = (Hotseat) hotseatLayout.getParent(); Workspace workspace = (Workspace) v.getRootView().findViewById(R.id.workspace); int pageIndex = workspace.getNextPage(); @@ -240,7 +240,10 @@ public class FocusHelper { } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT && profile.isVerticalBarLayout()) { keyCode = KeyEvent.KEYCODE_PAGE_DOWN; - }else { + } else if (keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_FORWARD_DEL) { + ItemInfo info = (ItemInfo) v.getTag(); + launcher.removeItem(v, info, true /* deleteFromDb */); + } else { // For other KEYCODE_DPAD_LEFT and KEYCODE_DPAD_RIGHT navigation, do not use the // matrix extended with hotseat. matrix = FocusLogic.createSparseMatrix(hotseatLayout); @@ -326,7 +329,8 @@ public class FocusHelper { !hotseat.hasIcons() /* ignore all apps icon, unless there are no other icons */); countX = countX + 1; } else if (keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_FORWARD_DEL) { - workspace.removeWorkspaceItem(v); + ItemInfo info = (ItemInfo) v.getTag(); + launcher.removeItem(v, info, true /* deleteFromDb */); return consume; } else { matrix = FocusLogic.createSparseMatrix(iconLayout); -- cgit v1.2.3