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