Debian Codegraph @

core/java/android/widget/inline/InlinePresentationSpec.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package android.widget.inline;
18
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.os.Bundle;
22 import android.os.Parcelable;
23 import android.util.Size;
24
25 import com.android.internal.util.DataClass;
26 import com.android.internal.widget.InlinePresentationStyleUtils;
27
28 /**
29 * This class represents the presentation specification by which an inline suggestion
30 * should abide when constructing its UI. Since suggestions are inlined in a
31 * host application while provided by another source, they need to be consistent
32 * with the host's look at feel to allow building smooth and integrated UIs.
33 */
34 @DataClass(genEqualsHashCode = true, genToString = true, genBuilder = true)
35 public final class InlinePresentationSpec implements Parcelable {
36
37 /** The minimal size of the suggestion. */
38 @NonNull
39 private final Size mMinSize;
40 /** The maximal size of the suggestion. */
41 @NonNull
42 private final Size mMaxSize;
43
44 /**
45 * The extras encoding the UI style information.
46 *
47 * <p>The style bundles can be created using the relevant Style classes and their builders in
48 * the androidx autofill library e.g. {@code androidx.autofill.inline.UiVersions.StylesBuilder}.
49 * </p>
50 *
51 * <p>The style must be set for the suggestion to render properly.</p>
52 *
53 * <p>Note: There should be no remote objects in the bundle, all included remote objects will
54 * be removed from the bundle before transmission.</p>
55 */
56 @NonNull
57 private final Bundle mStyle;
58
59 @NonNull
60 private static Bundle defaultStyle() {
61 return Bundle.EMPTY;
62 }
63
64 private boolean styleEquals(@NonNull Bundle style) {
65 return InlinePresentationStyleUtils.bundleEquals(mStyle, style);
66 }
67
68 /**
69 * Removes the remote objects from the {@code mStyle}.
70 * @hide
71 */
72 public void filterContentTypes() {
73 InlinePresentationStyleUtils.filterContentTypes(mStyle);
74 }
75
76 /** @hide */
77 @DataClass.Suppress({"setMaxSize", "setMinSize"})
78 abstract static class BaseBuilder {
79 }
80
81
82
83 // Code below generated by codegen v1.0.15.
84 //
85 // DO NOT MODIFY!
86 // CHECKSTYLE:OFF Generated code
87 //
88 // To regenerate run:
89 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/widget/inline/InlinePresentationSpec.java
90 //
91 // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
92 // Settings > Editor > Code Style > Formatter Control
93 //@formatter:off
94
95
96 @DataClass.Generated.Member
97 /* package-private */ InlinePresentationSpec(
98 @NonNull Size minSize,
99 @NonNull Size maxSize,
100 @NonNull Bundle style) {
101 this.mMinSize = minSize;
102 com.android.internal.util.AnnotationValidations.validate(
103 NonNull.class, null, mMinSize);
104 this.mMaxSize = maxSize;
105 com.android.internal.util.AnnotationValidations.validate(
106 NonNull.class, null, mMaxSize);
107 this.mStyle = style;
108 com.android.internal.util.AnnotationValidations.validate(
109 NonNull.class, null, mStyle);
110
111 // onConstructed(); // You can define this method to get a callback
112 }
113
114 /**
115 * The minimal size of the suggestion.
116 */
117 @DataClass.Generated.Member
118 public @NonNull Size getMinSize() {
119 return mMinSize;
120 }
121
122 /**
123 * The maximal size of the suggestion.
124 */
125 @DataClass.Generated.Member
126 public @NonNull Size getMaxSize() {
127 return mMaxSize;
128 }
129
130 /**
131 * The extras encoding the UI style information.
132 *
133 * <p>The style bundles can be created using the relevant Style classes and their builders in
134 * the androidx autofill library e.g. {@code androidx.autofill.inline.UiVersions.StylesBuilder}.
135 * </p>
136 *
137 * <p>The style must be set for the suggestion to render properly.</p>
138 *
139 * <p>Note: There should be no remote objects in the bundle, all included remote objects will
140 * be removed from the bundle before transmission.</p>
141 */
142 @DataClass.Generated.Member
143 public @NonNull Bundle getStyle() {
144 return mStyle;
145 }
146
147 @Override
148 @DataClass.Generated.Member
149 public String toString() {
150 // You can override field toString logic by defining methods like:
151 // String fieldNameToString() { ... }
152
153 return "InlinePresentationSpec { " +
154 "minSize = " + mMinSize + ", " +
155 "maxSize = " + mMaxSize + ", " +
156 "style = " + mStyle +
157 " }";
158 }
159
160 @Override
161 @DataClass.Generated.Member
162 public boolean equals(@Nullable Object o) {
163 // You can override field equality logic by defining either of the methods like:
164 // boolean fieldNameEquals(InlinePresentationSpec other) { ... }
165 // boolean fieldNameEquals(FieldType otherValue) { ... }
166
167 if (this == o) return true;
168 if (o == null || getClass() != o.getClass()) return false;
169 @SuppressWarnings("unchecked")
170 InlinePresentationSpec that = (InlinePresentationSpec) o;
171 //noinspection PointlessBooleanExpression
172 return true
173 && java.util.Objects.equals(mMinSize, that.mMinSize)
174 && java.util.Objects.equals(mMaxSize, that.mMaxSize)
175 && styleEquals(that.mStyle);
176 }
177
178 @Override
179 @DataClass.Generated.Member
180 public int hashCode() {
181 // You can override field hashCode logic by defining methods like:
182 // int fieldNameHashCode() { ... }
183
184 int _hash = 1;
185 _hash = 31 * _hash + java.util.Objects.hashCode(mMinSize);
186 _hash = 31 * _hash + java.util.Objects.hashCode(mMaxSize);
187 _hash = 31 * _hash + java.util.Objects.hashCode(mStyle);
188 return _hash;
189 }
190
191 @Override
192 @DataClass.Generated.Member
193 public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
194 // You can override field parcelling by defining methods like:
195 // void parcelFieldName(Parcel dest, int flags) { ... }
196
197 dest.writeSize(mMinSize);
198 dest.writeSize(mMaxSize);
199 dest.writeBundle(mStyle);
200 }
201
202 @Override
203 @DataClass.Generated.Member
204 public int describeContents() { return 0; }
205
206 /** @hide */
207 @SuppressWarnings({"unchecked", "RedundantCast"})
208 @DataClass.Generated.Member
209 /* package-private */ InlinePresentationSpec(@NonNull android.os.Parcel in) {
210 // You can override field unparcelling by defining methods like:
211 // static FieldType unparcelFieldName(Parcel in) { ... }
212
213 Size minSize = (Size) in.readSize();
214 Size maxSize = (Size) in.readSize();
215 Bundle style = in.readBundle();
216
217 this.mMinSize = minSize;
218 com.android.internal.util.AnnotationValidations.validate(
219 NonNull.class, null, mMinSize);
220 this.mMaxSize = maxSize;
221 com.android.internal.util.AnnotationValidations.validate(
222 NonNull.class, null, mMaxSize);
223 this.mStyle = style;
224 com.android.internal.util.AnnotationValidations.validate(
225 NonNull.class, null, mStyle);
226
227 // onConstructed(); // You can define this method to get a callback
228 }
229
230 @DataClass.Generated.Member
231 public static final @NonNull Parcelable.Creator<InlinePresentationSpec> CREATOR
232 = new Parcelable.Creator<InlinePresentationSpec>() {
233 @Override
234 public InlinePresentationSpec[] newArray(int size) {
235 return new InlinePresentationSpec[size];
236 }
237
238 @Override
239 public InlinePresentationSpec createFromParcel(@NonNull android.os.Parcel in) {
240 return new InlinePresentationSpec(in);
241 }
242 };
243
244 /**
245 * A builder for {@link InlinePresentationSpec}
246 */
247 @SuppressWarnings("WeakerAccess")
248 @DataClass.Generated.Member
249 public static final class Builder extends BaseBuilder {
250
251 private @NonNull Size mMinSize;
252 private @NonNull Size mMaxSize;
253 private @NonNull Bundle mStyle;
254
255 private long mBuilderFieldsSet = 0L;
256
257 /**
258 * Creates a new Builder.
259 *
260 * @param minSize
261 * The minimal size of the suggestion.
262 * @param maxSize
263 * The maximal size of the suggestion.
264 */
265 public Builder(
266 @NonNull Size minSize,
267 @NonNull Size maxSize) {
268 mMinSize = minSize;
269 com.android.internal.util.AnnotationValidations.validate(
270 NonNull.class, null, mMinSize);
271 mMaxSize = maxSize;
272 com.android.internal.util.AnnotationValidations.validate(
273 NonNull.class, null, mMaxSize);
274 }
275
276 /**
277 * The extras encoding the UI style information.
278 *
279 * <p>The style bundles can be created using the relevant Style classes and their builders in
280 * the androidx autofill library e.g. {@code androidx.autofill.inline.UiVersions.StylesBuilder}.
281 * </p>
282 *
283 * <p>The style must be set for the suggestion to render properly.</p>
284 *
285 * <p>Note: There should be no remote objects in the bundle, all included remote objects will
286 * be removed from the bundle before transmission.</p>
287 */
288 @DataClass.Generated.Member
289 public @NonNull Builder setStyle(@NonNull Bundle value) {
290 checkNotUsed();
291 mBuilderFieldsSet |= 0x4;
292 mStyle = value;
293 return this;
294 }
295
296 /** Builds the instance. This builder should not be touched after calling this! */
297 public @NonNull InlinePresentationSpec build() {
298 checkNotUsed();
299 mBuilderFieldsSet |= 0x8; // Mark builder used
300
301 if ((mBuilderFieldsSet & 0x4) == 0) {
302 mStyle = defaultStyle();
303 }
304 InlinePresentationSpec o = new InlinePresentationSpec(
305 mMinSize,
306 mMaxSize,
307 mStyle);
308 return o;
309 }
310
311 private void checkNotUsed() {
312 if ((mBuilderFieldsSet & 0x8) != 0) {
313 throw new IllegalStateException(
314 "This Builder should not be reused. Use a new Builder instance instead");
315 }
316 }
317 }
318
319 @DataClass.Generated(
320 time = 1596485189661L,
321 codegenVersion = "1.0.15",
322 sourceFile = "frameworks/base/core/java/android/widget/inline/InlinePresentationSpec.java",
323 inputSignatures = "private final @android.annotation.NonNull android.util.Size mMinSize\nprivate final @android.annotation.NonNull android.util.Size mMaxSize\nprivate final @android.annotation.NonNull android.os.Bundle mStyle\nprivate static @android.annotation.NonNull android.os.Bundle defaultStyle()\nprivate boolean styleEquals(android.os.Bundle)\npublic void filterContentTypes()\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 []")
324 @Deprecated
325 private void __metadata() {}
326
327
328 //@formatter:on
329 // End of generated code
330
331 }