summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/accessibility
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-08-12 14:55:56 -0700
committerAlan Viverette <alanv@google.com>2014-08-12 14:55:56 -0700
commit029942f77d05ed3d20256403652b220c83dad6e1 (patch)
tree7876ce9e6045ebed1127ed219b004a3103d45879 /core/java/android/view/accessibility
parent61da0fdfeece43ee4060b3334774304488e817e3 (diff)
downloadframeworks_base-029942f77d05ed3d20256403652b220c83dad6e1.zip
frameworks_base-029942f77d05ed3d20256403652b220c83dad6e1.tar.gz
frameworks_base-029942f77d05ed3d20256403652b220c83dad6e1.tar.bz2
Add API for obtaining max text length for accessibility
BUG: 16736956 Change-Id: I15ffb9bf68e074adf3e0dbcd230367e115c03e3c
Diffstat (limited to 'core/java/android/view/accessibility')
-rw-r--r--core/java/android/view/accessibility/AccessibilityNodeInfo.java38
1 files changed, 36 insertions, 2 deletions
diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
index 1bf4639..3987fbc 100644
--- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java
+++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
@@ -562,6 +562,7 @@ public class AccessibilityNodeInfo implements Parcelable {
private LongArray mChildNodeIds;
private ArrayList<AccessibilityAction> mActions;
+ private int mMaxTextLength = -1;
private int mMovementGranularities;
private int mTextSelectionStart = UNDEFINED_SELECTION_INDEX;
@@ -1045,6 +1046,36 @@ public class AccessibilityNodeInfo implements Parcelable {
}
/**
+ * Sets the maximum text length, or -1 for no limit.
+ * <p>
+ * Typically used to indicate that an editable text field has a limit on
+ * the number of characters entered.
+ * <p>
+ * <strong>Note:</strong> Cannot be called from an
+ * {@link android.accessibilityservice.AccessibilityService}.
+ * This class is made immutable before being delivered to an AccessibilityService.
+ *
+ * @param max The maximum text length.
+ * @see #getMaxTextLength()
+ *
+ * @throws IllegalStateException If called from an AccessibilityService.
+ */
+ public void setMaxTextLength(int max) {
+ enforceNotSealed();
+ mMaxTextLength = max;
+ }
+
+ /**
+ * Returns the maximum text length for this node.
+ *
+ * @return The maximum text length, or -1 for no limit.
+ * @see #setMaxTextLength(int)
+ */
+ public int getMaxTextLength() {
+ return mMaxTextLength;
+ }
+
+ /**
* Sets the movement granularities for traversing the text of this node.
* <p>
* <strong>Note:</strong> Cannot be called from an
@@ -2469,8 +2500,8 @@ public class AccessibilityNodeInfo implements Parcelable {
parcel.writeInt(0);
}
+ parcel.writeInt(mMaxTextLength);
parcel.writeInt(mMovementGranularities);
-
parcel.writeInt(mBooleanProperties);
parcel.writeCharSequence(mPackageName);
@@ -2562,6 +2593,7 @@ public class AccessibilityNodeInfo implements Parcelable {
}
mBooleanProperties = other.mBooleanProperties;
+ mMaxTextLength = other.mMaxTextLength;
mMovementGranularities = other.mMovementGranularities;
final LongArray otherChildNodeIds = other.mChildNodeIds;
@@ -2636,8 +2668,8 @@ public class AccessibilityNodeInfo implements Parcelable {
}
}
+ mMaxTextLength = parcel.readInt();
mMovementGranularities = parcel.readInt();
-
mBooleanProperties = parcel.readInt();
mPackageName = parcel.readCharSequence();
@@ -2695,6 +2727,7 @@ public class AccessibilityNodeInfo implements Parcelable {
mLabeledById = ROOT_NODE_ID;
mWindowId = UNDEFINED_ITEM_ID;
mConnectionId = UNDEFINED_CONNECTION_ID;
+ mMaxTextLength = -1;
mMovementGranularities = 0;
if (mChildNodeIds != null) {
mChildNodeIds.clear();
@@ -2911,6 +2944,7 @@ public class AccessibilityNodeInfo implements Parcelable {
builder.append("; className: ").append(mClassName);
builder.append("; text: ").append(mText);
builder.append("; error: ").append(mError);
+ builder.append("; maxTextLength: ").append(mMaxTextLength);
builder.append("; contentDescription: ").append(mContentDescription);
builder.append("; viewIdResName: ").append(mViewIdResourceName);