Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.view; |
| 18 | |
Felipe Leme | f8a8174 | 2017-03-17 18:05:01 -0700 | [diff] [blame] | 19 | import android.annotation.NonNull; |
Philip P. Moltmann | 495cadd | 2017-03-10 16:45:02 -0800 | [diff] [blame] | 20 | import android.annotation.Nullable; |
Dianne Hackborn | 70d8be7 | 2015-06-23 19:33:02 +0000 | [diff] [blame] | 21 | import android.graphics.Matrix; |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 22 | import android.graphics.Rect; |
| 23 | import android.os.Bundle; |
Felipe Leme | b4ca701 | 2017-03-22 18:30:07 -0700 | [diff] [blame] | 24 | import android.os.LocaleList; |
Felipe Leme | 25bf787 | 2017-03-28 15:32:29 -0700 | [diff] [blame] | 25 | import android.util.Pair; |
felipeal | 53308c1 | 2018-02-07 14:43:30 +0100 | [diff] [blame] | 26 | import android.view.View.AutofillImportance; |
| 27 | import android.view.ViewStructure.HtmlInfo; |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 28 | import android.view.autofill.AutofillId; |
| 29 | import android.view.autofill.AutofillValue; |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 30 | |
Felipe Leme | 5dc45ca | 2018-01-03 09:02:27 -0800 | [diff] [blame] | 31 | import com.android.internal.util.Preconditions; |
| 32 | |
Felipe Leme | 09a7062 | 2017-04-27 15:24:19 -0700 | [diff] [blame] | 33 | import java.util.List; |
Felipe Leme | 25bf787 | 2017-03-28 15:32:29 -0700 | [diff] [blame] | 34 | |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 35 | /** |
Laura Davis | 43e75d9 | 2018-08-10 15:46:06 -0700 | [diff] [blame] | 36 | * <p><code>ViewStructure</code> is a container for storing additional |
| 37 | * per-view data generated by {@link View#onProvideStructure |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 38 | * View.onProvideStructure} and {@link View#onProvideAutofillStructure |
| 39 | * View.onProvideAutofillStructure}. |
Laura Davis | 43e75d9 | 2018-08-10 15:46:06 -0700 | [diff] [blame] | 40 | * |
| 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 Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 44 | */ |
| 45 | public abstract class ViewStructure { |
Felipe Leme | 0200d9e | 2017-01-24 15:10:26 -0800 | [diff] [blame] | 46 | |
| 47 | /** |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 48 | * 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 Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 55 | public abstract void setId(int id, String packageName, String typeName, String entryName); |
| 56 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 57 | /** |
| 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 Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 69 | public abstract void setDimens(int left, int top, int scrollX, int scrollY, int width, |
| 70 | int height); |
| 71 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 72 | /** |
Dianne Hackborn | 70d8be7 | 2015-06-23 19:33:02 +0000 | [diff] [blame] | 73 | * 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 Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 95 | * Set the visibility state of this view, as per |
| 96 | * {@link View#getVisibility View.getVisibility()}. |
| 97 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 98 | public abstract void setVisibility(int visibility); |
| 99 | |
| 100 | /** @hide */ |
| 101 | public abstract void setAssistBlocked(boolean state); |
| 102 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 103 | /** |
| 104 | * Set the enabled state of this view, as per {@link View#isEnabled View.isEnabled()}. |
| 105 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 106 | public abstract void setEnabled(boolean state); |
| 107 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 108 | /** |
| 109 | * Set the clickable state of this view, as per {@link View#isClickable View.isClickable()}. |
| 110 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 111 | public abstract void setClickable(boolean state); |
| 112 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 113 | /** |
| 114 | * Set the long clickable state of this view, as per |
| 115 | * {@link View#isLongClickable View.isLongClickable()}. |
| 116 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 117 | public abstract void setLongClickable(boolean state); |
| 118 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 119 | /** |
Mady Mellor | e860891 | 2015-06-05 09:02:55 -0700 | [diff] [blame] | 120 | * Set the context clickable state of this view, as per |
| 121 | * {@link View#isContextClickable View.isContextClickable()}. |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 122 | */ |
Mady Mellor | e860891 | 2015-06-05 09:02:55 -0700 | [diff] [blame] | 123 | public abstract void setContextClickable(boolean state); |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 124 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 125 | /** |
| 126 | * Set the focusable state of this view, as per {@link View#isFocusable View.isFocusable()}. |
| 127 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 128 | public abstract void setFocusable(boolean state); |
| 129 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 130 | /** |
| 131 | * Set the focused state of this view, as per {@link View#isFocused View.isFocused()}. |
| 132 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 133 | public abstract void setFocused(boolean state); |
| 134 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 135 | /** |
| 136 | * Set the accessibility focused state of this view, as per |
| 137 | * {@link View#isAccessibilityFocused View.isAccessibilityFocused()}. |
| 138 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 139 | public abstract void setAccessibilityFocused(boolean state); |
| 140 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 141 | /** |
| 142 | * Set the checkable state of this view, such as whether it implements the |
| 143 | * {@link android.widget.Checkable} interface. |
| 144 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 145 | public abstract void setCheckable(boolean state); |
| 146 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 147 | /** |
| 148 | * Set the checked state of this view, such as |
| 149 | * {@link android.widget.Checkable#isChecked Checkable.isChecked()}. |
| 150 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 151 | public abstract void setChecked(boolean state); |
| 152 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 153 | /** |
| 154 | * Set the selected state of this view, as per {@link View#isSelected View.isSelected()}. |
| 155 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 156 | public abstract void setSelected(boolean state); |
| 157 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 158 | /** |
| 159 | * Set the activated state of this view, as per {@link View#isActivated View.isActivated()}. |
| 160 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 161 | public abstract void setActivated(boolean state); |
| 162 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 163 | /** |
Amith Yamasani | 858f98d | 2017-02-22 12:59:53 -0800 | [diff] [blame] | 164 | * 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 Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 169 | * Set the class name of the view, as per |
| 170 | * {@link View#getAccessibilityClassName View.getAccessibilityClassName()}. |
| 171 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 172 | public abstract void setClassName(String className); |
| 173 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 174 | /** |
| 175 | * Set the content description of the view, as per |
| 176 | * {@link View#getContentDescription View.getContentDescription()}. |
| 177 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 178 | public abstract void setContentDescription(CharSequence contentDescription); |
| 179 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 180 | /** |
| 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 Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 185 | public abstract void setText(CharSequence text); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 186 | |
| 187 | /** |
| 188 | * Like {@link #setText(CharSequence)} but with an active selection |
| 189 | * extending from <var>selectionStart</var> through <var>selectionEnd</var>. |
| 190 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 191 | public abstract void setText(CharSequence text, int selectionStart, int selectionEnd); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 192 | |
| 193 | /** |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 194 | * 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 Hackborn | 16036f2 | 2015-06-22 14:05:51 -0700 | [diff] [blame] | 200 | * @param style Style flags, as defined by {@link android.app.assist.AssistStructure.ViewNode}. |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 201 | */ |
James Cook | 5cfaae4 | 2015-05-28 15:52:44 -0700 | [diff] [blame] | 202 | public abstract void setTextStyle(float size, int fgColor, int bgColor, int style); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 203 | |
| 204 | /** |
Dianne Hackborn | 6f0fdc4 | 2015-07-07 14:29:36 -0700 | [diff] [blame] | 205 | * 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 Leme | 5dc45ca | 2018-01-03 09:02:27 -0800 | [diff] [blame] | 216 | * 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 Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 226 | * 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 Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 229 | public abstract void setHint(CharSequence hint); |
| 230 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 231 | /** |
| 232 | * Retrieve the last {@link #setText(CharSequence)}. |
| 233 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 234 | public abstract CharSequence getText(); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 235 | |
| 236 | /** |
| 237 | * Retrieve the last selection start set by {@link #setText(CharSequence, int, int)}. |
| 238 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 239 | public abstract int getTextSelectionStart(); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 240 | |
| 241 | /** |
| 242 | * Retrieve the last selection end set by {@link #setText(CharSequence, int, int)}. |
| 243 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 244 | public abstract int getTextSelectionEnd(); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 245 | |
| 246 | /** |
| 247 | * Retrieve the last hint set by {@link #setHint}. |
| 248 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 249 | public abstract CharSequence getHint(); |
| 250 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 251 | /** |
| 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 Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 256 | public abstract Bundle getExtras(); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 257 | |
| 258 | /** |
| 259 | * Returns true if {@link #getExtras} has been used to create extra content. |
| 260 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 261 | public abstract boolean hasExtras(); |
| 262 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 263 | /** |
| 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 Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 269 | public abstract void setChildCount(int num); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 270 | |
| 271 | /** |
Dianne Hackborn | ece0f4f | 2015-06-11 13:29:01 -0700 | [diff] [blame] | 272 | * 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 Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 283 | * Return the child count as set by {@link #setChildCount}. |
| 284 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 285 | public abstract int getChildCount(); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 286 | |
| 287 | /** |
| 288 | * Create a new child {@link ViewStructure} in this view, putting into the list of |
| 289 | * children at <var>index</var>. |
Felipe Leme | dbe07a5 | 2017-03-03 14:29:17 -0800 | [diff] [blame] | 290 | * |
Felipe Leme | 2f6fc72 | 2017-05-31 11:57:46 -0700 | [diff] [blame] | 291 | * <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 Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 294 | * @return Returns an fresh {@link ViewStructure} ready to be filled in. |
| 295 | */ |
Dianne Hackborn | 8ecf16d | 2015-06-23 13:09:21 -0700 | [diff] [blame] | 296 | public abstract ViewStructure newChild(int index); |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 297 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 298 | /** |
| 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 Leme | 2f6fc72 | 2017-05-31 11:57:46 -0700 | [diff] [blame] | 304 | * |
| 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 Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 308 | * @return Returns an fresh {@link ViewStructure} ready to be filled in. |
| 309 | */ |
Dianne Hackborn | 8ecf16d | 2015-06-23 13:09:21 -0700 | [diff] [blame] | 310 | public abstract ViewStructure asyncNewChild(int index); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 311 | |
| 312 | /** |
Felipe Leme | e4f3065 | 2017-04-25 10:21:45 -0700 | [diff] [blame] | 313 | * 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 Leme | f8a8174 | 2017-03-17 18:05:01 -0700 | [diff] [blame] | 324 | * Sets the {@link AutofillId} for this virtual node. |
Felipe Leme | 0200d9e | 2017-01-24 15:10:26 -0800 | [diff] [blame] | 325 | * |
Felipe Leme | e4f3065 | 2017-04-25 10:21:45 -0700 | [diff] [blame] | 326 | * @param parentId id of the parent node. |
Felipe Leme | f8a8174 | 2017-03-17 18:05:01 -0700 | [diff] [blame] | 327 | * @param virtualId an opaque ID to the Android System; it's the same id used on |
Felipe Leme | 28afe0e | 2017-03-17 11:37:27 -0700 | [diff] [blame] | 328 | * {@link View#autofill(android.util.SparseArray)}. |
Felipe Leme | 6d55387 | 2016-12-08 17:13:25 -0800 | [diff] [blame] | 329 | */ |
Felipe Leme | e4f3065 | 2017-04-25 10:21:45 -0700 | [diff] [blame] | 330 | public abstract void setAutofillId(@NonNull AutofillId parentId, int virtualId); |
| 331 | |
| 332 | /** |
Felipe Leme | 8931e30 | 2017-03-06 13:44:35 -0800 | [diff] [blame] | 333 | * 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. Moltmann | 81192b4 | 2017-03-29 13:58:59 -0700 | [diff] [blame] | 338 | * Sets the a hints that helps the autofill service to select the appropriate data to fill the |
Philip P. Moltmann | ba6f462 | 2017-02-22 11:03:53 -0800 | [diff] [blame] | 339 | * view. |
| 340 | */ |
Philip P. Moltmann | 81192b4 | 2017-03-29 13:58:59 -0700 | [diff] [blame] | 341 | public abstract void setAutofillHints(@Nullable String[] hint); |
Philip P. Moltmann | ba6f462 | 2017-02-22 11:03:53 -0800 | [diff] [blame] | 342 | |
| 343 | /** |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 344 | * Sets the {@link AutofillValue} representing the current value of this node. |
Felipe Leme | 0200d9e | 2017-01-24 15:10:26 -0800 | [diff] [blame] | 345 | */ |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 346 | public abstract void setAutofillValue(AutofillValue value); |
Felipe Leme | 0200d9e | 2017-01-24 15:10:26 -0800 | [diff] [blame] | 347 | |
| 348 | /** |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 349 | * Sets the options that can be used to autofill this node. |
Felipe Leme | d09ccb8 | 2017-02-22 15:02:03 -0800 | [diff] [blame] | 350 | * |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 351 | * <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 Leme | d09ccb8 | 2017-02-22 15:02:03 -0800 | [diff] [blame] | 353 | */ |
Felipe Leme | 7e4c205 | 2017-04-18 09:45:58 -0700 | [diff] [blame] | 354 | public abstract void setAutofillOptions(CharSequence[] options); |
Felipe Leme | d09ccb8 | 2017-02-22 15:02:03 -0800 | [diff] [blame] | 355 | |
| 356 | /** |
felipeal | 53308c1 | 2018-02-07 14:43:30 +0100 | [diff] [blame] | 357 | * 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 Leme | 16aafc3 | 2017-02-27 13:41:37 -0800 | [diff] [blame] | 363 | * 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 Leme | c9a19b1 | 2017-03-13 18:05:22 -0700 | [diff] [blame] | 370 | * 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 Leme | 7e4c205 | 2017-04-18 09:45:58 -0700 | [diff] [blame] | 372 | * android.service.autofill.AutofillService#onFillRequest(android.service.autofill.FillRequest, |
| 373 | * android.os.CancellationSignal, android.service.autofill.FillCallback)}. |
Felipe Leme | 0200d9e | 2017-01-24 15:10:26 -0800 | [diff] [blame] | 374 | * |
Felipe Leme | c9a19b1 | 2017-03-13 18:05:22 -0700 | [diff] [blame] | 375 | * <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 Leme | 7e4c205 | 2017-04-18 09:45:58 -0700 | [diff] [blame] | 382 | * android.service.autofill.AutofillService#onSaveRequest(android.service.autofill.SaveRequest, |
| 383 | * android.service.autofill.SaveCallback)} call) when the user consented to save |
Felipe Leme | 2ac463e | 2017-03-13 14:06:25 -0700 | [diff] [blame] | 384 | * thedata, so it is important to set the content of sensitive nodes as well, but mark them as |
Felipe Leme | c9a19b1 | 2017-03-13 18:05:22 -0700 | [diff] [blame] | 385 | * sensitive. |
Felipe Leme | 33791fd | 2017-02-16 08:07:56 -0800 | [diff] [blame] | 386 | * |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 387 | * <p>Should only be set when the node is used for autofill purposes - it will be ignored |
Felipe Leme | 33791fd | 2017-02-16 08:07:56 -0800 | [diff] [blame] | 388 | * when used for Assist. |
Felipe Leme | 0200d9e | 2017-01-24 15:10:26 -0800 | [diff] [blame] | 389 | */ |
Felipe Leme | c9a19b1 | 2017-03-13 18:05:22 -0700 | [diff] [blame] | 390 | public abstract void setDataIsSensitive(boolean sensitive); |
Felipe Leme | 0200d9e | 2017-01-24 15:10:26 -0800 | [diff] [blame] | 391 | |
| 392 | /** |
Felipe Leme | aa7e229 | 2017-10-05 18:19:48 -0700 | [diff] [blame] | 393 | * 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 Leme | 4d14ec2 | 2017-10-19 13:07:22 -0700 | [diff] [blame] | 398 | public void setMinTextEms(@SuppressWarnings("unused") int minEms) {} |
Felipe Leme | aa7e229 | 2017-10-05 18:19:48 -0700 | [diff] [blame] | 399 | |
| 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 Leme | 4d14ec2 | 2017-10-19 13:07:22 -0700 | [diff] [blame] | 406 | public void setMaxTextEms(@SuppressWarnings("unused") int maxEms) {} |
Felipe Leme | aa7e229 | 2017-10-05 18:19:48 -0700 | [diff] [blame] | 407 | |
| 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 Leme | 4d14ec2 | 2017-10-19 13:07:22 -0700 | [diff] [blame] | 414 | public void setMaxTextLength(@SuppressWarnings("unused") int maxLength) {} |
Felipe Leme | aa7e229 | 2017-10-05 18:19:48 -0700 | [diff] [blame] | 415 | |
| 416 | /** |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 417 | * Call when done populating a {@link ViewStructure} returned by |
| 418 | * {@link #asyncNewChild}. |
| 419 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 420 | public abstract void asyncCommit(); |
| 421 | |
| 422 | /** @hide */ |
| 423 | public abstract Rect getTempRect(); |
Felipe Leme | 29a5b0d | 2016-10-25 14:57:11 -0700 | [diff] [blame] | 424 | |
Felipe Leme | c324100 | 2017-02-15 12:55:11 -0800 | [diff] [blame] | 425 | /** |
Felipe Leme | 4711ed9 | 2017-04-21 16:47:18 -0700 | [diff] [blame] | 426 | * Sets the Web domain represented by this node. |
Felipe Leme | c324100 | 2017-02-15 12:55:11 -0800 | [diff] [blame] | 427 | * |
Felipe Leme | 25bf787 | 2017-03-28 15:32:29 -0700 | [diff] [blame] | 428 | * <p>Typically used when the view is a container for an HTML document. |
Felipe Leme | 4711ed9 | 2017-04-21 16:47:18 -0700 | [diff] [blame] | 429 | * |
Felipe Leme | 114a441 | 2017-09-26 13:02:11 -0700 | [diff] [blame] | 430 | * @param domain RFC 2396-compliant URI representing the domain. |
Felipe Leme | c324100 | 2017-02-15 12:55:11 -0800 | [diff] [blame] | 431 | */ |
Felipe Leme | 4711ed9 | 2017-04-21 16:47:18 -0700 | [diff] [blame] | 432 | public abstract void setWebDomain(@Nullable String domain); |
Felipe Leme | b4ca701 | 2017-03-22 18:30:07 -0700 | [diff] [blame] | 433 | |
| 434 | /** |
| 435 | * Sets the the list of locales associated with this node. |
| 436 | */ |
| 437 | public abstract void setLocaleList(LocaleList localeList); |
Felipe Leme | 25bf787 | 2017-03-28 15:32:29 -0700 | [diff] [blame] | 438 | |
| 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 Leme | 09a7062 | 2017-04-27 15:24:19 -0700 | [diff] [blame] | 474 | public abstract List<Pair<String, String>> getAttributes(); |
Felipe Leme | 25bf787 | 2017-03-28 15:32:29 -0700 | [diff] [blame] | 475 | |
| 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 Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 498 | } |