Debian Codegraph @

core/java/android/service/autofill/InlinePresentation.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.service.autofill;
18
19 import android.annotation.NonNull;
20 import android.annotation.Size;
21 import android.app.slice.Slice;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 import android.widget.inline.InlinePresentationSpec;
25
26 import com.android.internal.util.DataClass;
27
28 import java.util.List;
29
30 /**
31 * Wrapper class holding a {@link Slice} and an {@link InlinePresentationSpec} for rendering UI
32 * for an Inline Suggestion.
33 */
34 @DataClass(
35 genToString = true,
36 genHiddenConstDefs = true,
37 genEqualsHashCode = true)
38 public final class InlinePresentation implements Parcelable {
39
40
41 /**
42 * Represents the UI content and the action for the inline suggestion.
43 *
44 * <p>The Slice should be constructed using the Content builder provided in the androidx
45 * autofill library e.g. {@code androidx.autofill.inline.v1.InlineSuggestionUi.Content.Builder}
46 * and then converted to a Slice with
47 * {@code androidx.autofill.inline.UiVersions.Content#getSlice()}.</p>
48 */
49 private final @NonNull Slice mSlice;
50
51 /**
52 * Specifies the UI specification for the inline suggestion.
53 */
54 private final @NonNull InlinePresentationSpec mInlinePresentationSpec;
55
56 /**
57 * Indicates whether the UI should be pinned, hence non-scrollable and non-filterable, in the
58 * host. However, it's eventually up to the host whether the UI is pinned or not.
59 *
60 * <p> Also a {@link Dataset} with a pinned inline presentation will not be replaced by the
61 * new data set returned from authentication intent. See
62 * {@link Dataset.Builder#setAuthentication(android.content.IntentSender)} for more information.
63 */
64 private final boolean mPinned;
65
66 /**
67 * Returns the autofill hints set in the slice.
68 *
69 * @hide
70 */
71 @NonNull
72 @Size(min = 0)
73 public String[] getAutofillHints() {
74 List<String> hints = mSlice.getHints();
75 return hints.toArray(new String[hints.size()]);
76 }
77
78 /**
79 * Creates a presentation for the inline suggestion tooltip
80 *
81 * @param slice Represents the UI content and the action for the inline suggestion tooltip.
82 * @param spec Specifies the UI specification for the inline suggestion tooltip.
83 * @return An {@link InlinePresentation} for the inline suggestion tooltip
84 */
85 @NonNull
86 public static InlinePresentation createTooltipPresentation(@NonNull Slice slice,
87 @NonNull InlinePresentationSpec spec) {
88 return new InlinePresentation(slice, spec, /* pinned */ false);
89
90 }
91
92
93
94 // Code below generated by codegen v1.0.22.
95 //
96 // DO NOT MODIFY!
97 // CHECKSTYLE:OFF Generated code
98 //
99 // To regenerate run:
100 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/service/autofill/InlinePresentation.java
101 //
102 // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
103 // Settings > Editor > Code Style > Formatter Control
104 //@formatter:off
105
106
107 /**
108 * Creates a new InlinePresentation.
109 *
110 * @param slice
111 * Represents the UI content and the action for the inline suggestion.
112 *
113 * <p>The Slice should be constructed using the Content builder provided in the androidx
114 * autofill library e.g. {@code androidx.autofill.inline.v1.InlineSuggestionUi.Content.Builder}
115 * and then converted to a Slice with
116 * {@code androidx.autofill.inline.UiVersions.Content#getSlice()}.</p>
117 * @param inlinePresentationSpec
118 * Specifies the UI specification for the inline suggestion.
119 * @param pinned
120 * Indicates whether the UI should be pinned, hence non-scrollable and non-filterable, in the
121 * host. However, it's eventually up to the host whether the UI is pinned or not.
122 *
123 * <p> Also a {@link Dataset} with a pinned inline presentation will not be replaced by the
124 * new data set returned from authentication intent. See
125 * {@link Dataset.Builder#setAuthentication(android.content.IntentSender)} for more information.
126 */
127 @DataClass.Generated.Member
128 public InlinePresentation(
129 @NonNull Slice slice,
130 @NonNull InlinePresentationSpec inlinePresentationSpec,
131 boolean pinned) {
132 this.mSlice = slice;
133 com.android.internal.util.AnnotationValidations.validate(
134 NonNull.class, null, mSlice);
135 this.mInlinePresentationSpec = inlinePresentationSpec;
136 com.android.internal.util.AnnotationValidations.validate(
137 NonNull.class, null, mInlinePresentationSpec);
138 this.mPinned = pinned;
139
140 // onConstructed(); // You can define this method to get a callback
141 }
142
143 /**
144 * Represents the UI content and the action for the inline suggestion.
145 *
146 * <p>The Slice should be constructed using the Content builder provided in the androidx
147 * autofill library e.g. {@code androidx.autofill.inline.v1.InlineSuggestionUi.Content.Builder}
148 * and then converted to a Slice with
149 * {@code androidx.autofill.inline.UiVersions.Content#getSlice()}.</p>
150 */
151 @DataClass.Generated.Member
152 public @NonNull Slice getSlice() {
153 return mSlice;
154 }
155
156 /**
157 * Specifies the UI specification for the inline suggestion.
158 */
159 @DataClass.Generated.Member
160 public @NonNull InlinePresentationSpec getInlinePresentationSpec() {
161 return mInlinePresentationSpec;
162 }
163
164 /**
165 * Indicates whether the UI should be pinned, hence non-scrollable and non-filterable, in the
166 * host. However, it's eventually up to the host whether the UI is pinned or not.
167 *
168 * <p> Also a {@link Dataset} with a pinned inline presentation will not be replaced by the
169 * new data set returned from authentication intent. See
170 * {@link Dataset.Builder#setAuthentication(android.content.IntentSender)} for more information.
171 */
172 @DataClass.Generated.Member
173 public boolean isPinned() {
174 return mPinned;
175 }
176
177 @Override
178 @DataClass.Generated.Member
179 public String toString() {
180 // You can override field toString logic by defining methods like:
181 // String fieldNameToString() { ... }
182
183 return "InlinePresentation { " +
184 "slice = " + mSlice + ", " +
185 "inlinePresentationSpec = " + mInlinePresentationSpec + ", " +
186 "pinned = " + mPinned +
187 " }";
188 }
189
190 @Override
191 @DataClass.Generated.Member
192 public boolean equals(@android.annotation.Nullable Object o) {
193 // You can override field equality logic by defining either of the methods like:
194 // boolean fieldNameEquals(InlinePresentation other) { ... }
195 // boolean fieldNameEquals(FieldType otherValue) { ... }
196
197 if (this == o) return true;
198 if (o == null || getClass() != o.getClass()) return false;
199 @SuppressWarnings("unchecked")
200 InlinePresentation that = (InlinePresentation) o;
201 //noinspection PointlessBooleanExpression
202 return true
203 && java.util.Objects.equals(mSlice, that.mSlice)
204 && java.util.Objects.equals(mInlinePresentationSpec, that.mInlinePresentationSpec)
205 && mPinned == that.mPinned;
206 }
207
208 @Override
209 @DataClass.Generated.Member
210 public int hashCode() {
211 // You can override field hashCode logic by defining methods like:
212 // int fieldNameHashCode() { ... }
213
214 int _hash = 1;
215 _hash = 31 * _hash + java.util.Objects.hashCode(mSlice);
216 _hash = 31 * _hash + java.util.Objects.hashCode(mInlinePresentationSpec);
217 _hash = 31 * _hash + Boolean.hashCode(mPinned);
218 return _hash;
219 }
220
221 @Override
222 @DataClass.Generated.Member
223 public void writeToParcel(@NonNull Parcel dest, int flags) {
224 // You can override field parcelling by defining methods like:
225 // void parcelFieldName(Parcel dest, int flags) { ... }
226
227 byte flg = 0;
228 if (mPinned) flg |= 0x4;
229 dest.writeByte(flg);
230 dest.writeTypedObject(mSlice, flags);
231 dest.writeTypedObject(mInlinePresentationSpec, flags);
232 }
233
234 @Override
235 @DataClass.Generated.Member
236 public int describeContents() { return 0; }
237
238 /** @hide */
239 @SuppressWarnings({"unchecked", "RedundantCast"})
240 @DataClass.Generated.Member
241 /* package-private */ InlinePresentation(@NonNull Parcel in) {
242 // You can override field unparcelling by defining methods like:
243 // static FieldType unparcelFieldName(Parcel in) { ... }
244
245 byte flg = in.readByte();
246 boolean pinned = (flg & 0x4) != 0;
247 Slice slice = (Slice) in.readTypedObject(Slice.CREATOR);
248 InlinePresentationSpec inlinePresentationSpec = (InlinePresentationSpec) in.readTypedObject(InlinePresentationSpec.CREATOR);
249
250 this.mSlice = slice;
251 com.android.internal.util.AnnotationValidations.validate(
252 NonNull.class, null, mSlice);
253 this.mInlinePresentationSpec = inlinePresentationSpec;
254 com.android.internal.util.AnnotationValidations.validate(
255 NonNull.class, null, mInlinePresentationSpec);
256 this.mPinned = pinned;
257
258 // onConstructed(); // You can define this method to get a callback
259 }
260
261 @DataClass.Generated.Member
262 public static final @NonNull Parcelable.Creator<InlinePresentation> CREATOR
263 = new Parcelable.Creator<InlinePresentation>() {
264 @Override
265 public InlinePresentation[] newArray(int size) {
266 return new InlinePresentation[size];
267 }
268
269 @Override
270 public InlinePresentation createFromParcel(@NonNull Parcel in) {
271 return new InlinePresentation(in);
272 }
273 };
274
275 @DataClass.Generated(
276 time = 1615968415006L,
277 codegenVersion = "1.0.22",
278 sourceFile = "frameworks/base/core/java/android/service/autofill/InlinePresentation.java",
279 inputSignatures = "private final @android.annotation.NonNull android.app.slice.Slice mSlice\nprivate final @android.annotation.NonNull android.widget.inline.InlinePresentationSpec mInlinePresentationSpec\nprivate final boolean mPinned\npublic @android.annotation.NonNull @android.annotation.Size java.lang.String[] getAutofillHints()\npublic static @android.annotation.NonNull android.service.autofill.InlinePresentation createTooltipPresentation(android.app.slice.Slice,android.widget.inline.InlinePresentationSpec)\nclass InlinePresentation extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstDefs=true, genEqualsHashCode=true)")
280 @Deprecated
281 private void __metadata() {}
282
283
284 //@formatter:on
285 // End of generated code
286
287 }