diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2015-04-29 16:30:23 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2015-04-29 18:15:36 -0700 |
commit | 9ae77771d751a5a7fe87f660ab70908b5f55d9fc (patch) | |
tree | 85ae80f7241366c957fa79af8dbb30d869f795e5 | |
parent | 65d076b2ffe7ca96f014a95bd362c7d1ce004b97 (diff) | |
download | android_packages_apps_Trebuchet-9ae77771d751a5a7fe87f660ab70908b5f55d9fc.tar.gz android_packages_apps_Trebuchet-9ae77771d751a5a7fe87f660ab70908b5f55d9fc.tar.bz2 android_packages_apps_Trebuchet-9ae77771d751a5a7fe87f660ab70908b5f55d9fc.zip |
Adding accessibility action to move item out of a folder
Change-Id: If67e3472793d6e0913adfbc9d78f64de7f751664
-rw-r--r-- | res/values/config.xml | 1 | ||||
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherAccessibilityDelegate.java | 32 |
3 files changed, 35 insertions, 0 deletions
diff --git a/res/values/config.xml b/res/values/config.xml index 7ce40594f..21e1d6987 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -99,4 +99,5 @@ <item type="id" name="action_info" /> <item type="id" name="action_add_to_workspace" /> <item type="id" name="action_move" /> + <item type="id" name="action_move_to_workspace" /> </resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index a5a681a4f..57f23ae98 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -241,4 +241,6 @@ <!-- Accessibility confirmation for folder created [DO NOT TRANSLATE] --> <string name="folder_created">Folder created</string> + <!-- Accessibility action to move an item from folder to workspace. [CHAR_LIMIT=30] [DO NOT TRANSLATE] --> + <string name="action_move_to_workspace">Move to home screen</string> </resources> diff --git a/src/com/android/launcher3/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/LauncherAccessibilityDelegate.java index a527db423..8a9a0508c 100644 --- a/src/com/android/launcher3/LauncherAccessibilityDelegate.java +++ b/src/com/android/launcher3/LauncherAccessibilityDelegate.java @@ -4,6 +4,7 @@ import android.annotation.TargetApi; import android.graphics.Rect; import android.os.Build; import android.os.Bundle; +import android.os.Handler; import android.text.TextUtils; import android.util.Log; import android.util.SparseArray; @@ -26,6 +27,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate { private static final int UNINSTALL = R.id.action_uninstall; private static final int ADD_TO_WORKSPACE = R.id.action_add_to_workspace; private static final int MOVE = R.id.action_move; + private static final int MOVE_TO_WORKSPACE = R.id.action_move_to_workspace; public enum DragType { ICON, @@ -58,6 +60,8 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate { launcher.getText(R.string.action_add_to_workspace))); mActions.put(MOVE, new AccessibilityAction(MOVE, launcher.getText(R.string.action_move))); + mActions.put(MOVE_TO_WORKSPACE, new AccessibilityAction(MOVE_TO_WORKSPACE, + launcher.getText(R.string.action_move_to_workspace))); } @Override @@ -80,6 +84,10 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate { || (item instanceof LauncherAppWidgetInfo) || (item instanceof FolderInfo)) { info.addAction(mActions.get(MOVE)); + + if (item.container >= 0) { + info.addAction(mActions.get(MOVE_TO_WORKSPACE)); + } } if ((item instanceof AppInfo) || (item instanceof PendingAddItemInfo)) { info.addAction(mActions.get(ADD_TO_WORKSPACE)); } @@ -135,6 +143,30 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate { } }); return true; + } else if (action == MOVE_TO_WORKSPACE) { + Folder folder = mLauncher.getWorkspace().getOpenFolder(); + mLauncher.closeFolder(folder); + ShortcutInfo info = (ShortcutInfo) item; + folder.getInfo().remove(info); + + final int[] coordinates = new int[2]; + final long screenId = findSpaceOnWorkspace(item, coordinates); + LauncherModel.moveItemInDatabase(mLauncher, info, + LauncherSettings.Favorites.CONTAINER_DESKTOP, + screenId, coordinates[0], coordinates[1]); + + // Bind the item in next frame so that if a new workspace page was created, + // it will get laid out. + new Handler().post(new Runnable() { + + @Override + public void run() { + ArrayList<ItemInfo> itemList = new ArrayList<>(); + itemList.add(item); + mLauncher.bindItems(itemList, 0, itemList.size(), true); + announceConfirmation(R.string.item_moved); + } + }); } return false; } |