Merge "Rename getOnReceiveContentMimeTypes (drop "On")" into sc-dev

This commit is contained in:
Nikita Dubrovsky
2021-03-31 21:06:21 +00:00
committed by Android (Google) Code Review
9 changed files with 37 additions and 37 deletions

View File

@@ -7712,7 +7712,7 @@ package android.app.assist {
method public int getMaxTextEms();
method public int getMaxTextLength();
method public int getMinTextEms();
method @Nullable public String[] getOnReceiveContentMimeTypes();
method @Nullable public String[] getReceiveContentMimeTypes();
method public int getScrollX();
method public int getScrollY();
method @Nullable public CharSequence getText();
@@ -48649,7 +48649,6 @@ package android.view {
method @IdRes public int getNextFocusRightId();
method @IdRes public int getNextFocusUpId();
method public android.view.View.OnFocusChangeListener getOnFocusChangeListener();
method @Nullable public String[] getOnReceiveContentMimeTypes();
method @ColorInt public int getOutlineAmbientShadowColor();
method public android.view.ViewOutlineProvider getOutlineProvider();
method @ColorInt public int getOutlineSpotShadowColor();
@@ -48666,6 +48665,7 @@ package android.view {
method public float getPivotX();
method public float getPivotY();
method public android.view.PointerIcon getPointerIcon();
method @Nullable public String[] getReceiveContentMimeTypes();
method public android.content.res.Resources getResources();
method public final boolean getRevealOnFocusHint();
method public final int getRight();
@@ -49845,8 +49845,8 @@ package android.view {
method public void setMaxTextEms(int);
method public void setMaxTextLength(int);
method public void setMinTextEms(int);
method public void setOnReceiveContentMimeTypes(@Nullable String[]);
method public abstract void setOpaque(boolean);
method public void setReceiveContentMimeTypes(@Nullable String[]);
method public abstract void setSelected(boolean);
method public abstract void setText(CharSequence);
method public abstract void setText(CharSequence, int, int);

View File

@@ -717,7 +717,7 @@ public class AssistStructure implements Parcelable {
String mWebDomain;
Bundle mExtras;
LocaleList mLocaleList;
String[] mOnReceiveContentMimeTypes;
String[] mReceiveContentMimeTypes;
ViewNode[] mChildren;
@@ -884,7 +884,7 @@ public class AssistStructure implements Parcelable {
mLocaleList = in.readParcelable(null);
}
if ((flags & FLAGS_HAS_MIME_TYPES) != 0) {
mOnReceiveContentMimeTypes = in.readStringArray();
mReceiveContentMimeTypes = in.readStringArray();
}
if ((flags&FLAGS_HAS_EXTRAS) != 0) {
mExtras = in.readBundle();
@@ -945,7 +945,7 @@ public class AssistStructure implements Parcelable {
if (mLocaleList != null) {
flags |= FLAGS_HAS_LOCALE_LIST;
}
if (mOnReceiveContentMimeTypes != null) {
if (mReceiveContentMimeTypes != null) {
flags |= FLAGS_HAS_MIME_TYPES;
}
if (mExtras != null) {
@@ -1119,7 +1119,7 @@ public class AssistStructure implements Parcelable {
out.writeParcelable(mLocaleList, 0);
}
if ((flags & FLAGS_HAS_MIME_TYPES) != 0) {
out.writeStringArray(mOnReceiveContentMimeTypes);
out.writeStringArray(mReceiveContentMimeTypes);
}
if ((flags&FLAGS_HAS_EXTRAS) != 0) {
out.writeBundle(mExtras);
@@ -1540,12 +1540,12 @@ public class AssistStructure implements Parcelable {
/**
* Returns the MIME types accepted by {@link View#performReceiveContent} for this view. See
* {@link View#getOnReceiveContentMimeTypes()} for details.
* {@link View#getReceiveContentMimeTypes()} for details.
*/
@Nullable
@SuppressLint("NullableCollection")
public String[] getOnReceiveContentMimeTypes() {
return mOnReceiveContentMimeTypes;
public String[] getReceiveContentMimeTypes() {
return mReceiveContentMimeTypes;
}
/**
@@ -2168,8 +2168,8 @@ public class AssistStructure implements Parcelable {
}
@Override
public void setOnReceiveContentMimeTypes(@Nullable String[] mimeTypes) {
mNode.mOnReceiveContentMimeTypes = mimeTypes;
public void setReceiveContentMimeTypes(@Nullable String[] mimeTypes) {
mNode.mReceiveContentMimeTypes = mimeTypes;
}
@Override
@@ -2449,7 +2449,7 @@ public class AssistStructure implements Parcelable {
if (localeList != null) {
Log.i(TAG, prefix + " LocaleList: " + localeList);
}
String[] mimeTypes = node.getOnReceiveContentMimeTypes();
String[] mimeTypes = node.getReceiveContentMimeTypes();
if (mimeTypes != null) {
Log.i(TAG, prefix + " MIME types: " + Arrays.toString(mimeTypes));
}

View File

@@ -5255,7 +5255,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
int mUnbufferedInputSource = InputDevice.SOURCE_CLASS_NONE;
@Nullable
private String[] mOnReceiveContentMimeTypes;
private String[] mReceiveContentMimeTypes;
@Nullable
private ViewTranslationCallback mViewTranslationCallback;
@@ -8847,7 +8847,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
structure.setAutofillValue(getAutofillValue());
}
structure.setImportantForAutofill(getImportantForAutofill());
structure.setOnReceiveContentMimeTypes(getOnReceiveContentMimeTypes());
structure.setReceiveContentMimeTypes(getReceiveContentMimeTypes());
}
int ignoredParentLeft = 0;
@@ -9066,7 +9066,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
Preconditions.checkArgument(Arrays.stream(mimeTypes).noneMatch(t -> t.startsWith("*")),
"A MIME type set here must not start with *: " + Arrays.toString(mimeTypes));
}
mOnReceiveContentMimeTypes = ArrayUtils.isEmpty(mimeTypes) ? null : mimeTypes;
mReceiveContentMimeTypes = ArrayUtils.isEmpty(mimeTypes) ? null : mimeTypes;
getListenerInfo().mOnReceiveContentListener = listener;
}
@@ -9134,8 +9134,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*/
@SuppressLint("NullableCollection")
@Nullable
public String[] getOnReceiveContentMimeTypes() {
return mOnReceiveContentMimeTypes;
public String[] getReceiveContentMimeTypes() {
return mReceiveContentMimeTypes;
}
/**

View File

@@ -373,12 +373,12 @@ public abstract class ViewStructure {
public void setImportantForAutofill(@AutofillImportance int mode) {}
/**
* Sets the MIME types accepted by this view. See {@link View#getOnReceiveContentMimeTypes()}.
* Sets the MIME types accepted by this view. See {@link View#getReceiveContentMimeTypes()}.
*
* <p>Should only be set when the node is used for Autofill or Content Capture purposes - it
* will be ignored when used for Assist.
*/
public void setOnReceiveContentMimeTypes(
public void setReceiveContentMimeTypes(
@SuppressLint("NullableCollection") @Nullable String[] mimeTypes) {}
/**

View File

@@ -114,7 +114,7 @@ public final class ViewNode extends AssistStructure.ViewNode {
private String[] mAutofillHints;
private AutofillValue mAutofillValue;
private CharSequence[] mAutofillOptions;
private String[] mOnReceiveContentMimeTypes;
private String[] mReceiveContentMimeTypes;
/** @hide */
public ViewNode() {
@@ -172,7 +172,7 @@ public final class ViewNode extends AssistStructure.ViewNode {
mLocaleList = parcel.readParcelable(null);
}
if ((nodeFlags & FLAGS_HAS_MIME_TYPES) != 0) {
mOnReceiveContentMimeTypes = parcel.readStringArray();
mReceiveContentMimeTypes = parcel.readStringArray();
}
if ((nodeFlags & FLAGS_HAS_INPUT_TYPE) != 0) {
mInputType = parcel.readInt();
@@ -470,8 +470,8 @@ public final class ViewNode extends AssistStructure.ViewNode {
@Override
@Nullable
public String[] getOnReceiveContentMimeTypes() {
return mOnReceiveContentMimeTypes;
public String[] getReceiveContentMimeTypes() {
return mReceiveContentMimeTypes;
}
@Nullable
@@ -519,7 +519,7 @@ public final class ViewNode extends AssistStructure.ViewNode {
if (mLocaleList != null) {
nodeFlags |= FLAGS_HAS_LOCALE_LIST;
}
if (mOnReceiveContentMimeTypes != null) {
if (mReceiveContentMimeTypes != null) {
nodeFlags |= FLAGS_HAS_MIME_TYPES;
}
if (mInputType != 0) {
@@ -599,7 +599,7 @@ public final class ViewNode extends AssistStructure.ViewNode {
parcel.writeParcelable(mLocaleList, 0);
}
if ((nodeFlags & FLAGS_HAS_MIME_TYPES) != 0) {
parcel.writeStringArray(mOnReceiveContentMimeTypes);
parcel.writeStringArray(mReceiveContentMimeTypes);
}
if ((nodeFlags & FLAGS_HAS_INPUT_TYPE) != 0) {
parcel.writeInt(mInputType);
@@ -929,8 +929,8 @@ public final class ViewNode extends AssistStructure.ViewNode {
}
@Override
public void setOnReceiveContentMimeTypes(@Nullable String[] mimeTypes) {
mNode.mOnReceiveContentMimeTypes = mimeTypes;
public void setReceiveContentMimeTypes(@Nullable String[] mimeTypes) {
mNode.mReceiveContentMimeTypes = mimeTypes;
}
@Override

View File

@@ -938,12 +938,12 @@ public class BaseInputConnection implements InputConnection {
/**
* Default implementation which invokes {@link View#performReceiveContent} on the target
* view if the view {@link View#getOnReceiveContentMimeTypes allows} content insertion;
* view if the view {@link View#getReceiveContentMimeTypes allows} content insertion;
* otherwise returns false without any side effects.
*/
public boolean commitContent(InputContentInfo inputContentInfo, int flags, Bundle opts) {
ClipDescription description = inputContentInfo.getDescription();
if (mTargetView.getOnReceiveContentMimeTypes() == null) {
if (mTargetView.getReceiveContentMimeTypes() == null) {
if (DEBUG) {
Log.d(TAG, "Can't insert content from IME: content=" + description);
}

View File

@@ -8773,7 +8773,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
outAttrs.initialSelEnd = getSelectionEnd();
outAttrs.initialCapsMode = ic.getCursorCapsMode(getInputType());
outAttrs.setInitialSurroundingText(mText);
outAttrs.contentMimeTypes = getOnReceiveContentMimeTypes();
outAttrs.contentMimeTypes = getReceiveContentMimeTypes();
return ic;
}
}
@@ -11741,10 +11741,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
}
}
String[] mimeTypes = getOnReceiveContentMimeTypes();
String[] mimeTypes = getReceiveContentMimeTypes();
if (mimeTypes == null && mEditor != null) {
// If the app hasn't set a listener for receiving content on this view (ie,
// getOnReceiveContentMimeTypes() returns null), check if it implements the
// getReceiveContentMimeTypes() returns null), check if it implements the
// keyboard image API and, if possible, use those MIME types as fallback.
// This fallback is only in place for autofill, not other mechanisms for
// inserting content. See AUTOFILL_NON_TEXT_REQUIRES_ON_RECEIVE_CONTENT_LISTENER
@@ -11752,7 +11752,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
mimeTypes = mEditor.getDefaultOnReceiveContentListener()
.getFallbackMimeTypesForAutofill(this);
}
structure.setOnReceiveContentMimeTypes(mimeTypes);
structure.setReceiveContentMimeTypes(mimeTypes);
}
if (!isPassword || viewFor == VIEW_STRUCTURE_FOR_AUTOFILL

View File

@@ -194,7 +194,7 @@ public final class TextViewOnReceiveContentListener implements OnReceiveContentL
* non-text content.
*/
private static boolean isUsageOfImeCommitContentEnabled(@NonNull View view) {
if (view.getOnReceiveContentMimeTypes() != null) {
if (view.getReceiveContentMimeTypes() != null) {
if (Log.isLoggable(LOG_TAG, Log.VERBOSE)) {
Log.v(LOG_TAG, "Fallback to commitContent disabled (custom callback is set)");
}

View File

@@ -61,12 +61,12 @@ import org.mockito.Mockito;
/**
* Tests for {@link TextViewOnReceiveContentListener}. Most of the test cases are in the CTS test
* {@link android.widget.cts.TextViewOnReceiveContentTest}. This class tests some internal
* {@link android.widget.cts.TextViewReceiveContentTest}. This class tests some internal
* implementation details, e.g. fallback to the keyboard image API.
*/
@MediumTest
@RunWith(AndroidJUnit4.class)
public class TextViewOnReceiveContentTest {
public class TextViewReceiveContentTest {
private static final Uri SAMPLE_CONTENT_URI = Uri.parse("content://com.example/path");
@Rule