blob: 1c703ecf06ca68d3badb60c56cca70953579ad0a [file] [log] [blame]
Feng Cao04830a32019-11-13 00:45:19 -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.view.inputmethod;
18
19import android.annotation.NonNull;
20import android.annotation.Nullable;
Feng Cao91994982020-01-22 13:32:36 -080021import android.annotation.SuppressLint;
Joanne Chung2e707602020-01-09 18:14:49 +080022import android.annotation.TestApi;
Feng Cao04830a32019-11-13 00:45:19 -080023import android.os.Parcelable;
Adam Hef27433a2020-03-25 15:11:18 -070024import android.widget.inline.InlinePresentationSpec;
Feng Cao04830a32019-11-13 00:45:19 -080025
26import com.android.internal.util.DataClass;
27
28/**
29 * This class represents the description of an inline suggestion. It contains information to help
30 * the IME to decide where and when to show the suggestions. See {@link InlineSuggestion} for more
31 * information.
32 */
33@DataClass(
34 genEqualsHashCode = true,
35 genToString = true,
36 genHiddenConstDefs = true,
37 genHiddenConstructor = true)
38public final class InlineSuggestionInfo implements Parcelable {
39
40 /**
41 * Suggestion source: the suggestion is made by the user selected autofill service.
42 */
43 public static final @Source String SOURCE_AUTOFILL = "android:autofill";
44 /**
45 * Suggestion source: the suggestion is made by the platform.
46 */
47 public static final @Source String SOURCE_PLATFORM = "android:platform";
48
Feng Cao91994982020-01-22 13:32:36 -080049 /**
50 * UI type: the UI contains an Autofill suggestion that will autofill the fields when tapped.
51 */
52 public static final @Type String TYPE_SUGGESTION = "android:autofill:suggestion";
53
54 /**
55 * UI type: the UI contains an widget that will launch an intent when tapped.
56 */
57 @SuppressLint({"IntentName"})
58 public static final @Type String TYPE_ACTION = "android:autofill:action";
59
Feng Cao04830a32019-11-13 00:45:19 -080060 /** The presentation spec to which the inflated suggestion view abides. */
Adam Hef27433a2020-03-25 15:11:18 -070061 private final @NonNull InlinePresentationSpec mInlinePresentationSpec;
Feng Cao04830a32019-11-13 00:45:19 -080062
63 /** The source from which the suggestion is provided. */
64 private final @NonNull @Source String mSource;
65
66 /** Hints for the type of data being suggested. */
67 private final @Nullable String[] mAutofillHints;
68
Feng Cao91994982020-01-22 13:32:36 -080069 /** The type of the UI. */
70 private final @NonNull @Type String mType;
71
Feng Cao4b0ef392020-02-25 18:18:36 -080072 /** Whether the suggestion should be pinned or not. */
73 private final boolean mPinned;
74
Joanne Chung2e707602020-01-09 18:14:49 +080075 /**
76 * Creates a new {@link InlineSuggestionInfo}, for testing purpose.
77 *
78 * @hide
79 */
80 @TestApi
81 @NonNull
82 public static InlineSuggestionInfo newInlineSuggestionInfo(
83 @NonNull InlinePresentationSpec presentationSpec,
84 @NonNull @Source String source,
Feng Cao4b0ef392020-02-25 18:18:36 -080085 @Nullable String[] autofillHints, @NonNull @Type String type, boolean isPinned) {
86 return new InlineSuggestionInfo(presentationSpec, source, autofillHints, type, isPinned);
Joanne Chung2e707602020-01-09 18:14:49 +080087 }
Feng Cao04830a32019-11-13 00:45:19 -080088
Feng Cao04830a32019-11-13 00:45:19 -080089
Adam Hef27433a2020-03-25 15:11:18 -070090
91 // Code below generated by codegen v1.0.15.
Feng Cao04830a32019-11-13 00:45:19 -080092 //
93 // DO NOT MODIFY!
94 // CHECKSTYLE:OFF Generated code
95 //
96 // To regenerate run:
97 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/view/inputmethod/InlineSuggestionInfo.java
98 //
99 // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
100 // Settings > Editor > Code Style > Formatter Control
101 //@formatter:off
102
103
104 /** @hide */
105 @android.annotation.StringDef(prefix = "SOURCE_", value = {
106 SOURCE_AUTOFILL,
107 SOURCE_PLATFORM
108 })
109 @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE)
110 @DataClass.Generated.Member
111 public @interface Source {}
112
Feng Cao91994982020-01-22 13:32:36 -0800113 /** @hide */
114 @android.annotation.StringDef(prefix = "TYPE_", value = {
115 TYPE_SUGGESTION,
116 TYPE_ACTION
117 })
118 @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE)
119 @DataClass.Generated.Member
120 public @interface Type {}
121
Feng Cao04830a32019-11-13 00:45:19 -0800122 /**
123 * Creates a new InlineSuggestionInfo.
124 *
Adam Hef27433a2020-03-25 15:11:18 -0700125 * @param inlinePresentationSpec
Feng Cao04830a32019-11-13 00:45:19 -0800126 * The presentation spec to which the inflated suggestion view abides.
127 * @param source
128 * The source from which the suggestion is provided.
129 * @param autofillHints
130 * Hints for the type of data being suggested.
Feng Cao91994982020-01-22 13:32:36 -0800131 * @param type
132 * The type of the UI.
Feng Cao4b0ef392020-02-25 18:18:36 -0800133 * @param pinned
134 * Whether the suggestion should be pinned or not.
Feng Cao04830a32019-11-13 00:45:19 -0800135 * @hide
136 */
137 @DataClass.Generated.Member
138 public InlineSuggestionInfo(
Adam Hef27433a2020-03-25 15:11:18 -0700139 @NonNull InlinePresentationSpec inlinePresentationSpec,
Feng Cao04830a32019-11-13 00:45:19 -0800140 @NonNull @Source String source,
Feng Cao91994982020-01-22 13:32:36 -0800141 @Nullable String[] autofillHints,
Feng Cao4b0ef392020-02-25 18:18:36 -0800142 @NonNull @Type String type,
143 boolean pinned) {
Adam Hef27433a2020-03-25 15:11:18 -0700144 this.mInlinePresentationSpec = inlinePresentationSpec;
Feng Cao04830a32019-11-13 00:45:19 -0800145 com.android.internal.util.AnnotationValidations.validate(
Adam Hef27433a2020-03-25 15:11:18 -0700146 NonNull.class, null, mInlinePresentationSpec);
Feng Cao04830a32019-11-13 00:45:19 -0800147 this.mSource = source;
148
149 if (!(java.util.Objects.equals(mSource, SOURCE_AUTOFILL))
150 && !(java.util.Objects.equals(mSource, SOURCE_PLATFORM))) {
151 throw new java.lang.IllegalArgumentException(
152 "source was " + mSource + " but must be one of: "
153 + "SOURCE_AUTOFILL(" + SOURCE_AUTOFILL + "), "
154 + "SOURCE_PLATFORM(" + SOURCE_PLATFORM + ")");
155 }
156
157 com.android.internal.util.AnnotationValidations.validate(
158 NonNull.class, null, mSource);
159 this.mAutofillHints = autofillHints;
Feng Cao91994982020-01-22 13:32:36 -0800160 this.mType = type;
161
162 if (!(java.util.Objects.equals(mType, TYPE_SUGGESTION))
163 && !(java.util.Objects.equals(mType, TYPE_ACTION))) {
164 throw new java.lang.IllegalArgumentException(
165 "type was " + mType + " but must be one of: "
166 + "TYPE_SUGGESTION(" + TYPE_SUGGESTION + "), "
167 + "TYPE_ACTION(" + TYPE_ACTION + ")");
168 }
169
170 com.android.internal.util.AnnotationValidations.validate(
171 NonNull.class, null, mType);
Feng Cao4b0ef392020-02-25 18:18:36 -0800172 this.mPinned = pinned;
Feng Cao04830a32019-11-13 00:45:19 -0800173
174 // onConstructed(); // You can define this method to get a callback
175 }
176
177 /**
178 * The presentation spec to which the inflated suggestion view abides.
179 */
180 @DataClass.Generated.Member
Adam Hef27433a2020-03-25 15:11:18 -0700181 public @NonNull InlinePresentationSpec getInlinePresentationSpec() {
182 return mInlinePresentationSpec;
Feng Cao04830a32019-11-13 00:45:19 -0800183 }
184
185 /**
186 * The source from which the suggestion is provided.
187 */
188 @DataClass.Generated.Member
189 public @NonNull @Source String getSource() {
190 return mSource;
191 }
192
193 /**
194 * Hints for the type of data being suggested.
195 */
196 @DataClass.Generated.Member
197 public @Nullable String[] getAutofillHints() {
198 return mAutofillHints;
199 }
200
Feng Cao91994982020-01-22 13:32:36 -0800201 /**
202 * The type of the UI.
203 */
204 @DataClass.Generated.Member
205 public @NonNull @Type String getType() {
206 return mType;
207 }
208
Feng Cao4b0ef392020-02-25 18:18:36 -0800209 /**
210 * Whether the suggestion should be pinned or not.
211 */
212 @DataClass.Generated.Member
213 public boolean isPinned() {
214 return mPinned;
215 }
216
Feng Cao04830a32019-11-13 00:45:19 -0800217 @Override
218 @DataClass.Generated.Member
219 public String toString() {
220 // You can override field toString logic by defining methods like:
221 // String fieldNameToString() { ... }
222
223 return "InlineSuggestionInfo { " +
Adam Hef27433a2020-03-25 15:11:18 -0700224 "inlinePresentationSpec = " + mInlinePresentationSpec + ", " +
Feng Cao04830a32019-11-13 00:45:19 -0800225 "source = " + mSource + ", " +
Feng Cao91994982020-01-22 13:32:36 -0800226 "autofillHints = " + java.util.Arrays.toString(mAutofillHints) + ", " +
Feng Cao4b0ef392020-02-25 18:18:36 -0800227 "type = " + mType + ", " +
228 "pinned = " + mPinned +
Feng Cao04830a32019-11-13 00:45:19 -0800229 " }";
230 }
231
232 @Override
233 @DataClass.Generated.Member
234 public boolean equals(@Nullable Object o) {
235 // You can override field equality logic by defining either of the methods like:
236 // boolean fieldNameEquals(InlineSuggestionInfo other) { ... }
237 // boolean fieldNameEquals(FieldType otherValue) { ... }
238
239 if (this == o) return true;
240 if (o == null || getClass() != o.getClass()) return false;
241 @SuppressWarnings("unchecked")
242 InlineSuggestionInfo that = (InlineSuggestionInfo) o;
243 //noinspection PointlessBooleanExpression
244 return true
Adam Hef27433a2020-03-25 15:11:18 -0700245 && java.util.Objects.equals(mInlinePresentationSpec, that.mInlinePresentationSpec)
Feng Cao04830a32019-11-13 00:45:19 -0800246 && java.util.Objects.equals(mSource, that.mSource)
Feng Cao91994982020-01-22 13:32:36 -0800247 && java.util.Arrays.equals(mAutofillHints, that.mAutofillHints)
Feng Cao4b0ef392020-02-25 18:18:36 -0800248 && java.util.Objects.equals(mType, that.mType)
249 && mPinned == that.mPinned;
Feng Cao04830a32019-11-13 00:45:19 -0800250 }
251
252 @Override
253 @DataClass.Generated.Member
254 public int hashCode() {
255 // You can override field hashCode logic by defining methods like:
256 // int fieldNameHashCode() { ... }
257
258 int _hash = 1;
Adam Hef27433a2020-03-25 15:11:18 -0700259 _hash = 31 * _hash + java.util.Objects.hashCode(mInlinePresentationSpec);
Feng Cao04830a32019-11-13 00:45:19 -0800260 _hash = 31 * _hash + java.util.Objects.hashCode(mSource);
261 _hash = 31 * _hash + java.util.Arrays.hashCode(mAutofillHints);
Feng Cao91994982020-01-22 13:32:36 -0800262 _hash = 31 * _hash + java.util.Objects.hashCode(mType);
Feng Cao4b0ef392020-02-25 18:18:36 -0800263 _hash = 31 * _hash + Boolean.hashCode(mPinned);
Feng Cao04830a32019-11-13 00:45:19 -0800264 return _hash;
265 }
266
267 @Override
268 @DataClass.Generated.Member
269 public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
270 // You can override field parcelling by defining methods like:
271 // void parcelFieldName(Parcel dest, int flags) { ... }
272
273 byte flg = 0;
Feng Cao4b0ef392020-02-25 18:18:36 -0800274 if (mPinned) flg |= 0x10;
Feng Cao04830a32019-11-13 00:45:19 -0800275 if (mAutofillHints != null) flg |= 0x4;
276 dest.writeByte(flg);
Adam Hef27433a2020-03-25 15:11:18 -0700277 dest.writeTypedObject(mInlinePresentationSpec, flags);
Feng Cao04830a32019-11-13 00:45:19 -0800278 dest.writeString(mSource);
279 if (mAutofillHints != null) dest.writeStringArray(mAutofillHints);
Feng Cao91994982020-01-22 13:32:36 -0800280 dest.writeString(mType);
Feng Cao04830a32019-11-13 00:45:19 -0800281 }
282
283 @Override
284 @DataClass.Generated.Member
285 public int describeContents() { return 0; }
286
287 /** @hide */
288 @SuppressWarnings({"unchecked", "RedundantCast"})
289 @DataClass.Generated.Member
290 /* package-private */ InlineSuggestionInfo(@NonNull android.os.Parcel in) {
291 // You can override field unparcelling by defining methods like:
292 // static FieldType unparcelFieldName(Parcel in) { ... }
293
294 byte flg = in.readByte();
Feng Cao4b0ef392020-02-25 18:18:36 -0800295 boolean pinned = (flg & 0x10) != 0;
Adam Hef27433a2020-03-25 15:11:18 -0700296 InlinePresentationSpec inlinePresentationSpec = (InlinePresentationSpec) in.readTypedObject(InlinePresentationSpec.CREATOR);
Feng Cao04830a32019-11-13 00:45:19 -0800297 String source = in.readString();
298 String[] autofillHints = (flg & 0x4) == 0 ? null : in.createStringArray();
Feng Cao91994982020-01-22 13:32:36 -0800299 String type = in.readString();
Feng Cao04830a32019-11-13 00:45:19 -0800300
Adam Hef27433a2020-03-25 15:11:18 -0700301 this.mInlinePresentationSpec = inlinePresentationSpec;
Feng Cao04830a32019-11-13 00:45:19 -0800302 com.android.internal.util.AnnotationValidations.validate(
Adam Hef27433a2020-03-25 15:11:18 -0700303 NonNull.class, null, mInlinePresentationSpec);
Feng Cao04830a32019-11-13 00:45:19 -0800304 this.mSource = source;
305
306 if (!(java.util.Objects.equals(mSource, SOURCE_AUTOFILL))
307 && !(java.util.Objects.equals(mSource, SOURCE_PLATFORM))) {
308 throw new java.lang.IllegalArgumentException(
309 "source was " + mSource + " but must be one of: "
310 + "SOURCE_AUTOFILL(" + SOURCE_AUTOFILL + "), "
311 + "SOURCE_PLATFORM(" + SOURCE_PLATFORM + ")");
312 }
313
314 com.android.internal.util.AnnotationValidations.validate(
315 NonNull.class, null, mSource);
316 this.mAutofillHints = autofillHints;
Feng Cao91994982020-01-22 13:32:36 -0800317 this.mType = type;
318
319 if (!(java.util.Objects.equals(mType, TYPE_SUGGESTION))
320 && !(java.util.Objects.equals(mType, TYPE_ACTION))) {
321 throw new java.lang.IllegalArgumentException(
322 "type was " + mType + " but must be one of: "
323 + "TYPE_SUGGESTION(" + TYPE_SUGGESTION + "), "
324 + "TYPE_ACTION(" + TYPE_ACTION + ")");
325 }
326
327 com.android.internal.util.AnnotationValidations.validate(
328 NonNull.class, null, mType);
Feng Cao4b0ef392020-02-25 18:18:36 -0800329 this.mPinned = pinned;
Feng Cao04830a32019-11-13 00:45:19 -0800330
331 // onConstructed(); // You can define this method to get a callback
332 }
333
334 @DataClass.Generated.Member
335 public static final @NonNull Parcelable.Creator<InlineSuggestionInfo> CREATOR
336 = new Parcelable.Creator<InlineSuggestionInfo>() {
337 @Override
338 public InlineSuggestionInfo[] newArray(int size) {
339 return new InlineSuggestionInfo[size];
340 }
341
342 @Override
343 public InlineSuggestionInfo createFromParcel(@NonNull android.os.Parcel in) {
344 return new InlineSuggestionInfo(in);
345 }
346 };
347
348 @DataClass.Generated(
Adam He3f8cdb52020-04-15 15:31:46 -0700349 time = 1586992414034L,
Adam Hef27433a2020-03-25 15:11:18 -0700350 codegenVersion = "1.0.15",
Feng Cao04830a32019-11-13 00:45:19 -0800351 sourceFile = "frameworks/base/core/java/android/view/inputmethod/InlineSuggestionInfo.java",
Adam He3f8cdb52020-04-15 15:31:46 -0700352 inputSignatures = "public static final @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String SOURCE_AUTOFILL\npublic static final @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String SOURCE_PLATFORM\npublic static final @android.view.inputmethod.InlineSuggestionInfo.Type java.lang.String TYPE_SUGGESTION\npublic static final @android.annotation.SuppressLint({\"IntentName\"}) @android.view.inputmethod.InlineSuggestionInfo.Type java.lang.String TYPE_ACTION\nprivate final @android.annotation.NonNull android.widget.inline.InlinePresentationSpec mInlinePresentationSpec\nprivate final @android.annotation.NonNull @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String mSource\nprivate final @android.annotation.Nullable java.lang.String[] mAutofillHints\nprivate final @android.annotation.NonNull @android.view.inputmethod.InlineSuggestionInfo.Type java.lang.String mType\nprivate final boolean mPinned\npublic static @android.annotation.TestApi @android.annotation.NonNull android.view.inputmethod.InlineSuggestionInfo newInlineSuggestionInfo(android.widget.inline.InlinePresentationSpec,java.lang.String,java.lang.String[],java.lang.String,boolean)\nclass InlineSuggestionInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genHiddenConstDefs=true, genHiddenConstructor=true)")
Feng Cao04830a32019-11-13 00:45:19 -0800353 @Deprecated
354 private void __metadata() {}
355
356
357 //@formatter:on
358 // End of generated code
359
360}