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 | |
Dianne Hackborn | 70d8be7 | 2015-06-23 19:33:02 +0000 | [diff] [blame] | 19 | import android.graphics.Matrix; |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 20 | import android.graphics.Rect; |
| 21 | import android.os.Bundle; |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 22 | |
| 23 | /** |
| 24 | * Container for storing additional per-view data generated by {@link View#onProvideStructure |
| 25 | * View.onProvideStructure}. |
| 26 | */ |
| 27 | public abstract class ViewStructure { |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 28 | /** |
| 29 | * Set the identifier for this view. |
| 30 | * |
| 31 | * @param id The view's identifier, as per {@link View#getId View.getId()}. |
| 32 | * @param packageName The package name of the view's identifier, or null if there is none. |
| 33 | * @param typeName The type name of the view's identifier, or null if there is none. |
| 34 | * @param entryName The entry name of the view's identifier, or null if there is none. |
| 35 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 36 | public abstract void setId(int id, String packageName, String typeName, String entryName); |
| 37 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 38 | /** |
| 39 | * Set the basic dimensions of this view. |
| 40 | * |
| 41 | * @param left The view's left position, in pixels relative to its parent's left edge. |
| 42 | * @param top The view's top position, in pixels relative to its parent's top edge. |
| 43 | * @param scrollX How much the view's x coordinate space has been scrolled, in pixels. |
| 44 | * @param scrollY How much the view's y coordinate space has been scrolled, in pixels. |
| 45 | * @param width The view's visible width, in pixels. This is the width visible on screen, |
| 46 | * not the total data width of a scrollable view. |
| 47 | * @param height The view's visible height, in pixels. This is the height visible on |
| 48 | * screen, not the total data height of a scrollable view. |
| 49 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 50 | public abstract void setDimens(int left, int top, int scrollX, int scrollY, int width, |
| 51 | int height); |
| 52 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 53 | /** |
Dianne Hackborn | 70d8be7 | 2015-06-23 19:33:02 +0000 | [diff] [blame] | 54 | * Set the transformation matrix associated with this view, as per |
| 55 | * {@link View#getMatrix View.getMatrix()}, or null if there is none. |
| 56 | */ |
| 57 | public abstract void setTransformation(Matrix matrix); |
| 58 | |
| 59 | /** |
| 60 | * Set the visual elevation (shadow) of the view, as per |
| 61 | * {@link View#getZ View.getZ()}. Note this is <em>not</em> related |
| 62 | * to the physical Z-ordering of this view relative to its other siblings (that is how |
| 63 | * they overlap when drawing), it is only the visual representation for shadowing. |
| 64 | */ |
| 65 | public abstract void setElevation(float elevation); |
| 66 | |
| 67 | /** |
| 68 | * Set an alpha transformation that is applied to this view, as per |
| 69 | * {@link View#getAlpha View.getAlpha()}. Value ranges from 0 |
| 70 | * (completely transparent) to 1 (completely opaque); the default is 1, which means |
| 71 | * no transformation. |
| 72 | */ |
| 73 | public abstract void setAlpha(float alpha); |
| 74 | |
| 75 | /** |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 76 | * Set the visibility state of this view, as per |
| 77 | * {@link View#getVisibility View.getVisibility()}. |
| 78 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 79 | public abstract void setVisibility(int visibility); |
| 80 | |
| 81 | /** @hide */ |
| 82 | public abstract void setAssistBlocked(boolean state); |
| 83 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 84 | /** |
| 85 | * Set the enabled state of this view, as per {@link View#isEnabled View.isEnabled()}. |
| 86 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 87 | public abstract void setEnabled(boolean state); |
| 88 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 89 | /** |
| 90 | * Set the clickable state of this view, as per {@link View#isClickable View.isClickable()}. |
| 91 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 92 | public abstract void setClickable(boolean state); |
| 93 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 94 | /** |
| 95 | * Set the long clickable state of this view, as per |
| 96 | * {@link View#isLongClickable View.isLongClickable()}. |
| 97 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 98 | public abstract void setLongClickable(boolean state); |
| 99 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 100 | /** |
Mady Mellor | e860891 | 2015-06-05 09:02:55 -0700 | [diff] [blame] | 101 | * Set the context clickable state of this view, as per |
| 102 | * {@link View#isContextClickable View.isContextClickable()}. |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 103 | */ |
Mady Mellor | e860891 | 2015-06-05 09:02:55 -0700 | [diff] [blame] | 104 | public abstract void setContextClickable(boolean state); |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 105 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 106 | /** |
| 107 | * Set the focusable state of this view, as per {@link View#isFocusable View.isFocusable()}. |
| 108 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 109 | public abstract void setFocusable(boolean state); |
| 110 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 111 | /** |
| 112 | * Set the focused state of this view, as per {@link View#isFocused View.isFocused()}. |
| 113 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 114 | public abstract void setFocused(boolean state); |
| 115 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 116 | /** |
| 117 | * Set the accessibility focused state of this view, as per |
| 118 | * {@link View#isAccessibilityFocused View.isAccessibilityFocused()}. |
| 119 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 120 | public abstract void setAccessibilityFocused(boolean state); |
| 121 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 122 | /** |
| 123 | * Set the checkable state of this view, such as whether it implements the |
| 124 | * {@link android.widget.Checkable} interface. |
| 125 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 126 | public abstract void setCheckable(boolean state); |
| 127 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 128 | /** |
| 129 | * Set the checked state of this view, such as |
| 130 | * {@link android.widget.Checkable#isChecked Checkable.isChecked()}. |
| 131 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 132 | public abstract void setChecked(boolean state); |
| 133 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 134 | /** |
| 135 | * Set the selected state of this view, as per {@link View#isSelected View.isSelected()}. |
| 136 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 137 | public abstract void setSelected(boolean state); |
| 138 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 139 | /** |
| 140 | * Set the activated state of this view, as per {@link View#isActivated View.isActivated()}. |
| 141 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 142 | public abstract void setActivated(boolean state); |
| 143 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 144 | /** |
| 145 | * Set the class name of the view, as per |
| 146 | * {@link View#getAccessibilityClassName View.getAccessibilityClassName()}. |
| 147 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 148 | public abstract void setClassName(String className); |
| 149 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 150 | /** |
| 151 | * Set the content description of the view, as per |
| 152 | * {@link View#getContentDescription View.getContentDescription()}. |
| 153 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 154 | public abstract void setContentDescription(CharSequence contentDescription); |
| 155 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 156 | /** |
| 157 | * Set the text that is associated with this view. There is no selection |
| 158 | * associated with the text. The text may have style spans to supply additional |
| 159 | * display and semantic information. |
| 160 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 161 | public abstract void setText(CharSequence text); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 162 | |
| 163 | /** |
| 164 | * Like {@link #setText(CharSequence)} but with an active selection |
| 165 | * extending from <var>selectionStart</var> through <var>selectionEnd</var>. |
| 166 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 167 | public abstract void setText(CharSequence text, int selectionStart, int selectionEnd); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 168 | |
| 169 | /** |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 170 | * Explicitly set default global style information for text that was previously set with |
| 171 | * {@link #setText}. |
| 172 | * |
| 173 | * @param size The size, in pixels, of the text. |
| 174 | * @param fgColor The foreground color, packed as 0xAARRGGBB. |
| 175 | * @param bgColor The background color, packed as 0xAARRGGBB. |
Dianne Hackborn | 16036f2 | 2015-06-22 14:05:51 -0700 | [diff] [blame] | 176 | * @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] | 177 | */ |
James Cook | 5cfaae4 | 2015-05-28 15:52:44 -0700 | [diff] [blame] | 178 | public abstract void setTextStyle(float size, int fgColor, int bgColor, int style); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 179 | |
| 180 | /** |
Dianne Hackborn | 6f0fdc4 | 2015-07-07 14:29:36 -0700 | [diff] [blame] | 181 | * Set line information for test that was previously supplied through |
| 182 | * {@link #setText(CharSequence)}. This provides the line breaking of the text as it |
| 183 | * is shown on screen. This function takes ownership of the provided arrays; you should |
| 184 | * not make further modification to them. |
| 185 | * |
| 186 | * @param charOffsets The offset in to {@link #setText} where a line starts. |
| 187 | * @param baselines The baseline where the line is drawn on screen. |
| 188 | */ |
| 189 | public abstract void setTextLines(int[] charOffsets, int[] baselines); |
| 190 | |
| 191 | /** |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 192 | * Set optional hint text associated with this view; this is for example the text that is |
| 193 | * shown by an EditText when it is empty to indicate to the user the kind of text to input. |
| 194 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 195 | public abstract void setHint(CharSequence hint); |
| 196 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 197 | /** |
| 198 | * Retrieve the last {@link #setText(CharSequence)}. |
| 199 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 200 | public abstract CharSequence getText(); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 201 | |
| 202 | /** |
| 203 | * Retrieve the last selection start set by {@link #setText(CharSequence, int, int)}. |
| 204 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 205 | public abstract int getTextSelectionStart(); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 206 | |
| 207 | /** |
| 208 | * Retrieve the last selection end set by {@link #setText(CharSequence, int, int)}. |
| 209 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 210 | public abstract int getTextSelectionEnd(); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 211 | |
| 212 | /** |
| 213 | * Retrieve the last hint set by {@link #setHint}. |
| 214 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 215 | public abstract CharSequence getHint(); |
| 216 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 217 | /** |
| 218 | * Get extra data associated with this view structure; the returned Bundle is mutable, |
| 219 | * allowing you to view and modify its contents. Keys placed in the Bundle should use |
| 220 | * an appropriate namespace prefix (such as com.google.MY_KEY) to avoid conflicts. |
| 221 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 222 | public abstract Bundle getExtras(); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 223 | |
| 224 | /** |
| 225 | * Returns true if {@link #getExtras} has been used to create extra content. |
| 226 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 227 | public abstract boolean hasExtras(); |
| 228 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 229 | /** |
| 230 | * Set the number of children of this view, which defines the range of indices you can |
| 231 | * use with {@link #newChild} and {@link #asyncNewChild}. Calling this method again |
| 232 | * resets all of the child state of the view, removing any children that had previously |
| 233 | * been added. |
| 234 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 235 | public abstract void setChildCount(int num); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 236 | |
| 237 | /** |
Dianne Hackborn | ece0f4f | 2015-06-11 13:29:01 -0700 | [diff] [blame] | 238 | * Add to this view's child count. This increases the current child count by |
| 239 | * <var>num</var> children beyond what was last set by {@link #setChildCount} |
| 240 | * or {@link #addChildCount}. The index at which the new child starts in the child |
| 241 | * array is returned. |
| 242 | * |
| 243 | * @param num The number of new children to add. |
| 244 | * @return Returns the index in the child array at which the new children start. |
| 245 | */ |
| 246 | public abstract int addChildCount(int num); |
| 247 | |
| 248 | /** |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 249 | * Return the child count as set by {@link #setChildCount}. |
| 250 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 251 | public abstract int getChildCount(); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 252 | |
| 253 | /** |
| 254 | * Create a new child {@link ViewStructure} in this view, putting into the list of |
| 255 | * children at <var>index</var>. |
| 256 | * @return Returns an fresh {@link ViewStructure} ready to be filled in. |
| 257 | */ |
Dianne Hackborn | 8ecf16d | 2015-06-23 13:09:21 -0700 | [diff] [blame] | 258 | public abstract ViewStructure newChild(int index); |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 259 | |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 260 | /** |
| 261 | * Like {@link #newChild}, but allows the caller to asynchronously populate the returned |
| 262 | * child. It can transfer the returned {@link ViewStructure} to another thread for it |
| 263 | * to build its content (and children etc). Once done, some thread must call |
| 264 | * {@link #asyncCommit} to tell the containing {@link ViewStructure} that the async |
| 265 | * population is done. |
| 266 | * @return Returns an fresh {@link ViewStructure} ready to be filled in. |
| 267 | */ |
Dianne Hackborn | 8ecf16d | 2015-06-23 13:09:21 -0700 | [diff] [blame] | 268 | public abstract ViewStructure asyncNewChild(int index); |
Dianne Hackborn | 02beb41 | 2015-05-19 11:18:16 -0700 | [diff] [blame] | 269 | |
| 270 | /** |
| 271 | * Call when done populating a {@link ViewStructure} returned by |
| 272 | * {@link #asyncNewChild}. |
| 273 | */ |
Dianne Hackborn | 49b043f | 2015-05-07 14:21:38 -0700 | [diff] [blame] | 274 | public abstract void asyncCommit(); |
| 275 | |
| 276 | /** @hide */ |
| 277 | public abstract Rect getTempRect(); |
| 278 | } |