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 16import type accessibility from './@ohos.accessibility'; 17import type { KeyEvent } from './@ohos.multimodalInput.keyEvent'; 18import type { 19 AccessibilityElement as _AccessibilityElement, 20 ElementAttributeValues as _ElementAttributeValues, 21 FocusDirection as _FocusDirection, 22 FocusType as _FocusType, 23 WindowType as _WindowType, 24 Rect as _Rect, 25 Span as _Span, 26} from './application/AccessibilityExtensionContext'; 27import type * as _AccessibilityExtensionContext from './application/AccessibilityExtensionContext'; 28 29 30/** 31 * Indicates an accessibility element. 32 * Supports querying element attributes, requesting execution actions, and finding child elements by condition. 33 * 34 * @syscap SystemCapability.BarrierFree.Accessibility.Core 35 * @since 10 36 */ 37export type AccessibilityElement = _AccessibilityElement; 38 39/** 40 * Indicates the possible attributes of the element and the type of the attribute value. 41 * 42 * @syscap SystemCapability.BarrierFree.Accessibility.Core 43 * @since 10 44 */ 45export type ElementAttributeValues = _ElementAttributeValues; 46 47/** 48 * Indicates the direction of the search focus. 49 * 50 * @syscap SystemCapability.BarrierFree.Accessibility.Core 51 * @since 10 52 */ 53export type FocusDirection = _FocusDirection; 54 55/** 56 * Indicates the key of the attribute value. 57 * 58 * @syscap SystemCapability.BarrierFree.Accessibility.Core 59 * @since 10 60 */ 61export type ElementAttributeKeys = keyof ElementAttributeValues; 62 63/** 64 * Indicates the type of the focus. 65 * 66 * @syscap SystemCapability.BarrierFree.Accessibility.Core 67 * @since 10 68 */ 69export type FocusType = _FocusType; 70 71/** 72 * Indicates the type of the window. 73 * 74 * @syscap SystemCapability.BarrierFree.Accessibility.Core 75 * @since 10 76 */ 77export type WindowType = _WindowType; 78 79/** 80 * Indicates rectangle. 81 * 82 * @syscap SystemCapability.BarrierFree.Accessibility.Core 83 * @since 10 84 */ 85export type Rect = _Rect; 86 87/** 88 * Indicates rectangle. 89 * 90 * @syscap SystemCapability.BarrierFree.Accessibility.Core 91 * @since 12 92 */ 93export type Span = _Span; 94 95/** 96 * The accessibility extension context. Used to configure, query information, and inject gestures. 97 * 98 * @syscap SystemCapability.BarrierFree.Accessibility.Core 99 * @since 10 100 */ 101 102export type AccessibilityExtensionContext = _AccessibilityExtensionContext.default; 103 104/** 105 * class of accessibility extension ability. 106 * 107 * @syscap SystemCapability.BarrierFree.Accessibility.Core 108 * @since 9 109 */ 110export default class AccessibilityExtensionAbility { 111 /** 112 * Indicates accessibility extension ability context. 113 * 114 * @syscap SystemCapability.BarrierFree.Accessibility.Core 115 * @since 9 116 */ 117 context: AccessibilityExtensionContext; 118 119 /** 120 * Called when extension ability is connected. 121 * 122 * @syscap SystemCapability.BarrierFree.Accessibility.Core 123 * @since 9 124 */ 125 onConnect(): void; 126 127 /** 128 * Called when extension ability is disconnected. 129 * 130 * @syscap SystemCapability.BarrierFree.Accessibility.Core 131 * @since 9 132 */ 133 onDisconnect(): void; 134 135 /** 136 * Called when an accessibility event occurs, such as when the user touches the application interface. 137 * 138 * @param { AccessibilityEvent } event Indicates an accessibility event. 139 * @syscap SystemCapability.BarrierFree.Accessibility.Core 140 * @since 9 141 */ 142 onAccessibilityEvent(event: AccessibilityEvent): void; 143 144 /** 145 * Called when a physical key is pressed, such as when the user presses the volume button . 146 * 147 * @param { KeyEvent } keyEvent Indicates the physical key event. 148 * @returns { boolean } 149 * @syscap SystemCapability.BarrierFree.Accessibility.Core 150 * @since 9 151 */ 152 onKeyEvent(keyEvent: KeyEvent): boolean; 153} 154 155/** 156 * Indicates the accessibility event. 157 * It provides the event type and the target element of the event if any. 158 * 159 * @typedef AccessibilityEvent 160 * @syscap SystemCapability.BarrierFree.Accessibility.Core 161 * @since 9 162 */ 163declare interface AccessibilityEvent { 164 eventType: accessibility.EventType | accessibility.WindowUpdateType | TouchGuideType | GestureType | PageUpdateType; 165 target?: AccessibilityElement; 166 timeStamp?: number; 167 elementId?: number; 168 textAnnouncedForAccessibility?: string; 169} 170 171/** 172 * Indicates the gesture type. 173 * 174 * @syscap SystemCapability.BarrierFree.Accessibility.Core 175 * @since 9 176 */ 177type GestureType = 'left' | 'leftThenRight' | 'leftThenUp' | 'leftThenDown' | 178 'right' | 'rightThenLeft' | 'rightThenUp' | 'rightThenDown' | 179 'up' | 'upThenLeft' | 'upThenRight' | 'upThenDown' | 180 'down' | 'downThenLeft' | 'downThenRight' | 'downThenUp' | 181 'twoFingerSingleTap' | 'twoFingerDoubleTap' | 'twoFingerDoubleTapAndHold' | 'twoFingerTripleTap' | 182 'twoFingerTripleTapAndHold' | 'threeFingerSingleTap' | 'threeFingerDoubleTap' | 'threeFingerDoubleTapAndHold' | 183 'threeFingerTripleTap' | 'threeFingerTripleTapAndHold' | 'fourFingerSingleTap' | 'fourFingerDoubleTap' | 184 'fourFingerDoubleTapAndHold' | 'fourFingerTripleTap' | 'fourFingerTripleTapAndHold' | 185 'threeFingerSwipeUp' | 'threeFingerSwipeDown' | 'threeFingerSwipeLeft' | 'threeFingerSwipeRight' | 186 'fourFingerSwipeUp' | 'fourFingerSwipeDown' | 'fourFingerSwipeLeft' | 'fourFingerSwipeRight'; 187 188/** 189 * Indicates the page update type. 190 * 191 * @syscap SystemCapability.BarrierFree.Accessibility.Core 192 * @since 9 193 */ 194type PageUpdateType = 'pageContentUpdate' | 'pageStateUpdate'; 195 196/** 197 * Indicates the type of touch event during touch browsing. 198 * 199 * @syscap SystemCapability.BarrierFree.Accessibility.Core 200 * @since 9 201 */ 202type TouchGuideType = 'touchBegin' | 'touchEnd';