summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-06-29 20:10:49 -0700
committerWinson Chung <winsonc@google.com>2011-06-29 20:11:07 -0700
commit6a0f57dfafced837a2a282d8feec28d5418be3b9 (patch)
tree4d3c2d584509c239aefce01dbe14fda6569f0b3e /src
parente87b924efaaf1cfb555a4327dc653929a4c182f1 (diff)
downloadandroid_packages_apps_Trebuchet-6a0f57dfafced837a2a282d8feec28d5418be3b9.tar.gz
android_packages_apps_Trebuchet-6a0f57dfafced837a2a282d8feec28d5418be3b9.tar.bz2
android_packages_apps_Trebuchet-6a0f57dfafced837a2a282d8feec28d5418be3b9.zip
Populating some more accessibility events.
Change-Id: I7813abdd6dcc0979949caec9e31029486be0396d
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java15
-rw-r--r--src/com/android/launcher2/FolderIcon.java2
-rw-r--r--src/com/android/launcher2/PagedView.java51
-rw-r--r--src/com/android/launcher2/PagedViewWidget.java5
-rw-r--r--src/com/android/launcher2/Workspace.java7
5 files changed, 77 insertions, 3 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 5696b5029..54a2e42ff 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -1192,4 +1192,19 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
final int count = getChildCount();
return Math.min(page + 2, count - 1);
}
+
+ @Override
+ protected String getCurrentPageDescription() {
+ int page = (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage;
+ int stringId = R.string.default_scroll_format;
+ switch (mContentType) {
+ case Applications:
+ stringId = R.string.apps_customize_apps_scroll_format;
+ break;
+ case Widgets:
+ stringId = R.string.apps_customize_widgets_scroll_format;
+ break;
+ }
+ return String.format(mContext.getString(stringId), page + 1, getChildCount());
+ }
}
diff --git a/src/com/android/launcher2/FolderIcon.java b/src/com/android/launcher2/FolderIcon.java
index 059711051..bae2fd77c 100644
--- a/src/com/android/launcher2/FolderIcon.java
+++ b/src/com/android/launcher2/FolderIcon.java
@@ -95,6 +95,7 @@ public class FolderIcon extends LinearLayout implements FolderListener {
icon.mFolderName = (BubbleTextView) icon.findViewById(R.id.folder_name);
icon.mFolderName.setText(folderInfo.title);
icon.mPreviewBackground = (ImageView) icon.findViewById(R.id.preview_background);
+ icon.mPreviewBackground.setContentDescription(folderInfo.title);
icon.setTag(folderInfo);
icon.setOnClickListener(launcher);
@@ -383,5 +384,6 @@ public class FolderIcon extends LinearLayout implements FolderListener {
public void onTitleChanged(CharSequence title) {
mFolderName.setText(title.toString());
+ mPreviewBackground.setContentDescription(title.toString());
}
}
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index fa6a57009..9ca2f90ff 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -16,8 +16,6 @@
package com.android.launcher2;
-import java.util.ArrayList;
-
import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.animation.AnimatorListenerAdapter;
@@ -39,6 +37,8 @@ import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.Interpolator;
import android.widget.Checkable;
import android.widget.ImageView;
@@ -46,6 +46,8 @@ import android.widget.Scroller;
import com.android.launcher.R;
+import java.util.ArrayList;
+
/**
* An abstraction of the original Workspace which supports browsing through a
* sequential list of "pages"
@@ -1699,4 +1701,49 @@ public abstract class PagedView extends ViewGroup {
int indicatorPos = (int) (offset * pageWidth) + pageOffset + indicatorCenterOffset;
mScrollIndicator.setTranslationX(indicatorPos);
}
+
+ /* Accessibility */
+ @Override
+ public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
+ super.onInitializeAccessibilityNodeInfo(info);
+ info.setScrollable(true);
+ }
+
+ @Override
+ public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
+ super.onInitializeAccessibilityEvent(event);
+ event.setScrollable(true);
+ if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
+ event.setFromIndex(mCurrentPage);
+ event.setToIndex(mCurrentPage);
+ event.setItemCount(getChildCount());
+ }
+ }
+
+ @Override
+ public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
+ // Do not append text content to scroll events they are fired frequently
+ // and the client has already received another event type with the text.
+ if (event.getEventType() != AccessibilityEvent.TYPE_VIEW_SCROLLED) {
+ super.dispatchPopulateAccessibilityEvent(event);
+ }
+
+ onPopulateAccessibilityEvent(event);
+ return false;
+ }
+
+ @Override
+ public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
+ super.onPopulateAccessibilityEvent(event);
+
+ if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
+ event.getText().add(getCurrentPageDescription());
+ }
+ }
+
+ protected String getCurrentPageDescription() {
+ int page = (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage;
+ return String.format(mContext.getString(R.string.default_scroll_format),
+ page + 1, getChildCount());
+ }
}
diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java
index 365965d13..d9c2a84a1 100644
--- a/src/com/android/launcher2/PagedViewWidget.java
+++ b/src/com/android/launcher2/PagedViewWidget.java
@@ -105,6 +105,7 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
image.setMaxWidth(maxWidth);
}
image.setImageDrawable(preview);
+ image.setContentDescription(info.label);
mPreviewImageView = image;
final TextView name = (TextView) findViewById(R.id.widget_name);
name.setText(info.label);
@@ -117,11 +118,13 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
public void applyFromResolveInfo(PackageManager pm, ResolveInfo info,
FastBitmapDrawable preview, HolographicOutlineHelper holoOutlineHelper) {
mHolographicOutlineHelper = holoOutlineHelper;
+ CharSequence label = info.loadLabel(pm);
final ImageView image = (ImageView) findViewById(R.id.widget_preview);
image.setImageDrawable(preview);
+ image.setContentDescription(label);
mPreviewImageView = image;
final TextView name = (TextView) findViewById(R.id.widget_name);
- name.setText(info.loadLabel(pm));
+ name.setText(label);
name.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
final TextView dims = (TextView) findViewById(R.id.widget_dims);
if (dims != null) {
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 4eea5c3a8..e53768d5b 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -3477,4 +3477,11 @@ public class Workspace extends SmoothPagedView
@Override
public void syncPageItems(int page) {
}
+
+ @Override
+ protected String getCurrentPageDescription() {
+ int page = (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage;
+ return String.format(mContext.getString(R.string.workspace_scroll_format),
+ page + 1, getChildCount());
+ }
}