blob: 2e4ba74159f9f76c8c96083c140d6e4aeec8b4b8 [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
Dianne Hackborn70d8be72015-06-23 19:33:02 +000019import android.graphics.Matrix;
Dianne Hackborn49b043f2015-05-07 14:21:38 -070020import android.graphics.Rect;
21import android.os.Bundle;
Dianne Hackborn49b043f2015-05-07 14:21:38 -070022
23/**
24 * Container for storing additional per-view data generated by {@link View#onProvideStructure
25 * View.onProvideStructure}.
26 */
27public abstract class ViewStructure {
Dianne Hackborn02beb412015-05-19 11:18:16 -070028 /**
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 Hackborn49b043f2015-05-07 14:21:38 -070036 public abstract void setId(int id, String packageName, String typeName, String entryName);
37
Dianne Hackborn02beb412015-05-19 11:18:16 -070038 /**
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 Hackborn49b043f2015-05-07 14:21:38 -070050 public abstract void setDimens(int left, int top, int scrollX, int scrollY, int width,
51 int height);
52
Dianne Hackborn02beb412015-05-19 11:18:16 -070053 /**
Dianne Hackborn70d8be72015-06-23 19:33:02 +000054 * 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 Hackborn02beb412015-05-19 11:18:16 -070076 * Set the visibility state of this view, as per
77 * {@link View#getVisibility View.getVisibility()}.
78 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -070079 public abstract void setVisibility(int visibility);
80
81 /** @hide */
82 public abstract void setAssistBlocked(boolean state);
83
Dianne Hackborn02beb412015-05-19 11:18:16 -070084 /**
85 * Set the enabled state of this view, as per {@link View#isEnabled View.isEnabled()}.
86 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -070087 public abstract void setEnabled(boolean state);
88
Dianne Hackborn02beb412015-05-19 11:18:16 -070089 /**
90 * Set the clickable state of this view, as per {@link View#isClickable View.isClickable()}.
91 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -070092 public abstract void setClickable(boolean state);
93
Dianne Hackborn02beb412015-05-19 11:18:16 -070094 /**
95 * Set the long clickable state of this view, as per
96 * {@link View#isLongClickable View.isLongClickable()}.
97 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -070098 public abstract void setLongClickable(boolean state);
99
Dianne Hackborn02beb412015-05-19 11:18:16 -0700100 /**
Mady Mellore8608912015-06-05 09:02:55 -0700101 * Set the context clickable state of this view, as per
102 * {@link View#isContextClickable View.isContextClickable()}.
Dianne Hackborn02beb412015-05-19 11:18:16 -0700103 */
Mady Mellore8608912015-06-05 09:02:55 -0700104 public abstract void setContextClickable(boolean state);
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700105
Dianne Hackborn02beb412015-05-19 11:18:16 -0700106 /**
107 * Set the focusable state of this view, as per {@link View#isFocusable View.isFocusable()}.
108 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700109 public abstract void setFocusable(boolean state);
110
Dianne Hackborn02beb412015-05-19 11:18:16 -0700111 /**
112 * Set the focused state of this view, as per {@link View#isFocused View.isFocused()}.
113 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700114 public abstract void setFocused(boolean state);
115
Dianne Hackborn02beb412015-05-19 11:18:16 -0700116 /**
117 * Set the accessibility focused state of this view, as per
118 * {@link View#isAccessibilityFocused View.isAccessibilityFocused()}.
119 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700120 public abstract void setAccessibilityFocused(boolean state);
121
Dianne Hackborn02beb412015-05-19 11:18:16 -0700122 /**
123 * Set the checkable state of this view, such as whether it implements the
124 * {@link android.widget.Checkable} interface.
125 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700126 public abstract void setCheckable(boolean state);
127
Dianne Hackborn02beb412015-05-19 11:18:16 -0700128 /**
129 * Set the checked state of this view, such as
130 * {@link android.widget.Checkable#isChecked Checkable.isChecked()}.
131 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700132 public abstract void setChecked(boolean state);
133
Dianne Hackborn02beb412015-05-19 11:18:16 -0700134 /**
135 * Set the selected state of this view, as per {@link View#isSelected View.isSelected()}.
136 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700137 public abstract void setSelected(boolean state);
138
Dianne Hackborn02beb412015-05-19 11:18:16 -0700139 /**
140 * Set the activated state of this view, as per {@link View#isActivated View.isActivated()}.
141 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700142 public abstract void setActivated(boolean state);
143
Dianne Hackborn02beb412015-05-19 11:18:16 -0700144 /**
145 * Set the class name of the view, as per
146 * {@link View#getAccessibilityClassName View.getAccessibilityClassName()}.
147 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700148 public abstract void setClassName(String className);
149
Dianne Hackborn02beb412015-05-19 11:18:16 -0700150 /**
151 * Set the content description of the view, as per
152 * {@link View#getContentDescription View.getContentDescription()}.
153 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700154 public abstract void setContentDescription(CharSequence contentDescription);
155
Dianne Hackborn02beb412015-05-19 11:18:16 -0700156 /**
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 Hackborn49b043f2015-05-07 14:21:38 -0700161 public abstract void setText(CharSequence text);
Dianne Hackborn02beb412015-05-19 11:18:16 -0700162
163 /**
164 * Like {@link #setText(CharSequence)} but with an active selection
165 * extending from <var>selectionStart</var> through <var>selectionEnd</var>.
166 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700167 public abstract void setText(CharSequence text, int selectionStart, int selectionEnd);
Dianne Hackborn02beb412015-05-19 11:18:16 -0700168
169 /**
Dianne Hackborn02beb412015-05-19 11:18:16 -0700170 * 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 Hackborn16036f22015-06-22 14:05:51 -0700176 * @param style Style flags, as defined by {@link android.app.assist.AssistStructure.ViewNode}.
Dianne Hackborn02beb412015-05-19 11:18:16 -0700177 */
James Cook5cfaae42015-05-28 15:52:44 -0700178 public abstract void setTextStyle(float size, int fgColor, int bgColor, int style);
Dianne Hackborn02beb412015-05-19 11:18:16 -0700179
180 /**
Dianne Hackborn6f0fdc42015-07-07 14:29:36 -0700181 * 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 Hackborn02beb412015-05-19 11:18:16 -0700192 * 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 Hackborn49b043f2015-05-07 14:21:38 -0700195 public abstract void setHint(CharSequence hint);
196
Dianne Hackborn02beb412015-05-19 11:18:16 -0700197 /**
198 * Retrieve the last {@link #setText(CharSequence)}.
199 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700200 public abstract CharSequence getText();
Dianne Hackborn02beb412015-05-19 11:18:16 -0700201
202 /**
203 * Retrieve the last selection start set by {@link #setText(CharSequence, int, int)}.
204 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700205 public abstract int getTextSelectionStart();
Dianne Hackborn02beb412015-05-19 11:18:16 -0700206
207 /**
208 * Retrieve the last selection end set by {@link #setText(CharSequence, int, int)}.
209 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700210 public abstract int getTextSelectionEnd();
Dianne Hackborn02beb412015-05-19 11:18:16 -0700211
212 /**
213 * Retrieve the last hint set by {@link #setHint}.
214 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700215 public abstract CharSequence getHint();
216
Dianne Hackborn02beb412015-05-19 11:18:16 -0700217 /**
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 Hackborn49b043f2015-05-07 14:21:38 -0700222 public abstract Bundle getExtras();
Dianne Hackborn02beb412015-05-19 11:18:16 -0700223
224 /**
225 * Returns true if {@link #getExtras} has been used to create extra content.
226 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700227 public abstract boolean hasExtras();
228
Dianne Hackborn02beb412015-05-19 11:18:16 -0700229 /**
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 Hackborn49b043f2015-05-07 14:21:38 -0700235 public abstract void setChildCount(int num);
Dianne Hackborn02beb412015-05-19 11:18:16 -0700236
237 /**
Dianne Hackbornece0f4f2015-06-11 13:29:01 -0700238 * 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 Hackborn02beb412015-05-19 11:18:16 -0700249 * Return the child count as set by {@link #setChildCount}.
250 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700251 public abstract int getChildCount();
Dianne Hackborn02beb412015-05-19 11:18:16 -0700252
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 Hackborn8ecf16d2015-06-23 13:09:21 -0700258 public abstract ViewStructure newChild(int index);
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700259
Dianne Hackborn02beb412015-05-19 11:18:16 -0700260 /**
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 Hackborn8ecf16d2015-06-23 13:09:21 -0700268 public abstract ViewStructure asyncNewChild(int index);
Dianne Hackborn02beb412015-05-19 11:18:16 -0700269
270 /**
271 * Call when done populating a {@link ViewStructure} returned by
272 * {@link #asyncNewChild}.
273 */
Dianne Hackborn49b043f2015-05-07 14:21:38 -0700274 public abstract void asyncCommit();
275
276 /** @hide */
277 public abstract Rect getTempRect();
278}