diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2013-08-23 20:37:28 -0700 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2013-08-27 08:26:13 -0700 |
commit | cb8ed39b3fb591be60b9fb1799d4ea4530eab758 (patch) | |
tree | b84af2b07ad0860f8e3e02ff8b6e37a28e82576f | |
parent | 94366313331a789440a3c077173aafcb85cabe78 (diff) | |
download | frameworks_base-cb8ed39b3fb591be60b9fb1799d4ea4530eab758.zip frameworks_base-cb8ed39b3fb591be60b9fb1799d4ea4530eab758.tar.gz frameworks_base-cb8ed39b3fb591be60b9fb1799d4ea4530eab758.tar.bz2 |
Update AccessibilityNodeInfo API as per API council request
bug:10461302
Change-Id: I9709a271ab3720e064b98c79c0950d811fe37b73
-rw-r--r-- | api/current.txt | 18 | ||||
-rw-r--r-- | core/java/android/view/accessibility/AccessibilityNodeInfo.java | 206 | ||||
-rw-r--r-- | core/java/android/widget/ActivityChooserView.java | 2 | ||||
-rw-r--r-- | core/java/android/widget/Spinner.java | 2 | ||||
-rw-r--r-- | core/java/com/android/internal/view/menu/ActionMenuPresenter.java | 2 | ||||
-rw-r--r-- | core/java/com/android/internal/view/menu/ListMenuItemView.java | 2 |
6 files changed, 128 insertions, 104 deletions
diff --git a/api/current.txt b/api/current.txt index 27a8480..70c33c4 100644 --- a/api/current.txt +++ b/api/current.txt @@ -28553,6 +28553,7 @@ package android.view.accessibility { method public void addAction(int); method public void addChild(android.view.View); method public void addChild(android.view.View, int); + method public boolean canOpenPopup(); method public int describeContents(); method public java.util.List<android.view.accessibility.AccessibilityNodeInfo> findAccessibilityNodeInfosByText(java.lang.String); method public java.util.List<android.view.accessibility.AccessibilityNodeInfo> findAccessibilityNodeInfosByViewId(java.lang.String); @@ -28561,18 +28562,17 @@ package android.view.accessibility { method public int getActions(); method public void getBoundsInParent(android.graphics.Rect); method public void getBoundsInScreen(android.graphics.Rect); - method public android.os.Bundle getBundle(); method public android.view.accessibility.AccessibilityNodeInfo getChild(int); method public int getChildCount(); method public java.lang.CharSequence getClassName(); method public android.view.accessibility.AccessibilityNodeInfo.CollectionInfo getCollectionInfo(); method public android.view.accessibility.AccessibilityNodeInfo.CollectionItemInfo getCollectionItemInfo(); method public java.lang.CharSequence getContentDescription(); + method public android.os.Bundle getExtras(); method public int getInputType(); method public android.view.accessibility.AccessibilityNodeInfo getLabelFor(); method public android.view.accessibility.AccessibilityNodeInfo getLabeledBy(); method public int getMovementGranularities(); - method public boolean getOpensPopup(); method public java.lang.CharSequence getPackageName(); method public android.view.accessibility.AccessibilityNodeInfo getParent(); method public android.view.accessibility.AccessibilityNodeInfo.RangeInfo getRangeInfo(); @@ -28611,6 +28611,7 @@ package android.view.accessibility { method public void setAccessibilityFocused(boolean); method public void setBoundsInParent(android.graphics.Rect); method public void setBoundsInScreen(android.graphics.Rect); + method public void setCanOpenPopup(boolean); method public void setCheckable(boolean); method public void setChecked(boolean); method public void setClassName(java.lang.CharSequence); @@ -28635,7 +28636,6 @@ package android.view.accessibility { method public void setLongClickable(boolean); method public void setMovementGranularities(int); method public void setMultiLine(boolean); - method public void setOpensPopup(boolean); method public void setPackageName(java.lang.CharSequence); method public void setParent(android.view.View); method public void setParent(android.view.View, int); @@ -28687,17 +28687,17 @@ package android.view.accessibility { } public static final class AccessibilityNodeInfo.CollectionInfo { - method public int getHorizontalSize(); - method public int getVerticalSize(); + method public int getColumnCount(); + method public int getRowCount(); method public boolean isHierarchical(); method public static android.view.accessibility.AccessibilityNodeInfo.CollectionInfo obtain(int, int, boolean); } public static final class AccessibilityNodeInfo.CollectionItemInfo { - method public int getHorizontalPosition(); - method public int getHorizontalSpan(); - method public int getVerticalPosition(); - method public int getVerticalSpan(); + method public int getColumnIndex(); + method public int getColumnSpan(); + method public int getRowIndex(); + method public int getRowSpan(); method public boolean isHeading(); method public static android.view.accessibility.AccessibilityNodeInfo.CollectionItemInfo obtain(int, int, int, int, boolean); } diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java index 6d54094..ba63421 100644 --- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java +++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java @@ -518,7 +518,7 @@ public class AccessibilityNodeInfo implements Parcelable { private int mTextSelectionEnd = UNDEFINED; private int mInputType = InputType.TYPE_NULL; - private Bundle mBundle; + private Bundle mExtras; private int mConnectionId = UNDEFINED; @@ -1471,9 +1471,18 @@ public class AccessibilityNodeInfo implements Parcelable { } /** - * Gets if the node is a live region for whose changes the user - * should be notified. It is the responsibility of the accessibility + * Gets if the node is a live region. + * <p> + * A live region is a node that contains information that is important + * for the user and when it changes the user has to be notified. For + * example, if the user plays a video and the application shows a + * progress indicator with the percentage of buffering, then the progress + * indicator should be marked as a live region. + * </p> + * <p> + * It is the responsibility of the accessibility * service to monitor this region and notify the user if it changes. + * </p> * * @return If the node is a live region. */ @@ -1525,7 +1534,7 @@ public class AccessibilityNodeInfo implements Parcelable { * * @return If the the node opens a popup. */ - public boolean getOpensPopup() { + public boolean canOpenPopup() { return getBooleanProperty(BOOLEAN_PROPERTY_OPENS_POPUP); } @@ -1539,7 +1548,8 @@ public class AccessibilityNodeInfo implements Parcelable { * * @param opensPopup If the the node opens a popup. */ - public void setOpensPopup(boolean opensPopup) { + public void setCanOpenPopup(boolean opensPopup) { + enforceNotSealed(); setBooleanProperty(BOOLEAN_PROPERTY_OPENS_POPUP, opensPopup); } @@ -1927,7 +1937,7 @@ public class AccessibilityNodeInfo implements Parcelable { } /** - * Gets an optional bundle with additional data. The bundle + * Gets an optional bundle with extra data. The bundle * is lazily created and never <code>null</code>. * <p> * <strong>Note:</strong> It is recommended to use the package @@ -1939,11 +1949,11 @@ public class AccessibilityNodeInfo implements Parcelable { * * @return The bundle. */ - public Bundle getBundle() { - if (mBundle == null) { - mBundle = new Bundle(); + public Bundle getExtras() { + if (mExtras == null) { + mExtras = new Bundle(); } - return mBundle; + return mExtras; } /** @@ -2194,9 +2204,9 @@ public class AccessibilityNodeInfo implements Parcelable { parcel.writeInt(mTextSelectionEnd); parcel.writeInt(mInputType); - if (mBundle != null) { + if (mExtras != null) { parcel.writeInt(1); - parcel.writeBundle(mBundle); + parcel.writeBundle(mExtras); } else { parcel.writeInt(0); } @@ -2213,8 +2223,8 @@ public class AccessibilityNodeInfo implements Parcelable { if (mCollectionInfo != null) { parcel.writeInt(1); - parcel.writeInt(mCollectionInfo.getHorizontalSize()); - parcel.writeInt(mCollectionInfo.getVerticalSize()); + parcel.writeInt(mCollectionInfo.getRowCount()); + parcel.writeInt(mCollectionInfo.getColumnCount()); parcel.writeInt(mCollectionInfo.isHierarchical() ? 1 : 0); } else { parcel.writeInt(0); @@ -2222,10 +2232,10 @@ public class AccessibilityNodeInfo implements Parcelable { if (mCollectionItemInfo != null) { parcel.writeInt(1); - parcel.writeInt(mCollectionItemInfo.getHorizontalPosition()); - parcel.writeInt(mCollectionItemInfo.getHorizontalSpan()); - parcel.writeInt(mCollectionItemInfo.getVerticalPosition()); - parcel.writeInt(mCollectionItemInfo.getVerticalSpan()); + parcel.writeInt(mCollectionItemInfo.getColumnIndex()); + parcel.writeInt(mCollectionItemInfo.getColumnSpan()); + parcel.writeInt(mCollectionItemInfo.getRowIndex()); + parcel.writeInt(mCollectionItemInfo.getRowSpan()); parcel.writeInt(mCollectionItemInfo.isHeading() ? 1 : 0); } else { parcel.writeInt(0); @@ -2266,8 +2276,8 @@ public class AccessibilityNodeInfo implements Parcelable { mTextSelectionStart = other.mTextSelectionStart; mTextSelectionEnd = other.mTextSelectionEnd; mInputType = other.mInputType; - if (other.mBundle != null && !other.mBundle.isEmpty()) { - getBundle().putAll(other.mBundle); + if (other.mExtras != null && !other.mExtras.isEmpty()) { + getExtras().putAll(other.mExtras); } mRangeInfo = other.mRangeInfo; mCollectionInfo = other.mCollectionInfo; @@ -2323,7 +2333,7 @@ public class AccessibilityNodeInfo implements Parcelable { mInputType = parcel.readInt(); if (parcel.readInt() == 1) { - getBundle().putAll(parcel.readBundle()); + getExtras().putAll(parcel.readBundle()); } if (parcel.readInt() == 1) { @@ -2376,8 +2386,8 @@ public class AccessibilityNodeInfo implements Parcelable { mTextSelectionStart = UNDEFINED; mTextSelectionEnd = UNDEFINED; mInputType = InputType.TYPE_NULL; - if (mBundle != null) { - mBundle.clear(); + if (mExtras != null) { + mExtras.clear(); } if (mRangeInfo != null) { mRangeInfo.recycle(); @@ -2677,7 +2687,15 @@ public class AccessibilityNodeInfo implements Parcelable { /** * Class with information if a node is a collection. Use - * {@link CollectionInfo#obtain(int, int, boolean) to an instance. + * {@link CollectionInfo#obtain(int, int, boolean)} to get an instance. + * <p> + * A collection of items has rows and columns and may be hierarchical. + * For example, a horizontal list is a collection with one column, as + * many rows as the list items, and is not hierarchical; A table is a + * collection with several rows, several columns, and is not hierarchical; + * A vertical tree is a hierarchical collection with one column and + * as many rows as the first level children. + * </p> */ public static final class CollectionInfo { private static final int MAX_POOL_SIZE = 20; @@ -2685,54 +2703,54 @@ public class AccessibilityNodeInfo implements Parcelable { private static final SynchronizedPool<CollectionInfo> sPool = new SynchronizedPool<CollectionInfo>(MAX_POOL_SIZE); - private int mHorizontalSize; - private int mVerticalSize; + private int mRowCount; + private int mColumnCount; private boolean mHierarchical; /** * Obtains a pooled instance. * - * @param horizontalSize The horizontal size. - * @param verticalSize The vertical size. + * @param rowCount The number of rows. + * @param columnCount The number of columns. * @param hierarchical Whether the collection is hierarchical. */ - public static CollectionInfo obtain(int horizontalSize, int verticalSize, + public static CollectionInfo obtain(int rowCount, int columnCount, boolean hierarchical) { CollectionInfo info = sPool.acquire(); - return (info != null) ? info : new CollectionInfo(horizontalSize, - verticalSize, hierarchical); + return (info != null) ? info : new CollectionInfo(rowCount, + columnCount, hierarchical); } /** * Creates a new instance. * - * @param horizontalSize The horizontal size. - * @param verticalSize The vertical size. + * @param rowCount The number of rows. + * @param columnCount The number of columns. * @param hierarchical Whether the collection is hierarchical. */ - private CollectionInfo(int horizontalSize, int verticalSize, + private CollectionInfo(int rowCount, int columnCount, boolean hierarchical) { - mHorizontalSize = horizontalSize; - mVerticalSize = verticalSize; + mRowCount = rowCount; + mColumnCount = columnCount; mHierarchical = hierarchical; } /** - * Gets the horizontal size in terms of item positions. + * Gets the number of rows. * - * @return The size. + * @return The row count. */ - public int getHorizontalSize() { - return mHorizontalSize; + public int getRowCount() { + return mRowCount; } /** - * Gets the vertical size in terms of item positions. + * Gets the number of columns. * - * @return The size. + * @return The column count. */ - public int getVerticalSize() { - return mVerticalSize; + public int getColumnCount() { + return mColumnCount; } /** @@ -2753,15 +2771,23 @@ public class AccessibilityNodeInfo implements Parcelable { } private void clear() { - mHorizontalSize = 0; - mVerticalSize = 0; + mRowCount = 0; + mColumnCount = 0; mHierarchical = false; } } /** * Class with information if a node is a collection item. Use - * {@link CollectionItemInfo#obtain(int, int, int, int, boolean) to get an instance. + * {@link CollectionItemInfo#obtain(int, int, int, int, boolean)} + * to get an instance. + * <p> + * A collection item is contained in a collection, it starts at + * a given row and column in the collection, and spans one or + * more rows and columns. For example, a header of two related + * table columns starts at the first row and the first column, + * spans one row and two columns. + * </p> */ public static final class CollectionItemInfo { private static final int MAX_POOL_SIZE = 20; @@ -2772,79 +2798,77 @@ public class AccessibilityNodeInfo implements Parcelable { /** * Obtains a pooled instance. * - * @param horizontalPosition The horizontal item position. - * @param horizontalSpan The horizontal item span. - * @param verticalPosition The vertical item position. - * @param verticalSpan The vertical item span. + * @param rowIndex The row index at which the item is located. + * @param rowSpan The number of rows the item spans. + * @param columnIndex The column index at which the item is located. + * @param columnSpan The number of columns the item spans. * @param heading Whether the item is a heading. */ - public static CollectionItemInfo obtain(int horizontalPosition, int horizontalSpan, - int verticalPosition, int verticalSpan, boolean heading) { + public static CollectionItemInfo obtain(int rowIndex, int rowSpan, + int columnIndex, int columnSpan, boolean heading) { CollectionItemInfo info = sPool.acquire(); - return (info != null) ? info : new CollectionItemInfo(horizontalPosition, - horizontalSpan, verticalPosition, verticalSpan, heading); + return (info != null) ? info : new CollectionItemInfo(rowIndex, + rowSpan, columnIndex, columnSpan, heading); } private boolean mHeading; - private int mHorizontalPosition; - private int mVerticalPosition; - private int mHorizontalSpan; - private int mVerticalSpan; + private int mColumnIndex; + private int mRowIndex; + private int mColumnSpan; + private int mRowSpan; /** * Creates a new instance. * - * @param horizontalPosition The horizontal item position. - * @param horizontalSpan The horizontal item span. - * @param verticalPosition The vertical item position. - * @param verticalSpan The vertical item span. + * @param rowIndex The row index at which the item is located. + * @param rowSpan The number of rows the item spans. + * @param columnIndex The column index at which the item is located. + * @param columnSpan The number of columns the item spans. * @param heading Whether the item is a heading. */ - private CollectionItemInfo(int horizontalPosition, int horizontalSpan, - int verticalPosition, int verticalSpan, boolean heading) { - mHorizontalPosition = horizontalPosition; - mHorizontalSpan = horizontalSpan; - mVerticalPosition = verticalPosition; - mVerticalSpan = verticalSpan; + private CollectionItemInfo(int rowIndex, int rowSpan, + int columnIndex, int columnSpan, boolean heading) { + mRowIndex = rowIndex; + mRowSpan = rowSpan; + mColumnIndex = columnIndex; + mColumnSpan = columnSpan; mHeading = heading; } /** - * Gets the horizontal item position in the parent collection. + * Gets the column index at which the item is located. * - * @return The position. + * @return The column index. */ - public int getHorizontalPosition() { - return mHorizontalPosition; + public int getColumnIndex() { + return mColumnIndex; } /** - * Gets the vertical item position in the parent collection. + * Gets the row index at which the item is located. * - * @return The position. + * @return The row index. */ - public int getVerticalPosition() { - return mVerticalPosition; + public int getRowIndex() { + return mRowIndex; } /** - * Gets the horizontal span in terms of item positions - * of the parent collection. + * Gets the number of columns the item spans. * - * @return The span. + * @return The column span. */ - public int getHorizontalSpan() { - return mHorizontalSpan; + public int getColumnSpan() { + return mColumnSpan; } /** - * Gets the vertical span in terms of item positions - * of the parent collection. + * Gets the number of rows the item spans. * - * @return The span. + * @return The row span. */ - public int getVerticalSpan() { - return mVerticalSpan; + public int getRowSpan() { + return mRowSpan; } /** @@ -2866,10 +2890,10 @@ public class AccessibilityNodeInfo implements Parcelable { } private void clear() { - mHorizontalPosition = 0; - mHorizontalSpan = 0; - mVerticalPosition = 0; - mVerticalSpan = 0; + mColumnIndex = 0; + mColumnSpan = 0; + mRowIndex = 0; + mRowSpan = 0; mHeading = false; } } diff --git a/core/java/android/widget/ActivityChooserView.java b/core/java/android/widget/ActivityChooserView.java index c070ee4..778c8db 100644 --- a/core/java/android/widget/ActivityChooserView.java +++ b/core/java/android/widget/ActivityChooserView.java @@ -234,7 +234,7 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod @Override public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(host, info); - info.setOpensPopup(true); + info.setCanOpenPopup(true); } }); mExpandActivityOverflowButtonImage = diff --git a/core/java/android/widget/Spinner.java b/core/java/android/widget/Spinner.java index 7c7df96..c65b667 100644 --- a/core/java/android/widget/Spinner.java +++ b/core/java/android/widget/Spinner.java @@ -675,7 +675,7 @@ public class Spinner extends AbsSpinner implements OnClickListener { info.setClassName(Spinner.class.getName()); if (mAdapter != null) { - info.setOpensPopup(true); + info.setCanOpenPopup(true); } } diff --git a/core/java/com/android/internal/view/menu/ActionMenuPresenter.java b/core/java/com/android/internal/view/menu/ActionMenuPresenter.java index 5d0a603..0fed4a4 100644 --- a/core/java/com/android/internal/view/menu/ActionMenuPresenter.java +++ b/core/java/com/android/internal/view/menu/ActionMenuPresenter.java @@ -630,7 +630,7 @@ public class ActionMenuPresenter extends BaseMenuPresenter @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); - info.setOpensPopup(true); + info.setCanOpenPopup(true); } } diff --git a/core/java/com/android/internal/view/menu/ListMenuItemView.java b/core/java/com/android/internal/view/menu/ListMenuItemView.java index 85d9cbd..a2a4acc 100644 --- a/core/java/com/android/internal/view/menu/ListMenuItemView.java +++ b/core/java/com/android/internal/view/menu/ListMenuItemView.java @@ -276,7 +276,7 @@ public class ListMenuItemView extends LinearLayout implements MenuView.ItemView super.onInitializeAccessibilityNodeInfo(info); if (mItemData != null && mItemData.hasSubMenu()) { - info.setOpensPopup(true); + info.setCanOpenPopup(true); } } } |