blob: 606e8f99999a7662660efc965222c991540b48d1 [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;
Felipe Leme640f30a2017-03-06 15:44:06 -080027import android.view.autofill.AutofillId;
28import android.view.autofill.AutofillValue;
Dianne Hackborn49b043f2015-05-07 14:21:38 -070029
Felipe Leme5dc45ca2018-01-03 09:02:27 -080030import com.android.internal.util.Preconditions;
31
Felipe Leme09a70622017-04-27 15:24:19 -070032import java.util.List;
Felipe Leme25bf7872017-03-28 15:32:29 -070033
Dianne Hackborn49b043f2015-05-07 14:21:38 -070034/**
Laura Davis43e75d92018-08-10 15:46:06 -070035 * <p><code>ViewStructure</code> is a container for storing additional
36 * per-view data generated by {@link View#onProvideStructure
Felipe Leme640f30a2017-03-06 15:44:06 -080037 * View.onProvideStructure} and {@link View#onProvideAutofillStructure
38 * View.onProvideAutofillStructure}.
Laura Davis43e75d92018-08-10 15:46:06 -070039 *
40 * <p>To learn more about using Autofill in your app, read the
41 * <a href="/guide/topics/text/autofill">Autofill Framework</a> guides.
42 *
Dianne Hackborn49b043f2015-05-07 14:21:38 -070043 */
44public abstract class ViewStructure {
Felipe Leme0200d9e2017-01-24 15:10:26 -080045
46 /**
Dianne Hackborn02beb412015-05-19 11:18:16 -070047 * Set the identifier for this view.
48 *
49 * @param id The view's identifier, as per {@link View#getId View.getId()}.
50 * @param packageName The package name of the view's identifier, or null if there is none.
51 * @param typeName The type name of the view's identifier, or null if there is none.
52 * @param entryName The entry name of the view's identifier, or null if there is none.
53 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -070054 public abstract void setId(int id, String packageName, String typeName, String entryName);
55
Dianne Hackborn02beb412015-05-19 11:18:16 -070056 /**
57 * Set the basic dimensions of this view.
58 *
59 * @param left The view's left position, in pixels relative to its parent's left edge.
60 * @param top The view's top position, in pixels relative to its parent's top edge.
61 * @param scrollX How much the view's x coordinate space has been scrolled, in pixels.
62 * @param scrollY How much the view's y coordinate space has been scrolled, in pixels.
63 * @param width The view's visible width, in pixels. This is the width visible on screen,
64 * not the total data width of a scrollable view.
65 * @param height The view's visible height, in pixels. This is the height visible on
66 * screen, not the total data height of a scrollable view.
67 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -070068 public abstract void setDimens(int left, int top, int scrollX, int scrollY, int width,
69 int height);
70
Dianne Hackborn02beb412015-05-19 11:18:16 -070071 /**
Dianne Hackborn70d8be72015-06-23 19:33:02 +000072 * Set the transformation matrix associated with this view, as per
73 * {@link View#getMatrix View.getMatrix()}, or null if there is none.
74 */
75 public abstract void setTransformation(Matrix matrix);
76
77 /**
78 * Set the visual elevation (shadow) of the view, as per
79 * {@link View#getZ View.getZ()}. Note this is <em>not</em> related
80 * to the physical Z-ordering of this view relative to its other siblings (that is how
81 * they overlap when drawing), it is only the visual representation for shadowing.
82 */
83 public abstract void setElevation(float elevation);
84
85 /**
86 * Set an alpha transformation that is applied to this view, as per
87 * {@link View#getAlpha View.getAlpha()}. Value ranges from 0
88 * (completely transparent) to 1 (completely opaque); the default is 1, which means
89 * no transformation.
90 */
91 public abstract void setAlpha(float alpha);
92
93 /**
Dianne Hackborn02beb412015-05-19 11:18:16 -070094 * Set the visibility state of this view, as per
95 * {@link View#getVisibility View.getVisibility()}.
96 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -070097 public abstract void setVisibility(int visibility);
98
99 /** @hide */
100 public abstract void setAssistBlocked(boolean state);
101
Dianne Hackborn02beb412015-05-19 11:18:16 -0700102 /**
103 * Set the enabled state of this view, as per {@link View#isEnabled View.isEnabled()}.
104 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700105 public abstract void setEnabled(boolean state);
106
Dianne Hackborn02beb412015-05-19 11:18:16 -0700107 /**
108 * Set the clickable state of this view, as per {@link View#isClickable View.isClickable()}.
109 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700110 public abstract void setClickable(boolean state);
111
Dianne Hackborn02beb412015-05-19 11:18:16 -0700112 /**
113 * Set the long clickable state of this view, as per
114 * {@link View#isLongClickable View.isLongClickable()}.
115 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700116 public abstract void setLongClickable(boolean state);
117
Dianne Hackborn02beb412015-05-19 11:18:16 -0700118 /**
Mady Mellore8608912015-06-05 09:02:55 -0700119 * Set the context clickable state of this view, as per
120 * {@link View#isContextClickable View.isContextClickable()}.
Dianne Hackborn02beb412015-05-19 11:18:16 -0700121 */
Mady Mellore8608912015-06-05 09:02:55 -0700122 public abstract void setContextClickable(boolean state);
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700123
Dianne Hackborn02beb412015-05-19 11:18:16 -0700124 /**
125 * Set the focusable state of this view, as per {@link View#isFocusable View.isFocusable()}.
126 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700127 public abstract void setFocusable(boolean state);
128
Dianne Hackborn02beb412015-05-19 11:18:16 -0700129 /**
130 * Set the focused state of this view, as per {@link View#isFocused View.isFocused()}.
131 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700132 public abstract void setFocused(boolean state);
133
Dianne Hackborn02beb412015-05-19 11:18:16 -0700134 /**
135 * Set the accessibility focused state of this view, as per
136 * {@link View#isAccessibilityFocused View.isAccessibilityFocused()}.
137 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700138 public abstract void setAccessibilityFocused(boolean state);
139
Dianne Hackborn02beb412015-05-19 11:18:16 -0700140 /**
141 * Set the checkable state of this view, such as whether it implements the
142 * {@link android.widget.Checkable} interface.
143 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700144 public abstract void setCheckable(boolean state);
145
Dianne Hackborn02beb412015-05-19 11:18:16 -0700146 /**
147 * Set the checked state of this view, such as
148 * {@link android.widget.Checkable#isChecked Checkable.isChecked()}.
149 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700150 public abstract void setChecked(boolean state);
151
Dianne Hackborn02beb412015-05-19 11:18:16 -0700152 /**
153 * Set the selected state of this view, as per {@link View#isSelected View.isSelected()}.
154 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700155 public abstract void setSelected(boolean state);
156
Dianne Hackborn02beb412015-05-19 11:18:16 -0700157 /**
158 * Set the activated state of this view, as per {@link View#isActivated View.isActivated()}.
159 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700160 public abstract void setActivated(boolean state);
161
Dianne Hackborn02beb412015-05-19 11:18:16 -0700162 /**
Amith Yamasani858f98d2017-02-22 12:59:53 -0800163 * Set the opaque state of this view, as per {@link View#isOpaque View.isOpaque()}.
164 */
165 public abstract void setOpaque(boolean opaque);
166
167 /**
Dianne Hackborn02beb412015-05-19 11:18:16 -0700168 * Set the class name of the view, as per
169 * {@link View#getAccessibilityClassName View.getAccessibilityClassName()}.
170 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700171 public abstract void setClassName(String className);
172
Dianne Hackborn02beb412015-05-19 11:18:16 -0700173 /**
174 * Set the content description of the view, as per
175 * {@link View#getContentDescription View.getContentDescription()}.
176 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700177 public abstract void setContentDescription(CharSequence contentDescription);
178
Dianne Hackborn02beb412015-05-19 11:18:16 -0700179 /**
180 * Set the text that is associated with this view. There is no selection
181 * associated with the text. The text may have style spans to supply additional
182 * display and semantic information.
183 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700184 public abstract void setText(CharSequence text);
Dianne Hackborn02beb412015-05-19 11:18:16 -0700185
186 /**
187 * Like {@link #setText(CharSequence)} but with an active selection
188 * extending from <var>selectionStart</var> through <var>selectionEnd</var>.
189 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700190 public abstract void setText(CharSequence text, int selectionStart, int selectionEnd);
Dianne Hackborn02beb412015-05-19 11:18:16 -0700191
192 /**
Dianne Hackborn02beb412015-05-19 11:18:16 -0700193 * Explicitly set default global style information for text that was previously set with
194 * {@link #setText}.
195 *
196 * @param size The size, in pixels, of the text.
197 * @param fgColor The foreground color, packed as 0xAARRGGBB.
198 * @param bgColor The background color, packed as 0xAARRGGBB.
Dianne Hackborn16036f22015-06-22 14:05:51 -0700199 * @param style Style flags, as defined by {@link android.app.assist.AssistStructure.ViewNode}.
Dianne Hackborn02beb412015-05-19 11:18:16 -0700200 */
James Cook5cfaae42015-05-28 15:52:44 -0700201 public abstract void setTextStyle(float size, int fgColor, int bgColor, int style);
Dianne Hackborn02beb412015-05-19 11:18:16 -0700202
203 /**
Dianne Hackborn6f0fdc42015-07-07 14:29:36 -0700204 * Set line information for test that was previously supplied through
205 * {@link #setText(CharSequence)}. This provides the line breaking of the text as it
206 * is shown on screen. This function takes ownership of the provided arrays; you should
207 * not make further modification to them.
208 *
209 * @param charOffsets The offset in to {@link #setText} where a line starts.
210 * @param baselines The baseline where the line is drawn on screen.
211 */
212 public abstract void setTextLines(int[] charOffsets, int[] baselines);
213
214 /**
Felipe Leme5dc45ca2018-01-03 09:02:27 -0800215 * Sets the identifier used to set the text associated with this view.
216 *
217 * <p>Should only be set when the node is used for autofill purposes - it will be ignored
218 * when used for Assist.
219 */
220 public void setTextIdEntry(@NonNull String entryName) {
221 Preconditions.checkNotNull(entryName);
222 }
223
224 /**
Dianne Hackborn02beb412015-05-19 11:18:16 -0700225 * Set optional hint text associated with this view; this is for example the text that is
226 * shown by an EditText when it is empty to indicate to the user the kind of text to input.
227 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700228 public abstract void setHint(CharSequence hint);
229
Dianne Hackborn02beb412015-05-19 11:18:16 -0700230 /**
Adam Hed55b16e2019-07-19 11:19:56 -0700231 * Sets the identifier used to set the hint associated with this view.
232 *
Adam He295e6d72019-09-26 15:12:48 -0700233 * <p>Used as metadata for fingerprinting view nodes/structures.
234 *
Adam Hed55b16e2019-07-19 11:19:56 -0700235 * <p>Should only be set when the node is used for autofill purposes - it will be ignored
236 * when used for Assist.
237 */
238 public void setHintIdEntry(@NonNull String entryName) {
239 Preconditions.checkNotNull(entryName);
240 }
241
242 /**
Dianne Hackborn02beb412015-05-19 11:18:16 -0700243 * Retrieve the last {@link #setText(CharSequence)}.
244 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700245 public abstract CharSequence getText();
Dianne Hackborn02beb412015-05-19 11:18:16 -0700246
247 /**
248 * Retrieve the last selection start set by {@link #setText(CharSequence, int, int)}.
249 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700250 public abstract int getTextSelectionStart();
Dianne Hackborn02beb412015-05-19 11:18:16 -0700251
252 /**
253 * Retrieve the last selection end set by {@link #setText(CharSequence, int, int)}.
254 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700255 public abstract int getTextSelectionEnd();
Dianne Hackborn02beb412015-05-19 11:18:16 -0700256
257 /**
258 * Retrieve the last hint set by {@link #setHint}.
259 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700260 public abstract CharSequence getHint();
261
Dianne Hackborn02beb412015-05-19 11:18:16 -0700262 /**
263 * Get extra data associated with this view structure; the returned Bundle is mutable,
264 * allowing you to view and modify its contents. Keys placed in the Bundle should use
265 * an appropriate namespace prefix (such as com.google.MY_KEY) to avoid conflicts.
266 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700267 public abstract Bundle getExtras();
Dianne Hackborn02beb412015-05-19 11:18:16 -0700268
269 /**
270 * Returns true if {@link #getExtras} has been used to create extra content.
271 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700272 public abstract boolean hasExtras();
273
Dianne Hackborn02beb412015-05-19 11:18:16 -0700274 /**
275 * Set the number of children of this view, which defines the range of indices you can
276 * use with {@link #newChild} and {@link #asyncNewChild}. Calling this method again
277 * resets all of the child state of the view, removing any children that had previously
278 * been added.
279 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700280 public abstract void setChildCount(int num);
Dianne Hackborn02beb412015-05-19 11:18:16 -0700281
282 /**
Dianne Hackbornece0f4f2015-06-11 13:29:01 -0700283 * Add to this view's child count. This increases the current child count by
284 * <var>num</var> children beyond what was last set by {@link #setChildCount}
285 * or {@link #addChildCount}. The index at which the new child starts in the child
286 * array is returned.
287 *
288 * @param num The number of new children to add.
289 * @return Returns the index in the child array at which the new children start.
290 */
291 public abstract int addChildCount(int num);
292
293 /**
Dianne Hackborn02beb412015-05-19 11:18:16 -0700294 * Return the child count as set by {@link #setChildCount}.
295 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700296 public abstract int getChildCount();
Dianne Hackborn02beb412015-05-19 11:18:16 -0700297
298 /**
299 * Create a new child {@link ViewStructure} in this view, putting into the list of
300 * children at <var>index</var>.
Felipe Lemedbe07a52017-03-03 14:29:17 -0800301 *
Felipe Leme2f6fc722017-05-31 11:57:46 -0700302 * <p><b>NOTE: </b>you must pre-allocate space for the child first, by calling either
303 * {@link #addChildCount(int)} or {@link #setChildCount(int)}.
304 *
Dianne Hackborn02beb412015-05-19 11:18:16 -0700305 * @return Returns an fresh {@link ViewStructure} ready to be filled in.
306 */
Dianne Hackborn8ecf16d2015-06-23 13:09:21 -0700307 public abstract ViewStructure newChild(int index);
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700308
Dianne Hackborn02beb412015-05-19 11:18:16 -0700309 /**
310 * Like {@link #newChild}, but allows the caller to asynchronously populate the returned
311 * child. It can transfer the returned {@link ViewStructure} to another thread for it
312 * to build its content (and children etc). Once done, some thread must call
313 * {@link #asyncCommit} to tell the containing {@link ViewStructure} that the async
314 * population is done.
Felipe Leme2f6fc722017-05-31 11:57:46 -0700315 *
316 * <p><b>NOTE: </b>you must pre-allocate space for the child first, by calling either
317 * {@link #addChildCount(int)} or {@link #setChildCount(int)}.
318 *
Dianne Hackborn02beb412015-05-19 11:18:16 -0700319 * @return Returns an fresh {@link ViewStructure} ready to be filled in.
320 */
Dianne Hackborn8ecf16d2015-06-23 13:09:21 -0700321 public abstract ViewStructure asyncNewChild(int index);
Dianne Hackborn02beb412015-05-19 11:18:16 -0700322
323 /**
Felipe Lemee4f30652017-04-25 10:21:45 -0700324 * Gets the {@link AutofillId} associated with this node.
325 */
326 @Nullable
327 public abstract AutofillId getAutofillId();
328
329 /**
330 * Sets the {@link AutofillId} associated with this node.
331 */
332 public abstract void setAutofillId(@NonNull AutofillId id);
333
334 /**
Felipe Lemef8a81742017-03-17 18:05:01 -0700335 * Sets the {@link AutofillId} for this virtual node.
Felipe Leme0200d9e2017-01-24 15:10:26 -0800336 *
Felipe Lemee4f30652017-04-25 10:21:45 -0700337 * @param parentId id of the parent node.
Felipe Lemef8a81742017-03-17 18:05:01 -0700338 * @param virtualId an opaque ID to the Android System; it's the same id used on
Felipe Leme28afe0e2017-03-17 11:37:27 -0700339 * {@link View#autofill(android.util.SparseArray)}.
Felipe Leme6d553872016-12-08 17:13:25 -0800340 */
Felipe Lemee4f30652017-04-25 10:21:45 -0700341 public abstract void setAutofillId(@NonNull AutofillId parentId, int virtualId);
342
343 /**
Felipe Leme8931e302017-03-06 13:44:35 -0800344 * Sets the {@link View#getAutofillType()} that can be used to autofill this node.
345 */
346 public abstract void setAutofillType(@View.AutofillType int type);
347
348 /**
Philip P. Moltmann81192b42017-03-29 13:58:59 -0700349 * 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 -0800350 * view.
351 */
Philip P. Moltmann81192b42017-03-29 13:58:59 -0700352 public abstract void setAutofillHints(@Nullable String[] hint);
Philip P. Moltmannba6f4622017-02-22 11:03:53 -0800353
354 /**
Felipe Leme640f30a2017-03-06 15:44:06 -0800355 * Sets the {@link AutofillValue} representing the current value of this node.
Felipe Leme0200d9e2017-01-24 15:10:26 -0800356 */
Felipe Leme640f30a2017-03-06 15:44:06 -0800357 public abstract void setAutofillValue(AutofillValue value);
Felipe Leme0200d9e2017-01-24 15:10:26 -0800358
359 /**
Felipe Leme640f30a2017-03-06 15:44:06 -0800360 * Sets the options that can be used to autofill this node.
Felipe Lemed09ccb82017-02-22 15:02:03 -0800361 *
Felipe Leme640f30a2017-03-06 15:44:06 -0800362 * <p>Typically used by nodes whose {@link View#getAutofillType()} is a list to indicate the
363 * meaning of each possible value in the list.
Felipe Lemed09ccb82017-02-22 15:02:03 -0800364 */
Felipe Leme7e4c2052017-04-18 09:45:58 -0700365 public abstract void setAutofillOptions(CharSequence[] options);
Felipe Lemed09ccb82017-02-22 15:02:03 -0800366
367 /**
felipeal53308c12018-02-07 14:43:30 +0100368 * Sets the {@link View#setImportantForAutofill(int) importantForAutofill mode} of the
369 * view associated with this node.
370 */
371 public void setImportantForAutofill(@AutofillImportance int mode) {}
372
373 /**
Felipe Leme16aafc32017-02-27 13:41:37 -0800374 * Sets the {@link android.text.InputType} bits of this node.
375 *
376 * @param inputType inputType bits as defined by {@link android.text.InputType}.
377 */
378 public abstract void setInputType(int inputType);
379
380 /**
Felipe Lemec9a19b12017-03-13 18:05:22 -0700381 * Sets whether the data on this node is sensitive; if it is, then its content (text, autofill
382 * value, etc..) is striped before calls to {@link
Felipe Leme7e4c2052017-04-18 09:45:58 -0700383 * android.service.autofill.AutofillService#onFillRequest(android.service.autofill.FillRequest,
384 * android.os.CancellationSignal, android.service.autofill.FillCallback)}.
Felipe Leme0200d9e2017-01-24 15:10:26 -0800385 *
Felipe Lemec9a19b12017-03-13 18:05:22 -0700386 * <p>By default, all nodes are assumed to be sensitive, and only nodes that does not have PII
387 * (Personally Identifiable Information - sensitive data such as email addresses, credit card
388 * numbers, passwords, etc...) should be marked as non-sensitive; a good rule of thumb is to
389 * mark as non-sensitive nodes whose value were statically set from resources.
390 *
391 * <p>Notice that the content of even sensitive nodes are sent to the service (through the
392 * {@link
Felipe Leme7e4c2052017-04-18 09:45:58 -0700393 * android.service.autofill.AutofillService#onSaveRequest(android.service.autofill.SaveRequest,
394 * android.service.autofill.SaveCallback)} call) when the user consented to save
Felipe Leme2ac463e2017-03-13 14:06:25 -0700395 * 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 -0700396 * sensitive.
Felipe Leme33791fd2017-02-16 08:07:56 -0800397 *
Felipe Leme640f30a2017-03-06 15:44:06 -0800398 * <p>Should only be set when the node is used for autofill purposes - it will be ignored
Felipe Leme33791fd2017-02-16 08:07:56 -0800399 * when used for Assist.
Felipe Leme0200d9e2017-01-24 15:10:26 -0800400 */
Felipe Lemec9a19b12017-03-13 18:05:22 -0700401 public abstract void setDataIsSensitive(boolean sensitive);
Felipe Leme0200d9e2017-01-24 15:10:26 -0800402
403 /**
Felipe Lemeaa7e2292017-10-05 18:19:48 -0700404 * Sets the minimum width in ems of the text associated with this view, when supported.
405 *
406 * <p>Should only be set when the node is used for autofill purposes - it will be ignored
407 * when used for Assist.
408 */
Felipe Leme4d14ec22017-10-19 13:07:22 -0700409 public void setMinTextEms(@SuppressWarnings("unused") int minEms) {}
Felipe Lemeaa7e2292017-10-05 18:19:48 -0700410
411 /**
412 * Sets the maximum width in ems of the text associated with this view, when supported.
413 *
414 * <p>Should only be set when the node is used for autofill purposes - it will be ignored
415 * when used for Assist.
416 */
Felipe Leme4d14ec22017-10-19 13:07:22 -0700417 public void setMaxTextEms(@SuppressWarnings("unused") int maxEms) {}
Felipe Lemeaa7e2292017-10-05 18:19:48 -0700418
419 /**
420 * Sets the maximum length of the text associated with this view, when supported.
421 *
422 * <p>Should only be set when the node is used for autofill purposes - it will be ignored
423 * when used for Assist.
424 */
Felipe Leme4d14ec22017-10-19 13:07:22 -0700425 public void setMaxTextLength(@SuppressWarnings("unused") int maxLength) {}
Felipe Lemeaa7e2292017-10-05 18:19:48 -0700426
427 /**
Dianne Hackborn02beb412015-05-19 11:18:16 -0700428 * Call when done populating a {@link ViewStructure} returned by
429 * {@link #asyncNewChild}.
430 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700431 public abstract void asyncCommit();
432
433 /** @hide */
434 public abstract Rect getTempRect();
Felipe Leme29a5b0d2016-10-25 14:57:11 -0700435
Felipe Lemec3241002017-02-15 12:55:11 -0800436 /**
Felipe Leme4711ed92017-04-21 16:47:18 -0700437 * Sets the Web domain represented by this node.
Felipe Lemec3241002017-02-15 12:55:11 -0800438 *
Felipe Leme25bf7872017-03-28 15:32:29 -0700439 * <p>Typically used when the view is a container for an HTML document.
Felipe Leme4711ed92017-04-21 16:47:18 -0700440 *
Felipe Leme114a4412017-09-26 13:02:11 -0700441 * @param domain RFC 2396-compliant URI representing the domain.
Felipe Lemec3241002017-02-15 12:55:11 -0800442 */
Felipe Leme4711ed92017-04-21 16:47:18 -0700443 public abstract void setWebDomain(@Nullable String domain);
Felipe Lemeb4ca7012017-03-22 18:30:07 -0700444
445 /**
446 * Sets the the list of locales associated with this node.
447 */
448 public abstract void setLocaleList(LocaleList localeList);
Felipe Leme25bf7872017-03-28 15:32:29 -0700449
450 /**
451 * Creates a new {@link HtmlInfo.Builder} for the given HTML tag.
452 *
453 * @param tagName name of the HTML tag.
454 * @return a new builder.
455 */
456 public abstract HtmlInfo.Builder newHtmlInfoBuilder(@NonNull String tagName);
457
458 /**
459 * Sets the HTML properties of this node when it represents an HTML element.
460 *
461 * <p>Should only be set when the node is used for autofill purposes - it will be ignored
462 * when used for assist.
463 *
464 * @param htmlInfo HTML properties.
465 */
466 public abstract void setHtmlInfo(@NonNull HtmlInfo htmlInfo);
467
468 /**
469 * Simplified representation of the HTML properties of a node that represents an HTML element.
470 */
471 public abstract static class HtmlInfo {
472
473 /**
474 * Gets the HTML tag.
475 */
476 @NonNull
477 public abstract String getTag();
478
479 /**
480 * Gets the list of HTML attributes.
481 *
482 * @return list of key/value pairs; could contain pairs with the same keys.
483 */
484 @Nullable
Felipe Leme09a70622017-04-27 15:24:19 -0700485 public abstract List<Pair<String, String>> getAttributes();
Felipe Leme25bf7872017-03-28 15:32:29 -0700486
487 /**
488 * Builder for {@link HtmlInfo} objects.
489 */
490 public abstract static class Builder {
491
492 /**
493 * Adds an HTML attribute.
494 *
495 * @param name name of the attribute.
496 * @param value value of the attribute.
497 * @return same builder, for chaining.
498 */
499 public abstract Builder addAttribute(@NonNull String name, @NonNull String value);
500
501 /**
502 * Builds the {@link HtmlInfo} object.
503 *
504 * @return a new {@link HtmlInfo} instance.
505 */
506 public abstract HtmlInfo build();
507 }
508 }
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700509}