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