Merge "Add styling related fields to Inline presentation spec."
This commit is contained in:
committed by
Android (Google) Code Review
commit
4c3a915c36
@@ -54334,6 +54334,7 @@ package android.view.inline {
|
||||
public static final class InlinePresentationSpec.Builder {
|
||||
ctor public InlinePresentationSpec.Builder(@NonNull android.util.Size, @NonNull android.util.Size);
|
||||
method @NonNull public android.view.inline.InlinePresentationSpec build();
|
||||
method @NonNull public android.view.inline.InlinePresentationSpec.Builder setStyle(@Nullable String);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.android.internal.util.DataClass;
|
||||
*/
|
||||
@DataClass(genEqualsHashCode = true, genToString = true, genBuilder = true)
|
||||
public final class InlinePresentationSpec implements Parcelable {
|
||||
|
||||
/** The minimal size of the suggestion. */
|
||||
@NonNull
|
||||
private final Size mMinSize;
|
||||
@@ -38,7 +39,26 @@ public final class InlinePresentationSpec implements Parcelable {
|
||||
@NonNull
|
||||
private final Size mMaxSize;
|
||||
|
||||
// TODO(b/137800469): add more attributes, such as text appearance info.
|
||||
/**
|
||||
* 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)}.
|
||||
*/
|
||||
@Nullable
|
||||
private final String mStyle;
|
||||
|
||||
private static String defaultStyle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public @Nullable String getStyle() {
|
||||
return mStyle;
|
||||
}
|
||||
|
||||
|
||||
/** @hide */
|
||||
@DataClass.Suppress({"setMaxSize", "setMinSize"})
|
||||
@@ -63,13 +83,15 @@ public final class InlinePresentationSpec implements Parcelable {
|
||||
@DataClass.Generated.Member
|
||||
/* package-private */ InlinePresentationSpec(
|
||||
@NonNull Size minSize,
|
||||
@NonNull Size maxSize) {
|
||||
@NonNull Size maxSize,
|
||||
@Nullable String style) {
|
||||
this.mMinSize = minSize;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mMinSize);
|
||||
this.mMaxSize = maxSize;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mMaxSize);
|
||||
this.mStyle = style;
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
@@ -98,7 +120,8 @@ public final class InlinePresentationSpec implements Parcelable {
|
||||
|
||||
return "InlinePresentationSpec { " +
|
||||
"minSize = " + mMinSize + ", " +
|
||||
"maxSize = " + mMaxSize +
|
||||
"maxSize = " + mMaxSize + ", " +
|
||||
"style = " + mStyle +
|
||||
" }";
|
||||
}
|
||||
|
||||
@@ -116,7 +139,8 @@ public final class InlinePresentationSpec implements Parcelable {
|
||||
//noinspection PointlessBooleanExpression
|
||||
return true
|
||||
&& java.util.Objects.equals(mMinSize, that.mMinSize)
|
||||
&& java.util.Objects.equals(mMaxSize, that.mMaxSize);
|
||||
&& java.util.Objects.equals(mMaxSize, that.mMaxSize)
|
||||
&& java.util.Objects.equals(mStyle, that.mStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,6 +152,7 @@ public final class InlinePresentationSpec implements Parcelable {
|
||||
int _hash = 1;
|
||||
_hash = 31 * _hash + java.util.Objects.hashCode(mMinSize);
|
||||
_hash = 31 * _hash + java.util.Objects.hashCode(mMaxSize);
|
||||
_hash = 31 * _hash + java.util.Objects.hashCode(mStyle);
|
||||
return _hash;
|
||||
}
|
||||
|
||||
@@ -137,8 +162,12 @@ public final class InlinePresentationSpec implements Parcelable {
|
||||
// You can override field parcelling by defining methods like:
|
||||
// void parcelFieldName(Parcel dest, int flags) { ... }
|
||||
|
||||
byte flg = 0;
|
||||
if (mStyle != null) flg |= 0x4;
|
||||
dest.writeByte(flg);
|
||||
dest.writeSize(mMinSize);
|
||||
dest.writeSize(mMaxSize);
|
||||
if (mStyle != null) dest.writeString(mStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -152,8 +181,10 @@ public final class InlinePresentationSpec implements Parcelable {
|
||||
// You can override field unparcelling by defining methods like:
|
||||
// static FieldType unparcelFieldName(Parcel in) { ... }
|
||||
|
||||
byte flg = in.readByte();
|
||||
Size minSize = (Size) in.readSize();
|
||||
Size maxSize = (Size) in.readSize();
|
||||
String style = (flg & 0x4) == 0 ? null : in.readString();
|
||||
|
||||
this.mMinSize = minSize;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
@@ -161,6 +192,7 @@ public final class InlinePresentationSpec implements Parcelable {
|
||||
this.mMaxSize = maxSize;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mMaxSize);
|
||||
this.mStyle = style;
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
@@ -188,6 +220,7 @@ public final class InlinePresentationSpec implements Parcelable {
|
||||
|
||||
private @NonNull Size mMinSize;
|
||||
private @NonNull Size mMaxSize;
|
||||
private @Nullable String mStyle;
|
||||
|
||||
private long mBuilderFieldsSet = 0L;
|
||||
|
||||
@@ -210,19 +243,37 @@ public final class InlinePresentationSpec implements Parcelable {
|
||||
NonNull.class, null, 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 @NonNull Builder setStyle(@Nullable String value) {
|
||||
checkNotUsed();
|
||||
mBuilderFieldsSet |= 0x4;
|
||||
mStyle = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Builds the instance. This builder should not be touched after calling this! */
|
||||
public @NonNull InlinePresentationSpec build() {
|
||||
checkNotUsed();
|
||||
mBuilderFieldsSet |= 0x4; // Mark builder used
|
||||
mBuilderFieldsSet |= 0x8; // Mark builder used
|
||||
|
||||
if ((mBuilderFieldsSet & 0x4) == 0) {
|
||||
mStyle = defaultStyle();
|
||||
}
|
||||
InlinePresentationSpec o = new InlinePresentationSpec(
|
||||
mMinSize,
|
||||
mMaxSize);
|
||||
mMaxSize,
|
||||
mStyle);
|
||||
return o;
|
||||
}
|
||||
|
||||
private void checkNotUsed() {
|
||||
if ((mBuilderFieldsSet & 0x4) != 0) {
|
||||
if ((mBuilderFieldsSet & 0x8) != 0) {
|
||||
throw new IllegalStateException(
|
||||
"This Builder should not be reused. Use a new Builder instance instead");
|
||||
}
|
||||
@@ -230,10 +281,10 @@ public final class InlinePresentationSpec implements Parcelable {
|
||||
}
|
||||
|
||||
@DataClass.Generated(
|
||||
time = 1574406062532L,
|
||||
time = 1577145109444L,
|
||||
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\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()\npublic @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 []")
|
||||
@Deprecated
|
||||
private void __metadata() {}
|
||||
|
||||
|
||||
@@ -36,7 +36,17 @@ public final class InlineSuggestionsRequest implements Parcelable {
|
||||
/** Constant used to indicate not putting a cap on the number of suggestions to return. */
|
||||
public static final int SUGGESTION_COUNT_UNLIMITED = Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* Max number of suggestions expected from the response. Defaults to {@code
|
||||
* SUGGESTION_COUNT_UNLIMITED} if not set.
|
||||
*/
|
||||
private final int mMaxSuggestionCount;
|
||||
|
||||
/**
|
||||
* The {@link InlinePresentationSpec} for each suggestion in the response. If the max suggestion
|
||||
* count is larger than the number of specs in the list, then the last spec is used for the
|
||||
* remainder of the suggestions.
|
||||
*/
|
||||
private final @NonNull List<InlinePresentationSpec> mPresentationSpecs;
|
||||
|
||||
private void onConstructed() {
|
||||
@@ -79,11 +89,20 @@ public final class InlineSuggestionsRequest implements Parcelable {
|
||||
onConstructed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Max number of suggestions expected from the response. Defaults to {@code
|
||||
* SUGGESTION_COUNT_UNLIMITED} if not set.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public int getMaxSuggestionCount() {
|
||||
return mMaxSuggestionCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link InlinePresentationSpec} for each suggestion in the response. If the max suggestion
|
||||
* count is larger than the number of specs in the list, then the last spec is used for the
|
||||
* remainder of the suggestions.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull List<InlinePresentationSpec> getPresentationSpecs() {
|
||||
return mPresentationSpecs;
|
||||
@@ -189,6 +208,14 @@ public final class InlineSuggestionsRequest implements Parcelable {
|
||||
|
||||
private long mBuilderFieldsSet = 0L;
|
||||
|
||||
/**
|
||||
* Creates a new Builder.
|
||||
*
|
||||
* @param presentationSpecs
|
||||
* The {@link InlinePresentationSpec} for each suggestion in the response. If the max suggestion
|
||||
* count is larger than the number of specs in the list, then the last spec is used for the
|
||||
* remainder of the suggestions.
|
||||
*/
|
||||
public Builder(
|
||||
@NonNull List<InlinePresentationSpec> presentationSpecs) {
|
||||
mPresentationSpecs = presentationSpecs;
|
||||
@@ -196,6 +223,10 @@ public final class InlineSuggestionsRequest implements Parcelable {
|
||||
NonNull.class, null, mPresentationSpecs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Max number of suggestions expected from the response. Defaults to {@code
|
||||
* SUGGESTION_COUNT_UNLIMITED} if not set.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull Builder setMaxSuggestionCount(int value) {
|
||||
checkNotUsed();
|
||||
@@ -204,6 +235,11 @@ public final class InlineSuggestionsRequest implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link InlinePresentationSpec} for each suggestion in the response. If the max suggestion
|
||||
* count is larger than the number of specs in the list, then the last spec is used for the
|
||||
* remainder of the suggestions.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
@Override
|
||||
@NonNull Builder setPresentationSpecs(@NonNull List<InlinePresentationSpec> value) {
|
||||
@@ -247,7 +283,7 @@ public final class InlineSuggestionsRequest implements Parcelable {
|
||||
}
|
||||
|
||||
@DataClass.Generated(
|
||||
time = 1574406255024L,
|
||||
time = 1576637222199L,
|
||||
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 void onConstructed()\nprivate static int defaultMaxSuggestionCount()\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>)\nclass BaseBuilder extends java.lang.Object implements []")
|
||||
|
||||
Reference in New Issue
Block a user