• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License"),
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit AccessibilityKit
19 */
20
21import type accessibility from './@ohos.accessibility';
22import type { KeyEvent } from './@ohos.multimodalInput.keyEvent';
23import type {
24  AccessibilityElement as _AccessibilityElement,
25  ElementAttributeValues as _ElementAttributeValues,
26  FocusDirection as _FocusDirection,
27  FocusType as _FocusType,
28  WindowType as _WindowType,
29  Rect as _Rect,
30} from './application/AccessibilityExtensionContext';
31import type * as _AccessibilityExtensionContext from './application/AccessibilityExtensionContext';
32
33
34/**
35 * Indicates an accessibility element.
36 * Supports querying element attributes, requesting execution actions, and finding child elements by condition.
37 *
38 * @typedef {_AccessibilityElement}
39 * @syscap SystemCapability.BarrierFree.Accessibility.Core
40 * @since 10
41 */
42export type AccessibilityElement = _AccessibilityElement;
43
44/**
45 * Indicates the possible attributes of the element and the type of the attribute value.
46 *
47 * @typedef {_ElementAttributeValues}
48 * @syscap SystemCapability.BarrierFree.Accessibility.Core
49 * @since 10
50 */
51export type ElementAttributeValues = _ElementAttributeValues;
52
53/**
54 * Indicates the direction of the search focus.
55 *
56 * @typedef {_FocusDirection}
57 * @syscap SystemCapability.BarrierFree.Accessibility.Core
58 * @since 10
59 */
60export type FocusDirection = _FocusDirection;
61
62/**
63 * Indicates the key of the attribute value.
64 *
65 * @typedef {keyof ElementAttributeValues}
66 * @syscap SystemCapability.BarrierFree.Accessibility.Core
67 * @since 10
68 */
69export type ElementAttributeKeys = keyof ElementAttributeValues;
70
71/**
72 * Indicates the type of the focus.
73 *
74 * @typedef {_FocusType}
75 * @syscap SystemCapability.BarrierFree.Accessibility.Core
76 * @since 10
77 */
78export type FocusType = _FocusType;
79
80/**
81 * Indicates the type of the window.
82 *
83 * @typedef {_WindowType}
84 * @syscap SystemCapability.BarrierFree.Accessibility.Core
85 * @since 10
86 */
87export type WindowType = _WindowType;
88
89/**
90 * Indicates rectangle.
91 *
92 * @typedef {_Rect}
93 * @syscap SystemCapability.BarrierFree.Accessibility.Core
94 * @since 10
95 */
96export type Rect = _Rect;
97
98/**
99 * The accessibility extension context. Used to configure, query information, and inject gestures.
100 *
101 * @typedef {_AccessibilityExtensionContext.default}
102 * @syscap SystemCapability.BarrierFree.Accessibility.Core
103 * @since 10
104 */
105
106export type AccessibilityExtensionContext = _AccessibilityExtensionContext.default;
107
108/**
109 * class of accessibility extension ability.
110 *
111 * @syscap SystemCapability.BarrierFree.Accessibility.Core
112 * @since 9
113 */
114export default class AccessibilityExtensionAbility {
115  /**
116   * Indicates accessibility extension ability context.
117   *
118   * @type {AccessibilityExtensionContext}
119   * @syscap SystemCapability.BarrierFree.Accessibility.Core
120   * @since 9
121   */
122  context: AccessibilityExtensionContext;
123
124  /**
125   * Called when extension ability is connected.
126   *
127   * @syscap SystemCapability.BarrierFree.Accessibility.Core
128   * @since 9
129   * @deprecated since 12
130   */
131  onConnect(): void;
132
133  /**
134   * Called when extension ability is disconnected.
135   *
136   * @syscap SystemCapability.BarrierFree.Accessibility.Core
137   * @since 9
138   * @deprecated since 12
139   */
140  onDisconnect(): void;
141
142  /**
143   * Called when an accessibility event occurs, such as when the user touches the application interface.
144   *
145   * @param { AccessibilityEvent } event Indicates an accessibility event.
146   * @syscap SystemCapability.BarrierFree.Accessibility.Core
147   * @since 9
148   * @deprecated since 12
149   */
150  onAccessibilityEvent(event: AccessibilityEvent): void;
151
152  /**
153   * Called when a physical key is pressed, such as when the user presses the volume button .
154   *
155   * @param { KeyEvent } keyEvent Indicates the physical key event.
156   * @returns { boolean }
157   * @syscap SystemCapability.BarrierFree.Accessibility.Core
158   * @since 9
159   * @deprecated since 12
160   */
161  onKeyEvent(keyEvent: KeyEvent): boolean;
162}
163
164/**
165 * Indicates the accessibility event.
166 * It provides the event type and the target element of the event if any.
167 *
168 * @typedef AccessibilityEvent
169 * @syscap SystemCapability.BarrierFree.Accessibility.Core
170 * @since 9
171 */
172declare interface AccessibilityEvent {
173  /**
174   * EventType
175   *
176   * @type { accessibility.EventType | accessibility.WindowUpdateType | TouchGuideType | GestureType | PageUpdateType }
177   * @syscap SystemCapability.BarrierFree.Accessibility.Core
178   * @since 9
179   */
180  eventType: accessibility.EventType | accessibility.WindowUpdateType | TouchGuideType | GestureType | PageUpdateType;
181
182  /**
183   * Target
184   *
185   * @type { ?AccessibilityElement }
186   * @syscap SystemCapability.BarrierFree.Accessibility.Core
187   * @since 9
188   */
189  target?: AccessibilityElement;
190
191  /**
192   * TimeStamp
193   *
194   * @type { ?number }
195   * @syscap SystemCapability.BarrierFree.Accessibility.Core
196   * @since 9
197   */
198  timeStamp?: number;
199
200  /**
201   * ElementId
202   *
203   * @type { ?number }
204   * @syscap SystemCapability.BarrierFree.Accessibility.Core
205   * @since 12
206   */
207  elementId?: number;
208
209  /**
210   * The content of announce accessibility text.
211   *
212   * @type { ?string }
213   * @syscap SystemCapability.BarrierFree.Accessibility.Core
214   * @since 12
215   */
216  textAnnouncedForAccessibility?: string;
217}
218
219/**
220 * Indicates the gesture type.
221 * value range: { 'left' | 'leftThenRight' | 'leftThenUp' | 'leftThenDown' |
222 * 'right' | 'rightThenLeft' | 'rightThenUp' | 'rightThenDown' |
223 * 'up' | 'upThenLeft' | 'upThenRight' | 'upThenDown' |
224 * 'down' | 'downThenLeft' | 'downThenRight' | 'downThenUp' }
225 * @syscap SystemCapability.BarrierFree.Accessibility.Core
226 * @since 9
227 */
228/**
229 * Indicates the gesture type.
230 * value range: { 'left' | 'leftThenRight' | 'leftThenUp' | 'leftThenDown' |
231 * 'right' | 'rightThenLeft' | 'rightThenUp' | 'rightThenDown' |
232 * 'up' | 'upThenLeft' | 'upThenRight' | 'upThenDown' |
233 * 'down' | 'downThenLeft' | 'downThenRight' | 'downThenUp' |
234 * 'twoFingerSingleTap' | 'twoFingerDoubleTap' | 'twoFingerDoubleTapAndHold' | 'twoFingerTripleTap' |
235 * 'twoFingerTripleTapAndHold' | 'threeFingerSingleTap' | 'threeFingerDoubleTap' | 'threeFingerDoubleTapAndHold' |
236 * 'threeFingerTripleTap' | 'threeFingerTripleTapAndHold' | 'fourFingerSingleTap' | 'fourFingerDoubleTap' |
237 * 'fourFingerDoubleTapAndHold' | 'fourFingerTripleTap' | 'fourFingerTripleTapAndHold' |
238 * 'threeFingerSwipeUp' | 'threeFingerSwipeDown' | 'threeFingerSwipeLeft' | 'threeFingerSwipeRight' |
239 * 'fourFingerSwipeUp' | 'fourFingerSwipeDown' | 'fourFingerSwipeLeft' | 'fourFingerSwipeRight' }
240* @typedef {'left' | 'leftThenRight' | 'leftThenUp' | 'leftThenDown' | 'right' | 'rightThenLeft' | 'rightThenUp' | 'rightThenDown' | 'up' | 'upThenLeft' | 'upThenRight' | 'upThenDown' | 'down' | 'downThenLeft' | 'downThenRight' | 'downThenUp' | 'twoFingerSingleTap' | 'twoFingerDoubleTap' | 'twoFingerDoubleTapAndHold' | 'twoFingerTripleTap' | 'twoFingerTripleTapAndHold' | 'threeFingerSingleTap' | 'threeFingerDoubleTap' | 'threeFingerDoubleTapAndHold' | 'threeFingerTripleTap' | 'threeFingerTripleTapAndHold' | 'fourFingerSingleTap' | 'fourFingerDoubleTap' | 'fourFingerDoubleTapAndHold' | 'fourFingerTripleTap' | 'fourFingerTripleTapAndHold' | 'threeFingerSwipeUp' | 'threeFingerSwipeDown' | 'threeFingerSwipeLeft' | 'threeFingerSwipeRight' | 'fourFingerSwipeUp' | 'fourFingerSwipeDown' | 'fourFingerSwipeLeft' | 'fourFingerSwipeRight'}
241* @syscap SystemCapability.BarrierFree.Accessibility.Core
242* @since 11
243*/
244type GestureType = 'left' | 'leftThenRight' | 'leftThenUp' | 'leftThenDown' |
245  'right' | 'rightThenLeft' | 'rightThenUp' | 'rightThenDown' |
246  'up' | 'upThenLeft' | 'upThenRight' | 'upThenDown' |
247  'down' | 'downThenLeft' | 'downThenRight' | 'downThenUp' |
248  'twoFingerSingleTap' | 'twoFingerDoubleTap' | 'twoFingerDoubleTapAndHold' | 'twoFingerTripleTap' |
249  'twoFingerTripleTapAndHold' | 'threeFingerSingleTap' | 'threeFingerDoubleTap' | 'threeFingerDoubleTapAndHold' |
250  'threeFingerTripleTap' | 'threeFingerTripleTapAndHold' | 'fourFingerSingleTap' | 'fourFingerDoubleTap' |
251  'fourFingerDoubleTapAndHold' | 'fourFingerTripleTap' | 'fourFingerTripleTapAndHold' |
252  'threeFingerSwipeUp' | 'threeFingerSwipeDown' | 'threeFingerSwipeLeft' | 'threeFingerSwipeRight' |
253  'fourFingerSwipeUp' | 'fourFingerSwipeDown' | 'fourFingerSwipeLeft' | 'fourFingerSwipeRight';
254
255/**
256 * Indicates the page update type.
257 *
258 * @typedef {'pageContentUpdate' | 'pageStateUpdate'}
259 * @syscap SystemCapability.BarrierFree.Accessibility.Core
260 * @since 9
261 */
262type PageUpdateType = 'pageContentUpdate' | 'pageStateUpdate';
263
264/**
265 * Indicates the type of touch event during touch browsing.
266 *
267 * @typedef {'touchBegin' | 'touchEnd'}
268 * @syscap SystemCapability.BarrierFree.Accessibility.Core
269 * @since 9
270 */
271type TouchGuideType = 'touchBegin' | 'touchEnd';
272