Merge "Add selection properties to CollectionInfo, CollectionItemInfo"
This commit is contained in:
committed by
Android (Google) Code Review
commit
7d57765db9
@@ -30255,8 +30255,12 @@ package android.view.accessibility {
|
|||||||
public static final class AccessibilityNodeInfo.CollectionInfo {
|
public static final class AccessibilityNodeInfo.CollectionInfo {
|
||||||
method public int getColumnCount();
|
method public int getColumnCount();
|
||||||
method public int getRowCount();
|
method public int getRowCount();
|
||||||
|
method public int getSelectionMode();
|
||||||
method public boolean isHierarchical();
|
method public boolean isHierarchical();
|
||||||
method public static android.view.accessibility.AccessibilityNodeInfo.CollectionInfo obtain(int, int, boolean);
|
method public static android.view.accessibility.AccessibilityNodeInfo.CollectionInfo obtain(int, int, boolean);
|
||||||
|
field public static final int SELECTION_MODE_MULTIPLE = 2; // 0x2
|
||||||
|
field public static final int SELECTION_MODE_NONE = 0; // 0x0
|
||||||
|
field public static final int SELECTION_MODE_SINGLE = 1; // 0x1
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class AccessibilityNodeInfo.CollectionItemInfo {
|
public static final class AccessibilityNodeInfo.CollectionItemInfo {
|
||||||
@@ -30265,6 +30269,7 @@ package android.view.accessibility {
|
|||||||
method public int getRowIndex();
|
method public int getRowIndex();
|
||||||
method public int getRowSpan();
|
method public int getRowSpan();
|
||||||
method public boolean isHeading();
|
method public boolean isHeading();
|
||||||
|
method public boolean isSelected();
|
||||||
method public static android.view.accessibility.AccessibilityNodeInfo.CollectionItemInfo obtain(int, int, int, int, boolean);
|
method public static android.view.accessibility.AccessibilityNodeInfo.CollectionItemInfo obtain(int, int, int, int, boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2283,6 +2283,7 @@ public class AccessibilityNodeInfo implements Parcelable {
|
|||||||
parcel.writeInt(mCollectionInfo.getRowCount());
|
parcel.writeInt(mCollectionInfo.getRowCount());
|
||||||
parcel.writeInt(mCollectionInfo.getColumnCount());
|
parcel.writeInt(mCollectionInfo.getColumnCount());
|
||||||
parcel.writeInt(mCollectionInfo.isHierarchical() ? 1 : 0);
|
parcel.writeInt(mCollectionInfo.isHierarchical() ? 1 : 0);
|
||||||
|
parcel.writeInt(mCollectionInfo.getSelectionMode());
|
||||||
} else {
|
} else {
|
||||||
parcel.writeInt(0);
|
parcel.writeInt(0);
|
||||||
}
|
}
|
||||||
@@ -2294,6 +2295,7 @@ public class AccessibilityNodeInfo implements Parcelable {
|
|||||||
parcel.writeInt(mCollectionItemInfo.getRowIndex());
|
parcel.writeInt(mCollectionItemInfo.getRowIndex());
|
||||||
parcel.writeInt(mCollectionItemInfo.getRowSpan());
|
parcel.writeInt(mCollectionItemInfo.getRowSpan());
|
||||||
parcel.writeInt(mCollectionItemInfo.isHeading() ? 1 : 0);
|
parcel.writeInt(mCollectionItemInfo.isHeading() ? 1 : 0);
|
||||||
|
parcel.writeInt(mCollectionItemInfo.isSelected() ? 1 : 0);
|
||||||
} else {
|
} else {
|
||||||
parcel.writeInt(0);
|
parcel.writeInt(0);
|
||||||
}
|
}
|
||||||
@@ -2420,7 +2422,8 @@ public class AccessibilityNodeInfo implements Parcelable {
|
|||||||
mCollectionInfo = CollectionInfo.obtain(
|
mCollectionInfo = CollectionInfo.obtain(
|
||||||
parcel.readInt(),
|
parcel.readInt(),
|
||||||
parcel.readInt(),
|
parcel.readInt(),
|
||||||
parcel.readInt() == 1);
|
parcel.readInt() == 1,
|
||||||
|
parcel.readInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parcel.readInt() == 1) {
|
if (parcel.readInt() == 1) {
|
||||||
@@ -2429,6 +2432,7 @@ public class AccessibilityNodeInfo implements Parcelable {
|
|||||||
parcel.readInt(),
|
parcel.readInt(),
|
||||||
parcel.readInt(),
|
parcel.readInt(),
|
||||||
parcel.readInt(),
|
parcel.readInt(),
|
||||||
|
parcel.readInt() == 1,
|
||||||
parcel.readInt() == 1);
|
parcel.readInt() == 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2786,6 +2790,15 @@ public class AccessibilityNodeInfo implements Parcelable {
|
|||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public static final class CollectionInfo {
|
public static final class CollectionInfo {
|
||||||
|
/** Selection mode where items are not selectable. */
|
||||||
|
public static final int SELECTION_MODE_NONE = 0;
|
||||||
|
|
||||||
|
/** Selection mode where a single item may be selected. */
|
||||||
|
public static final int SELECTION_MODE_SINGLE = 1;
|
||||||
|
|
||||||
|
/** Selection mode where multiple items may be selected. */
|
||||||
|
public static final int SELECTION_MODE_MULTIPLE = 2;
|
||||||
|
|
||||||
private static final int MAX_POOL_SIZE = 20;
|
private static final int MAX_POOL_SIZE = 20;
|
||||||
|
|
||||||
private static final SynchronizedPool<CollectionInfo> sPool =
|
private static final SynchronizedPool<CollectionInfo> sPool =
|
||||||
@@ -2794,17 +2807,17 @@ public class AccessibilityNodeInfo implements Parcelable {
|
|||||||
private int mRowCount;
|
private int mRowCount;
|
||||||
private int mColumnCount;
|
private int mColumnCount;
|
||||||
private boolean mHierarchical;
|
private boolean mHierarchical;
|
||||||
|
private int mSelectionMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtains a pooled instance that is a clone of another one.
|
* Obtains a pooled instance that is a clone of another one.
|
||||||
*
|
*
|
||||||
* @param other The instance to clone.
|
* @param other The instance to clone.
|
||||||
*
|
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static CollectionInfo obtain(CollectionInfo other) {
|
public static CollectionInfo obtain(CollectionInfo other) {
|
||||||
return CollectionInfo.obtain(other.mRowCount, other.mColumnCount,
|
return CollectionInfo.obtain(other.mRowCount, other.mColumnCount, other.mHierarchical,
|
||||||
other.mHierarchical);
|
other.mSelectionMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2814,15 +2827,35 @@ public class AccessibilityNodeInfo implements Parcelable {
|
|||||||
* @param columnCount The number of columns.
|
* @param columnCount The number of columns.
|
||||||
* @param hierarchical Whether the collection is hierarchical.
|
* @param hierarchical Whether the collection is hierarchical.
|
||||||
*/
|
*/
|
||||||
public static CollectionInfo obtain(int rowCount, int columnCount, boolean hierarchical) {
|
public static CollectionInfo obtain(int rowCount, int columnCount,
|
||||||
final CollectionInfo info = sPool.acquire();
|
boolean hierarchical) {
|
||||||
|
return obtain(rowCount, columnCount, hierarchical, SELECTION_MODE_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains a pooled instance.
|
||||||
|
*
|
||||||
|
* @param rowCount The number of rows.
|
||||||
|
* @param columnCount The number of columns.
|
||||||
|
* @param hierarchical Whether the collection is hierarchical.
|
||||||
|
* @param selectionMode The collection's selection mode, one of:
|
||||||
|
* <ul>
|
||||||
|
* <li>{@link #SELECTION_MODE_NONE}
|
||||||
|
* <li>{@link #SELECTION_MODE_SINGLE}
|
||||||
|
* <li>{@link #SELECTION_MODE_MULTIPLE}
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
public static CollectionInfo obtain(int rowCount, int columnCount,
|
||||||
|
boolean hierarchical, int selectionMode) {
|
||||||
|
final CollectionInfo info = sPool.acquire();
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
return new CollectionInfo(rowCount, columnCount, hierarchical);
|
return new CollectionInfo(rowCount, columnCount, hierarchical, selectionMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
info.mRowCount = rowCount;
|
info.mRowCount = rowCount;
|
||||||
info.mColumnCount = columnCount;
|
info.mColumnCount = columnCount;
|
||||||
info.mHierarchical = hierarchical;
|
info.mHierarchical = hierarchical;
|
||||||
|
info.mSelectionMode = selectionMode;
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2832,12 +2865,14 @@ public class AccessibilityNodeInfo implements Parcelable {
|
|||||||
* @param rowCount The number of rows.
|
* @param rowCount The number of rows.
|
||||||
* @param columnCount The number of columns.
|
* @param columnCount The number of columns.
|
||||||
* @param hierarchical Whether the collection is hierarchical.
|
* @param hierarchical Whether the collection is hierarchical.
|
||||||
|
* @param selectionMode The collection's selection mode.
|
||||||
*/
|
*/
|
||||||
private CollectionInfo(int rowCount, int columnCount,
|
private CollectionInfo(int rowCount, int columnCount, boolean hierarchical,
|
||||||
boolean hierarchical) {
|
int selectionMode) {
|
||||||
mRowCount = rowCount;
|
mRowCount = rowCount;
|
||||||
mColumnCount = columnCount;
|
mColumnCount = columnCount;
|
||||||
mHierarchical = hierarchical;
|
mHierarchical = hierarchical;
|
||||||
|
mSelectionMode = selectionMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2867,6 +2902,20 @@ public class AccessibilityNodeInfo implements Parcelable {
|
|||||||
return mHierarchical;
|
return mHierarchical;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the collection's selection mode.
|
||||||
|
*
|
||||||
|
* @return The collection's selection mode, one of:
|
||||||
|
* <ul>
|
||||||
|
* <li>{@link #SELECTION_MODE_NONE}
|
||||||
|
* <li>{@link #SELECTION_MODE_SINGLE}
|
||||||
|
* <li>{@link #SELECTION_MODE_MULTIPLE}
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
public int getSelectionMode() {
|
||||||
|
return mSelectionMode;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recycles this instance.
|
* Recycles this instance.
|
||||||
*/
|
*/
|
||||||
@@ -2879,6 +2928,7 @@ public class AccessibilityNodeInfo implements Parcelable {
|
|||||||
mRowCount = 0;
|
mRowCount = 0;
|
||||||
mColumnCount = 0;
|
mColumnCount = 0;
|
||||||
mHierarchical = false;
|
mHierarchical = false;
|
||||||
|
mSelectionMode = SELECTION_MODE_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2904,12 +2954,11 @@ public class AccessibilityNodeInfo implements Parcelable {
|
|||||||
* Obtains a pooled instance that is a clone of another one.
|
* Obtains a pooled instance that is a clone of another one.
|
||||||
*
|
*
|
||||||
* @param other The instance to clone.
|
* @param other The instance to clone.
|
||||||
*
|
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static CollectionItemInfo obtain(CollectionItemInfo other) {
|
public static CollectionItemInfo obtain(CollectionItemInfo other) {
|
||||||
return CollectionItemInfo.obtain(other.mRowIndex, other.mRowSpan,
|
return CollectionItemInfo.obtain(other.mRowIndex, other.mRowSpan, other.mColumnIndex,
|
||||||
other.mColumnIndex, other.mColumnSpan, other.mHeading);
|
other.mColumnSpan, other.mHeading, other.mSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2921,11 +2970,27 @@ public class AccessibilityNodeInfo implements Parcelable {
|
|||||||
* @param columnSpan The number of columns the item spans.
|
* @param columnSpan The number of columns the item spans.
|
||||||
* @param heading Whether the item is a heading.
|
* @param heading Whether the item is a heading.
|
||||||
*/
|
*/
|
||||||
public static CollectionItemInfo obtain(int rowIndex, int rowSpan, int columnIndex,
|
public static CollectionItemInfo obtain(int rowIndex, int rowSpan,
|
||||||
int columnSpan, boolean heading) {
|
int columnIndex, int columnSpan, boolean heading) {
|
||||||
|
return obtain(rowIndex, rowSpan, columnIndex, columnSpan, heading, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains a pooled instance.
|
||||||
|
*
|
||||||
|
* @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.
|
||||||
|
* @param selected Whether the item is selected.
|
||||||
|
*/
|
||||||
|
public static CollectionItemInfo obtain(int rowIndex, int rowSpan,
|
||||||
|
int columnIndex, int columnSpan, boolean heading, boolean selected) {
|
||||||
final CollectionItemInfo info = sPool.acquire();
|
final CollectionItemInfo info = sPool.acquire();
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
return new CollectionItemInfo(rowIndex, rowSpan, columnIndex, columnSpan, heading);
|
return new CollectionItemInfo(
|
||||||
|
rowIndex, rowSpan, columnIndex, columnSpan, heading, selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
info.mRowIndex = rowIndex;
|
info.mRowIndex = rowIndex;
|
||||||
@@ -2933,6 +2998,7 @@ public class AccessibilityNodeInfo implements Parcelable {
|
|||||||
info.mColumnIndex = columnIndex;
|
info.mColumnIndex = columnIndex;
|
||||||
info.mColumnSpan = columnSpan;
|
info.mColumnSpan = columnSpan;
|
||||||
info.mHeading = heading;
|
info.mHeading = heading;
|
||||||
|
info.mSelected = selected;
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2941,6 +3007,7 @@ public class AccessibilityNodeInfo implements Parcelable {
|
|||||||
private int mRowIndex;
|
private int mRowIndex;
|
||||||
private int mColumnSpan;
|
private int mColumnSpan;
|
||||||
private int mRowSpan;
|
private int mRowSpan;
|
||||||
|
private boolean mSelected;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
@@ -2951,13 +3018,14 @@ public class AccessibilityNodeInfo implements Parcelable {
|
|||||||
* @param columnSpan The number of columns the item spans.
|
* @param columnSpan The number of columns the item spans.
|
||||||
* @param heading Whether the item is a heading.
|
* @param heading Whether the item is a heading.
|
||||||
*/
|
*/
|
||||||
private CollectionItemInfo(int rowIndex, int rowSpan,
|
private CollectionItemInfo(int rowIndex, int rowSpan, int columnIndex, int columnSpan,
|
||||||
int columnIndex, int columnSpan, boolean heading) {
|
boolean heading, boolean selected) {
|
||||||
mRowIndex = rowIndex;
|
mRowIndex = rowIndex;
|
||||||
mRowSpan = rowSpan;
|
mRowSpan = rowSpan;
|
||||||
mColumnIndex = columnIndex;
|
mColumnIndex = columnIndex;
|
||||||
mColumnSpan = columnSpan;
|
mColumnSpan = columnSpan;
|
||||||
mHeading = heading;
|
mHeading = heading;
|
||||||
|
mSelected = selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3006,6 +3074,15 @@ public class AccessibilityNodeInfo implements Parcelable {
|
|||||||
return mHeading;
|
return mHeading;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets if the collection item is selected.
|
||||||
|
*
|
||||||
|
* @return If the item is selected.
|
||||||
|
*/
|
||||||
|
public boolean isSelected() {
|
||||||
|
return mSelected;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recycles this instance.
|
* Recycles this instance.
|
||||||
*/
|
*/
|
||||||
@@ -3020,6 +3097,7 @@ public class AccessibilityNodeInfo implements Parcelable {
|
|||||||
mRowIndex = 0;
|
mRowIndex = 0;
|
||||||
mRowSpan = 0;
|
mRowSpan = 0;
|
||||||
mHeading = false;
|
mHeading = false;
|
||||||
|
mSelected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ import android.view.ViewTreeObserver;
|
|||||||
import android.view.accessibility.AccessibilityEvent;
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
import android.view.accessibility.AccessibilityNodeInfo;
|
import android.view.accessibility.AccessibilityNodeInfo;
|
||||||
|
import android.view.accessibility.AccessibilityNodeInfo.CollectionInfo;
|
||||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
import android.view.animation.Interpolator;
|
import android.view.animation.Interpolator;
|
||||||
@@ -1491,6 +1492,21 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getSelectionModeForAccessibility() {
|
||||||
|
final int choiceMode = getChoiceMode();
|
||||||
|
switch (choiceMode) {
|
||||||
|
case CHOICE_MODE_NONE:
|
||||||
|
return CollectionInfo.SELECTION_MODE_NONE;
|
||||||
|
case CHOICE_MODE_SINGLE:
|
||||||
|
return CollectionInfo.SELECTION_MODE_SINGLE;
|
||||||
|
case CHOICE_MODE_MULTIPLE:
|
||||||
|
case CHOICE_MODE_MULTIPLE_MODAL:
|
||||||
|
return CollectionInfo.SELECTION_MODE_MULTIPLE;
|
||||||
|
default:
|
||||||
|
return CollectionInfo.SELECTION_MODE_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean performAccessibilityAction(int action, Bundle arguments) {
|
public boolean performAccessibilityAction(int action, Bundle arguments) {
|
||||||
if (super.performAccessibilityAction(action, arguments)) {
|
if (super.performAccessibilityAction(action, arguments)) {
|
||||||
|
|||||||
@@ -2327,7 +2327,9 @@ public class GridView extends AbsListView {
|
|||||||
|
|
||||||
final int columnsCount = getNumColumns();
|
final int columnsCount = getNumColumns();
|
||||||
final int rowsCount = getCount() / columnsCount;
|
final int rowsCount = getCount() / columnsCount;
|
||||||
final CollectionInfo collectionInfo = CollectionInfo.obtain(columnsCount, rowsCount, false);
|
final int selectionMode = getSelectionModeForAccessibility();
|
||||||
|
final CollectionInfo collectionInfo = CollectionInfo.obtain(
|
||||||
|
columnsCount, rowsCount, false, selectionMode);
|
||||||
info.setCollectionInfo(collectionInfo);
|
info.setCollectionInfo(collectionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2354,7 +2356,9 @@ public class GridView extends AbsListView {
|
|||||||
|
|
||||||
final LayoutParams lp = (LayoutParams) view.getLayoutParams();
|
final LayoutParams lp = (LayoutParams) view.getLayoutParams();
|
||||||
final boolean isHeading = lp != null && lp.viewType != ITEM_VIEW_TYPE_HEADER_OR_FOOTER;
|
final boolean isHeading = lp != null && lp.viewType != ITEM_VIEW_TYPE_HEADER_OR_FOOTER;
|
||||||
final CollectionItemInfo itemInfo = CollectionItemInfo.obtain(column, 1, row, 1, isHeading);
|
final boolean isSelected = isItemChecked(position);
|
||||||
|
final CollectionItemInfo itemInfo = CollectionItemInfo.obtain(
|
||||||
|
column, 1, row, 1, isHeading, isSelected);
|
||||||
info.setCollectionItemInfo(itemInfo);
|
info.setCollectionItemInfo(itemInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3796,7 +3796,8 @@ public class ListView extends AbsListView {
|
|||||||
info.setClassName(ListView.class.getName());
|
info.setClassName(ListView.class.getName());
|
||||||
|
|
||||||
final int count = getCount();
|
final int count = getCount();
|
||||||
final CollectionInfo collectionInfo = CollectionInfo.obtain(1, count, false);
|
final int selectionMode = getSelectionModeForAccessibility();
|
||||||
|
final CollectionInfo collectionInfo = CollectionInfo.obtain(1, count, false, selectionMode);
|
||||||
info.setCollectionInfo(collectionInfo);
|
info.setCollectionInfo(collectionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3807,7 +3808,9 @@ public class ListView extends AbsListView {
|
|||||||
|
|
||||||
final LayoutParams lp = (LayoutParams) view.getLayoutParams();
|
final LayoutParams lp = (LayoutParams) view.getLayoutParams();
|
||||||
final boolean isHeading = lp != null && lp.viewType != ITEM_VIEW_TYPE_HEADER_OR_FOOTER;
|
final boolean isHeading = lp != null && lp.viewType != ITEM_VIEW_TYPE_HEADER_OR_FOOTER;
|
||||||
final CollectionItemInfo itemInfo = CollectionItemInfo.obtain(0, 1, position, 1, isHeading);
|
final boolean isSelected = isItemChecked(position);
|
||||||
|
final CollectionItemInfo itemInfo = CollectionItemInfo.obtain(
|
||||||
|
0, 1, position, 1, isHeading, isSelected);
|
||||||
info.setCollectionItemInfo(itemInfo);
|
info.setCollectionItemInfo(itemInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user