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