diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-02-18 04:00:52 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-02-18 04:00:52 +0000 |
| commit | 2d4e0f25f2571910af0220cde751a45eaf32421b (patch) | |
| tree | dc6dbf1aadad5fd00a57053d6cc5edcdb5b6f833 /core/java/android | |
| parent | dc50039ae6ec9609c29604f20880fe872b2508cc (diff) | |
| parent | 5f7e99e5d8263c22c5f3e8b031d1e55b78412f3a (diff) | |
Merge "Add the locale field and an extra Bundle to the InlineSuggestionsRequest."
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/view/inline/InlinePresentationSpec.java | 25 | ||||
| -rw-r--r-- | core/java/android/view/inputmethod/InlineSuggestionsRequest.java | 119 |
2 files changed, 116 insertions, 28 deletions
diff --git a/core/java/android/view/inline/InlinePresentationSpec.java b/core/java/android/view/inline/InlinePresentationSpec.java index 406e599a67fb..8bda339bea16 100644 --- a/core/java/android/view/inline/InlinePresentationSpec.java +++ b/core/java/android/view/inline/InlinePresentationSpec.java @@ -18,7 +18,6 @@ package android.view.inline; import android.annotation.NonNull; import android.annotation.Nullable; -import android.annotation.SystemApi; import android.os.Parcelable; import android.util.Size; @@ -53,15 +52,6 @@ public final class InlinePresentationSpec implements Parcelable { return null; } - /** - * @hide - */ - @SystemApi - public @Nullable String getStyle() { - return mStyle; - } - - /** @hide */ @DataClass.Suppress({"setMaxSize", "setMinSize"}) abstract static class BaseBuilder { @@ -114,6 +104,17 @@ public final class InlinePresentationSpec implements Parcelable { return mMaxSize; } + /** + * The fully qualified resource name of the UI style resource identifier, defaults to {@code + * null}. + * + * <p> The value can be obtained by calling {@code Resources#getResourceName(int)}. + */ + @DataClass.Generated.Member + public @Nullable String getStyle() { + return mStyle; + } + @Override @DataClass.Generated.Member public String toString() { @@ -283,10 +284,10 @@ public final class InlinePresentationSpec implements Parcelable { } @DataClass.Generated( - time = 1581117017522L, + time = 1581736227796L, codegenVersion = "1.0.14", sourceFile = "frameworks/base/core/java/android/view/inline/InlinePresentationSpec.java", - inputSignatures = "private final @android.annotation.NonNull android.util.Size mMinSize\nprivate final @android.annotation.NonNull android.util.Size mMaxSize\nprivate final @android.annotation.Nullable java.lang.String mStyle\nprivate static java.lang.String defaultStyle()\npublic @android.annotation.SystemApi @android.annotation.Nullable java.lang.String getStyle()\nclass InlinePresentationSpec extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genBuilder=true)\nclass BaseBuilder extends java.lang.Object implements []") + inputSignatures = "private final @android.annotation.NonNull android.util.Size mMinSize\nprivate final @android.annotation.NonNull android.util.Size mMaxSize\nprivate final @android.annotation.Nullable java.lang.String mStyle\nprivate static java.lang.String defaultStyle()\nclass InlinePresentationSpec extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genBuilder=true)\nclass BaseBuilder extends java.lang.Object implements []") @Deprecated private void __metadata() {} diff --git a/core/java/android/view/inputmethod/InlineSuggestionsRequest.java b/core/java/android/view/inputmethod/InlineSuggestionsRequest.java index be9370a7e2af..5700dda3a2e3 100644 --- a/core/java/android/view/inputmethod/InlineSuggestionsRequest.java +++ b/core/java/android/view/inputmethod/InlineSuggestionsRequest.java @@ -19,7 +19,9 @@ package android.view.inputmethod; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityThread; +import android.os.Bundle; import android.os.IBinder; +import android.os.LocaleList; import android.os.Parcelable; import android.view.inline.InlinePresentationSpec; @@ -60,6 +62,13 @@ public final class InlineSuggestionsRequest implements Parcelable { private @NonNull String mHostPackageName; /** + * The IME provided locales for the request. If non-empty, the inline suggestions should + * return languages from the supported locales. If not provided, it'll default to system locale. + */ + private @NonNull LocaleList mSupportedLocales; + + // TODO(b/149609075): the generated code needs to be manually fixed due to the bug. + /** * The host input token of the IME that made the request. This will be set by the system for * safety reasons. * @@ -68,12 +77,9 @@ public final class InlineSuggestionsRequest implements Parcelable { private @Nullable IBinder mHostInputToken; /** - * @hide - * @see {@link #mHostPackageName}. + * The extras state propagated from the IME to pass extra data. */ - public void setHostPackageName(@NonNull String hostPackageName) { - mHostPackageName = hostPackageName; - } + private @Nullable Bundle mExtras; /** * @hide @@ -95,10 +101,20 @@ public final class InlineSuggestionsRequest implements Parcelable { return ActivityThread.currentPackageName(); } + private static LocaleList defaultSupportedLocales() { + return LocaleList.getDefault(); + } + + @Nullable private static IBinder defaultHostInputToken() { return null; } + @Nullable + private static Bundle defaultExtras() { + return null; + } + /** @hide */ abstract static class BaseBuilder { abstract Builder setPresentationSpecs(@NonNull List<InlinePresentationSpec> value); @@ -128,7 +144,9 @@ public final class InlineSuggestionsRequest implements Parcelable { int maxSuggestionCount, @NonNull List<InlinePresentationSpec> presentationSpecs, @NonNull String hostPackageName, - @Nullable IBinder hostInputToken) { + @NonNull LocaleList supportedLocales, + @Nullable IBinder hostInputToken, + @Nullable Bundle extras) { this.mMaxSuggestionCount = maxSuggestionCount; this.mPresentationSpecs = presentationSpecs; com.android.internal.util.AnnotationValidations.validate( @@ -136,7 +154,11 @@ public final class InlineSuggestionsRequest implements Parcelable { this.mHostPackageName = hostPackageName; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mHostPackageName); + this.mSupportedLocales = supportedLocales; + com.android.internal.util.AnnotationValidations.validate( + NonNull.class, null, mSupportedLocales); this.mHostInputToken = hostInputToken; + this.mExtras = extras; onConstructed(); } @@ -171,6 +193,15 @@ public final class InlineSuggestionsRequest implements Parcelable { } /** + * The IME provided locales for the request. If non-empty, the inline suggestions should + * return languages from the supported locales. If not provided, it'll default to system locale. + */ + @DataClass.Generated.Member + public @NonNull LocaleList getSupportedLocales() { + return mSupportedLocales; + } + + /** * The host input token of the IME that made the request. This will be set by the system for * safety reasons. * @@ -181,6 +212,14 @@ public final class InlineSuggestionsRequest implements Parcelable { return mHostInputToken; } + /** + * The extras state propagated from the IME to pass extra data. + */ + @DataClass.Generated.Member + public @Nullable Bundle getExtras() { + return mExtras; + } + @Override @DataClass.Generated.Member public String toString() { @@ -191,7 +230,9 @@ public final class InlineSuggestionsRequest implements Parcelable { "maxSuggestionCount = " + mMaxSuggestionCount + ", " + "presentationSpecs = " + mPresentationSpecs + ", " + "hostPackageName = " + mHostPackageName + ", " + - "hostInputToken = " + mHostInputToken + + "supportedLocales = " + mSupportedLocales + ", " + + "hostInputToken = " + mHostInputToken + ", " + + "extras = " + mExtras + " }"; } @@ -211,7 +252,9 @@ public final class InlineSuggestionsRequest implements Parcelable { && mMaxSuggestionCount == that.mMaxSuggestionCount && java.util.Objects.equals(mPresentationSpecs, that.mPresentationSpecs) && java.util.Objects.equals(mHostPackageName, that.mHostPackageName) - && java.util.Objects.equals(mHostInputToken, that.mHostInputToken); + && java.util.Objects.equals(mSupportedLocales, that.mSupportedLocales) + && java.util.Objects.equals(mHostInputToken, that.mHostInputToken) + && java.util.Objects.equals(mExtras, that.mExtras); } @Override @@ -224,7 +267,9 @@ public final class InlineSuggestionsRequest implements Parcelable { _hash = 31 * _hash + mMaxSuggestionCount; _hash = 31 * _hash + java.util.Objects.hashCode(mPresentationSpecs); _hash = 31 * _hash + java.util.Objects.hashCode(mHostPackageName); + _hash = 31 * _hash + java.util.Objects.hashCode(mSupportedLocales); _hash = 31 * _hash + java.util.Objects.hashCode(mHostInputToken); + _hash = 31 * _hash + java.util.Objects.hashCode(mExtras); return _hash; } @@ -235,12 +280,15 @@ public final class InlineSuggestionsRequest implements Parcelable { // void parcelFieldName(Parcel dest, int flags) { ... } byte flg = 0; - if (mHostInputToken != null) flg |= 0x8; + if (mHostInputToken != null) flg |= 0x10; + if (mExtras != null) flg |= 0x20; dest.writeByte(flg); dest.writeInt(mMaxSuggestionCount); dest.writeParcelableList(mPresentationSpecs, flags); dest.writeString(mHostPackageName); + dest.writeTypedObject(mSupportedLocales, flags); if (mHostInputToken != null) dest.writeStrongBinder(mHostInputToken); + if (mExtras != null) dest.writeBundle(mExtras); } @Override @@ -259,7 +307,9 @@ public final class InlineSuggestionsRequest implements Parcelable { List<InlinePresentationSpec> presentationSpecs = new ArrayList<>(); in.readParcelableList(presentationSpecs, InlinePresentationSpec.class.getClassLoader()); String hostPackageName = in.readString(); - IBinder hostInputToken = (flg & 0x8) == 0 ? null : in.readStrongBinder(); + LocaleList supportedLocales = (LocaleList) in.readTypedObject(LocaleList.CREATOR); + IBinder hostInputToken = (flg & 0x10) == 0 ? null : in.readStrongBinder(); + Bundle extras = (flg & 0x20) == 0 ? null : in.readBundle(); this.mMaxSuggestionCount = maxSuggestionCount; this.mPresentationSpecs = presentationSpecs; @@ -268,7 +318,11 @@ public final class InlineSuggestionsRequest implements Parcelable { this.mHostPackageName = hostPackageName; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mHostPackageName); + this.mSupportedLocales = supportedLocales; + com.android.internal.util.AnnotationValidations.validate( + NonNull.class, null, mSupportedLocales); this.mHostInputToken = hostInputToken; + this.mExtras = extras; onConstructed(); } @@ -297,7 +351,9 @@ public final class InlineSuggestionsRequest implements Parcelable { private int mMaxSuggestionCount; private @NonNull List<InlinePresentationSpec> mPresentationSpecs; private @NonNull String mHostPackageName; + private @NonNull LocaleList mSupportedLocales; private @Nullable IBinder mHostInputToken; + private @Nullable Bundle mExtras; private long mBuilderFieldsSet = 0L; @@ -368,6 +424,18 @@ public final class InlineSuggestionsRequest implements Parcelable { } /** + * The IME provided locales for the request. If non-empty, the inline suggestions should + * return languages from the supported locales. If not provided, it'll default to system locale. + */ + @DataClass.Generated.Member + public @NonNull Builder setSupportedLocales(@NonNull LocaleList value) { + checkNotUsed(); + mBuilderFieldsSet |= 0x8; + mSupportedLocales = value; + return this; + } + + /** * The host input token of the IME that made the request. This will be set by the system for * safety reasons. * @@ -377,15 +445,26 @@ public final class InlineSuggestionsRequest implements Parcelable { @Override @NonNull Builder setHostInputToken(@Nullable IBinder value) { checkNotUsed(); - mBuilderFieldsSet |= 0x8; + mBuilderFieldsSet |= 0x10; mHostInputToken = value; return this; } + /** + * The extras state propagated from the IME to pass extra data. + */ + @DataClass.Generated.Member + public @NonNull Builder setExtras(@Nullable Bundle value) { + checkNotUsed(); + mBuilderFieldsSet |= 0x20; + mExtras = value; + return this; + } + /** Builds the instance. This builder should not be touched after calling this! */ public @NonNull InlineSuggestionsRequest build() { checkNotUsed(); - mBuilderFieldsSet |= 0x10; // Mark builder used + mBuilderFieldsSet |= 0x40; // Mark builder used if ((mBuilderFieldsSet & 0x1) == 0) { mMaxSuggestionCount = defaultMaxSuggestionCount(); @@ -394,18 +473,26 @@ public final class InlineSuggestionsRequest implements Parcelable { mHostPackageName = defaultHostPackageName(); } if ((mBuilderFieldsSet & 0x8) == 0) { + mSupportedLocales = defaultSupportedLocales(); + } + if ((mBuilderFieldsSet & 0x10) == 0) { mHostInputToken = defaultHostInputToken(); } + if ((mBuilderFieldsSet & 0x20) == 0) { + mExtras = defaultExtras(); + } InlineSuggestionsRequest o = new InlineSuggestionsRequest( mMaxSuggestionCount, mPresentationSpecs, mHostPackageName, - mHostInputToken); + mSupportedLocales, + mHostInputToken, + mExtras); return o; } private void checkNotUsed() { - if ((mBuilderFieldsSet & 0x10) != 0) { + if ((mBuilderFieldsSet & 0x40) != 0) { throw new IllegalStateException( "This Builder should not be reused. Use a new Builder instance instead"); } @@ -413,10 +500,10 @@ public final class InlineSuggestionsRequest implements Parcelable { } @DataClass.Generated( - time = 1581555687721L, + time = 1581747892762L, codegenVersion = "1.0.14", sourceFile = "frameworks/base/core/java/android/view/inputmethod/InlineSuggestionsRequest.java", - inputSignatures = "public static final int SUGGESTION_COUNT_UNLIMITED\nprivate final int mMaxSuggestionCount\nprivate final @android.annotation.NonNull java.util.List<android.view.inline.InlinePresentationSpec> mPresentationSpecs\nprivate @android.annotation.NonNull java.lang.String mHostPackageName\nprivate @android.annotation.Nullable android.os.IBinder mHostInputToken\npublic void setHostPackageName(java.lang.String)\npublic void setHostInputToken(android.os.IBinder)\nprivate void onConstructed()\nprivate static int defaultMaxSuggestionCount()\nprivate static java.lang.String defaultHostPackageName()\nprivate static android.os.IBinder defaultHostInputToken()\nclass InlineSuggestionsRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genBuilder=true)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setPresentationSpecs(java.util.List<android.view.inline.InlinePresentationSpec>)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostPackageName(java.lang.String)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostInputToken(android.os.IBinder)\nclass BaseBuilder extends java.lang.Object implements []") + inputSignatures = "public static final int SUGGESTION_COUNT_UNLIMITED\nprivate final int mMaxSuggestionCount\nprivate final @android.annotation.NonNull java.util.List<android.view.inline.InlinePresentationSpec> mPresentationSpecs\nprivate @android.annotation.NonNull java.lang.String mHostPackageName\nprivate @android.annotation.NonNull android.os.LocaleList mSupportedLocales\nprivate @android.annotation.Nullable android.os.IBinder mHostInputToken\nprivate @android.annotation.Nullable android.os.Bundle mExtras\npublic void setHostInputToken(android.os.IBinder)\nprivate void onConstructed()\nprivate static int defaultMaxSuggestionCount()\nprivate static java.lang.String defaultHostPackageName()\nprivate static android.os.LocaleList defaultSupportedLocales()\nprivate static @android.annotation.Nullable android.os.IBinder defaultHostInputToken()\nprivate static @android.annotation.Nullable android.os.Bundle defaultExtras()\nclass InlineSuggestionsRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genBuilder=true)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setPresentationSpecs(java.util.List<android.view.inline.InlinePresentationSpec>)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostPackageName(java.lang.String)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostInputToken(android.os.IBinder)\nclass BaseBuilder extends java.lang.Object implements []") @Deprecated private void __metadata() {} |
