summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/accessibility
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-09-25 11:50:16 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-09-25 11:50:16 -0700
commit9d4380856ff41ecb26c0d5aee1747b6060d2ef0e (patch)
tree59f1195b66f6adab842c52e86c3e83688b835a3b /src/com/android/launcher3/accessibility
parent1f832f85d59600fc4c212dec51a5112a6b7427d5 (diff)
parente78e3d734b577c1ab6dc0738a83600374908ea52 (diff)
downloadandroid_packages_apps_Trebuchet-9d4380856ff41ecb26c0d5aee1747b6060d2ef0e.tar.gz
android_packages_apps_Trebuchet-9d4380856ff41ecb26c0d5aee1747b6060d2ef0e.tar.bz2
android_packages_apps_Trebuchet-9d4380856ff41ecb26c0d5aee1747b6060d2ef0e.zip
resolved conflicts for e78e3d73 to ub-launcher3-master
Change-Id: Idc119a57e21cf6016ee0fd91866839301db072d6
Diffstat (limited to 'src/com/android/launcher3/accessibility')
-rw-r--r--src/com/android/launcher3/accessibility/DragViewStateAnnouncer.java57
-rw-r--r--src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java7
-rw-r--r--src/com/android/launcher3/accessibility/WorkspaceAccessibilityHelper.java37
3 files changed, 80 insertions, 21 deletions
diff --git a/src/com/android/launcher3/accessibility/DragViewStateAnnouncer.java b/src/com/android/launcher3/accessibility/DragViewStateAnnouncer.java
new file mode 100644
index 000000000..b5e6194a0
--- /dev/null
+++ b/src/com/android/launcher3/accessibility/DragViewStateAnnouncer.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2015 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.content.Context;
+import android.view.View;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityManager;
+
+/**
+ * Periodically sends accessibility events to announce ongoing state changed. Based on the
+ * implementation in ProgressBar.
+ */
+public class DragViewStateAnnouncer implements Runnable {
+
+ private static final int TIMEOUT_SEND_ACCESSIBILITY_EVENT = 200;
+
+ private final View mTargetView;
+
+ private DragViewStateAnnouncer(View view) {
+ mTargetView = view;
+ }
+
+ public void announce(CharSequence msg) {
+ mTargetView.setContentDescription(msg);
+ mTargetView.removeCallbacks(this);
+ mTargetView.postDelayed(this, TIMEOUT_SEND_ACCESSIBILITY_EVENT);
+ }
+
+ @Override
+ public void run() {
+ mTargetView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
+ }
+
+ public static DragViewStateAnnouncer createFor(View v) {
+ if (((AccessibilityManager) v.getContext().getSystemService(Context.ACCESSIBILITY_SERVICE))
+ .isEnabled()) {
+ return new DragViewStateAnnouncer(v);
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
index 947968587..f8bf5a85b 100644
--- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
@@ -134,11 +134,8 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
public boolean performAction(final View host, final ItemInfo item, int action) {
if (action == REMOVE) {
- if (DeleteDropTarget.removeWorkspaceOrFolderItem(mLauncher, item, host)) {
- announceConfirmation(R.string.item_removed);
- return true;
- }
- return false;
+ DeleteDropTarget.removeWorkspaceOrFolderItem(mLauncher, item, host);
+ return true;
} else if (action == INFO) {
InfoDropTarget.startDetailsActivityForInfo(item, mLauncher);
return true;
diff --git a/src/com/android/launcher3/accessibility/WorkspaceAccessibilityHelper.java b/src/com/android/launcher3/accessibility/WorkspaceAccessibilityHelper.java
index 80ddc13b7..73b824bb5 100644
--- a/src/com/android/launcher3/accessibility/WorkspaceAccessibilityHelper.java
+++ b/src/com/android/launcher3/accessibility/WorkspaceAccessibilityHelper.java
@@ -16,6 +16,7 @@
package com.android.launcher3.accessibility;
+import android.content.Context;
import android.text.TextUtils;
import android.view.View;
@@ -140,26 +141,30 @@ public class WorkspaceAccessibilityHelper extends DragAndDropAccessibilityDelega
return mContext.getString(R.string.move_to_empty_cell, y + 1, x + 1);
}
} else {
- ItemInfo info = (ItemInfo) child.getTag();
- if (info instanceof ShortcutInfo) {
- return mContext.getString(R.string.create_folder_with, info.title);
- } else if (info instanceof FolderInfo) {
- if (TextUtils.isEmpty(info.title)) {
- // Find the first item in the folder.
- FolderInfo folder = (FolderInfo) info;
- ShortcutInfo firstItem = null;
- for (ShortcutInfo shortcut : folder.contents) {
- if (firstItem == null || firstItem.rank > shortcut.rank) {
- firstItem = shortcut;
- }
- }
+ return getDescriptionForDropOver(child, mContext);
+ }
+ }
- if (firstItem != null) {
- return mContext.getString(R.string.add_to_folder_with_app, firstItem.title);
+ public static String getDescriptionForDropOver(View overChild, Context context) {
+ ItemInfo info = (ItemInfo) overChild.getTag();
+ if (info instanceof ShortcutInfo) {
+ return context.getString(R.string.create_folder_with, info.title);
+ } else if (info instanceof FolderInfo) {
+ if (TextUtils.isEmpty(info.title)) {
+ // Find the first item in the folder.
+ FolderInfo folder = (FolderInfo) info;
+ ShortcutInfo firstItem = null;
+ for (ShortcutInfo shortcut : folder.contents) {
+ if (firstItem == null || firstItem.rank > shortcut.rank) {
+ firstItem = shortcut;
}
}
- return mContext.getString(R.string.add_to_folder, info.title);
+
+ if (firstItem != null) {
+ return context.getString(R.string.add_to_folder_with_app, firstItem.title);
+ }
}
+ return context.getString(R.string.add_to_folder, info.title);
}
return "";
}