From 977d9b14c415cfabb31796bf78fd15d268c2b351 Mon Sep 17 00:00:00 2001 From: yichengzhao Date: Mon, 14 Feb 2022 09:50:36 +0800 Subject: [PATCH] add accessibility.d.ts Signed-off-by: yichengzhao Change-Id: Ie39548a1409851fdd07087912db805350c6be0ee --- api/@ohos.accessibility.d.ts | 406 +++++++++++++++++++++++++++++++++++ 1 file changed, 406 insertions(+) create mode 100644 api/@ohos.accessibility.d.ts diff --git a/api/@ohos.accessibility.d.ts b/api/@ohos.accessibility.d.ts new file mode 100644 index 0000000000..c5419d5294 --- /dev/null +++ b/api/@ohos.accessibility.d.ts @@ -0,0 +1,406 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AsyncCallback } from './basic'; +import { Callback } from './basic'; +import { AbilityInfo } from './bundle/abilityInfo'; + +/** + * Accessibility + * @name Accessibility + * @since 7 + * @syscap SystemCapability.Barrierfree.Accessibility.Core + * @import basic,abilityInfo + */ +declare namespace accessibility { + + /** + * The type of the Ability app. + * @syscap SystemCapability.Barrierfree.Accessibility.Core + * @since 7 + */ + type AbilityType = 'audible' | 'generic' | 'haptic' | 'spoken' | 'visual'; + + /** + * The action that the ability can execute. + * @syscap SystemCapability.Barrierfree.Accessibility.Core + * @since 7 + */ + type Action = 'accessibilityFocus' | 'clearAccessibilityFocus' | 'focus' | 'clearFocus' | 'clearSelection' | + 'click' | 'longClick' | 'cut' | 'copy' | 'paste' | 'select' | 'setText' | 'delete' | + 'scrollForward' | 'scrollBackward' | 'setSelection'; + + /** + * The type of the accessibility event. + * @note windowsChange + * @note windowContentChange + * @note windowStateChange + * @note announcement + * @note notificationChange + * @note textTraversedAtMove + * @syscap SystemCapability.Barrierfree.Accessibility.Core + * @since 7 + */ + type EventType = 'accessibilityFocus' | 'accessibilityFocusClear' | + 'click' | 'longClick' | 'focus' | 'select' | 'hoverEnter' | 'hoverExit' | + 'textUpdate' | 'textSelectionUpdate' | 'scroll'; + + /** + * The change type of the windowsChange event. + * @note It's used when received the {@code windowsChange} event. + * @syscap SystemCapability.Barrierfree.Accessibility.Core + * @since 7 + */ + type WindowUpdateType = 'add' | 'remove' | 'bounds' | 'active' | 'focus'; + + /** + * The type of the ability state. + * @syscap SystemCapability.Barrierfree.Accessibility.Core + * @since 7 + */ + type AbilityState = 'enable' | 'disable' | 'install'; + + /** + * The ability that accessibility subsystem support. + * @note touchExplorer: Describes the capability to talkback. + * magnification: Describes the capability to request to control the display magnification. + * gesturesSimulation: Describes the capability to request to simulate the gesture. + * windowContent: Describes the capability to search for the content of the active window. + * filterKeyEvents: Describes the capability to request to filter key events. + * fingerprintGesture: Describes the capability to request to fingerprint gesture. + * @syscap SystemCapability.Barrierfree.Accessibility.Core + * @since 7 + */ + type Capability = 'retrieve' | 'touchGuide' | 'keyEventObserver' | 'zoom' | 'gesture'; + + /** + * The granularity of text move. + * @note The granularity of text move. + * @syscap SystemCapability.Barrierfree.Accessibility.Core + * @since 7 + */ + type TextMoveUnit = 'char' | 'word' | 'line' | 'page' | 'paragraph'; + + /** + * Checks whether accessibility ability is enabled. + * @since 7 + * @param callback Asynchronous callback interface. + * @syscap SystemCapability.Barrierfree.Accessibility.Core + * @return Returns {@code true} if the accessibility is enabled; returns {@code false} otherwise. + */ + function isOpenAccessibility(callback: AsyncCallback): void; + function isOpenAccessibility(): Promise; + + /** + * Checks touch browser ability (which is used by talkback) is enabled. + * @since 7 + * @param callback Asynchronous callback interface. + * @syscap SystemCapability.Barrierfree.Accessibility.Vision + * @return Returns {@code true} if the touch browser is enabled; returns {@code false} otherwise. + */ + function isOpenTouchGuide(callback: AsyncCallback): void; + function isOpenTouchGuide(): Promise; + + /** + * Queries the list of accessibility abilities. + * @since 7 + * @param abilityType The type of the accessibility ability. {@code AbilityType} eg.spoken + * @param stateType The state of the accessibility ability. {@code AbilityState} eg.installed + * @syscap SystemCapability.Barrierfree.Accessibility.Core + * @return Returns the list of abilityInfos. + */ + function getAbilityLists(abilityType: AbilityType, stateType: AbilityState, + callback: AsyncCallback>): void; + function getAbilityLists(abilityType: AbilityType, + stateType: AbilityState): Promise>; + + /** + * Send accessibility Event. + * @since 7 + * @param event The object of the accessibility {@code EventInfo} . + * @param callback Asynchronous callback interface. + * @syscap SystemCapability.Barrierfree.Accessibility.Core + * @return Returns {@code true} if success ; returns {@code false} otherwise. + */ + function sendEvent(event: EventInfo, callback: AsyncCallback): void; + function sendEvent(event: EventInfo): Promise; + + /** + * Register the observe of the accessibility state changed. + * @since 7 + * @param type state event type. + * @param callback Asynchronous callback interface. + * @syscap SystemCapability.Barrierfree.Accessibility.Core + * @return Returns {@code true} if the register is success ; returns {@code false} otherwise. + */ + function on(type: 'accessibilityStateChange', callback: Callback): void; + + /** + * Register the observe of the touchGuide state changed. + * @since 7 + * @param type state event type. + * @param callback Asynchronous callback interface. + * @syscap SystemCapability.Barrierfree.Accessibility.Vision + * @return Returns {@code true} if the register is success ; returns {@code false} otherwise. + */ + function on(type: 'touchGuideStateChange', callback: Callback): void; + + /** + * Deregister the observe of the accessibility state changed. + * @since 7 + * @param type state event type + * @param callback Asynchronous callback interface. + * @syscap SystemCapability.Barrierfree.Accessibility.Core + * @return Returns {@code true} if the deregister is success ; returns {@code false} otherwise. + */ + function off(type: 'accessibilityStateChange', callback?: Callback): void; + + /** + * Deregister the observe of the touchGuide state changed. + * @since 7 + * @param type state event type + * @param callback Asynchronous callback interface. + * @return Returns {@code true} if the deregister is success ; returns {@code false} otherwise. + */ + function off(type: 'touchGuideStateChange', callback?: Callback): void; + + /** + * Get the captions manager. + * @syscap SystemCapability.Barrierfree.Accessibility.Hearing + * @since 8 + * @return Returns the captions manager. + */ + function getCaptionsManager(): CaptionsManager; + + /** + * Indicates the captions manager. + * @syscap SystemCapability.Barrierfree.Accessibility.Hearing + * @since 8 + */ + interface CaptionsManager { + /** + * Indicates whether captions are enabled. + */ + enabled: boolean; + /** + * Indicates the style of captions. + */ + style: CaptionsStyle; + + /** + * Register the observe of the enable state. + */ + on(type: 'enableChange', callback: Callback): void; + /** + * Register the observer of the style. + */ + on(type: 'styleChange', callback: Callback): void; + /** + * Deregister the observe of the enable state. + */ + off(type: 'enableChange', callback?: Callback): void; + /** + * Deregister the observer of the style. + */ + off(type: 'styleChange', callback?: Callback): void; + } + + /** + * Indicates the edge type of the captions font. + * @syscap SystemCapability.Barrierfree.Accessibility.Hearing + * @since 8 + */ + type CaptionsFontEdgeType = 'none' | 'raised' | 'depressed' | 'uniform' | 'dropShadow'; + /** + * Indicates the font family of captions. + * @syscap SystemCapability.Barrierfree.Accessibility.Hearing + * @since 8 + */ + type CaptionsFontFamily = 'default' | 'monospacedSerif' | 'serif' | + 'monospacedSansSerif' | 'sansSerif' | 'casual' | 'cursive' | 'smallCapitals'; + /** + * Indicates the style of captions. + * @syscap SystemCapability.Barrierfree.Accessibility.Hearing + * @since 8 + */ + interface CaptionsStyle { + /** + * Indicates the font family of captions. + */ + fontFamily: CaptionsFontFamily; + /** + * Indicates the font scaling of captions. + */ + fontScale: number; + /** + * Indicates the font color of captions. + */ + fontColor: number | string; + /** + * Indicates the edge type of the captions font. + */ + fontEdgeType: CaptionsFontEdgeType; + /** + * Indicates the background color of captions. + */ + backgroundColor: number | string; + /** + * Indicates the window color of captions. + */ + windowColor: number | string; + } + + /** + * Indicates the info of accessibility. + * @syscap SystemCapability.Barrierfree.Accessibility.Core + * @since 8 + */ + interface AccessibilityAbilityInfo { + /** + * The ability id. + * @since 7 + */ + readonly id: string; + + /* The ability name. + * @since 7 + */ + readonly name: string; + + /* The bundle name of the ability. + * @since 7 + */ + readonly bundleName: string; + + /** + * The type of the ability. + * @since 7 + */ + readonly abilityTypes: Array; + + /** + * The capabilities of the ability. + * @since 7 + */ + readonly capabilities: Array; + + /** + * The description of the ability. + * @since 7 + */ + readonly description: string; + + /** + * The events which the accessibility ability wants to observe. + * @since 7 + */ + readonly eventTypes: Array; + + } + + /** + * Indicates the info of events. + * @syscap SystemCapability.Barrierfree.Accessibility.Core + * @since 8 + */ + class EventInfo { + constructor(jsonObject); + /** + * The type of an accessibility event. + * @since 7 + */ + type: EventType; + + /** + * The type of the window change event. + * @since 7 + */ + windowUpdateType?: WindowUpdateType; + + /** + * The bundle name of the target application. + * @since 7 + */ + bundleName: string; + + /** + * The type of the event source component,such as button, chart. + * @since 7 + */ + componentType?: string; + + /** The page id of the event source. + * @since 7 + */ + pageId ?: number; + + /** + * The accessibility event description. + * @since 7 + */ + description?: string; + + /** + * The action that triggers the accessibility event, for example, clicking or focusing a view. + * @since 7 + */ + triggerAction: Action; + + /** + * The movement step used for reading texts. + * @since 7 + */ + textMoveUnit?: TextMoveUnit; + + /** + * The content list. + * @note + * @since 7 + */ + contents?: Array; + + /** + * The content changed before. + * @since 7 + */ + lastContent?: string; + + /** + * The start index of listed items on the screen. + * @since 7 + */ + beginIndex?: number; + + /** + * The index of the current item on the screen. + * @since 7 + */ + currentIndex?: number; + + /** + * The end index of listed items on the screen. + * @since 7 + */ + endIndex?: number; + + /** + * The total of the items. + * @note talkback used it when scroll. + * @since 7 + */ + itemCount?: number; + } +} +export default accessibility; \ No newline at end of file -- Gitee