1/* 2 * Copyright (c) 2022 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 AccessibilityExtensionContext from './application/AccessibilityExtensionContext'; 18import type { AccessibilityElement } from './application/AccessibilityExtensionContext'; 19import type { KeyEvent } from './@ohos.multimodalInput.keyEvent'; 20 21/** 22 * class of accessibility extension ability. 23 * 24 * @syscap SystemCapability.BarrierFree.Accessibility.Core 25 * @since 9 26 */ 27export default class AccessibilityExtensionAbility { 28 /** 29 * Indicates accessibility extension ability context. 30 * 31 * @syscap SystemCapability.BarrierFree.Accessibility.Core 32 * @since 9 33 */ 34 context: AccessibilityExtensionContext; 35 36 /** 37 * Called when extension ability is connected. 38 * 39 * @syscap SystemCapability.BarrierFree.Accessibility.Core 40 * @since 9 41 */ 42 onConnect(): void; 43 44 /** 45 * Called when extension ability is disconnected. 46 * 47 * @syscap SystemCapability.BarrierFree.Accessibility.Core 48 * @since 9 49 */ 50 onDisconnect(): void; 51 52 /** 53 * Called when an accessibility event occurs, such as when the user touches the application interface. 54 * 55 * @param { AccessibilityEvent } event Indicates an accessibility event. 56 * @syscap SystemCapability.BarrierFree.Accessibility.Core 57 * @since 9 58 */ 59 onAccessibilityEvent(event: AccessibilityEvent): void; 60 61 /** 62 * Called when a physical key is pressed, such as when the user presses the volume button . 63 * 64 * @param { KeyEvent } keyEvent Indicates the physical key event. 65 * @returns { boolean } 66 * @syscap SystemCapability.BarrierFree.Accessibility.Core 67 * @since 9 68 */ 69 onKeyEvent(keyEvent: KeyEvent): boolean; 70} 71 72/** 73 * Indicates the accessibility event. 74 * It provides the event type and the target element of the event if any. 75 * 76 * @typedef AccessibilityEvent 77 * @syscap SystemCapability.BarrierFree.Accessibility.Core 78 * @since 9 79 */ 80declare interface AccessibilityEvent { 81 eventType: accessibility.EventType | accessibility.WindowUpdateType | TouchGuideType | GestureType | PageUpdateType; 82 target?: AccessibilityElement; 83 timeStamp?: number; 84} 85 86/** 87 * Indicates the gusture type. 88 * 89 * @syscap SystemCapability.BarrierFree.Accessibility.Core 90 * @since 9 91 */ 92type GestureType = 'left' | 'leftThenRight' | 'leftThenUp' | 'leftThenDown' | 93 'right' | 'rightThenLeft' | 'rightThenUp' | 'rightThenDown' | 94 'up' | 'upThenLeft' | 'upThenRight' | 'upThenDown' | 95 'down' | 'downThenLeft' | 'downThenRight' | 'downThenUp'; 96 97/** 98 * Indicates the page update type. 99 * 100 * @syscap SystemCapability.BarrierFree.Accessibility.Core 101 * @since 9 102 */ 103type PageUpdateType = 'pageContentUpdate' | 'pageStateUpdate'; 104 105/** 106 * Indicates the type of touch event during touch browsing. 107 * 108 * @syscap SystemCapability.BarrierFree.Accessibility.Core 109 * @since 9 110 */ 111type TouchGuideType = 'touchBegin' | 'touchEnd'; 112