• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
19 import android.graphics.Matrix;
20 import android.graphics.Rect;
21 import android.os.Bundle;
22 
23 /**
24  * Container for storing additional per-view data generated by {@link View#onProvideStructure
25  * View.onProvideStructure}.
26  */
27 public abstract class ViewStructure {
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      */
setId(int id, String packageName, String typeName, String entryName)36     public abstract void setId(int id, String packageName, String typeName, String entryName);
37 
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      */
setDimens(int left, int top, int scrollX, int scrollY, int width, int height)50     public abstract void setDimens(int left, int top, int scrollX, int scrollY, int width,
51             int height);
52 
53     /**
54      * Set the transformation matrix associated with this view, as per
55      * {@link View#getMatrix View.getMatrix()}, or null if there is none.
56      */
setTransformation(Matrix matrix)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      */
setElevation(float elevation)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      */
setAlpha(float alpha)73     public abstract void setAlpha(float alpha);
74 
75     /**
76      * Set the visibility state of this view, as per
77      * {@link View#getVisibility View.getVisibility()}.
78      */
setVisibility(int visibility)79     public abstract void setVisibility(int visibility);
80 
81     /** @hide */
setAssistBlocked(boolean state)82     public abstract void setAssistBlocked(boolean state);
83 
84     /**
85      * Set the enabled state of this view, as per {@link View#isEnabled View.isEnabled()}.
86      */
setEnabled(boolean state)87     public abstract void setEnabled(boolean state);
88 
89     /**
90      * Set the clickable state of this view, as per {@link View#isClickable View.isClickable()}.
91      */
setClickable(boolean state)92     public abstract void setClickable(boolean state);
93 
94     /**
95      * Set the long clickable state of this view, as per
96      * {@link View#isLongClickable View.isLongClickable()}.
97      */
setLongClickable(boolean state)98     public abstract void setLongClickable(boolean state);
99 
100     /**
101      * Set the context clickable state of this view, as per
102      * {@link View#isContextClickable View.isContextClickable()}.
103      */
setContextClickable(boolean state)104     public abstract void setContextClickable(boolean state);
105 
106     /**
107      * Set the focusable state of this view, as per {@link View#isFocusable View.isFocusable()}.
108      */
setFocusable(boolean state)109     public abstract void setFocusable(boolean state);
110 
111     /**
112      * Set the focused state of this view, as per {@link View#isFocused View.isFocused()}.
113      */
setFocused(boolean state)114     public abstract void setFocused(boolean state);
115 
116     /**
117      * Set the accessibility focused state of this view, as per
118      * {@link View#isAccessibilityFocused View.isAccessibilityFocused()}.
119      */
setAccessibilityFocused(boolean state)120     public abstract void setAccessibilityFocused(boolean state);
121 
122     /**
123      * Set the checkable state of this view, such as whether it implements the
124      * {@link android.widget.Checkable} interface.
125      */
setCheckable(boolean state)126     public abstract void setCheckable(boolean state);
127 
128     /**
129      * Set the checked state of this view, such as
130      * {@link android.widget.Checkable#isChecked Checkable.isChecked()}.
131      */
setChecked(boolean state)132     public abstract void setChecked(boolean state);
133 
134     /**
135      * Set the selected state of this view, as per {@link View#isSelected View.isSelected()}.
136      */
setSelected(boolean state)137     public abstract void setSelected(boolean state);
138 
139     /**
140      * Set the activated state of this view, as per {@link View#isActivated View.isActivated()}.
141      */
setActivated(boolean state)142     public abstract void setActivated(boolean state);
143 
144     /**
145      * Set the class name of the view, as per
146      * {@link View#getAccessibilityClassName View.getAccessibilityClassName()}.
147      */
setClassName(String className)148     public abstract void setClassName(String className);
149 
150     /**
151      * Set the content description of the view, as per
152      * {@link View#getContentDescription View.getContentDescription()}.
153      */
setContentDescription(CharSequence contentDescription)154     public abstract void setContentDescription(CharSequence contentDescription);
155 
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      */
setText(CharSequence text)161     public abstract void setText(CharSequence text);
162 
163     /**
164      * Like {@link #setText(CharSequence)} but with an active selection
165      * extending from <var>selectionStart</var> through <var>selectionEnd</var>.
166      */
setText(CharSequence text, int selectionStart, int selectionEnd)167     public abstract void setText(CharSequence text, int selectionStart, int selectionEnd);
168 
169     /**
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.
176      * @param style Style flags, as defined by {@link android.app.assist.AssistStructure.ViewNode}.
177      */
setTextStyle(float size, int fgColor, int bgColor, int style)178     public abstract void setTextStyle(float size, int fgColor, int bgColor, int style);
179 
180     /**
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      */
setTextLines(int[] charOffsets, int[] baselines)189     public abstract void setTextLines(int[] charOffsets, int[] baselines);
190 
191     /**
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      */
setHint(CharSequence hint)195     public abstract void setHint(CharSequence hint);
196 
197     /**
198      * Retrieve the last {@link #setText(CharSequence)}.
199      */
getText()200     public abstract CharSequence getText();
201 
202     /**
203      * Retrieve the last selection start set by {@link #setText(CharSequence, int, int)}.
204      */
getTextSelectionStart()205     public abstract int getTextSelectionStart();
206 
207     /**
208      * Retrieve the last selection end set by {@link #setText(CharSequence, int, int)}.
209      */
getTextSelectionEnd()210     public abstract int getTextSelectionEnd();
211 
212     /**
213      * Retrieve the last hint set by {@link #setHint}.
214      */
getHint()215     public abstract CharSequence getHint();
216 
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      */
getExtras()222     public abstract Bundle getExtras();
223 
224     /**
225      * Returns true if {@link #getExtras} has been used to create extra content.
226      */
hasExtras()227     public abstract boolean hasExtras();
228 
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      */
setChildCount(int num)235     public abstract void setChildCount(int num);
236 
237     /**
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      */
addChildCount(int num)246     public abstract int addChildCount(int num);
247 
248     /**
249      * Return the child count as set by {@link #setChildCount}.
250      */
getChildCount()251     public abstract int getChildCount();
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      */
newChild(int index)258     public abstract ViewStructure newChild(int index);
259 
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      */
asyncNewChild(int index)268     public abstract ViewStructure asyncNewChild(int index);
269 
270     /**
271      * Call when done populating a {@link ViewStructure} returned by
272      * {@link #asyncNewChild}.
273      */
asyncCommit()274     public abstract void asyncCommit();
275 
276     /** @hide */
getTempRect()277     public abstract Rect getTempRect();
278 }
279