Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-apps-Launcher3: Commit

packages/apps/Launcher3


Commit MetaInfo

Revisión8af16760dcb367dc7568ae3736b797cd2c8406c1 (tree)
Tiempo2017-05-18 10:06:46
AutorTony Wickham <twickham@goog...>
CommiterAndroid (Google) Code Review

Log Message

Merge "Update accessibility for popup" into ub-launcher3-dorval

Cambiar Resumen

Diferencia incremental

--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -133,4 +133,5 @@
133133 <item type="id" name="action_move_screen_forwards" />
134134 <item type="id" name="action_resize" />
135135 <item type="id" name="action_deep_shortcuts" />
136+ <item type="id" name="action_dismiss_notification" />
136137 </resources>
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -292,5 +292,13 @@
292292
293293 <!-- Accessibility description for the shortcuts menu shown for an app. -->
294294 <string name="shortcuts_menu_description"><xliff:g id="number_of_shortcuts" example="3">%1$d</xliff:g> shortcuts for <xliff:g id="app_name" example="Messenger">%2$s</xliff:g></string>
295+ <!-- Accessibility description when the shortcuts menu has notifications as well as shortcuts. -->
296+ <string name="shortcuts_menu_with_notifications_description"><xliff:g id="number_of_shortcuts" example="3">%1$d</xliff:g> shortcuts and <xliff:g id="number_of_notifications" example="3">%2$d</xliff:g> notifications for <xliff:g id="app_name" example="Messenger">%3$s</xliff:g></string>
297+
298+ <!-- Accessibility action to dismiss a notification in the shortcuts menu for an icon. [CHAR_LIMIT=30] -->
299+ <string name="action_dismiss_notification">Dismiss</string>
300+
301+ <!-- Accessibility confirmation for notification being dismissed. -->
302+ <string name="notification_dismissed">Notification dismissed</string>
295303
296304 </resources>
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -660,14 +660,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver {
660660 }
661661
662662 /**
663- * Returns true if the view can show custom shortcuts.
664- */
665- public boolean hasDeepShortcuts() {
666- return !mLauncher.getPopupDataProvider().getShortcutIdsForItem((ItemInfo) getTag())
667- .isEmpty();
668- }
669-
670- /**
671663 * Interface to be implemented by the grand parent to allow click shadow effect.
672664 */
673665 public interface BubbleTextShadowHandler {
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -4061,8 +4061,8 @@ public class Launcher extends BaseActivity
40614061 shortcutInfos.add(new KeyboardShortcutInfo(getString(R.string.custom_actions),
40624062 KeyEvent.KEYCODE_O, KeyEvent.META_CTRL_ON));
40634063 }
4064- if (currentFocus instanceof BubbleTextView &&
4065- ((BubbleTextView) currentFocus).hasDeepShortcuts()) {
4064+ if (currentFocus.getTag() instanceof ItemInfo
4065+ && DeepShortcutManager.supportsShortcuts((ItemInfo) currentFocus.getTag())) {
40664066 shortcutInfos.add(new KeyboardShortcutInfo(getString(R.string.action_deep_shortcut),
40674067 KeyEvent.KEYCODE_S, KeyEvent.META_CTRL_ON));
40684068 }
--- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
@@ -37,6 +37,7 @@ import com.android.launcher3.Workspace;
3737 import com.android.launcher3.dragndrop.DragController.DragListener;
3838 import com.android.launcher3.dragndrop.DragOptions;
3939 import com.android.launcher3.folder.Folder;
40+import com.android.launcher3.shortcuts.DeepShortcutManager;
4041 import com.android.launcher3.util.Thunk;
4142
4243 import java.util.ArrayList;
@@ -104,8 +105,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
104105
105106 // If the request came from keyboard, do not add custom shortcuts as that is already
106107 // exposed as a direct shortcut
107- if (!fromKeyboard && host instanceof BubbleTextView
108- && ((BubbleTextView) host).hasDeepShortcuts()) {
108+ if (!fromKeyboard && DeepShortcutManager.supportsShortcuts(item)) {
109109 info.addAction(mActions.get(DEEP_SHORTCUTS));
110110 }
111111
--- a/src/com/android/launcher3/accessibility/ShortcutMenuAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/ShortcutMenuAccessibilityDelegate.java
@@ -18,14 +18,15 @@ package com.android.launcher3.accessibility;
1818
1919 import android.view.View;
2020 import android.view.accessibility.AccessibilityNodeInfo;
21+import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
2122
2223 import com.android.launcher3.AbstractFloatingView;
2324 import com.android.launcher3.ItemInfo;
2425 import com.android.launcher3.Launcher;
25-import com.android.launcher3.LauncherModel;
2626 import com.android.launcher3.LauncherSettings;
2727 import com.android.launcher3.R;
2828 import com.android.launcher3.ShortcutInfo;
29+import com.android.launcher3.notification.NotificationMainView;
2930 import com.android.launcher3.shortcuts.DeepShortcutView;
3031
3132 import java.util.ArrayList;
@@ -36,14 +37,23 @@ import java.util.ArrayList;
3637 */
3738 public class ShortcutMenuAccessibilityDelegate extends LauncherAccessibilityDelegate {
3839
40+ private static final int DISMISS_NOTIFICATION = R.id.action_dismiss_notification;
41+
3942 public ShortcutMenuAccessibilityDelegate(Launcher launcher) {
4043 super(launcher);
44+ mActions.put(DISMISS_NOTIFICATION, new AccessibilityAction(DISMISS_NOTIFICATION,
45+ launcher.getText(R.string.action_dismiss_notification)));
4146 }
4247
4348 @Override
4449 public void addSupportedActions(View host, AccessibilityNodeInfo info, boolean fromKeyboard) {
4550 if ((host.getParent() instanceof DeepShortcutView)) {
4651 info.addAction(mActions.get(ADD_TO_WORKSPACE));
52+ } else if (host instanceof NotificationMainView) {
53+ NotificationMainView notificationView = (NotificationMainView) host;
54+ if (notificationView.canChildBeDismissed(notificationView)) {
55+ info.addAction(mActions.get(DISMISS_NOTIFICATION));
56+ }
4757 }
4858 }
4959
@@ -74,6 +84,14 @@ public class ShortcutMenuAccessibilityDelegate extends LauncherAccessibilityDele
7484 onComplete.run();
7585 }
7686 return true;
87+ } else if (action == DISMISS_NOTIFICATION) {
88+ if (!(host instanceof NotificationMainView)) {
89+ return false;
90+ }
91+ NotificationMainView notificationView = (NotificationMainView) host;
92+ notificationView.onChildDismissed(notificationView);
93+ announceConfirmation(R.string.notification_dismissed);
94+ return true;
7795 }
7896 return false;
7997 }
--- a/src/com/android/launcher3/notification/NotificationFooterLayout.java
+++ b/src/com/android/launcher3/notification/NotificationFooterLayout.java
@@ -141,6 +141,7 @@ public class NotificationFooterLayout extends FrameLayout {
141141 icon.setBackground(info.getIconForBackground(getContext(), mBackgroundColor));
142142 icon.setOnClickListener(info);
143143 icon.setTag(info);
144+ icon.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
144145 mIconRow.addView(icon, 0, mIconLayoutParams);
145146 return icon;
146147 }
--- a/src/com/android/launcher3/notification/NotificationItemView.java
+++ b/src/com/android/launcher3/notification/NotificationItemView.java
@@ -77,6 +77,10 @@ public class NotificationItemView extends PopupItemView implements LogContainerP
7777 mSwipeHelper.setDisableHardwareLayers(true);
7878 }
7979
80+ public NotificationMainView getMainView() {
81+ return mMainView;
82+ }
83+
8084 public int getHeightMinusFooter() {
8185 int footerHeight = mFooter.getParent() == null ? 0 : mFooter.getHeight();
8286 return getHeight() - footerHeight;
--- a/src/com/android/launcher3/notification/NotificationMainView.java
+++ b/src/com/android/launcher3/notification/NotificationMainView.java
@@ -122,7 +122,7 @@ public class NotificationMainView extends FrameLayout implements SwipeHelper.Cal
122122
123123 @Override
124124 public boolean canChildBeDismissed(View v) {
125- return mNotificationInfo.dismissable;
125+ return mNotificationInfo != null && mNotificationInfo.dismissable;
126126 }
127127
128128 @Override
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -114,7 +114,6 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
114114
115115 mStartDragThreshold = getResources().getDimensionPixelSize(
116116 R.dimen.deep_shortcuts_start_drag_threshold);
117- // TODO: make sure the delegate works for all items, not just shortcuts.
118117 mAccessibilityDelegate = new ShortcutMenuAccessibilityDelegate(mLauncher);
119118 mIsRtl = Utilities.isRtl(getResources());
120119 }
@@ -176,7 +175,7 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
176175 // Add dummy views first, and populate with real info when ready.
177176 PopupPopulator.Item[] itemsToPopulate = PopupPopulator
178177 .getItemsToPopulate(shortcutIds, notificationKeys, systemShortcuts);
179- addDummyViews(originalIcon, itemsToPopulate, notificationKeys.size() > 1);
178+ addDummyViews(itemsToPopulate, notificationKeys.size() > 1);
180179
181180 measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
182181 orientAboutIcon(originalIcon, arrowHeight + arrowVerticalOffset);
@@ -187,7 +186,7 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
187186 mNotificationItemView = null;
188187 mShortcutsItemView = null;
189188 itemsToPopulate = PopupPopulator.reverseItems(itemsToPopulate);
190- addDummyViews(originalIcon, itemsToPopulate, notificationKeys.size() > 1);
189+ addDummyViews(itemsToPopulate, notificationKeys.size() > 1);
191190
192191 measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
193192 orientAboutIcon(originalIcon, arrowHeight + arrowVerticalOffset);
@@ -204,6 +203,17 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
204203 updateNotificationHeader();
205204 }
206205
206+ int numShortcuts = shortcutViews.size() + systemShortcutViews.size();
207+ int numNotifications = notificationKeys.size();
208+ if (numNotifications == 0) {
209+ setContentDescription(getContext().getString(R.string.shortcuts_menu_description,
210+ numShortcuts, originalIcon.getContentDescription().toString()));
211+ } else {
212+ setContentDescription(getContext().getString(
213+ R.string.shortcuts_menu_with_notifications_description, numShortcuts,
214+ numNotifications, originalIcon.getContentDescription().toString()));
215+ }
216+
207217 // Add the arrow.
208218 final int arrowHorizontalOffset = resources.getDimensionPixelSize(isAlignedWithStart() ?
209219 R.dimen.popup_arrow_horizontal_offset_start :
@@ -225,8 +235,8 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
225235 systemShortcuts, systemShortcutViews));
226236 }
227237
228- private void addDummyViews(BubbleTextView originalIcon,
229- PopupPopulator.Item[] itemTypesToPopulate, boolean notificationFooterHasIcons) {
238+ private void addDummyViews(PopupPopulator.Item[] itemTypesToPopulate,
239+ boolean notificationFooterHasIcons) {
230240 final Resources res = getResources();
231241 final int spacing = res.getDimensionPixelSize(R.dimen.popup_items_spacing);
232242 final LayoutInflater inflater = mLauncher.getLayoutInflater();
@@ -243,12 +253,14 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
243253 int footerHeight = notificationFooterHasIcons ?
244254 res.getDimensionPixelSize(R.dimen.notification_footer_height) : 0;
245255 item.findViewById(R.id.footer).getLayoutParams().height = footerHeight;
256+ mNotificationItemView.getMainView().setAccessibilityDelegate(mAccessibilityDelegate);
257+ } else if (itemTypeToPopulate == PopupPopulator.Item.SHORTCUT) {
258+ item.setAccessibilityDelegate(mAccessibilityDelegate);
246259 }
247260
248261 boolean shouldAddBottomMargin = nextItemTypeToPopulate != null
249262 && itemTypeToPopulate.isShortcut ^ nextItemTypeToPopulate.isShortcut;
250263
251- item.setAccessibilityDelegate(mAccessibilityDelegate);
252264 if (itemTypeToPopulate.isShortcut) {
253265 if (mShortcutsItemView == null) {
254266 mShortcutsItemView = (ShortcutsItemView) inflater.inflate(
@@ -266,9 +278,6 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
266278 }
267279 }
268280 }
269- // TODO: update this, since not all items are shortcuts
270- setContentDescription(getContext().getString(R.string.shortcuts_menu_description,
271- numItems, originalIcon.getContentDescription().toString()));
272281 }
273282
274283 protected PopupItemView getItemViewAt(int index) {
Show on old repository browser