2018-03-17 05:04:01 +08:00
|
|
|
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
|
2017-05-10 06:24:59 +08:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Mobile Accessibility
|
|
|
|
* @description
|
|
|
|
* This plugin exposes information on the status of various accessibility features of mobile operating systems, including, for example, whether a screen reader is running, invert colors is enabled, and the preferred scaling for text.
|
|
|
|
* It also allows an application to send a string to be spoken by the screen reader, or a command to stop the screen reader from speaking.
|
|
|
|
*
|
|
|
|
* @usage
|
|
|
|
* ```typescript
|
|
|
|
* import { MobileAccessibility } from 'ionic-native';
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* constructor(private mobileAccessibility: MobileAccessibility) { }
|
|
|
|
*
|
|
|
|
* ...
|
|
|
|
*
|
|
|
|
* if(this.mobileAccessibility.isScreenReaderRunningCallback();
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
@Plugin({
|
|
|
|
pluginName: 'MobileAccessibility',
|
2017-06-06 11:04:02 +08:00
|
|
|
plugin: 'phonegap-plugin-mobile-accessibility',
|
2017-06-08 15:17:41 +08:00
|
|
|
pluginRef: 'MobileAccessibility',
|
2017-05-10 06:24:59 +08:00
|
|
|
repo: 'https://github.com/phonegap/phonegap-mobile-accessibility',
|
2017-06-03 03:34:18 +08:00
|
|
|
platforms: ['Android Fire OS', 'Android', 'iOS', 'Windows']
|
2017-05-10 06:24:59 +08:00
|
|
|
})
|
|
|
|
@Injectable()
|
|
|
|
export class MobileAccessibility extends IonicNativePlugin {
|
2018-03-17 05:04:01 +08:00
|
|
|
|
2017-05-10 06:24:59 +08:00
|
|
|
MobileAccessibilityNotifications: {
|
2018-03-17 05:04:01 +08:00
|
|
|
ANNOUNCEMENT: 'ANNOUNCEMENT',
|
|
|
|
BOLD_TEXT_STATUS_CHANGED: 'BOLD_TEXT_STATUS_CHANGED',
|
|
|
|
CLOSED_CAPTIONING_STATUS_CHANGED: 'CLOSED_CAPTIONING_STATUS_CHANGED',
|
|
|
|
DARKER_SYSTEM_COLORS_STATUS_CHANGED: 'DARKER_SYSTEM_COLORS_STATUS_CHANGED',
|
|
|
|
GRAYSCALE_STATUS_CHANGED: 'GRAYSCALE_STATUS_CHANGED',
|
|
|
|
GUIDED_ACCESS_STATUS_CHANGED: 'GUIDED_ACCESS_STATUS_CHANGED',
|
|
|
|
INVERT_COLORS_STATUS_CHANGED: 'INVERT_COLORS_STATUS_CHANGED',
|
|
|
|
LAYOUT_CHANGED: 'LAYOUT_CHANGED',
|
|
|
|
MONO_AUDIO_STATUS_CHANGED: 'MONO_AUDIO_STATUS_CHANGED',
|
|
|
|
PAGE_SCROLLED: 'PAGE_SCROLLED',
|
|
|
|
REDUCE_MOTION_STATUS_CHANGED: 'REDUCE_MOTION_STATUS_CHANGED',
|
|
|
|
REDUCE_TRANSPARENCY_STATUS_CHANGED: 'REDUCE_TRANSPARENCY_STATUS_CHANGED',
|
|
|
|
SCREEN_CHANGED: 'SCREEN_CHANGED',
|
|
|
|
SCREEN_READER_STATUS_CHANGED: 'SCREEN_READER_STATUS_CHANGED',
|
|
|
|
SPEAK_SCREEN_STATUS_CHANGED: 'SPEAK_SCREEN_STATUS_CHANGED',
|
|
|
|
SPEAK_SELECTION_STATUS_CHANGED: 'SPEAK_SELECTION_STATUS_CHANGED',
|
|
|
|
SWITCH_CONTROL_STATUS_CHANGED: 'SWITCH_CONTROL_STATUS_CHANGED',
|
|
|
|
TOUCH_EXPLORATION_STATUS_CHANGED: 'TOUCH_EXPLORATION_STATUS_CHANGED'
|
2017-05-10 06:24:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Makes an asynchronous call to native MobileAccessibility to determine if a screen reader is running.
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} A result method to receive the boolean result asynchronously from the native MobileAccessibility plugin.
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova()
|
2018-03-17 05:04:01 +08:00
|
|
|
isScreenReaderRunning(): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An iOS-specific proxy for the MobileAccessibility.isScreenReaderRunning method
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} A result method to receive the boolean result asynchronously from the native MobileAccessibility plugin.
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova({ platforms: ['iOS'] })
|
2018-03-17 05:04:01 +08:00
|
|
|
isVoiceOverRunning(): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An Android/Amazon Fire OS-specific proxy for the MobileAccessibility.isScreenReaderRunning method.
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} A result method to receive the boolean result asynchronously from the native MobileAccessibility plugin.
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova({ platforms: ['Amazon Fire OS', 'Android'] })
|
2018-03-17 05:04:01 +08:00
|
|
|
isTalkBackRunning(): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* On Android, this method returns true if ChromeVox is active and properly initialized with access to the text to speech API in the WebView.
|
|
|
|
* If TalkBack is running but ChromeVox is not active, this method is useful to alert the user of a potential problem.
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} Returns the result
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova({ platforms: ['Amazon Fire OS', 'Android'] })
|
2018-03-17 05:04:01 +08:00
|
|
|
isChromeVoxActive(): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} Returns the result
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova({ platforms: ['iOS'] })
|
2018-03-17 05:04:01 +08:00
|
|
|
isBoldTextEnabled(): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} Returns the result
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova()
|
2018-03-17 05:04:01 +08:00
|
|
|
isClosedCaptioningEnabled(): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} Returns the result
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova({ platforms: ['iOS'] })
|
2018-03-17 05:04:01 +08:00
|
|
|
isDarkerSystemColorsEnabled(): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} Returns the result
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova({ platforms: ['iOS'] })
|
2018-03-17 05:04:01 +08:00
|
|
|
isGrayscaleEnabled(): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} Returns the result
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova({ platforms: ['iOS'] })
|
2018-03-17 05:04:01 +08:00
|
|
|
isGuidedAccessEnabled(): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} Returns the result
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova({ platforms: ['iOS'] })
|
2018-03-17 05:04:01 +08:00
|
|
|
isInvertColorsEnabled(): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} Returns the result
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova({ platforms: ['iOS'] })
|
2018-03-17 05:04:01 +08:00
|
|
|
isMonoAudioEnabled(): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} Returns the result
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova({ platforms: ['iOS'] })
|
2018-03-17 05:04:01 +08:00
|
|
|
isReduceMotionEnabled(): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} Returns the result
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova({ platforms: ['iOS'] })
|
2018-03-17 05:04:01 +08:00
|
|
|
isReduceTransparencyEnabled(): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} Returns the result
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova({ platforms: ['iOS'] })
|
2018-03-17 05:04:01 +08:00
|
|
|
isSpeakScreenEnabled(): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} Returns the result
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova({ platforms: ['iOS'] })
|
2018-03-17 05:04:01 +08:00
|
|
|
isSpeakSelectionEnabled(): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} Returns the result
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova({ platforms: ['iOS'] })
|
2018-03-17 05:04:01 +08:00
|
|
|
isSwitchControlRunning(): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} Returns the result
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova({ platforms: ['Amazon Fire OS', 'Android'] })
|
2018-03-17 05:04:01 +08:00
|
|
|
isTouchExplorationEnabled(): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* * @returns {Promise<number>} Returns the result
|
|
|
|
*/
|
|
|
|
@Cordova()
|
2018-03-17 05:04:01 +08:00
|
|
|
getTextZoom(): Promise<number> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
2017-06-19 05:22:28 +08:00
|
|
|
* @param textZoom {number} A percentage value by which text in the WebView should be scaled.
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova({ sync: true })
|
2018-03-17 05:04:01 +08:00
|
|
|
setTextZoom(textZoom: number): void { }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
@Cordova({ sync: true })
|
2018-03-17 05:04:01 +08:00
|
|
|
updateTextZoom(): void { }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A Boolean value which specifies whether to use the preferred text zoom of a default percent value of 100.
|
|
|
|
* @param value {boolean} Returns the result
|
|
|
|
*/
|
|
|
|
@Cordova({ sync: true })
|
2018-03-17 05:04:01 +08:00
|
|
|
usePreferredTextZoom(value: boolean): void { }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Posts a notification with a string for the screen reader to announce if it is running.
|
|
|
|
* @param mobileAccessibilityNotification {any}
|
|
|
|
* @param value {string} A string to be announced by a screen reader.
|
2017-05-10 06:25:48 +08:00
|
|
|
* @returns {Promise<boolean>} Returns the result
|
2017-05-10 06:24:59 +08:00
|
|
|
*/
|
|
|
|
@Cordova({ platforms: ['iOS'] })
|
2018-03-17 05:04:01 +08:00
|
|
|
postNotification(mobileAccessibilityNotification: any, value: string): Promise<boolean> { return; }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Speaks a given string through the screenreader. On Android, if ChromeVox is active, it will use the specified queueMode and properties.
|
|
|
|
* @param value {string}
|
|
|
|
* @param queueMode {mumber}
|
|
|
|
* @param properties {any}
|
|
|
|
*/
|
|
|
|
@Cordova({ sync: true })
|
2018-03-17 05:04:01 +08:00
|
|
|
speak(value: string, queueMode?: number, properties?: any): void { }
|
2017-05-10 06:24:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Stops speech.
|
|
|
|
*/
|
|
|
|
@Cordova({ sync: true })
|
2018-03-17 05:04:01 +08:00
|
|
|
stop(): void { }
|
|
|
|
|
2017-05-10 06:24:59 +08:00
|
|
|
}
|