blob: 9cf1b87f7eabd9408d1164eeebd32a797c335f7e [file] [log] [blame]
Adam He3e01bc32019-12-13 14:30:13 -08001/*
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
17package android.service.autofill;
18
19import android.annotation.NonNull;
Feng Cao4b0ef392020-02-25 18:18:36 -080020import android.annotation.Size;
Adam He3e01bc32019-12-13 14:30:13 -080021import android.app.slice.Slice;
22import android.os.Parcel;
23import android.os.Parcelable;
Adam Hef27433a2020-03-25 15:11:18 -070024import android.widget.inline.InlinePresentationSpec;
Adam He3e01bc32019-12-13 14:30:13 -080025
26import com.android.internal.util.DataClass;
27
Feng Cao4b0ef392020-02-25 18:18:36 -080028import java.util.List;
29
Adam He3e01bc32019-12-13 14:30:13 -080030/**
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)
38public final class InlinePresentation implements Parcelable {
39
Feng Cao91994982020-01-22 13:32:36 -080040
41 /**
42 * Represents the UI content and the action for the inline suggestion.
43 */
Adam He3e01bc32019-12-13 14:30:13 -080044 private final @NonNull Slice mSlice;
45
Feng Cao91994982020-01-22 13:32:36 -080046 /**
47 * Specifies the UI specification for the inline suggestion.
48 */
Adam He3e01bc32019-12-13 14:30:13 -080049 private final @NonNull InlinePresentationSpec mInlinePresentationSpec;
50
Feng Cao91994982020-01-22 13:32:36 -080051 /**
Ahaan Ugale8893d302020-03-24 19:27:26 -070052 * Indicates whether the UI should be pinned, hence non-scrollable and non-filterable, in the
53 * host.
Feng Cao91994982020-01-22 13:32:36 -080054 */
55 private final boolean mPinned;
56
Feng Cao4b0ef392020-02-25 18:18:36 -080057 /**
58 * Returns the autofill hints set in the slice.
59 *
60 * @hide
61 */
62 @NonNull
63 @Size(min = 0)
64 public String[] getAutofillHints() {
65 List<String> hints = mSlice.getHints();
66 return hints.toArray(new String[hints.size()]);
67 }
68
Adam He3e01bc32019-12-13 14:30:13 -080069
Feng Cao77636e82020-03-30 19:57:12 -070070
71 // Code below generated by codegen v1.0.15.
Adam He3e01bc32019-12-13 14:30:13 -080072 //
73 // DO NOT MODIFY!
74 // CHECKSTYLE:OFF Generated code
75 //
76 // To regenerate run:
77 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/service/autofill/InlinePresentation.java
78 //
79 // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
80 // Settings > Editor > Code Style > Formatter Control
81 //@formatter:off
82
83
Feng Cao91994982020-01-22 13:32:36 -080084 /**
85 * Creates a new InlinePresentation.
86 *
87 * @param slice
88 * Represents the UI content and the action for the inline suggestion.
89 * @param inlinePresentationSpec
90 * Specifies the UI specification for the inline suggestion.
91 * @param pinned
Feng Cao77636e82020-03-30 19:57:12 -070092 * Indicates whether the UI should be pinned, hence non-scrollable and non-filterable, in the
93 * host.
Feng Cao91994982020-01-22 13:32:36 -080094 */
Adam He3e01bc32019-12-13 14:30:13 -080095 @DataClass.Generated.Member
96 public InlinePresentation(
97 @NonNull Slice slice,
Feng Cao91994982020-01-22 13:32:36 -080098 @NonNull InlinePresentationSpec inlinePresentationSpec,
99 boolean pinned) {
Adam He3e01bc32019-12-13 14:30:13 -0800100 this.mSlice = slice;
101 com.android.internal.util.AnnotationValidations.validate(
102 NonNull.class, null, mSlice);
103 this.mInlinePresentationSpec = inlinePresentationSpec;
104 com.android.internal.util.AnnotationValidations.validate(
105 NonNull.class, null, mInlinePresentationSpec);
Feng Cao91994982020-01-22 13:32:36 -0800106 this.mPinned = pinned;
Adam He3e01bc32019-12-13 14:30:13 -0800107
108 // onConstructed(); // You can define this method to get a callback
109 }
110
Feng Cao91994982020-01-22 13:32:36 -0800111 /**
112 * Represents the UI content and the action for the inline suggestion.
113 */
Adam He3e01bc32019-12-13 14:30:13 -0800114 @DataClass.Generated.Member
115 public @NonNull Slice getSlice() {
116 return mSlice;
117 }
118
Feng Cao91994982020-01-22 13:32:36 -0800119 /**
120 * Specifies the UI specification for the inline suggestion.
121 */
Adam He3e01bc32019-12-13 14:30:13 -0800122 @DataClass.Generated.Member
123 public @NonNull InlinePresentationSpec getInlinePresentationSpec() {
124 return mInlinePresentationSpec;
125 }
126
Feng Cao91994982020-01-22 13:32:36 -0800127 /**
Feng Cao77636e82020-03-30 19:57:12 -0700128 * Indicates whether the UI should be pinned, hence non-scrollable and non-filterable, in the
129 * host.
Feng Cao91994982020-01-22 13:32:36 -0800130 */
131 @DataClass.Generated.Member
132 public boolean isPinned() {
133 return mPinned;
134 }
135
Adam He3e01bc32019-12-13 14:30:13 -0800136 @Override
137 @DataClass.Generated.Member
138 public String toString() {
139 // You can override field toString logic by defining methods like:
140 // String fieldNameToString() { ... }
141
142 return "InlinePresentation { " +
143 "slice = " + mSlice + ", " +
Feng Cao91994982020-01-22 13:32:36 -0800144 "inlinePresentationSpec = " + mInlinePresentationSpec + ", " +
145 "pinned = " + mPinned +
Adam He3e01bc32019-12-13 14:30:13 -0800146 " }";
147 }
148
149 @Override
150 @DataClass.Generated.Member
151 public boolean equals(@android.annotation.Nullable Object o) {
152 // You can override field equality logic by defining either of the methods like:
153 // boolean fieldNameEquals(InlinePresentation other) { ... }
154 // boolean fieldNameEquals(FieldType otherValue) { ... }
155
156 if (this == o) return true;
157 if (o == null || getClass() != o.getClass()) return false;
158 @SuppressWarnings("unchecked")
159 InlinePresentation that = (InlinePresentation) o;
160 //noinspection PointlessBooleanExpression
161 return true
162 && java.util.Objects.equals(mSlice, that.mSlice)
Feng Cao91994982020-01-22 13:32:36 -0800163 && java.util.Objects.equals(mInlinePresentationSpec, that.mInlinePresentationSpec)
164 && mPinned == that.mPinned;
Adam He3e01bc32019-12-13 14:30:13 -0800165 }
166
167 @Override
168 @DataClass.Generated.Member
169 public int hashCode() {
170 // You can override field hashCode logic by defining methods like:
171 // int fieldNameHashCode() { ... }
172
173 int _hash = 1;
174 _hash = 31 * _hash + java.util.Objects.hashCode(mSlice);
175 _hash = 31 * _hash + java.util.Objects.hashCode(mInlinePresentationSpec);
Feng Cao91994982020-01-22 13:32:36 -0800176 _hash = 31 * _hash + Boolean.hashCode(mPinned);
Adam He3e01bc32019-12-13 14:30:13 -0800177 return _hash;
178 }
179
180 @Override
181 @DataClass.Generated.Member
182 public void writeToParcel(@NonNull Parcel dest, int flags) {
183 // You can override field parcelling by defining methods like:
184 // void parcelFieldName(Parcel dest, int flags) { ... }
185
Feng Cao91994982020-01-22 13:32:36 -0800186 byte flg = 0;
187 if (mPinned) flg |= 0x4;
188 dest.writeByte(flg);
Adam He3e01bc32019-12-13 14:30:13 -0800189 dest.writeTypedObject(mSlice, flags);
190 dest.writeTypedObject(mInlinePresentationSpec, flags);
191 }
192
193 @Override
194 @DataClass.Generated.Member
195 public int describeContents() { return 0; }
196
197 /** @hide */
198 @SuppressWarnings({"unchecked", "RedundantCast"})
199 @DataClass.Generated.Member
200 /* package-private */ InlinePresentation(@NonNull Parcel in) {
201 // You can override field unparcelling by defining methods like:
202 // static FieldType unparcelFieldName(Parcel in) { ... }
203
Feng Cao91994982020-01-22 13:32:36 -0800204 byte flg = in.readByte();
205 boolean pinned = (flg & 0x4) != 0;
Adam He3e01bc32019-12-13 14:30:13 -0800206 Slice slice = (Slice) in.readTypedObject(Slice.CREATOR);
207 InlinePresentationSpec inlinePresentationSpec = (InlinePresentationSpec) in.readTypedObject(InlinePresentationSpec.CREATOR);
208
209 this.mSlice = slice;
210 com.android.internal.util.AnnotationValidations.validate(
211 NonNull.class, null, mSlice);
212 this.mInlinePresentationSpec = inlinePresentationSpec;
213 com.android.internal.util.AnnotationValidations.validate(
214 NonNull.class, null, mInlinePresentationSpec);
Feng Cao91994982020-01-22 13:32:36 -0800215 this.mPinned = pinned;
Adam He3e01bc32019-12-13 14:30:13 -0800216
217 // onConstructed(); // You can define this method to get a callback
218 }
219
220 @DataClass.Generated.Member
221 public static final @NonNull Parcelable.Creator<InlinePresentation> CREATOR
222 = new Parcelable.Creator<InlinePresentation>() {
223 @Override
224 public InlinePresentation[] newArray(int size) {
225 return new InlinePresentation[size];
226 }
227
228 @Override
229 public InlinePresentation createFromParcel(@NonNull Parcel in) {
230 return new InlinePresentation(in);
231 }
232 };
233
234 @DataClass.Generated(
Adam He3f8cdb52020-04-15 15:31:46 -0700235 time = 1586992400667L,
Feng Cao77636e82020-03-30 19:57:12 -0700236 codegenVersion = "1.0.15",
Adam He3e01bc32019-12-13 14:30:13 -0800237 sourceFile = "frameworks/base/core/java/android/service/autofill/InlinePresentation.java",
Adam Hef27433a2020-03-25 15:11:18 -0700238 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(min=0L) java.lang.String[] getAutofillHints()\nclass InlinePresentation extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstDefs=true, genEqualsHashCode=true)")
Adam He3e01bc32019-12-13 14:30:13 -0800239 @Deprecated
240 private void __metadata() {}
241
242
243 //@formatter:on
244 // End of generated code
245
246}