Loading res/values/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -101,4 +101,5 @@ <item type="id" name="action_move_screen_backwards" /> <item type="id" name="action_move_screen_forwards" /> <item type="id" name="action_resize" /> <item type="id" name="action_deep_shortcuts" /> </resources> res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -249,4 +249,7 @@ <!-- Accessibility confirmation for widget resize. --> <string name="widget_resized">Widget resized to width <xliff:g id="number" example="2">%1$s</xliff:g> height <xliff:g id="number" example="1">%2$s</xliff:g></string> <!-- Accessibility action to show quick actions menu for an icon. [CHAR_LIMIT=30] --> <string name="action_deep_shortcut" translatable="false">Quick links</string> </resources> src/com/android/launcher3/BubbleTextView.java +7 −0 Original line number Diff line number Diff line Loading @@ -648,6 +648,13 @@ public class BubbleTextView extends TextView } } /** * Returns true if the view can show custom shortcuts. */ public boolean hasDeepShortcuts() { return !mLauncher.getShortcutIdsForItem((ItemInfo) getTag()).isEmpty(); } /** * Returns the start delay when animating between certain {@link FastBitmapDrawable} states. */ Loading src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java +26 −9 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; import com.android.launcher3.AppInfo; import com.android.launcher3.AppWidgetResizeFrame; import com.android.launcher3.BubbleTextView; import com.android.launcher3.CellLayout; import com.android.launcher3.DeleteDropTarget; import com.android.launcher3.DragSource; Loading @@ -36,6 +37,8 @@ import com.android.launcher3.ShortcutInfo; import com.android.launcher3.UninstallDropTarget; import com.android.launcher3.Workspace; import com.android.launcher3.dragndrop.DragController.DragListener; import com.android.launcher3.shortcuts.DeepShortcutTextView; import com.android.launcher3.shortcuts.DeepShortcutsContainer; import com.android.launcher3.util.Thunk; import java.util.ArrayList; Loading @@ -45,13 +48,14 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme private static final String TAG = "LauncherAccessibilityDelegate"; private static final int REMOVE = R.id.action_remove; private static final int INFO = R.id.action_info; 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; private static final int RESIZE = R.id.action_resize; protected static final int REMOVE = R.id.action_remove; protected static final int INFO = R.id.action_info; protected static final int UNINSTALL = R.id.action_uninstall; protected static final int ADD_TO_WORKSPACE = R.id.action_add_to_workspace; protected static final int MOVE = R.id.action_move; protected static final int MOVE_TO_WORKSPACE = R.id.action_move_to_workspace; protected static final int RESIZE = R.id.action_resize; protected static final int DEEP_SHORTCUTS = R.id.action_deep_shortcuts; public enum DragType { ICON, Loading @@ -65,7 +69,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme public View item; } private final SparseArray<AccessibilityAction> mActions = new SparseArray<>(); protected final SparseArray<AccessibilityAction> mActions = new SparseArray<>(); @Thunk final Launcher mLauncher; private DragInfo mDragInfo = null; Loading @@ -88,14 +92,24 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme launcher.getText(R.string.action_move_to_workspace))); mActions.put(RESIZE, new AccessibilityAction(RESIZE, launcher.getText(R.string.action_resize))); mActions.put(DEEP_SHORTCUTS, new AccessibilityAction(DEEP_SHORTCUTS, launcher.getText(R.string.action_deep_shortcut))); } @Override public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(host, info); addActions(host, info); } protected void addActions(View host, AccessibilityNodeInfo info) { if (!(host.getTag() instanceof ItemInfo)) return; ItemInfo item = (ItemInfo) host.getTag(); if (host instanceof BubbleTextView && ((BubbleTextView) host).hasDeepShortcuts()) { info.addAction(mActions.get(DEEP_SHORTCUTS)); } if (DeleteDropTarget.supportsAccessibleDrop(item)) { info.addAction(mActions.get(REMOVE)); } Loading Loading @@ -215,6 +229,9 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme } }) .show(); return true; } else if (action == DEEP_SHORTCUTS) { return DeepShortcutsContainer.showForIcon((BubbleTextView) host) != null; } return false; } Loading Loading @@ -397,7 +414,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme /** * Find empty space on the workspace and returns the screenId. */ private long findSpaceOnWorkspace(ItemInfo info, int[] outCoordinates) { protected long findSpaceOnWorkspace(ItemInfo info, int[] outCoordinates) { Workspace workspace = mLauncher.getWorkspace(); ArrayList<Long> workspaceScreens = workspace.getScreenOrder(); long screenId; Loading src/com/android/launcher3/accessibility/ShortcutMenuAccessibilityDelegate.java 0 → 100644 +73 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.launcher3.accessibility; import android.view.View; import android.view.accessibility.AccessibilityNodeInfo; import com.android.launcher3.ItemInfo; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherModel; import com.android.launcher3.LauncherSettings; import com.android.launcher3.R; import com.android.launcher3.ShortcutInfo; import java.util.ArrayList; /** * Extension of {@link LauncherAccessibilityDelegate} with actions specific to shortcuts in * deep shortcuts menu. */ public class ShortcutMenuAccessibilityDelegate extends LauncherAccessibilityDelegate { public ShortcutMenuAccessibilityDelegate(Launcher launcher) { super(launcher); } @Override protected void addActions(View host, AccessibilityNodeInfo info) { info.addAction(mActions.get(ADD_TO_WORKSPACE)); } @Override public boolean performAction(View host, ItemInfo item, int action) { if (action == ADD_TO_WORKSPACE) { final ShortcutInfo info = (ShortcutInfo) item; final int[] coordinates = new int[2]; final long screenId = findSpaceOnWorkspace(item, coordinates); Runnable onComplete = new Runnable() { @Override public void run() { LauncherModel.addItemToDatabase(mLauncher, info, LauncherSettings.Favorites.CONTAINER_DESKTOP, screenId, coordinates[0], coordinates[1]); ArrayList<ItemInfo> itemList = new ArrayList<>(); itemList.add(info); mLauncher.bindItems(itemList, 0, itemList.size(), true); mLauncher.closeShortcutsContainer(); announceConfirmation(R.string.item_added_to_workspace); } }; if (!mLauncher.showWorkspace(true, onComplete)) { onComplete.run(); } return true; } return false; } } Loading
res/values/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -101,4 +101,5 @@ <item type="id" name="action_move_screen_backwards" /> <item type="id" name="action_move_screen_forwards" /> <item type="id" name="action_resize" /> <item type="id" name="action_deep_shortcuts" /> </resources>
res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -249,4 +249,7 @@ <!-- Accessibility confirmation for widget resize. --> <string name="widget_resized">Widget resized to width <xliff:g id="number" example="2">%1$s</xliff:g> height <xliff:g id="number" example="1">%2$s</xliff:g></string> <!-- Accessibility action to show quick actions menu for an icon. [CHAR_LIMIT=30] --> <string name="action_deep_shortcut" translatable="false">Quick links</string> </resources>
src/com/android/launcher3/BubbleTextView.java +7 −0 Original line number Diff line number Diff line Loading @@ -648,6 +648,13 @@ public class BubbleTextView extends TextView } } /** * Returns true if the view can show custom shortcuts. */ public boolean hasDeepShortcuts() { return !mLauncher.getShortcutIdsForItem((ItemInfo) getTag()).isEmpty(); } /** * Returns the start delay when animating between certain {@link FastBitmapDrawable} states. */ Loading
src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java +26 −9 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; import com.android.launcher3.AppInfo; import com.android.launcher3.AppWidgetResizeFrame; import com.android.launcher3.BubbleTextView; import com.android.launcher3.CellLayout; import com.android.launcher3.DeleteDropTarget; import com.android.launcher3.DragSource; Loading @@ -36,6 +37,8 @@ import com.android.launcher3.ShortcutInfo; import com.android.launcher3.UninstallDropTarget; import com.android.launcher3.Workspace; import com.android.launcher3.dragndrop.DragController.DragListener; import com.android.launcher3.shortcuts.DeepShortcutTextView; import com.android.launcher3.shortcuts.DeepShortcutsContainer; import com.android.launcher3.util.Thunk; import java.util.ArrayList; Loading @@ -45,13 +48,14 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme private static final String TAG = "LauncherAccessibilityDelegate"; private static final int REMOVE = R.id.action_remove; private static final int INFO = R.id.action_info; 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; private static final int RESIZE = R.id.action_resize; protected static final int REMOVE = R.id.action_remove; protected static final int INFO = R.id.action_info; protected static final int UNINSTALL = R.id.action_uninstall; protected static final int ADD_TO_WORKSPACE = R.id.action_add_to_workspace; protected static final int MOVE = R.id.action_move; protected static final int MOVE_TO_WORKSPACE = R.id.action_move_to_workspace; protected static final int RESIZE = R.id.action_resize; protected static final int DEEP_SHORTCUTS = R.id.action_deep_shortcuts; public enum DragType { ICON, Loading @@ -65,7 +69,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme public View item; } private final SparseArray<AccessibilityAction> mActions = new SparseArray<>(); protected final SparseArray<AccessibilityAction> mActions = new SparseArray<>(); @Thunk final Launcher mLauncher; private DragInfo mDragInfo = null; Loading @@ -88,14 +92,24 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme launcher.getText(R.string.action_move_to_workspace))); mActions.put(RESIZE, new AccessibilityAction(RESIZE, launcher.getText(R.string.action_resize))); mActions.put(DEEP_SHORTCUTS, new AccessibilityAction(DEEP_SHORTCUTS, launcher.getText(R.string.action_deep_shortcut))); } @Override public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(host, info); addActions(host, info); } protected void addActions(View host, AccessibilityNodeInfo info) { if (!(host.getTag() instanceof ItemInfo)) return; ItemInfo item = (ItemInfo) host.getTag(); if (host instanceof BubbleTextView && ((BubbleTextView) host).hasDeepShortcuts()) { info.addAction(mActions.get(DEEP_SHORTCUTS)); } if (DeleteDropTarget.supportsAccessibleDrop(item)) { info.addAction(mActions.get(REMOVE)); } Loading Loading @@ -215,6 +229,9 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme } }) .show(); return true; } else if (action == DEEP_SHORTCUTS) { return DeepShortcutsContainer.showForIcon((BubbleTextView) host) != null; } return false; } Loading Loading @@ -397,7 +414,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme /** * Find empty space on the workspace and returns the screenId. */ private long findSpaceOnWorkspace(ItemInfo info, int[] outCoordinates) { protected long findSpaceOnWorkspace(ItemInfo info, int[] outCoordinates) { Workspace workspace = mLauncher.getWorkspace(); ArrayList<Long> workspaceScreens = workspace.getScreenOrder(); long screenId; Loading
src/com/android/launcher3/accessibility/ShortcutMenuAccessibilityDelegate.java 0 → 100644 +73 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.launcher3.accessibility; import android.view.View; import android.view.accessibility.AccessibilityNodeInfo; import com.android.launcher3.ItemInfo; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherModel; import com.android.launcher3.LauncherSettings; import com.android.launcher3.R; import com.android.launcher3.ShortcutInfo; import java.util.ArrayList; /** * Extension of {@link LauncherAccessibilityDelegate} with actions specific to shortcuts in * deep shortcuts menu. */ public class ShortcutMenuAccessibilityDelegate extends LauncherAccessibilityDelegate { public ShortcutMenuAccessibilityDelegate(Launcher launcher) { super(launcher); } @Override protected void addActions(View host, AccessibilityNodeInfo info) { info.addAction(mActions.get(ADD_TO_WORKSPACE)); } @Override public boolean performAction(View host, ItemInfo item, int action) { if (action == ADD_TO_WORKSPACE) { final ShortcutInfo info = (ShortcutInfo) item; final int[] coordinates = new int[2]; final long screenId = findSpaceOnWorkspace(item, coordinates); Runnable onComplete = new Runnable() { @Override public void run() { LauncherModel.addItemToDatabase(mLauncher, info, LauncherSettings.Favorites.CONTAINER_DESKTOP, screenId, coordinates[0], coordinates[1]); ArrayList<ItemInfo> itemList = new ArrayList<>(); itemList.add(info); mLauncher.bindItems(itemList, 0, itemList.size(), true); mLauncher.closeShortcutsContainer(); announceConfirmation(R.string.item_added_to_workspace); } }; if (!mLauncher.showWorkspace(true, onComplete)) { onComplete.run(); } return true; } return false; } }