Merge "Report less data in structure to autofill provider" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d19113b390
@@ -18,6 +18,7 @@ import android.os.PooledStringReader;
|
||||
import android.os.PooledStringWriter;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemClock;
|
||||
import android.service.autofill.FillContext;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
@@ -1103,6 +1104,9 @@ public class AssistStructure implements Parcelable {
|
||||
* Returns the transformation that has been applied to this view, such as a translation
|
||||
* or scaling. The returned Matrix object is owned by ViewNode; do not modify it.
|
||||
* Returns null if there is no transformation applied to the view.
|
||||
*
|
||||
* <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
|
||||
* not for Autofill purposes.
|
||||
*/
|
||||
public Matrix getTransformation() {
|
||||
return mMatrix;
|
||||
@@ -1112,6 +1116,9 @@ public class AssistStructure implements Parcelable {
|
||||
* Returns the visual elevation of the view, used for shadowing and other visual
|
||||
* characterstics, as set by {@link ViewStructure#setElevation
|
||||
* ViewStructure.setElevation(float)}.
|
||||
*
|
||||
* <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
|
||||
* not for Autofill purposes.
|
||||
*/
|
||||
public float getElevation() {
|
||||
return mElevation;
|
||||
@@ -1121,6 +1128,9 @@ public class AssistStructure implements Parcelable {
|
||||
* Returns the alpha transformation of the view, used to reduce the overall opacity
|
||||
* of the view's contents, as set by {@link ViewStructure#setAlpha
|
||||
* ViewStructure.setAlpha(float)}.
|
||||
*
|
||||
* <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
|
||||
* not for Autofill purposes.
|
||||
*/
|
||||
public float getAlpha() {
|
||||
return mAlpha;
|
||||
@@ -1289,6 +1299,9 @@ public class AssistStructure implements Parcelable {
|
||||
|
||||
/**
|
||||
* If {@link #getText()} is non-null, this is where the current selection starts.
|
||||
*
|
||||
* <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
|
||||
* not for Autofill purposes.
|
||||
*/
|
||||
public int getTextSelectionStart() {
|
||||
return mText != null ? mText.mTextSelectionStart : -1;
|
||||
@@ -1298,6 +1311,9 @@ public class AssistStructure implements Parcelable {
|
||||
* If {@link #getText()} is non-null, this is where the current selection starts.
|
||||
* If there is no selection, returns the same value as {@link #getTextSelectionStart()},
|
||||
* indicating the cursor position.
|
||||
*
|
||||
* <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
|
||||
* not for Autofill purposes.
|
||||
*/
|
||||
public int getTextSelectionEnd() {
|
||||
return mText != null ? mText.mTextSelectionEnd : -1;
|
||||
@@ -1319,6 +1335,9 @@ public class AssistStructure implements Parcelable {
|
||||
* If there is no text background color, {@link #TEXT_COLOR_UNDEFINED} is returned.
|
||||
* Note that the text may also contain style spans that modify the color of specific
|
||||
* parts of the text.
|
||||
*
|
||||
* <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
|
||||
* not for Autofill purposes.
|
||||
*/
|
||||
public int getTextBackgroundColor() {
|
||||
return mText != null ? mText.mTextBackgroundColor : TEXT_COLOR_UNDEFINED;
|
||||
@@ -1329,6 +1348,9 @@ public class AssistStructure implements Parcelable {
|
||||
* with it.
|
||||
* Note that the text may also contain style spans that modify the size of specific
|
||||
* parts of the text.
|
||||
*
|
||||
* <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
|
||||
* not for Autofill purposes.
|
||||
*/
|
||||
public float getTextSize() {
|
||||
return mText != null ? mText.mTextSize : 0;
|
||||
@@ -1341,6 +1363,9 @@ public class AssistStructure implements Parcelable {
|
||||
* {@link #TEXT_STYLE_UNDERLINE}.
|
||||
* Note that the text may also contain style spans that modify the style of specific
|
||||
* parts of the text.
|
||||
*
|
||||
* <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
|
||||
* not for Autofill purposes.
|
||||
*/
|
||||
public int getTextStyle() {
|
||||
return mText != null ? mText.mTextStyle : 0;
|
||||
@@ -1351,6 +1376,9 @@ public class AssistStructure implements Parcelable {
|
||||
* in the array is a formatted line of text, and the value it contains is the offset
|
||||
* into the text string where that line starts. May return null if there is no line
|
||||
* information.
|
||||
*
|
||||
* <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
|
||||
* not for Autofill purposes.
|
||||
*/
|
||||
public int[] getTextLineCharOffsets() {
|
||||
return mText != null ? mText.mLineCharOffsets : null;
|
||||
@@ -1361,6 +1389,9 @@ public class AssistStructure implements Parcelable {
|
||||
* in the array is a formatted line of text, and the value it contains is the baseline
|
||||
* where that text appears in the view. May return null if there is no line
|
||||
* information.
|
||||
*
|
||||
* <p>It's only relevant when the {@link AssistStructure} is used for Assist purposes,
|
||||
* not for Autofill purposes.
|
||||
*/
|
||||
public int[] getTextLineBaselines() {
|
||||
return mText != null ? mText.mLineBaselines : null;
|
||||
|
||||
@@ -7351,10 +7351,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
}
|
||||
|
||||
structure.setDimens(mLeft, mTop, mScrollX, mScrollY, mRight - mLeft, mBottom - mTop);
|
||||
if (!hasIdentityMatrix()) {
|
||||
structure.setTransformation(getMatrix());
|
||||
if (!forAutofill) {
|
||||
if (!hasIdentityMatrix()) {
|
||||
structure.setTransformation(getMatrix());
|
||||
}
|
||||
structure.setElevation(getZ());
|
||||
}
|
||||
structure.setElevation(getZ());
|
||||
structure.setVisibility(getVisibility());
|
||||
structure.setEnabled(isEnabled());
|
||||
if (isClickable()) {
|
||||
|
||||
@@ -10136,7 +10136,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
if (lineCount <= 1) {
|
||||
// Simple case: this is a single line.
|
||||
final CharSequence text = getText();
|
||||
structure.setText(text, getSelectionStart(), getSelectionEnd());
|
||||
if (forAutofill) {
|
||||
structure.setText(text);
|
||||
} else {
|
||||
structure.setText(text, getSelectionStart(), getSelectionEnd());
|
||||
}
|
||||
} else {
|
||||
// Complex case: multi-line, could be scrolled or within a scroll container
|
||||
// so some lines are not visible.
|
||||
@@ -10172,9 +10176,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
if (expandedBottomLine >= lineCount) {
|
||||
expandedBottomLine = lineCount - 1;
|
||||
}
|
||||
|
||||
// Convert lines into character offsets.
|
||||
int expandedTopChar = layout.getLineStart(expandedTopLine);
|
||||
int expandedBottomChar = layout.getLineEnd(expandedBottomLine);
|
||||
|
||||
// Take into account selection -- if there is a selection, we need to expand
|
||||
// the text we are returning to include that selection.
|
||||
final int selStart = getSelectionStart();
|
||||
@@ -10187,48 +10193,57 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
expandedBottomChar = selEnd;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the text and trim it to the range we are reporting.
|
||||
CharSequence text = getText();
|
||||
if (expandedTopChar > 0 || expandedBottomChar < text.length()) {
|
||||
text = text.subSequence(expandedTopChar, expandedBottomChar);
|
||||
}
|
||||
structure.setText(text, selStart - expandedTopChar, selEnd - expandedTopChar);
|
||||
final int[] lineOffsets = new int[bottomLine - topLine + 1];
|
||||
final int[] lineBaselines = new int[bottomLine - topLine + 1];
|
||||
final int baselineOffset = getBaselineOffset();
|
||||
for (int i = topLine; i <= bottomLine; i++) {
|
||||
lineOffsets[i - topLine] = layout.getLineStart(i);
|
||||
lineBaselines[i - topLine] = layout.getLineBaseline(i) + baselineOffset;
|
||||
|
||||
if (forAutofill) {
|
||||
structure.setText(text);
|
||||
} else {
|
||||
structure.setText(text, selStart - expandedTopChar, selEnd - expandedTopChar);
|
||||
|
||||
final int[] lineOffsets = new int[bottomLine - topLine + 1];
|
||||
final int[] lineBaselines = new int[bottomLine - topLine + 1];
|
||||
final int baselineOffset = getBaselineOffset();
|
||||
for (int i = topLine; i <= bottomLine; i++) {
|
||||
lineOffsets[i - topLine] = layout.getLineStart(i);
|
||||
lineBaselines[i - topLine] = layout.getLineBaseline(i) + baselineOffset;
|
||||
}
|
||||
structure.setTextLines(lineOffsets, lineBaselines);
|
||||
}
|
||||
structure.setTextLines(lineOffsets, lineBaselines);
|
||||
}
|
||||
|
||||
// Extract style information that applies to the TextView as a whole.
|
||||
int style = 0;
|
||||
int typefaceStyle = getTypefaceStyle();
|
||||
if ((typefaceStyle & Typeface.BOLD) != 0) {
|
||||
style |= AssistStructure.ViewNode.TEXT_STYLE_BOLD;
|
||||
}
|
||||
if ((typefaceStyle & Typeface.ITALIC) != 0) {
|
||||
style |= AssistStructure.ViewNode.TEXT_STYLE_ITALIC;
|
||||
}
|
||||
if (!forAutofill) {
|
||||
// Extract style information that applies to the TextView as a whole.
|
||||
int style = 0;
|
||||
int typefaceStyle = getTypefaceStyle();
|
||||
if ((typefaceStyle & Typeface.BOLD) != 0) {
|
||||
style |= AssistStructure.ViewNode.TEXT_STYLE_BOLD;
|
||||
}
|
||||
if ((typefaceStyle & Typeface.ITALIC) != 0) {
|
||||
style |= AssistStructure.ViewNode.TEXT_STYLE_ITALIC;
|
||||
}
|
||||
|
||||
// Global styles can also be set via TextView.setPaintFlags().
|
||||
int paintFlags = mTextPaint.getFlags();
|
||||
if ((paintFlags & Paint.FAKE_BOLD_TEXT_FLAG) != 0) {
|
||||
style |= AssistStructure.ViewNode.TEXT_STYLE_BOLD;
|
||||
}
|
||||
if ((paintFlags & Paint.UNDERLINE_TEXT_FLAG) != 0) {
|
||||
style |= AssistStructure.ViewNode.TEXT_STYLE_UNDERLINE;
|
||||
}
|
||||
if ((paintFlags & Paint.STRIKE_THRU_TEXT_FLAG) != 0) {
|
||||
style |= AssistStructure.ViewNode.TEXT_STYLE_STRIKE_THRU;
|
||||
}
|
||||
// Global styles can also be set via TextView.setPaintFlags().
|
||||
int paintFlags = mTextPaint.getFlags();
|
||||
if ((paintFlags & Paint.FAKE_BOLD_TEXT_FLAG) != 0) {
|
||||
style |= AssistStructure.ViewNode.TEXT_STYLE_BOLD;
|
||||
}
|
||||
if ((paintFlags & Paint.UNDERLINE_TEXT_FLAG) != 0) {
|
||||
style |= AssistStructure.ViewNode.TEXT_STYLE_UNDERLINE;
|
||||
}
|
||||
if ((paintFlags & Paint.STRIKE_THRU_TEXT_FLAG) != 0) {
|
||||
style |= AssistStructure.ViewNode.TEXT_STYLE_STRIKE_THRU;
|
||||
}
|
||||
|
||||
// TextView does not have its own text background color. A background is either part
|
||||
// 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);
|
||||
// TextView does not have its own text background color. A background is either part
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
structure.setHint(getHint());
|
||||
structure.setInputType(getInputType());
|
||||
|
||||
Reference in New Issue
Block a user