Merge "Added new ViewNode properties for Autofill (minEms, maxEms, maxLength)."
This commit is contained in:
committed by
Android (Google) Code Review
commit
02a20b7025
@@ -6674,6 +6674,9 @@ package android.app.assist {
|
||||
method public int getInputType();
|
||||
method public int getLeft();
|
||||
method public android.os.LocaleList getLocaleList();
|
||||
method public int getMaxTextEms();
|
||||
method public int getMaxTextLength();
|
||||
method public int getMinTextEms();
|
||||
method public int getScrollX();
|
||||
method public int getScrollY();
|
||||
method public java.lang.CharSequence getText();
|
||||
@@ -47015,6 +47018,9 @@ package android.view {
|
||||
method public abstract void setInputType(int);
|
||||
method public abstract void setLocaleList(android.os.LocaleList);
|
||||
method public abstract void setLongClickable(boolean);
|
||||
method public abstract void setMaxTextEms(int);
|
||||
method public abstract void setMaxTextLength(int);
|
||||
method public abstract void setMinTextEms(int);
|
||||
method public abstract void setOpaque(boolean);
|
||||
method public abstract void setSelected(boolean);
|
||||
method public abstract void setText(java.lang.CharSequence);
|
||||
|
||||
@@ -6925,6 +6925,9 @@ package android.app.assist {
|
||||
method public int getInputType();
|
||||
method public int getLeft();
|
||||
method public android.os.LocaleList getLocaleList();
|
||||
method public int getMaxTextEms();
|
||||
method public int getMaxTextLength();
|
||||
method public int getMinTextEms();
|
||||
method public int getScrollX();
|
||||
method public int getScrollY();
|
||||
method public java.lang.CharSequence getText();
|
||||
@@ -50740,6 +50743,9 @@ package android.view {
|
||||
method public abstract void setInputType(int);
|
||||
method public abstract void setLocaleList(android.os.LocaleList);
|
||||
method public abstract void setLongClickable(boolean);
|
||||
method public abstract void setMaxTextEms(int);
|
||||
method public abstract void setMaxTextLength(int);
|
||||
method public abstract void setMinTextEms(int);
|
||||
method public abstract void setOpaque(boolean);
|
||||
method public abstract void setSelected(boolean);
|
||||
method public abstract void setText(java.lang.CharSequence);
|
||||
|
||||
@@ -6743,6 +6743,9 @@ package android.app.assist {
|
||||
method public int getInputType();
|
||||
method public int getLeft();
|
||||
method public android.os.LocaleList getLocaleList();
|
||||
method public int getMaxTextEms();
|
||||
method public int getMaxTextLength();
|
||||
method public int getMinTextEms();
|
||||
method public int getScrollX();
|
||||
method public int getScrollY();
|
||||
method public java.lang.CharSequence getText();
|
||||
@@ -47596,6 +47599,9 @@ package android.view {
|
||||
method public abstract void setInputType(int);
|
||||
method public abstract void setLocaleList(android.os.LocaleList);
|
||||
method public abstract void setLongClickable(boolean);
|
||||
method public abstract void setMaxTextEms(int);
|
||||
method public abstract void setMaxTextLength(int);
|
||||
method public abstract void setMinTextEms(int);
|
||||
method public abstract void setOpaque(boolean);
|
||||
method public abstract void setSelected(boolean);
|
||||
method public abstract void setText(java.lang.CharSequence);
|
||||
|
||||
@@ -616,6 +616,9 @@ public class AssistStructure implements Parcelable {
|
||||
CharSequence[] mAutofillOptions;
|
||||
boolean mSanitized;
|
||||
HtmlInfo mHtmlInfo;
|
||||
int mMinEms = -1;
|
||||
int mMaxEms = -1;
|
||||
int mMaxLength = -1;
|
||||
|
||||
// POJO used to override some autofill-related values when the node is parcelized.
|
||||
// Not written to parcel.
|
||||
@@ -713,6 +716,9 @@ public class AssistStructure implements Parcelable {
|
||||
if (p instanceof HtmlInfo) {
|
||||
mHtmlInfo = (HtmlInfo) p;
|
||||
}
|
||||
mMinEms = in.readInt();
|
||||
mMaxEms = in.readInt();
|
||||
mMaxLength = in.readInt();
|
||||
}
|
||||
if ((flags&FLAGS_HAS_LARGE_COORDS) != 0) {
|
||||
mX = in.readInt();
|
||||
@@ -876,6 +882,9 @@ public class AssistStructure implements Parcelable {
|
||||
} else {
|
||||
out.writeParcelable(null, 0);
|
||||
}
|
||||
out.writeInt(mMinEms);
|
||||
out.writeInt(mMaxEms);
|
||||
out.writeInt(mMaxLength);
|
||||
}
|
||||
if ((flags&FLAGS_HAS_LARGE_COORDS) != 0) {
|
||||
out.writeInt(mX);
|
||||
@@ -1444,6 +1453,39 @@ public class AssistStructure implements Parcelable {
|
||||
public ViewNode getChildAt(int index) {
|
||||
return mChildren[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum width in ems of the text associated with this node, or {@code -1}
|
||||
* if not supported by the node.
|
||||
*
|
||||
* <p>It's only relevant when the {@link AssistStructure} is used for autofill purposes,
|
||||
* not for assist purposes.
|
||||
*/
|
||||
public int getMinTextEms() {
|
||||
return mMinEms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum width in ems of the text associated with this node, or {@code -1}
|
||||
* if not supported by the node.
|
||||
*
|
||||
* <p>It's only relevant when the {@link AssistStructure} is used for autofill purposes,
|
||||
* not for assist purposes.
|
||||
*/
|
||||
public int getMaxTextEms() {
|
||||
return mMaxEms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum length of the text associated with this node node, or {@code -1}
|
||||
* if not supported by the node or not set.
|
||||
*
|
||||
* <p>It's only relevant when the {@link AssistStructure} is used for autofill purposes,
|
||||
* not for assist purposes.
|
||||
*/
|
||||
public int getMaxTextLength() {
|
||||
return mMaxLength;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1775,6 +1817,21 @@ public class AssistStructure implements Parcelable {
|
||||
mNode.mInputType = inputType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMinTextEms(int minEms) {
|
||||
mNode.mMinEms = minEms;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxTextEms(int maxEms) {
|
||||
mNode.mMaxEms = maxEms;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxTextLength(int maxLength) {
|
||||
mNode.mMaxLength = maxLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataIsSensitive(boolean sensitive) {
|
||||
mNode.mSanitized = !sensitive;
|
||||
|
||||
@@ -364,6 +364,30 @@ public abstract class ViewStructure {
|
||||
*/
|
||||
public abstract void setDataIsSensitive(boolean sensitive);
|
||||
|
||||
/**
|
||||
* Sets the minimum width in ems of the text associated with this view, when supported.
|
||||
*
|
||||
* <p>Should only be set when the node is used for autofill purposes - it will be ignored
|
||||
* when used for Assist.
|
||||
*/
|
||||
public abstract void setMinTextEms(int minEms);
|
||||
|
||||
/**
|
||||
* Sets the maximum width in ems of the text associated with this view, when supported.
|
||||
*
|
||||
* <p>Should only be set when the node is used for autofill purposes - it will be ignored
|
||||
* when used for Assist.
|
||||
*/
|
||||
public abstract void setMaxTextEms(int maxEms);
|
||||
|
||||
/**
|
||||
* Sets the maximum length of the text associated with this view, when supported.
|
||||
*
|
||||
* <p>Should only be set when the node is used for autofill purposes - it will be ignored
|
||||
* when used for Assist.
|
||||
*/
|
||||
public abstract void setMaxTextLength(int maxLength);
|
||||
|
||||
/**
|
||||
* Call when done populating a {@link ViewStructure} returned by
|
||||
* {@link #asyncNewChild}.
|
||||
|
||||
@@ -10338,6 +10338,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
// of the View (and can be any drawable) or a BackgroundColorSpan inside the text.
|
||||
structure.setTextStyle(getTextSize(), getCurrentTextColor(),
|
||||
AssistStructure.ViewNode.TEXT_COLOR_UNDEFINED /* bgColor */, style);
|
||||
} else {
|
||||
structure.setMinTextEms(getMinEms());
|
||||
structure.setMaxTextEms(getMaxEms());
|
||||
int maxLength = -1;
|
||||
for (InputFilter filter: getFilters()) {
|
||||
if (filter instanceof InputFilter.LengthFilter) {
|
||||
maxLength = ((InputFilter.LengthFilter) filter).getMax();
|
||||
break;
|
||||
}
|
||||
}
|
||||
structure.setMaxTextLength(maxLength);
|
||||
}
|
||||
}
|
||||
structure.setHint(getHint());
|
||||
|
||||
Reference in New Issue
Block a user