svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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.accessibility; |
| 18 | |
| 19 | import android.os.Parcel; |
| 20 | import android.os.Parcelable; |
| 21 | import android.text.TextUtils; |
Svetoslav Ganov | f4782ec | 2012-11-28 09:11:41 -0800 | [diff] [blame] | 22 | import android.util.Pools.SynchronizedPool; |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 23 | |
| 24 | import java.util.ArrayList; |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 25 | import java.util.List; |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 26 | |
| 27 | /** |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 28 | * <p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 29 | * This class represents accessibility events that are sent by the system when |
| 30 | * something notable happens in the user interface. For example, when a |
| 31 | * {@link android.widget.Button} is clicked, a {@link android.view.View} is focused, etc. |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 32 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 33 | * <p> |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 34 | * An accessibility event is fired by an individual view which populates the event with |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 35 | * data for its state and requests from its parent to send the event to interested |
| 36 | * parties. The parent can optionally add an {@link AccessibilityRecord} for itself before |
| 37 | * dispatching a similar request to its parent. A parent can also choose not to respect the |
| 38 | * request for sending an event. The accessibility event is sent by the topmost view in the |
| 39 | * view tree. Therefore, an {@link android.accessibilityservice.AccessibilityService} can |
| 40 | * explore all records in an accessibility event to obtain more information about the |
| 41 | * context in which the event was fired. |
| 42 | * </p> |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 43 | * <p> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 44 | * The main purpose of an accessibility event is to expose enough information for an |
| 45 | * {@link android.accessibilityservice.AccessibilityService} to provide meaningful feedback |
| 46 | * to the user. Sometimes however, an accessibility service may need more contextual |
| 47 | * information then the one in the event pay-load. In such cases the service can obtain |
| 48 | * the event source which is an {@link AccessibilityNodeInfo} (snapshot of a View state) |
| 49 | * which can be used for exploring the window content. Note that the privilege for accessing |
| 50 | * an event's source, thus the window content, has to be explicitly requested. For more |
| 51 | * details refer to {@link android.accessibilityservice.AccessibilityService}. If an |
| 52 | * accessibility service has not requested to retrieve the window content the event will |
| 53 | * not contain reference to its source. Also for events of type |
| 54 | * {@link #TYPE_NOTIFICATION_STATE_CHANGED} the source is never available. |
| 55 | * </p> |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 56 | * <p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 57 | * This class represents various semantically different accessibility event |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 58 | * types. Each event type has an associated set of related properties. In other |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 59 | * words, each event type is characterized via a subset of the properties exposed |
| 60 | * by this class. For each event type there is a corresponding constant defined |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 61 | * in this class. Follows a specification of the event types and their associated properties: |
| 62 | * </p> |
Joe Fernandez | e1302ed | 2012-02-06 14:30:15 -0800 | [diff] [blame] | 63 | * <div class="special reference"> |
| 64 | * <h3>Developer Guides</h3> |
| 65 | * <p>For more information about creating and processing AccessibilityEvents, read the |
| 66 | * <a href="{@docRoot}guide/topics/ui/accessibility/index.html">Accessibility</a> |
| 67 | * developer guide.</p> |
| 68 | * </div> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 69 | * <p> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 70 | * <b>VIEW TYPES</b></br> |
| 71 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 72 | * <p> |
| 73 | * <b>View clicked</b> - represents the event of clicking on a {@link android.view.View} |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 74 | * like {@link android.widget.Button}, {@link android.widget.CompoundButton}, etc.</br> |
| 75 | * <em>Type:</em>{@link #TYPE_VIEW_CLICKED}</br> |
| 76 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 77 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 78 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 79 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 80 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 81 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 82 | * <li>{@link #getEventTime()} - The event time.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 83 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 84 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 85 | * <li>{@link #isPassword()} - Whether the source is password.</li> |
| 86 | * <li>{@link #isChecked()} - Whether the source is checked.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 87 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 88 | * <li>{@link #getScrollX()} - The offset of the source left edge in pixels |
| 89 | * (without descendants of AdapterView).</li> |
| 90 | * <li>{@link #getScrollY()} - The offset of the source top edge in pixels |
| 91 | * (without descendants of AdapterView).</li> |
| 92 | * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, |
| 93 | * inclusive (for descendants of AdapterView).</li> |
| 94 | * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, |
| 95 | * inclusive (for descendants of AdapterView).</li> |
| 96 | * <li>{@link #getItemCount()} - The total items of the source |
| 97 | * (for descendants of AdapterView).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 98 | * </ul> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 99 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 100 | * <p> |
| 101 | * <b>View long clicked</b> - represents the event of long clicking on a {@link android.view.View} |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 102 | * like {@link android.widget.Button}, {@link android.widget.CompoundButton}, etc </br> |
| 103 | * <em>Type:</em>{@link #TYPE_VIEW_LONG_CLICKED}</br> |
| 104 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 105 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 106 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 107 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 108 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 109 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 110 | * <li>{@link #getEventTime()} - The event time.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 111 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 112 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 113 | * <li>{@link #isPassword()} - Whether the source is password.</li> |
| 114 | * <li>{@link #isChecked()} - Whether the source is checked.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 115 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 116 | * <li>{@link #getScrollX()} - The offset of the source left edge in pixels |
| 117 | * (without descendants of AdapterView).</li> |
| 118 | * <li>{@link #getScrollY()} - The offset of the source top edge in pixels |
| 119 | * (without descendants of AdapterView).</li> |
| 120 | * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, |
| 121 | * inclusive (for descendants of AdapterView).</li> |
| 122 | * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, |
| 123 | * inclusive (for descendants of AdapterView).</li> |
| 124 | * <li>{@link #getItemCount()} - The total items of the source |
| 125 | * (for descendants of AdapterView).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 126 | * </ul> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 127 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 128 | * <p> |
| 129 | * <b>View selected</b> - represents the event of selecting an item usually in |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 130 | * the context of an {@link android.widget.AdapterView}.</br> |
| 131 | * <em>Type:</em> {@link #TYPE_VIEW_SELECTED}</br> |
| 132 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 133 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 134 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 135 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 136 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 137 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 138 | * <li>{@link #getEventTime()} - The event time.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 139 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 140 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 141 | * <li>{@link #isPassword()} - Whether the source is password.</li> |
| 142 | * <li>{@link #isChecked()} - Whether the source is checked.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 143 | * <li>{@link #getItemCount()} - The number of selectable items of the source.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 144 | * <li>{@link #getCurrentItemIndex()} - The currently selected item index.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 145 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 146 | * <li>{@link #getScrollX()} - The offset of the source left edge in pixels |
| 147 | * (without descendants of AdapterView).</li> |
| 148 | * <li>{@link #getScrollY()} - The offset of the source top edge in pixels |
| 149 | * (without descendants of AdapterView).</li> |
| 150 | * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, |
| 151 | * inclusive (for descendants of AdapterView).</li> |
| 152 | * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, |
| 153 | * inclusive (for descendants of AdapterView).</li> |
| 154 | * <li>{@link #getItemCount()} - The total items of the source |
| 155 | * (for descendants of AdapterView).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 156 | * </ul> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 157 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 158 | * <p> |
| 159 | * <b>View focused</b> - represents the event of focusing a |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 160 | * {@link android.view.View}.</br> |
| 161 | * <em>Type:</em> {@link #TYPE_VIEW_FOCUSED}</br> |
| 162 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 163 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 164 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 165 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 166 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 167 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 168 | * <li>{@link #getEventTime()} - The event time.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 169 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 170 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 171 | * <li>{@link #isPassword()} - Whether the source is password.</li> |
| 172 | * <li>{@link #isChecked()} - Whether the source is checked.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 173 | * <li>{@link #getItemCount()} - The number of focusable items on the screen.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 174 | * <li>{@link #getCurrentItemIndex()} - The currently focused item index.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 175 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 176 | * <li>{@link #getScrollX()} - The offset of the source left edge in pixels |
| 177 | * (without descendants of AdapterView).</li> |
| 178 | * <li>{@link #getScrollY()} - The offset of the source top edge in pixels |
| 179 | * (without descendants of AdapterView).</li> |
| 180 | * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, |
| 181 | * inclusive (for descendants of AdapterView).</li> |
| 182 | * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, |
| 183 | * inclusive (for descendants of AdapterView).</li> |
| 184 | * <li>{@link #getItemCount()} - The total items of the source |
| 185 | * (for descendants of AdapterView).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 186 | * </ul> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 187 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 188 | * <p> |
| 189 | * <b>View text changed</b> - represents the event of changing the text of an |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 190 | * {@link android.widget.EditText}.</br> |
| 191 | * <em>Type:</em> {@link #TYPE_VIEW_TEXT_CHANGED}</br> |
| 192 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 193 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 194 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 195 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 196 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 197 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 198 | * <li>{@link #getEventTime()} - The event time.</li> |
| 199 | * <li>{@link #getText()} - The text of the source.</li> |
| 200 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 201 | * <li>{@link #isPassword()} - Whether the source is password.</li> |
| 202 | * <li>{@link #isChecked()} - Whether the source is checked.</li> |
| 203 | * <li>{@link #getFromIndex()} - The text change start index.</li> |
| 204 | * <li>{@link #getAddedCount()} - The number of added characters.</li> |
| 205 | * <li>{@link #getRemovedCount()} - The number of removed characters.</li> |
| 206 | * <li>{@link #getBeforeText()} - The text of the source before the change.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 207 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 208 | * </ul> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 209 | * </p> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 210 | * <p> |
| 211 | * <b>View text selection changed</b> - represents the event of changing the text |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 212 | * selection of an {@link android.widget.EditText}.</br> |
| 213 | * <em>Type:</em> {@link #TYPE_VIEW_TEXT_SELECTION_CHANGED} </br> |
| 214 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 215 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 216 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 217 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 218 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 219 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 220 | * <li>{@link #getEventTime()} - The event time.</li> |
| 221 | * <li>{@link #getText()} - The text of the source.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 222 | * <li>{@link #isPassword()} - Whether the source is password.</li> |
| 223 | * <li>{@link #getFromIndex()} - The selection start index.</li> |
| 224 | * <li>{@link #getToIndex()} - The selection end index.</li> |
| 225 | * <li>{@link #getItemCount()} - The length of the source text.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 226 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 227 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 228 | * </ul> |
| 229 | * </p> |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 230 | * <b>View text traversed at movement granularity</b> - represents the event of traversing the |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 231 | * text of a view at a given granularity. For example, moving to the next word.</br> |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 232 | * <em>Type:</em> {@link #TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY} </br> |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 233 | * <em>Properties:</em></br> |
| 234 | * <ul> |
| 235 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 236 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
| 237 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 238 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 239 | * <li>{@link #getEventTime()} - The event time.</li> |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 240 | * <li>{@link #getMovementGranularity()} - Sets the granularity at which a view's text |
| 241 | * was traversed.</li> |
| 242 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
| 243 | * <li>{@link #getFromIndex()} - The start of the next/previous text at the specified granularity |
| 244 | * - inclusive.</li> |
| 245 | * <li>{@link #getToIndex()} - The end of the next/previous text at the specified granularity |
| 246 | * - exclusive.</li> |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 247 | * <li>{@link #isPassword()} - Whether the source is password.</li> |
| 248 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 249 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 250 | * <li>{@link #getMovementGranularity()} - Sets the granularity at which a view's text |
| 251 | * was traversed.</li> |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 252 | * <li>{@link #getAction()} - Gets traversal action which specifies the direction.</li> |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 253 | * </ul> |
| 254 | * </p> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 255 | * <p> |
| 256 | * <b>View scrolled</b> - represents the event of scrolling a view. If |
| 257 | * the source is a descendant of {@link android.widget.AdapterView} the |
| 258 | * scroll is reported in terms of visible items - the first visible item, |
| 259 | * the last visible item, and the total items - because the the source |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 260 | * is unaware of its pixel size since its adapter is responsible for |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 261 | * creating views. In all other cases the scroll is reported as the current |
| 262 | * scroll on the X and Y axis respectively plus the height of the source in |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 263 | * pixels.</br> |
| 264 | * <em>Type:</em> {@link #TYPE_VIEW_SCROLLED}</br> |
| 265 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 266 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 267 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 268 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 269 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 270 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 271 | * <li>{@link #getEventTime()} - The event time.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 272 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 273 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 274 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 275 | * <li>{@link #getScrollX()} - The offset of the source left edge in pixels |
| 276 | * (without descendants of AdapterView).</li> |
| 277 | * <li>{@link #getScrollY()} - The offset of the source top edge in pixels |
| 278 | * (without descendants of AdapterView).</li> |
| 279 | * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, |
| 280 | * inclusive (for descendants of AdapterView).</li> |
| 281 | * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, |
| 282 | * inclusive (for descendants of AdapterView).</li> |
| 283 | * <li>{@link #getItemCount()} - The total items of the source |
| 284 | * (for descendants of AdapterView).</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 285 | * </ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 286 | * <em>Note:</em> This event type is not dispatched to descendants though |
| 287 | * {@link android.view.View#dispatchPopulateAccessibilityEvent(AccessibilityEvent) |
| 288 | * View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)}, hence the event |
| 289 | * source {@link android.view.View} and the sub-tree rooted at it will not receive |
| 290 | * calls to {@link android.view.View#onPopulateAccessibilityEvent(AccessibilityEvent) |
| 291 | * View.onPopulateAccessibilityEvent(AccessibilityEvent)}. The preferred way to add |
| 292 | * text content to such events is by setting the |
| 293 | * {@link android.R.styleable#View_contentDescription contentDescription} of the source |
| 294 | * view.</br> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 295 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 296 | * <p> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 297 | * <b>TRANSITION TYPES</b></br> |
| 298 | * </p> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 299 | * <p> |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 300 | * <b>Window state changed</b> - represents the event of opening a |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 301 | * {@link android.widget.PopupWindow}, {@link android.view.Menu}, |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 302 | * {@link android.app.Dialog}, etc.</br> |
| 303 | * <em>Type:</em> {@link #TYPE_WINDOW_STATE_CHANGED}</br> |
| 304 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 305 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 306 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 307 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 308 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 309 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 310 | * <li>{@link #getEventTime()} - The event time.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 311 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
| 312 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 313 | * </ul> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 314 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 315 | * <p> |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 316 | * <b>Window content changed</b> - represents the event of change in the |
| 317 | * content of a window. This change can be adding/removing view, changing |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 318 | * a view size, etc.</br> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 319 | * </p> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 320 | * <p> |
| 321 | * <strong>Note:</strong> This event is fired only for the window source of the |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 322 | * last accessibility event different from {@link #TYPE_NOTIFICATION_STATE_CHANGED} |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 323 | * and its purpose is to notify clients that the content of the user interaction |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 324 | * window has changed.</br> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 325 | * <em>Type:</em> {@link #TYPE_WINDOW_CONTENT_CHANGED}</br> |
| 326 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 327 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 328 | * <li>{@link #getEventType()} - The type of the event.</li> |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 329 | * <li>{@link #getContentChangeTypes()} - The type of content changes.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 330 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 331 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 332 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 333 | * <li>{@link #getEventTime()} - The event time.</li> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 334 | * </ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 335 | * <em>Note:</em> This event type is not dispatched to descendants though |
| 336 | * {@link android.view.View#dispatchPopulateAccessibilityEvent(AccessibilityEvent) |
| 337 | * View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)}, hence the event |
| 338 | * source {@link android.view.View} and the sub-tree rooted at it will not receive |
| 339 | * calls to {@link android.view.View#onPopulateAccessibilityEvent(AccessibilityEvent) |
| 340 | * View.onPopulateAccessibilityEvent(AccessibilityEvent)}. The preferred way to add |
| 341 | * text content to such events is by setting the |
| 342 | * {@link android.R.styleable#View_contentDescription contentDescription} of the source |
| 343 | * view.</br> |
| 344 | * </p> |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 345 | * <p> |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 346 | * <b>Windows changed</b> - represents the event of changes in the windows shown on |
| 347 | * the screen such as a window appeared, a window disappeared, a window size changed, |
| 348 | * a window layer changed, etc.</br> |
| 349 | * <em>Type:</em> {@link #TYPE_WINDOWS_CHANGED}</br> |
| 350 | * <em>Properties:</em></br> |
| 351 | * <ul> |
| 352 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 353 | * <li>{@link #getEventTime()} - The event time.</li> |
| 354 | * </ul> |
| 355 | * <em>Note:</em> You can retrieve the {@link AccessibilityWindowInfo} for the window |
| 356 | * source of the event via {@link AccessibilityEvent#getSource()} to get the source |
| 357 | * node on which then call {@link AccessibilityNodeInfo#getWindow() |
| 358 | * AccessibilityNodeInfo.getWindow()} to get the window. Also all windows on the screen can |
| 359 | * be retrieved by a call to {@link android.accessibilityservice.AccessibilityService#getWindows() |
| 360 | * android.accessibilityservice.AccessibilityService.getWindows()}. |
| 361 | * </p> |
| 362 | * <p> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 363 | * <b>NOTIFICATION TYPES</b></br> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 364 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 365 | * <p> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 366 | * <b>Notification state changed</b> - represents the event showing |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 367 | * {@link android.app.Notification}.</br> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 368 | * <em>Type:</em> {@link #TYPE_NOTIFICATION_STATE_CHANGED}</br> |
| 369 | * <em>Properties:</em></br> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 370 | * <ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 371 | * <li>{@link #getEventType()} - The type of the event.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 372 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 373 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 374 | * <li>{@link #getEventTime()} - The event time.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 375 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 376 | * <li>{@link #getParcelableData()} - The posted {@link android.app.Notification}.</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 377 | * <li>{@link #getText()} - Text for providing more context.</li> |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 378 | * </ul> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 379 | * <em>Note:</em> This event type is not dispatched to descendants though |
| 380 | * {@link android.view.View#dispatchPopulateAccessibilityEvent(AccessibilityEvent) |
| 381 | * View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)}, hence the event |
| 382 | * source {@link android.view.View} and the sub-tree rooted at it will not receive |
| 383 | * calls to {@link android.view.View#onPopulateAccessibilityEvent(AccessibilityEvent) |
| 384 | * View.onPopulateAccessibilityEvent(AccessibilityEvent)}. The preferred way to add |
| 385 | * text content to such events is by setting the |
| 386 | * {@link android.R.styleable#View_contentDescription contentDescription} of the source |
| 387 | * view.</br> |
| 388 | * </p> |
| 389 | * <p> |
| 390 | * <b>EXPLORATION TYPES</b></br> |
| 391 | * </p> |
| 392 | * <p> |
| 393 | * <b>View hover enter</b> - represents the event of beginning to hover |
| 394 | * over a {@link android.view.View}. The hover may be generated via |
| 395 | * exploring the screen by touch or via a pointing device.</br> |
| 396 | * <em>Type:</em> {@link #TYPE_VIEW_HOVER_ENTER}</br> |
| 397 | * <em>Properties:</em></br> |
| 398 | * <ul> |
| 399 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 400 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
| 401 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 402 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 403 | * <li>{@link #getEventTime()} - The event time.</li> |
| 404 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
| 405 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 406 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 407 | * <li>{@link #getScrollX()} - The offset of the source left edge in pixels |
| 408 | * (without descendants of AdapterView).</li> |
| 409 | * <li>{@link #getScrollY()} - The offset of the source top edge in pixels |
| 410 | * (without descendants of AdapterView).</li> |
| 411 | * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, |
| 412 | * inclusive (for descendants of AdapterView).</li> |
| 413 | * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, |
| 414 | * inclusive (for descendants of AdapterView).</li> |
| 415 | * <li>{@link #getItemCount()} - The total items of the source |
| 416 | * (for descendants of AdapterView).</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 417 | * </ul> |
| 418 | * </p> |
| 419 | * <b>View hover exit</b> - represents the event of stopping to hover |
| 420 | * over a {@link android.view.View}. The hover may be generated via |
| 421 | * exploring the screen by touch or via a pointing device.</br> |
| 422 | * <em>Type:</em> {@link #TYPE_VIEW_HOVER_EXIT}</br> |
| 423 | * <em>Properties:</em></br> |
| 424 | * <ul> |
| 425 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 426 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
| 427 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 428 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 429 | * <li>{@link #getEventTime()} - The event time.</li> |
| 430 | * <li>{@link #getText()} - The text of the source's sub-tree.</li> |
| 431 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 432 | * <li>{@link #getContentDescription()} - The content description of the source.</li> |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 433 | * <li>{@link #getScrollX()} - The offset of the source left edge in pixels |
| 434 | * (without descendants of AdapterView).</li> |
| 435 | * <li>{@link #getScrollY()} - The offset of the source top edge in pixels |
| 436 | * (without descendants of AdapterView).</li> |
| 437 | * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, |
| 438 | * inclusive (for descendants of AdapterView).</li> |
| 439 | * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, |
| 440 | * inclusive (for descendants of AdapterView).</li> |
| 441 | * <li>{@link #getItemCount()} - The total items of the source |
| 442 | * (for descendants of AdapterView).</li> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 443 | * </ul> |
| 444 | * </p> |
| 445 | * <p> |
Svetoslav Ganov | 77276b6 | 2012-09-14 10:23:00 -0700 | [diff] [blame] | 446 | * <b>Touch interaction start</b> - represents the event of starting a touch |
| 447 | * interaction, which is the user starts touching the screen.</br> |
| 448 | * <em>Type:</em> {@link #TYPE_TOUCH_INTERACTION_START}</br> |
| 449 | * <em>Properties:</em></br> |
| 450 | * <ul> |
| 451 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 452 | * </ul> |
| 453 | * <em>Note:</em> This event is fired only by the system and is not passed to the |
| 454 | * view tree to be populated.</br> |
| 455 | * </p> |
| 456 | * <p> |
| 457 | * <b>Touch interaction end</b> - represents the event of ending a touch |
| 458 | * interaction, which is the user stops touching the screen.</br> |
| 459 | * <em>Type:</em> {@link #TYPE_TOUCH_INTERACTION_END}</br> |
| 460 | * <em>Properties:</em></br> |
| 461 | * <ul> |
| 462 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 463 | * </ul> |
| 464 | * <em>Note:</em> This event is fired only by the system and is not passed to the |
| 465 | * view tree to be populated.</br> |
| 466 | * </p> |
| 467 | * <p> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 468 | * <b>Touch exploration gesture start</b> - represents the event of starting a touch |
| 469 | * exploring gesture.</br> |
| 470 | * <em>Type:</em> {@link #TYPE_TOUCH_EXPLORATION_GESTURE_START}</br> |
| 471 | * <em>Properties:</em></br> |
| 472 | * <ul> |
| 473 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 474 | * </ul> |
Svetoslav Ganov | 77276b6 | 2012-09-14 10:23:00 -0700 | [diff] [blame] | 475 | * <em>Note:</em> This event is fired only by the system and is not passed to the |
| 476 | * view tree to be populated.</br> |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 477 | * </p> |
| 478 | * <p> |
| 479 | * <b>Touch exploration gesture end</b> - represents the event of ending a touch |
| 480 | * exploring gesture.</br> |
| 481 | * <em>Type:</em> {@link #TYPE_TOUCH_EXPLORATION_GESTURE_END}</br> |
| 482 | * <em>Properties:</em></br> |
| 483 | * <ul> |
| 484 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 485 | * </ul> |
Svetoslav Ganov | 77276b6 | 2012-09-14 10:23:00 -0700 | [diff] [blame] | 486 | * <em>Note:</em> This event is fired only by the system and is not passed to the |
| 487 | * view tree to be populated.</br> |
| 488 | * </p> |
| 489 | * <p> |
| 490 | * <b>Touch gesture detection start</b> - represents the event of starting a user |
| 491 | * gesture detection.</br> |
| 492 | * <em>Type:</em> {@link #TYPE_GESTURE_DETECTION_START}</br> |
| 493 | * <em>Properties:</em></br> |
| 494 | * <ul> |
| 495 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 496 | * </ul> |
| 497 | * <em>Note:</em> This event is fired only by the system and is not passed to the |
| 498 | * view tree to be populated.</br> |
| 499 | * </p> |
| 500 | * <p> |
| 501 | * <b>Touch gesture detection end</b> - represents the event of ending a user |
| 502 | * gesture detection.</br> |
| 503 | * <em>Type:</em> {@link #TYPE_GESTURE_DETECTION_END}</br> |
| 504 | * <em>Properties:</em></br> |
| 505 | * <ul> |
| 506 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 507 | * </ul> |
| 508 | * <em>Note:</em> This event is fired only by the system and is not passed to the |
| 509 | * view tree to be populated.</br> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 510 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 511 | * <p> |
Svetoslav Ganov | 51ab90c | 2012-03-09 10:54:49 -0800 | [diff] [blame] | 512 | * <b>MISCELLANEOUS TYPES</b></br> |
| 513 | * </p> |
| 514 | * <p> |
| 515 | * <b>Announcement</b> - represents the event of an application making an |
| 516 | * announcement. Usually this announcement is related to some sort of a context |
| 517 | * change for which none of the events representing UI transitions is a good fit. |
| 518 | * For example, announcing a new page in a book.</br> |
| 519 | * <em>Type:</em> {@link #TYPE_ANNOUNCEMENT}</br> |
| 520 | * <em>Properties:</em></br> |
| 521 | * <ul> |
| 522 | * <li>{@link #getEventType()} - The type of the event.</li> |
| 523 | * <li>{@link #getSource()} - The source info (for registered clients).</li> |
| 524 | * <li>{@link #getClassName()} - The class name of the source.</li> |
| 525 | * <li>{@link #getPackageName()} - The package name of the source.</li> |
| 526 | * <li>{@link #getEventTime()} - The event time.</li> |
| 527 | * <li>{@link #getText()} - The text of the announcement.</li> |
| 528 | * <li>{@link #isEnabled()} - Whether the source is enabled.</li> |
| 529 | * </ul> |
| 530 | * </p> |
| 531 | * <p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 532 | * <b>Security note</b> |
| 533 | * <p> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 534 | * Since an event contains the text of its source privacy can be compromised by leaking |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 535 | * sensitive information such as passwords. To address this issue any event fired in response |
| 536 | * to manipulation of a PASSWORD field does NOT CONTAIN the text of the password. |
Svetoslav Ganov | 82e236d | 2011-09-29 19:31:06 -0700 | [diff] [blame] | 537 | * </p> |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 538 | * |
| 539 | * @see android.view.accessibility.AccessibilityManager |
| 540 | * @see android.accessibilityservice.AccessibilityService |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 541 | * @see AccessibilityNodeInfo |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 542 | */ |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 543 | public final class AccessibilityEvent extends AccessibilityRecord implements Parcelable { |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 544 | private static final boolean DEBUG = false; |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 545 | |
| 546 | /** |
| 547 | * Invalid selection/focus position. |
| 548 | * |
| 549 | * @see #getCurrentItemIndex() |
| 550 | */ |
| 551 | public static final int INVALID_POSITION = -1; |
| 552 | |
| 553 | /** |
| 554 | * Maximum length of the text fields. |
| 555 | * |
| 556 | * @see #getBeforeText() |
| 557 | * @see #getText() |
Svetoslav Ganov | c0a8cd1 | 2011-03-18 17:05:56 -0700 | [diff] [blame] | 558 | * </br> |
| 559 | * Note: This constant is no longer needed since there |
| 560 | * is no limit on the length of text that is contained |
| 561 | * in an accessibility event anymore. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 562 | */ |
Svetoslav Ganov | c0a8cd1 | 2011-03-18 17:05:56 -0700 | [diff] [blame] | 563 | @Deprecated |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 564 | public static final int MAX_TEXT_LENGTH = 500; |
| 565 | |
| 566 | /** |
| 567 | * Represents the event of clicking on a {@link android.view.View} like |
| 568 | * {@link android.widget.Button}, {@link android.widget.CompoundButton}, etc. |
| 569 | */ |
| 570 | public static final int TYPE_VIEW_CLICKED = 0x00000001; |
| 571 | |
| 572 | /** |
| 573 | * Represents the event of long clicking on a {@link android.view.View} like |
| 574 | * {@link android.widget.Button}, {@link android.widget.CompoundButton}, etc. |
| 575 | */ |
| 576 | public static final int TYPE_VIEW_LONG_CLICKED = 0x00000002; |
| 577 | |
| 578 | /** |
| 579 | * Represents the event of selecting an item usually in the context of an |
| 580 | * {@link android.widget.AdapterView}. |
| 581 | */ |
| 582 | public static final int TYPE_VIEW_SELECTED = 0x00000004; |
| 583 | |
| 584 | /** |
Svetoslav Ganov | 4213804 | 2012-03-20 11:51:39 -0700 | [diff] [blame] | 585 | * Represents the event of setting input focus of a {@link android.view.View}. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 586 | */ |
| 587 | public static final int TYPE_VIEW_FOCUSED = 0x00000008; |
| 588 | |
| 589 | /** |
| 590 | * Represents the event of changing the text of an {@link android.widget.EditText}. |
| 591 | */ |
| 592 | public static final int TYPE_VIEW_TEXT_CHANGED = 0x00000010; |
| 593 | |
| 594 | /** |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 595 | * Represents the event of opening a {@link android.widget.PopupWindow}, |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 596 | * {@link android.view.Menu}, {@link android.app.Dialog}, etc. |
| 597 | */ |
| 598 | public static final int TYPE_WINDOW_STATE_CHANGED = 0x00000020; |
| 599 | |
| 600 | /** |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 601 | * Represents the event showing a {@link android.app.Notification}. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 602 | */ |
| 603 | public static final int TYPE_NOTIFICATION_STATE_CHANGED = 0x00000040; |
| 604 | |
| 605 | /** |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 606 | * Represents the event of a hover enter over a {@link android.view.View}. |
| 607 | */ |
| 608 | public static final int TYPE_VIEW_HOVER_ENTER = 0x00000080; |
| 609 | |
| 610 | /** |
| 611 | * Represents the event of a hover exit over a {@link android.view.View}. |
| 612 | */ |
| 613 | public static final int TYPE_VIEW_HOVER_EXIT = 0x00000100; |
| 614 | |
| 615 | /** |
| 616 | * Represents the event of starting a touch exploration gesture. |
| 617 | */ |
| 618 | public static final int TYPE_TOUCH_EXPLORATION_GESTURE_START = 0x00000200; |
| 619 | |
| 620 | /** |
| 621 | * Represents the event of ending a touch exploration gesture. |
| 622 | */ |
| 623 | public static final int TYPE_TOUCH_EXPLORATION_GESTURE_END = 0x00000400; |
| 624 | |
| 625 | /** |
Svetoslav Ganov | 4213804 | 2012-03-20 11:51:39 -0700 | [diff] [blame] | 626 | * Represents the event of changing the content of a window and more |
| 627 | * specifically the sub-tree rooted at the event's source. |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 628 | */ |
| 629 | public static final int TYPE_WINDOW_CONTENT_CHANGED = 0x00000800; |
| 630 | |
| 631 | /** |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 632 | * Represents the event of scrolling a view. |
| 633 | */ |
| 634 | public static final int TYPE_VIEW_SCROLLED = 0x00001000; |
| 635 | |
| 636 | /** |
| 637 | * Represents the event of changing the selection in an {@link android.widget.EditText}. |
| 638 | */ |
| 639 | public static final int TYPE_VIEW_TEXT_SELECTION_CHANGED = 0x00002000; |
| 640 | |
| 641 | /** |
Svetoslav Ganov | 51ab90c | 2012-03-09 10:54:49 -0800 | [diff] [blame] | 642 | * Represents the event of an application making an announcement. |
| 643 | */ |
| 644 | public static final int TYPE_ANNOUNCEMENT = 0x00004000; |
| 645 | |
| 646 | /** |
Svetoslav Ganov | 4213804 | 2012-03-20 11:51:39 -0700 | [diff] [blame] | 647 | * Represents the event of gaining accessibility focus. |
| 648 | */ |
| 649 | public static final int TYPE_VIEW_ACCESSIBILITY_FOCUSED = 0x00008000; |
| 650 | |
| 651 | /** |
| 652 | * Represents the event of clearing accessibility focus. |
| 653 | */ |
| 654 | public static final int TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED = 0x00010000; |
| 655 | |
| 656 | /** |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 657 | * Represents the event of traversing the text of a view at a given movement granularity. |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 658 | */ |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 659 | public static final int TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY = 0x00020000; |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 660 | |
| 661 | /** |
Svetoslav Ganov | 77276b6 | 2012-09-14 10:23:00 -0700 | [diff] [blame] | 662 | * Represents the event of beginning gesture detection. |
| 663 | */ |
| 664 | public static final int TYPE_GESTURE_DETECTION_START = 0x00040000; |
| 665 | |
| 666 | /** |
| 667 | * Represents the event of ending gesture detection. |
| 668 | */ |
| 669 | public static final int TYPE_GESTURE_DETECTION_END = 0x00080000; |
| 670 | |
| 671 | /** |
| 672 | * Represents the event of the user starting to touch the screen. |
| 673 | */ |
| 674 | public static final int TYPE_TOUCH_INTERACTION_START = 0x00100000; |
| 675 | |
| 676 | /** |
| 677 | * Represents the event of the user ending to touch the screen. |
| 678 | */ |
| 679 | public static final int TYPE_TOUCH_INTERACTION_END = 0x00200000; |
| 680 | |
| 681 | /** |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 682 | * Represents the event change in the windows shown on the screen. |
| 683 | */ |
| 684 | public static final int TYPE_WINDOWS_CHANGED = 0x00400000; |
| 685 | |
| 686 | /** |
Mady Mellor | e82067b | 2015-04-30 09:58:35 -0700 | [diff] [blame] | 687 | * Represents the event of a stylus button press on a {@link android.view.View}. |
| 688 | */ |
| 689 | public static final int TYPE_VIEW_STYLUS_BUTTON_PRESSED = 0x00800000; |
| 690 | |
| 691 | /** |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 692 | * Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event: |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 693 | * The type of change is not defined. |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 694 | */ |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 695 | public static final int CONTENT_CHANGE_TYPE_UNDEFINED = 0x00000000; |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 696 | |
| 697 | /** |
| 698 | * Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event: |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 699 | * A node in the subtree rooted at the source node was added or removed. |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 700 | */ |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 701 | public static final int CONTENT_CHANGE_TYPE_SUBTREE = 0x00000001; |
| 702 | |
| 703 | /** |
| 704 | * Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event: |
| 705 | * The node's text changed. |
| 706 | */ |
| 707 | public static final int CONTENT_CHANGE_TYPE_TEXT = 0x00000002; |
| 708 | |
| 709 | /** |
| 710 | * Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event: |
| 711 | * The node's content description changed. |
| 712 | */ |
| 713 | public static final int CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION = 0x00000004; |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 714 | |
| 715 | /** |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 716 | * Mask for {@link AccessibilityEvent} all types. |
| 717 | * |
| 718 | * @see #TYPE_VIEW_CLICKED |
| 719 | * @see #TYPE_VIEW_LONG_CLICKED |
| 720 | * @see #TYPE_VIEW_SELECTED |
| 721 | * @see #TYPE_VIEW_FOCUSED |
| 722 | * @see #TYPE_VIEW_TEXT_CHANGED |
| 723 | * @see #TYPE_WINDOW_STATE_CHANGED |
| 724 | * @see #TYPE_NOTIFICATION_STATE_CHANGED |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 725 | * @see #TYPE_VIEW_HOVER_ENTER |
| 726 | * @see #TYPE_VIEW_HOVER_EXIT |
| 727 | * @see #TYPE_TOUCH_EXPLORATION_GESTURE_START |
| 728 | * @see #TYPE_TOUCH_EXPLORATION_GESTURE_END |
| 729 | * @see #TYPE_WINDOW_CONTENT_CHANGED |
| 730 | * @see #TYPE_VIEW_SCROLLED |
| 731 | * @see #TYPE_VIEW_TEXT_SELECTION_CHANGED |
Svetoslav Ganov | 51ab90c | 2012-03-09 10:54:49 -0800 | [diff] [blame] | 732 | * @see #TYPE_ANNOUNCEMENT |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 733 | * @see #TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY |
Svetoslav Ganov | 77276b6 | 2012-09-14 10:23:00 -0700 | [diff] [blame] | 734 | * @see #TYPE_GESTURE_DETECTION_START |
| 735 | * @see #TYPE_GESTURE_DETECTION_END |
| 736 | * @see #TYPE_TOUCH_INTERACTION_START |
| 737 | * @see #TYPE_TOUCH_INTERACTION_END |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 738 | * @see #TYPE_WINDOWS_CHANGED |
Mady Mellor | e82067b | 2015-04-30 09:58:35 -0700 | [diff] [blame] | 739 | * @see #TYPE_VIEW_STYLUS_BUTTON_PRESSED |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 740 | */ |
| 741 | public static final int TYPES_ALL_MASK = 0xFFFFFFFF; |
| 742 | |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 743 | private static final int MAX_POOL_SIZE = 10; |
Svetoslav Ganov | f4782ec | 2012-11-28 09:11:41 -0800 | [diff] [blame] | 744 | private static final SynchronizedPool<AccessibilityEvent> sPool = |
| 745 | new SynchronizedPool<AccessibilityEvent>(MAX_POOL_SIZE); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 746 | |
| 747 | private int mEventType; |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 748 | private CharSequence mPackageName; |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 749 | private long mEventTime; |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 750 | int mMovementGranularity; |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 751 | int mAction; |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 752 | int mContentChangeTypes; |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 753 | |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 754 | private ArrayList<AccessibilityRecord> mRecords; |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 755 | |
| 756 | /* |
| 757 | * Hide constructor from clients. |
| 758 | */ |
| 759 | private AccessibilityEvent() { |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 760 | } |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 761 | |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 762 | /** |
| 763 | * Initialize an event from another one. |
| 764 | * |
| 765 | * @param event The event to initialize from. |
| 766 | */ |
| 767 | void init(AccessibilityEvent event) { |
| 768 | super.init(event); |
| 769 | mEventType = event.mEventType; |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 770 | mMovementGranularity = event.mMovementGranularity; |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 771 | mAction = event.mAction; |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 772 | mContentChangeTypes = event.mContentChangeTypes; |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 773 | mEventTime = event.mEventTime; |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 774 | mPackageName = event.mPackageName; |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 775 | } |
| 776 | |
| 777 | /** |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 778 | * Sets if this instance is sealed. |
| 779 | * |
| 780 | * @param sealed Whether is sealed. |
| 781 | * |
| 782 | * @hide |
| 783 | */ |
| 784 | @Override |
| 785 | public void setSealed(boolean sealed) { |
| 786 | super.setSealed(sealed); |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 787 | final List<AccessibilityRecord> records = mRecords; |
| 788 | if (records != null) { |
| 789 | final int recordCount = records.size(); |
| 790 | for (int i = 0; i < recordCount; i++) { |
| 791 | AccessibilityRecord record = records.get(i); |
| 792 | record.setSealed(sealed); |
| 793 | } |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 794 | } |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 795 | } |
| 796 | |
| 797 | /** |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 798 | * Gets the number of records contained in the event. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 799 | * |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 800 | * @return The number of records. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 801 | */ |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 802 | public int getRecordCount() { |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 803 | return mRecords == null ? 0 : mRecords.size(); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | /** |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 807 | * Appends an {@link AccessibilityRecord} to the end of event records. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 808 | * |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 809 | * @param record The record to append. |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 810 | * |
| 811 | * @throws IllegalStateException If called from an AccessibilityService. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 812 | */ |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 813 | public void appendRecord(AccessibilityRecord record) { |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 814 | enforceNotSealed(); |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 815 | if (mRecords == null) { |
| 816 | mRecords = new ArrayList<AccessibilityRecord>(); |
| 817 | } |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 818 | mRecords.add(record); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | /** |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 822 | * Gets the record at a given index. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 823 | * |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 824 | * @param index The index. |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 825 | * @return The record at the specified index. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 826 | */ |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 827 | public AccessibilityRecord getRecord(int index) { |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 828 | if (mRecords == null) { |
| 829 | throw new IndexOutOfBoundsException("Invalid index " + index + ", size is 0"); |
| 830 | } |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 831 | return mRecords.get(index); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 832 | } |
| 833 | |
| 834 | /** |
| 835 | * Gets the event type. |
| 836 | * |
| 837 | * @return The event type. |
| 838 | */ |
| 839 | public int getEventType() { |
| 840 | return mEventType; |
| 841 | } |
| 842 | |
| 843 | /** |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 844 | * Gets the bit mask of change types signaled by an |
| 845 | * {@link #TYPE_WINDOW_CONTENT_CHANGED} event. A single event may represent |
| 846 | * multiple change types. |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 847 | * |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 848 | * @return The bit mask of change types. One or more of: |
| 849 | * <ul> |
| 850 | * <li>{@link AccessibilityEvent#CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION} |
| 851 | * <li>{@link AccessibilityEvent#CONTENT_CHANGE_TYPE_SUBTREE} |
| 852 | * <li>{@link AccessibilityEvent#CONTENT_CHANGE_TYPE_TEXT} |
| 853 | * <li>{@link AccessibilityEvent#CONTENT_CHANGE_TYPE_UNDEFINED} |
| 854 | * </ul> |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 855 | */ |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 856 | public int getContentChangeTypes() { |
| 857 | return mContentChangeTypes; |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 858 | } |
| 859 | |
| 860 | /** |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 861 | * Sets the bit mask of node tree changes signaled by an |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 862 | * {@link #TYPE_WINDOW_CONTENT_CHANGED} event. |
| 863 | * |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 864 | * @param changeTypes The bit mask of change types. |
| 865 | * @throws IllegalStateException If called from an AccessibilityService. |
| 866 | * @see #getContentChangeTypes() |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 867 | */ |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 868 | public void setContentChangeTypes(int changeTypes) { |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 869 | enforceNotSealed(); |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 870 | mContentChangeTypes = changeTypes; |
Svetoslav | 6254f48 | 2013-06-04 17:22:14 -0700 | [diff] [blame] | 871 | } |
| 872 | |
| 873 | /** |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 874 | * Sets the event type. |
| 875 | * |
| 876 | * @param eventType The event type. |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 877 | * |
| 878 | * @throws IllegalStateException If called from an AccessibilityService. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 879 | */ |
| 880 | public void setEventType(int eventType) { |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 881 | enforceNotSealed(); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 882 | mEventType = eventType; |
| 883 | } |
| 884 | |
| 885 | /** |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 886 | * Gets the time in which this event was sent. |
| 887 | * |
| 888 | * @return The event time. |
| 889 | */ |
| 890 | public long getEventTime() { |
| 891 | return mEventTime; |
| 892 | } |
| 893 | |
| 894 | /** |
| 895 | * Sets the time in which this event was sent. |
| 896 | * |
| 897 | * @param eventTime The event time. |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 898 | * |
| 899 | * @throws IllegalStateException If called from an AccessibilityService. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 900 | */ |
| 901 | public void setEventTime(long eventTime) { |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 902 | enforceNotSealed(); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 903 | mEventTime = eventTime; |
| 904 | } |
| 905 | |
| 906 | /** |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 907 | * Gets the package name of the source. |
| 908 | * |
| 909 | * @return The package name. |
| 910 | */ |
| 911 | public CharSequence getPackageName() { |
| 912 | return mPackageName; |
| 913 | } |
| 914 | |
| 915 | /** |
| 916 | * Sets the package name of the source. |
| 917 | * |
| 918 | * @param packageName The package name. |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 919 | * |
| 920 | * @throws IllegalStateException If called from an AccessibilityService. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 921 | */ |
| 922 | public void setPackageName(CharSequence packageName) { |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 923 | enforceNotSealed(); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 924 | mPackageName = packageName; |
| 925 | } |
| 926 | |
| 927 | /** |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 928 | * Sets the movement granularity that was traversed. |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 929 | * |
| 930 | * @param granularity The granularity. |
| 931 | * |
| 932 | * @throws IllegalStateException If called from an AccessibilityService. |
| 933 | */ |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 934 | public void setMovementGranularity(int granularity) { |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 935 | enforceNotSealed(); |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 936 | mMovementGranularity = granularity; |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 937 | } |
| 938 | |
| 939 | /** |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 940 | * Gets the movement granularity that was traversed. |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 941 | * |
| 942 | * @return The granularity. |
| 943 | */ |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 944 | public int getMovementGranularity() { |
| 945 | return mMovementGranularity; |
Svetoslav Ganov | b7ff325 | 2012-04-24 18:40:07 -0700 | [diff] [blame] | 946 | } |
| 947 | |
| 948 | /** |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 949 | * Sets the performed action that triggered this event. |
Alan Viverette | af43110 | 2013-10-04 13:16:51 -0700 | [diff] [blame] | 950 | * <p> |
| 951 | * Valid actions are defined in {@link AccessibilityNodeInfo}: |
| 952 | * <ul> |
| 953 | * <li>{@link AccessibilityNodeInfo#ACTION_ACCESSIBILITY_FOCUS} |
| 954 | * <li>{@link AccessibilityNodeInfo#ACTION_CLEAR_ACCESSIBILITY_FOCUS} |
| 955 | * <li>{@link AccessibilityNodeInfo#ACTION_CLEAR_FOCUS} |
| 956 | * <li>{@link AccessibilityNodeInfo#ACTION_CLEAR_SELECTION} |
| 957 | * <li>{@link AccessibilityNodeInfo#ACTION_CLICK} |
| 958 | * <li>etc. |
| 959 | * </ul> |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 960 | * |
| 961 | * @param action The action. |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 962 | * @throws IllegalStateException If called from an AccessibilityService. |
Alan Viverette | af43110 | 2013-10-04 13:16:51 -0700 | [diff] [blame] | 963 | * @see AccessibilityNodeInfo#performAction(int) |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 964 | */ |
| 965 | public void setAction(int action) { |
| 966 | enforceNotSealed(); |
| 967 | mAction = action; |
| 968 | } |
| 969 | |
| 970 | /** |
| 971 | * Gets the performed action that triggered this event. |
| 972 | * |
| 973 | * @return The action. |
| 974 | */ |
| 975 | public int getAction() { |
| 976 | return mAction; |
| 977 | } |
| 978 | |
| 979 | /** |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 980 | * Returns a cached instance if such is available or a new one is |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 981 | * instantiated with its type property set. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 982 | * |
| 983 | * @param eventType The event type. |
| 984 | * @return An instance. |
| 985 | */ |
| 986 | public static AccessibilityEvent obtain(int eventType) { |
| 987 | AccessibilityEvent event = AccessibilityEvent.obtain(); |
| 988 | event.setEventType(eventType); |
| 989 | return event; |
| 990 | } |
| 991 | |
| 992 | /** |
| 993 | * Returns a cached instance if such is available or a new one is |
Svetoslav Ganov | 35bfede | 2011-07-14 17:57:06 -0700 | [diff] [blame] | 994 | * created. The returned instance is initialized from the given |
| 995 | * <code>event</code>. |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 996 | * |
| 997 | * @param event The other event. |
| 998 | * @return An instance. |
| 999 | */ |
| 1000 | public static AccessibilityEvent obtain(AccessibilityEvent event) { |
| 1001 | AccessibilityEvent eventClone = AccessibilityEvent.obtain(); |
| 1002 | eventClone.init(event); |
| 1003 | |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 1004 | if (event.mRecords != null) { |
| 1005 | final int recordCount = event.mRecords.size(); |
| 1006 | eventClone.mRecords = new ArrayList<AccessibilityRecord>(recordCount); |
| 1007 | for (int i = 0; i < recordCount; i++) { |
| 1008 | final AccessibilityRecord record = event.mRecords.get(i); |
| 1009 | final AccessibilityRecord recordClone = AccessibilityRecord.obtain(record); |
| 1010 | eventClone.mRecords.add(recordClone); |
| 1011 | } |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | return eventClone; |
| 1015 | } |
| 1016 | |
| 1017 | /** |
| 1018 | * Returns a cached instance if such is available or a new one is |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1019 | * instantiated. |
| 1020 | * |
| 1021 | * @return An instance. |
| 1022 | */ |
| 1023 | public static AccessibilityEvent obtain() { |
Svetoslav Ganov | f4782ec | 2012-11-28 09:11:41 -0800 | [diff] [blame] | 1024 | AccessibilityEvent event = sPool.acquire(); |
| 1025 | return (event != null) ? event : new AccessibilityEvent(); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1026 | } |
| 1027 | |
| 1028 | /** |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 1029 | * Recycles an instance back to be reused. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1030 | * <p> |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 1031 | * <b>Note: You must not touch the object after calling this function.</b> |
| 1032 | * </p> |
Svetoslav Ganov | 887e1a1 | 2011-04-29 15:09:28 -0700 | [diff] [blame] | 1033 | * |
| 1034 | * @throws IllegalStateException If the event is already recycled. |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1035 | */ |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1036 | @Override |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1037 | public void recycle() { |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1038 | clear(); |
Svetoslav Ganov | f4782ec | 2012-11-28 09:11:41 -0800 | [diff] [blame] | 1039 | sPool.release(this); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1040 | } |
| 1041 | |
| 1042 | /** |
| 1043 | * Clears the state of this instance. |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 1044 | * |
| 1045 | * @hide |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1046 | */ |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1047 | @Override |
| 1048 | protected void clear() { |
| 1049 | super.clear(); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1050 | mEventType = 0; |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 1051 | mMovementGranularity = 0; |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 1052 | mAction = 0; |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 1053 | mContentChangeTypes = 0; |
Adam Powell | 3fb3d7c | 2011-04-22 17:08:55 -0700 | [diff] [blame] | 1054 | mPackageName = null; |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1055 | mEventTime = 0; |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 1056 | if (mRecords != null) { |
| 1057 | while (!mRecords.isEmpty()) { |
| 1058 | AccessibilityRecord record = mRecords.remove(0); |
| 1059 | record.recycle(); |
| 1060 | } |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1061 | } |
| 1062 | } |
| 1063 | |
| 1064 | /** |
| 1065 | * Creates a new instance from a {@link Parcel}. |
| 1066 | * |
| 1067 | * @param parcel A parcel containing the state of a {@link AccessibilityEvent}. |
| 1068 | */ |
| 1069 | public void initFromParcel(Parcel parcel) { |
Svetoslav Ganov | d116d7c | 2011-11-21 18:41:59 -0800 | [diff] [blame] | 1070 | mSealed = (parcel.readInt() == 1); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1071 | mEventType = parcel.readInt(); |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 1072 | mMovementGranularity = parcel.readInt(); |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 1073 | mAction = parcel.readInt(); |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 1074 | mContentChangeTypes = parcel.readInt(); |
Adam Powell | 3fb3d7c | 2011-04-22 17:08:55 -0700 | [diff] [blame] | 1075 | mPackageName = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1076 | mEventTime = parcel.readLong(); |
Svetoslav Ganov | d116d7c | 2011-11-21 18:41:59 -0800 | [diff] [blame] | 1077 | mConnectionId = parcel.readInt(); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1078 | readAccessibilityRecordFromParcel(this, parcel); |
| 1079 | |
| 1080 | // Read the records. |
| 1081 | final int recordCount = parcel.readInt(); |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 1082 | if (recordCount > 0) { |
| 1083 | mRecords = new ArrayList<AccessibilityRecord>(recordCount); |
| 1084 | for (int i = 0; i < recordCount; i++) { |
| 1085 | AccessibilityRecord record = AccessibilityRecord.obtain(); |
| 1086 | readAccessibilityRecordFromParcel(record, parcel); |
| 1087 | record.mConnectionId = mConnectionId; |
| 1088 | mRecords.add(record); |
| 1089 | } |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1090 | } |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1091 | } |
| 1092 | |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1093 | /** |
| 1094 | * Reads an {@link AccessibilityRecord} from a parcel. |
| 1095 | * |
| 1096 | * @param record The record to initialize. |
| 1097 | * @param parcel The parcel to read from. |
| 1098 | */ |
| 1099 | private void readAccessibilityRecordFromParcel(AccessibilityRecord record, |
| 1100 | Parcel parcel) { |
| 1101 | record.mBooleanProperties = parcel.readInt(); |
| 1102 | record.mCurrentItemIndex = parcel.readInt(); |
| 1103 | record.mItemCount = parcel.readInt(); |
| 1104 | record.mFromIndex = parcel.readInt(); |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 1105 | record.mToIndex = parcel.readInt(); |
| 1106 | record.mScrollX = parcel.readInt(); |
| 1107 | record.mScrollY = parcel.readInt(); |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 1108 | record.mMaxScrollX = parcel.readInt(); |
| 1109 | record.mMaxScrollY = parcel.readInt(); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1110 | record.mAddedCount = parcel.readInt(); |
| 1111 | record.mRemovedCount = parcel.readInt(); |
| 1112 | record.mClassName = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel); |
| 1113 | record.mContentDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel); |
| 1114 | record.mBeforeText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel); |
| 1115 | record.mParcelableData = parcel.readParcelable(null); |
| 1116 | parcel.readList(record.mText, null); |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 1117 | record.mSourceWindowId = parcel.readInt(); |
Svetoslav Ganov | 0210785 | 2011-10-03 17:06:56 -0700 | [diff] [blame] | 1118 | record.mSourceNodeId = parcel.readLong(); |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 1119 | record.mSealed = (parcel.readInt() == 1); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1120 | } |
| 1121 | |
| 1122 | /** |
| 1123 | * {@inheritDoc} |
| 1124 | */ |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1125 | public void writeToParcel(Parcel parcel, int flags) { |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 1126 | parcel.writeInt(isSealed() ? 1 : 0); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1127 | parcel.writeInt(mEventType); |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 1128 | parcel.writeInt(mMovementGranularity); |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 1129 | parcel.writeInt(mAction); |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 1130 | parcel.writeInt(mContentChangeTypes); |
Adam Powell | 3fb3d7c | 2011-04-22 17:08:55 -0700 | [diff] [blame] | 1131 | TextUtils.writeToParcel(mPackageName, parcel, 0); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1132 | parcel.writeLong(mEventTime); |
Svetoslav Ganov | d116d7c | 2011-11-21 18:41:59 -0800 | [diff] [blame] | 1133 | parcel.writeInt(mConnectionId); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1134 | writeAccessibilityRecordToParcel(this, parcel, flags); |
| 1135 | |
| 1136 | // Write the records. |
| 1137 | final int recordCount = getRecordCount(); |
| 1138 | parcel.writeInt(recordCount); |
| 1139 | for (int i = 0; i < recordCount; i++) { |
| 1140 | AccessibilityRecord record = mRecords.get(i); |
| 1141 | writeAccessibilityRecordToParcel(record, parcel, flags); |
| 1142 | } |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1143 | } |
| 1144 | |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1145 | /** |
| 1146 | * Writes an {@link AccessibilityRecord} to a parcel. |
| 1147 | * |
| 1148 | * @param record The record to write. |
| 1149 | * @param parcel The parcel to which to write. |
| 1150 | */ |
| 1151 | private void writeAccessibilityRecordToParcel(AccessibilityRecord record, Parcel parcel, |
| 1152 | int flags) { |
| 1153 | parcel.writeInt(record.mBooleanProperties); |
| 1154 | parcel.writeInt(record.mCurrentItemIndex); |
| 1155 | parcel.writeInt(record.mItemCount); |
| 1156 | parcel.writeInt(record.mFromIndex); |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 1157 | parcel.writeInt(record.mToIndex); |
| 1158 | parcel.writeInt(record.mScrollX); |
| 1159 | parcel.writeInt(record.mScrollY); |
Svetoslav Ganov | d9ee72f | 2011-10-05 22:26:05 -0700 | [diff] [blame] | 1160 | parcel.writeInt(record.mMaxScrollX); |
| 1161 | parcel.writeInt(record.mMaxScrollY); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1162 | parcel.writeInt(record.mAddedCount); |
| 1163 | parcel.writeInt(record.mRemovedCount); |
| 1164 | TextUtils.writeToParcel(record.mClassName, parcel, flags); |
| 1165 | TextUtils.writeToParcel(record.mContentDescription, parcel, flags); |
| 1166 | TextUtils.writeToParcel(record.mBeforeText, parcel, flags); |
| 1167 | parcel.writeParcelable(record.mParcelableData, flags); |
| 1168 | parcel.writeList(record.mText); |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 1169 | parcel.writeInt(record.mSourceWindowId); |
Svetoslav Ganov | 0210785 | 2011-10-03 17:06:56 -0700 | [diff] [blame] | 1170 | parcel.writeLong(record.mSourceNodeId); |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 1171 | parcel.writeInt(record.mSealed ? 1 : 0); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1172 | } |
| 1173 | |
| 1174 | /** |
| 1175 | * {@inheritDoc} |
| 1176 | */ |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1177 | public int describeContents() { |
| 1178 | return 0; |
| 1179 | } |
| 1180 | |
| 1181 | @Override |
| 1182 | public String toString() { |
| 1183 | StringBuilder builder = new StringBuilder(); |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 1184 | builder.append("EventType: ").append(eventTypeToString(mEventType)); |
Svetoslav Ganov | cc4053e | 2011-05-23 13:37:44 -0700 | [diff] [blame] | 1185 | builder.append("; EventTime: ").append(mEventTime); |
| 1186 | builder.append("; PackageName: ").append(mPackageName); |
Svetoslav Ganov | 2b435aa | 2012-05-04 17:16:37 -0700 | [diff] [blame] | 1187 | builder.append("; MovementGranularity: ").append(mMovementGranularity); |
Svetoslav Ganov | 6d17a93 | 2012-04-27 19:30:38 -0700 | [diff] [blame] | 1188 | builder.append("; Action: ").append(mAction); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1189 | builder.append(super.toString()); |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 1190 | if (DEBUG) { |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1191 | builder.append("\n"); |
Alan Viverette | 77e9a28 | 2013-09-12 17:16:09 -0700 | [diff] [blame] | 1192 | builder.append("; ContentChangeTypes: ").append(mContentChangeTypes); |
Svetoslav Ganov | eeee4d2 | 2011-06-10 20:51:30 -0700 | [diff] [blame] | 1193 | builder.append("; sourceWindowId: ").append(mSourceWindowId); |
Svetoslav Ganov | 0210785 | 2011-10-03 17:06:56 -0700 | [diff] [blame] | 1194 | builder.append("; mSourceNodeId: ").append(mSourceNodeId); |
Alan Viverette | 502cb33 | 2013-10-15 18:29:53 -0700 | [diff] [blame] | 1195 | for (int i = 0; i < getRecordCount(); i++) { |
| 1196 | final AccessibilityRecord record = getRecord(i); |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 1197 | builder.append(" Record "); |
| 1198 | builder.append(i); |
| 1199 | builder.append(":"); |
| 1200 | builder.append(" [ ClassName: " + record.mClassName); |
| 1201 | builder.append("; Text: " + record.mText); |
| 1202 | builder.append("; ContentDescription: " + record.mContentDescription); |
| 1203 | builder.append("; ItemCount: " + record.mItemCount); |
| 1204 | builder.append("; CurrentItemIndex: " + record.mCurrentItemIndex); |
| 1205 | builder.append("; IsEnabled: " + record.isEnabled()); |
| 1206 | builder.append("; IsPassword: " + record.isPassword()); |
| 1207 | builder.append("; IsChecked: " + record.isChecked()); |
| 1208 | builder.append("; IsFullScreen: " + record.isFullScreen()); |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 1209 | builder.append("; Scrollable: " + record.isScrollable()); |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 1210 | builder.append("; BeforeText: " + record.mBeforeText); |
| 1211 | builder.append("; FromIndex: " + record.mFromIndex); |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 1212 | builder.append("; ToIndex: " + record.mToIndex); |
| 1213 | builder.append("; ScrollX: " + record.mScrollX); |
| 1214 | builder.append("; ScrollY: " + record.mScrollY); |
Svetoslav Ganov | 8643aa0 | 2011-04-20 12:12:33 -0700 | [diff] [blame] | 1215 | builder.append("; AddedCount: " + record.mAddedCount); |
| 1216 | builder.append("; RemovedCount: " + record.mRemovedCount); |
| 1217 | builder.append("; ParcelableData: " + record.mParcelableData); |
| 1218 | builder.append(" ]"); |
| 1219 | builder.append("\n"); |
| 1220 | } |
| 1221 | } else { |
Svetoslav Ganov | e4aa13b | 2011-07-31 20:43:45 -0700 | [diff] [blame] | 1222 | builder.append("; recordCount: ").append(getRecordCount()); |
Svetoslav Ganov | 736c275 | 2011-04-22 18:30:36 -0700 | [diff] [blame] | 1223 | } |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1224 | return builder.toString(); |
| 1225 | } |
| 1226 | |
| 1227 | /** |
Svetoslav Ganov | cc4053e | 2011-05-23 13:37:44 -0700 | [diff] [blame] | 1228 | * Returns the string representation of an event type. For example, |
| 1229 | * {@link #TYPE_VIEW_CLICKED} is represented by the string TYPE_VIEW_CLICKED. |
| 1230 | * |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 1231 | * @param eventType The event type |
Svetoslav Ganov | cc4053e | 2011-05-23 13:37:44 -0700 | [diff] [blame] | 1232 | * @return The string representation. |
| 1233 | */ |
Svetoslav Ganov | 38e8b4e | 2011-06-29 20:00:53 -0700 | [diff] [blame] | 1234 | public static String eventTypeToString(int eventType) { |
Svetoslav Ganov | 6ce77cd | 2012-11-21 16:35:57 -0800 | [diff] [blame] | 1235 | if (eventType == TYPES_ALL_MASK) { |
| 1236 | return "TYPES_ALL_MASK"; |
Svetoslav Ganov | cc4053e | 2011-05-23 13:37:44 -0700 | [diff] [blame] | 1237 | } |
Svetoslav Ganov | 6ce77cd | 2012-11-21 16:35:57 -0800 | [diff] [blame] | 1238 | StringBuilder builder = new StringBuilder(); |
| 1239 | int eventTypeCount = 0; |
| 1240 | while (eventType != 0) { |
| 1241 | final int eventTypeFlag = 1 << Integer.numberOfTrailingZeros(eventType); |
| 1242 | eventType &= ~eventTypeFlag; |
| 1243 | switch (eventTypeFlag) { |
| 1244 | case TYPE_VIEW_CLICKED: { |
| 1245 | if (eventTypeCount > 0) { |
| 1246 | builder.append(", "); |
| 1247 | } |
| 1248 | builder.append("TYPE_VIEW_CLICKED"); |
| 1249 | eventTypeCount++; |
| 1250 | } break; |
| 1251 | case TYPE_VIEW_LONG_CLICKED: { |
| 1252 | if (eventTypeCount > 0) { |
| 1253 | builder.append(", "); |
| 1254 | } |
| 1255 | builder.append("TYPE_VIEW_LONG_CLICKED"); |
| 1256 | eventTypeCount++; |
| 1257 | } break; |
| 1258 | case TYPE_VIEW_SELECTED: { |
| 1259 | if (eventTypeCount > 0) { |
| 1260 | builder.append(", "); |
| 1261 | } |
| 1262 | builder.append("TYPE_VIEW_SELECTED"); |
| 1263 | eventTypeCount++; |
| 1264 | } break; |
| 1265 | case TYPE_VIEW_FOCUSED: { |
| 1266 | if (eventTypeCount > 0) { |
| 1267 | builder.append(", "); |
| 1268 | } |
| 1269 | builder.append("TYPE_VIEW_FOCUSED"); |
| 1270 | eventTypeCount++; |
| 1271 | } break; |
| 1272 | case TYPE_VIEW_TEXT_CHANGED: { |
| 1273 | if (eventTypeCount > 0) { |
| 1274 | builder.append(", "); |
| 1275 | } |
| 1276 | builder.append("TYPE_VIEW_TEXT_CHANGED"); |
| 1277 | eventTypeCount++; |
| 1278 | } break; |
| 1279 | case TYPE_WINDOW_STATE_CHANGED: { |
| 1280 | if (eventTypeCount > 0) { |
| 1281 | builder.append(", "); |
| 1282 | } |
| 1283 | builder.append("TYPE_WINDOW_STATE_CHANGED"); |
| 1284 | eventTypeCount++; |
| 1285 | } break; |
| 1286 | case TYPE_VIEW_HOVER_ENTER: { |
| 1287 | if (eventTypeCount > 0) { |
| 1288 | builder.append(", "); |
| 1289 | } |
| 1290 | builder.append("TYPE_VIEW_HOVER_ENTER"); |
| 1291 | eventTypeCount++; |
| 1292 | } break; |
| 1293 | case TYPE_VIEW_HOVER_EXIT: { |
| 1294 | if (eventTypeCount > 0) { |
| 1295 | builder.append(", "); |
| 1296 | } |
| 1297 | builder.append("TYPE_VIEW_HOVER_EXIT"); |
| 1298 | eventTypeCount++; |
| 1299 | } break; |
| 1300 | case TYPE_NOTIFICATION_STATE_CHANGED: { |
| 1301 | if (eventTypeCount > 0) { |
| 1302 | builder.append(", "); |
| 1303 | } |
| 1304 | builder.append("TYPE_NOTIFICATION_STATE_CHANGED"); |
| 1305 | eventTypeCount++; |
| 1306 | } break; |
| 1307 | case TYPE_TOUCH_EXPLORATION_GESTURE_START: { |
| 1308 | if (eventTypeCount > 0) { |
| 1309 | builder.append(", "); |
| 1310 | } |
| 1311 | builder.append("TYPE_TOUCH_EXPLORATION_GESTURE_START"); |
| 1312 | eventTypeCount++; |
| 1313 | } break; |
| 1314 | case TYPE_TOUCH_EXPLORATION_GESTURE_END: { |
| 1315 | if (eventTypeCount > 0) { |
| 1316 | builder.append(", "); |
| 1317 | } |
| 1318 | builder.append("TYPE_TOUCH_EXPLORATION_GESTURE_END"); |
| 1319 | eventTypeCount++; |
| 1320 | } break; |
| 1321 | case TYPE_WINDOW_CONTENT_CHANGED: { |
| 1322 | if (eventTypeCount > 0) { |
| 1323 | builder.append(", "); |
| 1324 | } |
| 1325 | builder.append("TYPE_WINDOW_CONTENT_CHANGED"); |
| 1326 | eventTypeCount++; |
| 1327 | } break; |
| 1328 | case TYPE_VIEW_TEXT_SELECTION_CHANGED: { |
| 1329 | if (eventTypeCount > 0) { |
| 1330 | builder.append(", "); |
| 1331 | } |
| 1332 | builder.append("TYPE_VIEW_TEXT_SELECTION_CHANGED"); |
| 1333 | eventTypeCount++; |
| 1334 | } break; |
| 1335 | case TYPE_VIEW_SCROLLED: { |
| 1336 | if (eventTypeCount > 0) { |
| 1337 | builder.append(", "); |
| 1338 | } |
| 1339 | builder.append("TYPE_VIEW_SCROLLED"); |
| 1340 | eventTypeCount++; |
| 1341 | } break; |
| 1342 | case TYPE_ANNOUNCEMENT: { |
| 1343 | if (eventTypeCount > 0) { |
| 1344 | builder.append(", "); |
| 1345 | } |
| 1346 | builder.append("TYPE_ANNOUNCEMENT"); |
| 1347 | eventTypeCount++; |
| 1348 | } break; |
| 1349 | case TYPE_VIEW_ACCESSIBILITY_FOCUSED: { |
| 1350 | if (eventTypeCount > 0) { |
| 1351 | builder.append(", "); |
| 1352 | } |
| 1353 | builder.append("TYPE_VIEW_ACCESSIBILITY_FOCUSED"); |
| 1354 | eventTypeCount++; |
| 1355 | } break; |
| 1356 | case TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED: { |
| 1357 | if (eventTypeCount > 0) { |
| 1358 | builder.append(", "); |
| 1359 | } |
| 1360 | builder.append("TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED"); |
| 1361 | eventTypeCount++; |
| 1362 | } break; |
| 1363 | case TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY: { |
| 1364 | if (eventTypeCount > 0) { |
| 1365 | builder.append(", "); |
| 1366 | } |
Svetoslav | abad55d | 2013-05-07 18:49:51 -0700 | [diff] [blame] | 1367 | builder.append("TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY"); |
Svetoslav Ganov | 6ce77cd | 2012-11-21 16:35:57 -0800 | [diff] [blame] | 1368 | eventTypeCount++; |
| 1369 | } break; |
| 1370 | case TYPE_GESTURE_DETECTION_START: { |
| 1371 | if (eventTypeCount > 0) { |
| 1372 | builder.append(", "); |
| 1373 | } |
| 1374 | builder.append("TYPE_GESTURE_DETECTION_START"); |
| 1375 | eventTypeCount++; |
| 1376 | } break; |
| 1377 | case TYPE_GESTURE_DETECTION_END: { |
| 1378 | if (eventTypeCount > 0) { |
| 1379 | builder.append(", "); |
| 1380 | } |
| 1381 | builder.append("TYPE_GESTURE_DETECTION_END"); |
| 1382 | eventTypeCount++; |
| 1383 | } break; |
| 1384 | case TYPE_TOUCH_INTERACTION_START: { |
| 1385 | if (eventTypeCount > 0) { |
| 1386 | builder.append(", "); |
| 1387 | } |
| 1388 | builder.append("TYPE_TOUCH_INTERACTION_START"); |
| 1389 | eventTypeCount++; |
| 1390 | } break; |
| 1391 | case TYPE_TOUCH_INTERACTION_END: { |
| 1392 | if (eventTypeCount > 0) { |
| 1393 | builder.append(", "); |
| 1394 | } |
| 1395 | builder.append("TYPE_TOUCH_INTERACTION_END"); |
| 1396 | eventTypeCount++; |
| 1397 | } break; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 1398 | case TYPE_WINDOWS_CHANGED: { |
| 1399 | if (eventTypeCount > 0) { |
| 1400 | builder.append(", "); |
| 1401 | } |
| 1402 | builder.append("TYPE_WINDOWS_CHANGED"); |
| 1403 | eventTypeCount++; |
| 1404 | } break; |
Mady Mellor | e82067b | 2015-04-30 09:58:35 -0700 | [diff] [blame] | 1405 | case TYPE_VIEW_STYLUS_BUTTON_PRESSED: { |
| 1406 | if (eventTypeCount > 0) { |
| 1407 | builder.append(", "); |
| 1408 | } |
| 1409 | builder.append("TYPE_VIEW_STYLUS_BUTTON_PRESSED"); |
| 1410 | eventTypeCount++; |
| 1411 | } |
| 1412 | break; |
Svetoslav Ganov | 6ce77cd | 2012-11-21 16:35:57 -0800 | [diff] [blame] | 1413 | } |
| 1414 | } |
| 1415 | if (eventTypeCount > 1) { |
| 1416 | builder.insert(0, '['); |
| 1417 | builder.append(']'); |
| 1418 | } |
| 1419 | return builder.toString(); |
Svetoslav Ganov | cc4053e | 2011-05-23 13:37:44 -0700 | [diff] [blame] | 1420 | } |
| 1421 | |
| 1422 | /** |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1423 | * @see Parcelable.Creator |
| 1424 | */ |
| 1425 | public static final Parcelable.Creator<AccessibilityEvent> CREATOR = |
| 1426 | new Parcelable.Creator<AccessibilityEvent>() { |
| 1427 | public AccessibilityEvent createFromParcel(Parcel parcel) { |
| 1428 | AccessibilityEvent event = AccessibilityEvent.obtain(); |
| 1429 | event.initFromParcel(parcel); |
| 1430 | return event; |
| 1431 | } |
| 1432 | |
| 1433 | public AccessibilityEvent[] newArray(int size) { |
| 1434 | return new AccessibilityEvent[size]; |
| 1435 | } |
| 1436 | }; |
| 1437 | } |