blob: 38dcdd30d843e77fbccad9924a6e3ebf7c48dd92 [file] [log] [blame]
Dianne Hackborn49b043f2015-05-07 14:21:38 -07001/*
2 * Copyright (C) 2015 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;
18
Felipe Lemef8a81742017-03-17 18:05:01 -070019import android.annotation.NonNull;
Philip P. Moltmann495cadd2017-03-10 16:45:02 -080020import android.annotation.Nullable;
Dianne Hackborn70d8be72015-06-23 19:33:02 +000021import android.graphics.Matrix;
Dianne Hackborn49b043f2015-05-07 14:21:38 -070022import android.graphics.Rect;
23import android.os.Bundle;
Felipe Lemeb4ca7012017-03-22 18:30:07 -070024import android.os.LocaleList;
Felipe Leme25bf7872017-03-28 15:32:29 -070025import android.util.Pair;
felipeal53308c12018-02-07 14:43:30 +010026import android.view.View.AutofillImportance;
27import android.view.ViewStructure.HtmlInfo;
Felipe Leme640f30a2017-03-06 15:44:06 -080028import android.view.autofill.AutofillId;
29import android.view.autofill.AutofillValue;
Dianne Hackborn49b043f2015-05-07 14:21:38 -070030
Felipe Leme5dc45ca2018-01-03 09:02:27 -080031import com.android.internal.util.Preconditions;
32
Felipe Leme09a70622017-04-27 15:24:19 -070033import java.util.List;
Felipe Leme25bf7872017-03-28 15:32:29 -070034
Dianne Hackborn49b043f2015-05-07 14:21:38 -070035/**
Laura Davis43e75d92018-08-10 15:46:06 -070036 * <p><code>ViewStructure</code> is a container for storing additional
37 * per-view data generated by {@link View#onProvideStructure
Felipe Leme640f30a2017-03-06 15:44:06 -080038 * View.onProvideStructure} and {@link View#onProvideAutofillStructure
39 * View.onProvideAutofillStructure}.
Laura Davis43e75d92018-08-10 15:46:06 -070040 *
41 * <p>To learn more about using Autofill in your app, read the
42 * <a href="/guide/topics/text/autofill">Autofill Framework</a> guides.
43 *
Dianne Hackborn49b043f2015-05-07 14:21:38 -070044 */
45public abstract class ViewStructure {
Felipe Leme0200d9e2017-01-24 15:10:26 -080046
47 /**
Dianne Hackborn02beb412015-05-19 11:18:16 -070048 * Set the identifier for this view.
49 *
50 * @param id The view's identifier, as per {@link View#getId View.getId()}.
51 * @param packageName The package name of the view's identifier, or null if there is none.
52 * @param typeName The type name of the view's identifier, or null if there is none.
53 * @param entryName The entry name of the view's identifier, or null if there is none.
54 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -070055 public abstract void setId(int id, String packageName, String typeName, String entryName);
56
Dianne Hackborn02beb412015-05-19 11:18:16 -070057 /**
58 * Set the basic dimensions of this view.
59 *
60 * @param left The view's left position, in pixels relative to its parent's left edge.
61 * @param top The view's top position, in pixels relative to its parent's top edge.
62 * @param scrollX How much the view's x coordinate space has been scrolled, in pixels.
63 * @param scrollY How much the view's y coordinate space has been scrolled, in pixels.
64 * @param width The view's visible width, in pixels. This is the width visible on screen,
65 * not the total data width of a scrollable view.
66 * @param height The view's visible height, in pixels. This is the height visible on
67 * screen, not the total data height of a scrollable view.
68 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -070069 public abstract void setDimens(int left, int top, int scrollX, int scrollY, int width,
70 int height);
71
Dianne Hackborn02beb412015-05-19 11:18:16 -070072 /**
Dianne Hackborn70d8be72015-06-23 19:33:02 +000073 * Set the transformation matrix associated with this view, as per
74 * {@link View#getMatrix View.getMatrix()}, or null if there is none.
75 */
76 public abstract void setTransformation(Matrix matrix);
77
78 /**
79 * Set the visual elevation (shadow) of the view, as per
80 * {@link View#getZ View.getZ()}. Note this is <em>not</em> related
81 * to the physical Z-ordering of this view relative to its other siblings (that is how
82 * they overlap when drawing), it is only the visual representation for shadowing.
83 */
84 public abstract void setElevation(float elevation);
85
86 /**
87 * Set an alpha transformation that is applied to this view, as per
88 * {@link View#getAlpha View.getAlpha()}. Value ranges from 0
89 * (completely transparent) to 1 (completely opaque); the default is 1, which means
90 * no transformation.
91 */
92 public abstract void setAlpha(float alpha);
93
94 /**
Dianne Hackborn02beb412015-05-19 11:18:16 -070095 * Set the visibility state of this view, as per
96 * {@link View#getVisibility View.getVisibility()}.
97 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -070098 public abstract void setVisibility(int visibility);
99
100 /** @hide */
101 public abstract void setAssistBlocked(boolean state);
102
Dianne Hackborn02beb412015-05-19 11:18:16 -0700103 /**
104 * Set the enabled state of this view, as per {@link View#isEnabled View.isEnabled()}.
105 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700106 public abstract void setEnabled(boolean state);
107
Dianne Hackborn02beb412015-05-19 11:18:16 -0700108 /**
109 * Set the clickable state of this view, as per {@link View#isClickable View.isClickable()}.
110 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700111 public abstract void setClickable(boolean state);
112
Dianne Hackborn02beb412015-05-19 11:18:16 -0700113 /**
114 * Set the long clickable state of this view, as per
115 * {@link View#isLongClickable View.isLongClickable()}.
116 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700117 public abstract void setLongClickable(boolean state);
118
Dianne Hackborn02beb412015-05-19 11:18:16 -0700119 /**
Mady Mellore8608912015-06-05 09:02:55 -0700120 * Set the context clickable state of this view, as per
121 * {@link View#isContextClickable View.isContextClickable()}.
Dianne Hackborn02beb412015-05-19 11:18:16 -0700122 */
Mady Mellore8608912015-06-05 09:02:55 -0700123 public abstract void setContextClickable(boolean state);
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700124
Dianne Hackborn02beb412015-05-19 11:18:16 -0700125 /**
126 * Set the focusable state of this view, as per {@link View#isFocusable View.isFocusable()}.
127 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700128 public abstract void setFocusable(boolean state);
129
Dianne Hackborn02beb412015-05-19 11:18:16 -0700130 /**
131 * Set the focused state of this view, as per {@link View#isFocused View.isFocused()}.
132 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700133 public abstract void setFocused(boolean state);
134
Dianne Hackborn02beb412015-05-19 11:18:16 -0700135 /**
136 * Set the accessibility focused state of this view, as per
137 * {@link View#isAccessibilityFocused View.isAccessibilityFocused()}.
138 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700139 public abstract void setAccessibilityFocused(boolean state);
140
Dianne Hackborn02beb412015-05-19 11:18:16 -0700141 /**
142 * Set the checkable state of this view, such as whether it implements the
143 * {@link android.widget.Checkable} interface.
144 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700145 public abstract void setCheckable(boolean state);
146
Dianne Hackborn02beb412015-05-19 11:18:16 -0700147 /**
148 * Set the checked state of this view, such as
149 * {@link android.widget.Checkable#isChecked Checkable.isChecked()}.
150 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700151 public abstract void setChecked(boolean state);
152
Dianne Hackborn02beb412015-05-19 11:18:16 -0700153 /**
154 * Set the selected state of this view, as per {@link View#isSelected View.isSelected()}.
155 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700156 public abstract void setSelected(boolean state);
157
Dianne Hackborn02beb412015-05-19 11:18:16 -0700158 /**
159 * Set the activated state of this view, as per {@link View#isActivated View.isActivated()}.
160 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700161 public abstract void setActivated(boolean state);
162
Dianne Hackborn02beb412015-05-19 11:18:16 -0700163 /**
Amith Yamasani858f98d2017-02-22 12:59:53 -0800164 * Set the opaque state of this view, as per {@link View#isOpaque View.isOpaque()}.
165 */
166 public abstract void setOpaque(boolean opaque);
167
168 /**
Dianne Hackborn02beb412015-05-19 11:18:16 -0700169 * Set the class name of the view, as per
170 * {@link View#getAccessibilityClassName View.getAccessibilityClassName()}.
171 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700172 public abstract void setClassName(String className);
173
Dianne Hackborn02beb412015-05-19 11:18:16 -0700174 /**
175 * Set the content description of the view, as per
176 * {@link View#getContentDescription View.getContentDescription()}.
177 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700178 public abstract void setContentDescription(CharSequence contentDescription);
179
Dianne Hackborn02beb412015-05-19 11:18:16 -0700180 /**
181 * Set the text that is associated with this view. There is no selection
182 * associated with the text. The text may have style spans to supply additional
183 * display and semantic information.
184 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700185 public abstract void setText(CharSequence text);
Dianne Hackborn02beb412015-05-19 11:18:16 -0700186
187 /**
188 * Like {@link #setText(CharSequence)} but with an active selection
189 * extending from <var>selectionStart</var> through <var>selectionEnd</var>.
190 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700191 public abstract void setText(CharSequence text, int selectionStart, int selectionEnd);
Dianne Hackborn02beb412015-05-19 11:18:16 -0700192
193 /**
Dianne Hackborn02beb412015-05-19 11:18:16 -0700194 * Explicitly set default global style information for text that was previously set with
195 * {@link #setText}.
196 *
197 * @param size The size, in pixels, of the text.
198 * @param fgColor The foreground color, packed as 0xAARRGGBB.
199 * @param bgColor The background color, packed as 0xAARRGGBB.
Dianne Hackborn16036f22015-06-22 14:05:51 -0700200 * @param style Style flags, as defined by {@link android.app.assist.AssistStructure.ViewNode}.
Dianne Hackborn02beb412015-05-19 11:18:16 -0700201 */
James Cook5cfaae42015-05-28 15:52:44 -0700202 public abstract void setTextStyle(float size, int fgColor, int bgColor, int style);
Dianne Hackborn02beb412015-05-19 11:18:16 -0700203
204 /**
Dianne Hackborn6f0fdc42015-07-07 14:29:36 -0700205 * Set line information for test that was previously supplied through
206 * {@link #setText(CharSequence)}. This provides the line breaking of the text as it
207 * is shown on screen. This function takes ownership of the provided arrays; you should
208 * not make further modification to them.
209 *
210 * @param charOffsets The offset in to {@link #setText} where a line starts.
211 * @param baselines The baseline where the line is drawn on screen.
212 */
213 public abstract void setTextLines(int[] charOffsets, int[] baselines);
214
215 /**
Felipe Leme5dc45ca2018-01-03 09:02:27 -0800216 * Sets the identifier used to set the text associated with this view.
217 *
218 * <p>Should only be set when the node is used for autofill purposes - it will be ignored
219 * when used for Assist.
220 */
221 public void setTextIdEntry(@NonNull String entryName) {
222 Preconditions.checkNotNull(entryName);
223 }
224
225 /**
Dianne Hackborn02beb412015-05-19 11:18:16 -0700226 * Set optional hint text associated with this view; this is for example the text that is
227 * shown by an EditText when it is empty to indicate to the user the kind of text to input.
228 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700229 public abstract void setHint(CharSequence hint);
230
Dianne Hackborn02beb412015-05-19 11:18:16 -0700231 /**
232 * Retrieve the last {@link #setText(CharSequence)}.
233 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700234 public abstract CharSequence getText();
Dianne Hackborn02beb412015-05-19 11:18:16 -0700235
236 /**
237 * Retrieve the last selection start set by {@link #setText(CharSequence, int, int)}.
238 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700239 public abstract int getTextSelectionStart();
Dianne Hackborn02beb412015-05-19 11:18:16 -0700240
241 /**
242 * Retrieve the last selection end set by {@link #setText(CharSequence, int, int)}.
243 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700244 public abstract int getTextSelectionEnd();
Dianne Hackborn02beb412015-05-19 11:18:16 -0700245
246 /**
247 * Retrieve the last hint set by {@link #setHint}.
248 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700249 public abstract CharSequence getHint();
250
Dianne Hackborn02beb412015-05-19 11:18:16 -0700251 /**
252 * Get extra data associated with this view structure; the returned Bundle is mutable,
253 * allowing you to view and modify its contents. Keys placed in the Bundle should use
254 * an appropriate namespace prefix (such as com.google.MY_KEY) to avoid conflicts.
255 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700256 public abstract Bundle getExtras();
Dianne Hackborn02beb412015-05-19 11:18:16 -0700257
258 /**
259 * Returns true if {@link #getExtras} has been used to create extra content.
260 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700261 public abstract boolean hasExtras();
262
Dianne Hackborn02beb412015-05-19 11:18:16 -0700263 /**
264 * Set the number of children of this view, which defines the range of indices you can
265 * use with {@link #newChild} and {@link #asyncNewChild}. Calling this method again
266 * resets all of the child state of the view, removing any children that had previously
267 * been added.
268 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700269 public abstract void setChildCount(int num);
Dianne Hackborn02beb412015-05-19 11:18:16 -0700270
271 /**
Dianne Hackbornece0f4f2015-06-11 13:29:01 -0700272 * Add to this view's child count. This increases the current child count by
273 * <var>num</var> children beyond what was last set by {@link #setChildCount}
274 * or {@link #addChildCount}. The index at which the new child starts in the child
275 * array is returned.
276 *
277 * @param num The number of new children to add.
278 * @return Returns the index in the child array at which the new children start.
279 */
280 public abstract int addChildCount(int num);
281
282 /**
Dianne Hackborn02beb412015-05-19 11:18:16 -0700283 * Return the child count as set by {@link #setChildCount}.
284 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700285 public abstract int getChildCount();
Dianne Hackborn02beb412015-05-19 11:18:16 -0700286
287 /**
288 * Create a new child {@link ViewStructure} in this view, putting into the list of
289 * children at <var>index</var>.
Felipe Lemedbe07a52017-03-03 14:29:17 -0800290 *
Felipe Leme2f6fc722017-05-31 11:57:46 -0700291 * <p><b>NOTE: </b>you must pre-allocate space for the child first, by calling either
292 * {@link #addChildCount(int)} or {@link #setChildCount(int)}.
293 *
Dianne Hackborn02beb412015-05-19 11:18:16 -0700294 * @return Returns an fresh {@link ViewStructure} ready to be filled in.
295 */
Dianne Hackborn8ecf16d2015-06-23 13:09:21 -0700296 public abstract ViewStructure newChild(int index);
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700297
Dianne Hackborn02beb412015-05-19 11:18:16 -0700298 /**
299 * Like {@link #newChild}, but allows the caller to asynchronously populate the returned
300 * child. It can transfer the returned {@link ViewStructure} to another thread for it
301 * to build its content (and children etc). Once done, some thread must call
302 * {@link #asyncCommit} to tell the containing {@link ViewStructure} that the async
303 * population is done.
Felipe Leme2f6fc722017-05-31 11:57:46 -0700304 *
305 * <p><b>NOTE: </b>you must pre-allocate space for the child first, by calling either
306 * {@link #addChildCount(int)} or {@link #setChildCount(int)}.
307 *
Dianne Hackborn02beb412015-05-19 11:18:16 -0700308 * @return Returns an fresh {@link ViewStructure} ready to be filled in.
309 */
Dianne Hackborn8ecf16d2015-06-23 13:09:21 -0700310 public abstract ViewStructure asyncNewChild(int index);
Dianne Hackborn02beb412015-05-19 11:18:16 -0700311
312 /**
Felipe Lemee4f30652017-04-25 10:21:45 -0700313 * Gets the {@link AutofillId} associated with this node.
314 */
315 @Nullable
316 public abstract AutofillId getAutofillId();
317
318 /**
319 * Sets the {@link AutofillId} associated with this node.
320 */
321 public abstract void setAutofillId(@NonNull AutofillId id);
322
323 /**
Felipe Lemef8a81742017-03-17 18:05:01 -0700324 * Sets the {@link AutofillId} for this virtual node.
Felipe Leme0200d9e2017-01-24 15:10:26 -0800325 *
Felipe Lemee4f30652017-04-25 10:21:45 -0700326 * @param parentId id of the parent node.
Felipe Lemef8a81742017-03-17 18:05:01 -0700327 * @param virtualId an opaque ID to the Android System; it's the same id used on
Felipe Leme28afe0e2017-03-17 11:37:27 -0700328 * {@link View#autofill(android.util.SparseArray)}.
Felipe Leme6d553872016-12-08 17:13:25 -0800329 */
Felipe Lemee4f30652017-04-25 10:21:45 -0700330 public abstract void setAutofillId(@NonNull AutofillId parentId, int virtualId);
331
332 /**
Felipe Leme8931e302017-03-06 13:44:35 -0800333 * Sets the {@link View#getAutofillType()} that can be used to autofill this node.
334 */
335 public abstract void setAutofillType(@View.AutofillType int type);
336
337 /**
Philip P. Moltmann81192b42017-03-29 13:58:59 -0700338 * Sets the a hints that helps the autofill service to select the appropriate data to fill the
Philip P. Moltmannba6f4622017-02-22 11:03:53 -0800339 * view.
340 */
Philip P. Moltmann81192b42017-03-29 13:58:59 -0700341 public abstract void setAutofillHints(@Nullable String[] hint);
Philip P. Moltmannba6f4622017-02-22 11:03:53 -0800342
343 /**
Felipe Leme640f30a2017-03-06 15:44:06 -0800344 * Sets the {@link AutofillValue} representing the current value of this node.
Felipe Leme0200d9e2017-01-24 15:10:26 -0800345 */
Felipe Leme640f30a2017-03-06 15:44:06 -0800346 public abstract void setAutofillValue(AutofillValue value);
Felipe Leme0200d9e2017-01-24 15:10:26 -0800347
348 /**
Felipe Leme640f30a2017-03-06 15:44:06 -0800349 * Sets the options that can be used to autofill this node.
Felipe Lemed09ccb82017-02-22 15:02:03 -0800350 *
Felipe Leme640f30a2017-03-06 15:44:06 -0800351 * <p>Typically used by nodes whose {@link View#getAutofillType()} is a list to indicate the
352 * meaning of each possible value in the list.
Felipe Lemed09ccb82017-02-22 15:02:03 -0800353 */
Felipe Leme7e4c2052017-04-18 09:45:58 -0700354 public abstract void setAutofillOptions(CharSequence[] options);
Felipe Lemed09ccb82017-02-22 15:02:03 -0800355
356 /**
felipeal53308c12018-02-07 14:43:30 +0100357 * Sets the {@link View#setImportantForAutofill(int) importantForAutofill mode} of the
358 * view associated with this node.
359 */
360 public void setImportantForAutofill(@AutofillImportance int mode) {}
361
362 /**
Felipe Leme16aafc32017-02-27 13:41:37 -0800363 * Sets the {@link android.text.InputType} bits of this node.
364 *
365 * @param inputType inputType bits as defined by {@link android.text.InputType}.
366 */
367 public abstract void setInputType(int inputType);
368
369 /**
Felipe Lemec9a19b12017-03-13 18:05:22 -0700370 * Sets whether the data on this node is sensitive; if it is, then its content (text, autofill
371 * value, etc..) is striped before calls to {@link
Felipe Leme7e4c2052017-04-18 09:45:58 -0700372 * android.service.autofill.AutofillService#onFillRequest(android.service.autofill.FillRequest,
373 * android.os.CancellationSignal, android.service.autofill.FillCallback)}.
Felipe Leme0200d9e2017-01-24 15:10:26 -0800374 *
Felipe Lemec9a19b12017-03-13 18:05:22 -0700375 * <p>By default, all nodes are assumed to be sensitive, and only nodes that does not have PII
376 * (Personally Identifiable Information - sensitive data such as email addresses, credit card
377 * numbers, passwords, etc...) should be marked as non-sensitive; a good rule of thumb is to
378 * mark as non-sensitive nodes whose value were statically set from resources.
379 *
380 * <p>Notice that the content of even sensitive nodes are sent to the service (through the
381 * {@link
Felipe Leme7e4c2052017-04-18 09:45:58 -0700382 * android.service.autofill.AutofillService#onSaveRequest(android.service.autofill.SaveRequest,
383 * android.service.autofill.SaveCallback)} call) when the user consented to save
Felipe Leme2ac463e2017-03-13 14:06:25 -0700384 * thedata, so it is important to set the content of sensitive nodes as well, but mark them as
Felipe Lemec9a19b12017-03-13 18:05:22 -0700385 * sensitive.
Felipe Leme33791fd2017-02-16 08:07:56 -0800386 *
Felipe Leme640f30a2017-03-06 15:44:06 -0800387 * <p>Should only be set when the node is used for autofill purposes - it will be ignored
Felipe Leme33791fd2017-02-16 08:07:56 -0800388 * when used for Assist.
Felipe Leme0200d9e2017-01-24 15:10:26 -0800389 */
Felipe Lemec9a19b12017-03-13 18:05:22 -0700390 public abstract void setDataIsSensitive(boolean sensitive);
Felipe Leme0200d9e2017-01-24 15:10:26 -0800391
392 /**
Felipe Lemeaa7e2292017-10-05 18:19:48 -0700393 * Sets the minimum width in ems of the text associated with this view, when supported.
394 *
395 * <p>Should only be set when the node is used for autofill purposes - it will be ignored
396 * when used for Assist.
397 */
Felipe Leme4d14ec22017-10-19 13:07:22 -0700398 public void setMinTextEms(@SuppressWarnings("unused") int minEms) {}
Felipe Lemeaa7e2292017-10-05 18:19:48 -0700399
400 /**
401 * Sets the maximum width in ems of the text associated with this view, when supported.
402 *
403 * <p>Should only be set when the node is used for autofill purposes - it will be ignored
404 * when used for Assist.
405 */
Felipe Leme4d14ec22017-10-19 13:07:22 -0700406 public void setMaxTextEms(@SuppressWarnings("unused") int maxEms) {}
Felipe Lemeaa7e2292017-10-05 18:19:48 -0700407
408 /**
409 * Sets the maximum length of the text associated with this view, when supported.
410 *
411 * <p>Should only be set when the node is used for autofill purposes - it will be ignored
412 * when used for Assist.
413 */
Felipe Leme4d14ec22017-10-19 13:07:22 -0700414 public void setMaxTextLength(@SuppressWarnings("unused") int maxLength) {}
Felipe Lemeaa7e2292017-10-05 18:19:48 -0700415
416 /**
Dianne Hackborn02beb412015-05-19 11:18:16 -0700417 * Call when done populating a {@link ViewStructure} returned by
418 * {@link #asyncNewChild}.
419 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700420 public abstract void asyncCommit();
421
422 /** @hide */
423 public abstract Rect getTempRect();
Felipe Leme29a5b0d2016-10-25 14:57:11 -0700424
Felipe Lemec3241002017-02-15 12:55:11 -0800425 /**
Felipe Leme4711ed92017-04-21 16:47:18 -0700426 * Sets the Web domain represented by this node.
Felipe Lemec3241002017-02-15 12:55:11 -0800427 *
Felipe Leme25bf7872017-03-28 15:32:29 -0700428 * <p>Typically used when the view is a container for an HTML document.
Felipe Leme4711ed92017-04-21 16:47:18 -0700429 *
Felipe Leme114a4412017-09-26 13:02:11 -0700430 * @param domain RFC 2396-compliant URI representing the domain.
Felipe Lemec3241002017-02-15 12:55:11 -0800431 */
Felipe Leme4711ed92017-04-21 16:47:18 -0700432 public abstract void setWebDomain(@Nullable String domain);
Felipe Lemeb4ca7012017-03-22 18:30:07 -0700433
434 /**
435 * Sets the the list of locales associated with this node.
436 */
437 public abstract void setLocaleList(LocaleList localeList);
Felipe Leme25bf7872017-03-28 15:32:29 -0700438
439 /**
440 * Creates a new {@link HtmlInfo.Builder} for the given HTML tag.
441 *
442 * @param tagName name of the HTML tag.
443 * @return a new builder.
444 */
445 public abstract HtmlInfo.Builder newHtmlInfoBuilder(@NonNull String tagName);
446
447 /**
448 * Sets the HTML properties of this node when it represents an HTML element.
449 *
450 * <p>Should only be set when the node is used for autofill purposes - it will be ignored
451 * when used for assist.
452 *
453 * @param htmlInfo HTML properties.
454 */
455 public abstract void setHtmlInfo(@NonNull HtmlInfo htmlInfo);
456
457 /**
458 * Simplified representation of the HTML properties of a node that represents an HTML element.
459 */
460 public abstract static class HtmlInfo {
461
462 /**
463 * Gets the HTML tag.
464 */
465 @NonNull
466 public abstract String getTag();
467
468 /**
469 * Gets the list of HTML attributes.
470 *
471 * @return list of key/value pairs; could contain pairs with the same keys.
472 */
473 @Nullable
Felipe Leme09a70622017-04-27 15:24:19 -0700474 public abstract List<Pair<String, String>> getAttributes();
Felipe Leme25bf7872017-03-28 15:32:29 -0700475
476 /**
477 * Builder for {@link HtmlInfo} objects.
478 */
479 public abstract static class Builder {
480
481 /**
482 * Adds an HTML attribute.
483 *
484 * @param name name of the attribute.
485 * @param value value of the attribute.
486 * @return same builder, for chaining.
487 */
488 public abstract Builder addAttribute(@NonNull String name, @NonNull String value);
489
490 /**
491 * Builds the {@link HtmlInfo} object.
492 *
493 * @return a new {@link HtmlInfo} instance.
494 */
495 public abstract HtmlInfo build();
496 }
497 }
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700498}