15 Commits

Author SHA1 Message Date
94b5e51564 干掉github强依赖 2022-12-20 14:57:20 +08:00
Michael Jordan
e9821054c3 Update version to 1.0.5 2016-12-12 17:20:41 -05:00
Michael Jordan
2c1df73617 Update version after creating tag at 1.0.4 2016-04-13 18:31:46 -04:00
Michael Jordan
f1a49e8970 Update version to 1.0.4 2016-04-13 18:28:41 -04:00
Michael Jordan
4933f5075a Add additional iOS accessibility features
Adds support for detecting:
- Bold Text
- Darker System Colors
- Grayscale
- Reduce Motion
- Reduce Transparency
- Speak Screen
- Speak Selection
- Switch Control Running
2016-04-13 18:24:42 -04:00
Daniel Wilson
dbfde0134d add reduce motion for ios
limit reduce motion check to iOS 8+
2016-04-12 17:29:15 -04:00
Michael Jordan
e989af802c Update version after creating tag at 1.0.3 2016-02-11 08:28:32 -05:00
Michael Jordan
3224bc2332 Update version to 1.0.3 2016-02-11 08:23:53 -05:00
Michael Jordan
e3ac5fc92f Fix issue #32 Doesn't work with cordova-plugin-crosswalk-webview
Use reflection for getView, getSettings, getTextSize/getTextZoom, and
setTextSize/setTextZoom so that the View does not need to be cast as an
android.webkit.WebView.
2016-02-11 08:22:36 -05:00
Michael Jordan
9714162405 Merge pull request #30 from optionfactory/master
Fix resume event passed to updateTextZoom as callback argument
2016-02-03 09:52:48 -05:00
Simone Baruzza
7961963ac2 Fix resume event passed to updateTextZoom as callback argument
Wrapped resume event handler to avoid event argument being passed
 to updateTextZoom and hence being called .apply() onto.
2016-02-03 09:39:53 +01:00
Michael Jordan
995295bdcd Update version after creating tag at 1.0.2 2015-12-16 15:40:13 -05:00
Michael Jordan
af7394ccd3 Update version to 1.0.2 2015-12-16 15:34:14 -05:00
Michael Jordan
71640de527 Fix Issue #26: Fails to compile with cordova-ios 4.0.0
Per @shazron, use `self.commandDelegate evalJs`.
2015-12-16 15:29:21 -05:00
Michael Jordan
188d5c583c Update version after creating tag at 1.0.1 2015-10-07 13:30:58 -04:00
13 changed files with 960 additions and 197 deletions

571
README.md
View File

@@ -31,6 +31,7 @@ The `MobileAccessibility` object, exposed by `window.MobileAccessibility`, provi
- MobileAccessibility.isGuidedAccessEnabled
- MobileAccessibility.isInvertColorsEnabled
- MobileAccessibility.isMonoAudioEnabled
- MobileAccessibility.isReduceMotionEnabled
- MobileAccessibility.isTouchExplorationEnabled
- MobileAccessibility.getTextZoom
- MobileAccessibility.setTextZoom
@@ -167,10 +168,37 @@ If TalkBack is running but ChromeVox is not active, this method is useful to ale
- Amazon Fire OS
- Android
--------------------------------------------------------
#### MobileAccessibility.isBoldTextEnabled(callback)
Makes an asynchronous call to native `MobileAccessibility` to determine if Bold Text is enabled.
##### Parameters
- __callback__ (Function) A callback method to receive the boolean result asynchronously from the native `MobileAccessibility` plugin.
##### Usage
```javascript
function isBoldTextEnabledCallback(boolean) {
if (boolean) {
console.log("Bold Text: ON");
// Do something to improve the behavior of the application while Bold Text is enabled.
} else {
console.log("Bold Text: OFF");
}
}
MobileAccessibility.isBoldTextEnabled(isBoldTextEnabledCallback);
```
##### Supported Platforms
- iOS
------------------------------------------------------------
#### MobileAccessibility.isClosedCaptioningEnabled(callback)
Makes an asynchronous call to native `MobileAccessibility` to determine if system-level closed captioning is enabled on the device.
##### Parameters
@@ -199,8 +227,63 @@ Makes an asynchronous call to native `MobileAccessibility` to determine if syste
- iOS
--------------------------------------------------------
#### MobileAccessibility.isGuidedAccessEnabled(callback)
#### MobileAccessibility.isDarkerSystemColorsEnabled(callback)
Makes an asynchronous call to native `MobileAccessibility` to determine if Darker System Colors is enabled.
##### Parameters
- __callback__ (Function) A callback method to receive the boolean result asynchronously from the native `MobileAccessibility` plugin.
##### Usage
```javascript
function isDarkerSystemColorsEnabledCallback(boolean) {
if (boolean) {
console.log("Darker System Colors: ON");
// Do something to improve the behavior of the application while Darker System Colors is enabled.
} else {
console.log("Darker System Colors: OFF");
}
}
MobileAccessibility.isDarkerSystemColorsEnabled(isDarkerSystemColorsEnabledCallback);
```
##### Supported Platforms
- iOS
--------------------------------------------------------
#### MobileAccessibility.isGrayscaleEnabled(callback)
Makes an asynchronous call to native `MobileAccessibility` to determine if Grayscale is enabled.
##### Parameters
- __callback__ (Function) A callback method to receive the boolean result asynchronously from the native `MobileAccessibility` plugin.
##### Usage
```javascript
function isGrayscaleEnabledCallback(boolean) {
if (boolean) {
console.log("Grayscale: ON");
// Do something to improve the behavior of the application while Grayscale is enabled.
} else {
console.log("Grayscale: OFF");
}
}
MobileAccessibility.isGrayscaleEnabled(isGrayscaleEnabledCallback);
```
##### Supported Platforms
- iOS
--------------------------------------------------------
#### MobileAccessibility.isGuidedAccessEnabled(callback)
Makes an asynchronous call to native `MobileAccessibility` to determine if Guided Access is enabled.
@@ -230,7 +313,6 @@ Makes an asynchronous call to native `MobileAccessibility` to determine if Guide
--------------------------------------------------------
#### MobileAccessibility.isInvertColorsEnabled(callback)
Makes an asynchronous call to native `MobileAccessibility` to determine if the display colors have been inverted.
##### Parameters
@@ -284,6 +366,146 @@ Makes an asynchronous call to native `MobileAccessibility` to determine if mono
- iOS
----------------------------------------------------
#### MobileAccessibility.isReduceMotionEnabled(callback)
Makes an asynchronous call to native `MobileAccessibility` to determine if reduce motion is enabled.
##### Parameters
- __callback__ (Function) A callback method to receive the boolean result asynchronously from the native `MobileAccessibility` plugin.
##### Usage
```javascript
function isReduceMotionEnabledCallback(boolean) {
if (boolean) {
console.log("Reduce Motion: ON");
// Do something to improve the behavior of the application when reduce motion is enabled.
} else {
console.log("Reduce Motion: OFF");
}
}
MobileAccessibility.isReduceMotionEnabled(isReduceMotionEnabledCallback);
```
##### Supported Platforms
- iOS
----------------------------------------------------
#### MobileAccessibility.isReduceTransparencyEnabled(callback)
Makes an asynchronous call to native `MobileAccessibility` to determine if reduce transparency is enabled.
##### Parameters
- __callback__ (Function) A callback method to receive the boolean result asynchronously from the native `MobileAccessibility` plugin.
##### Usage
```javascript
function isReduceTransparencyEnabledCallback(boolean) {
if (boolean) {
console.log("Reduce Transparency: ON");
// Do something to improve the behavior of the application when reduce transparency is enabled.
} else {
console.log("Reduce Transparency: OFF");
}
}
MobileAccessibility.isReduceTransparencyEnabled(isReduceTransparencyEnabledCallback);
```
##### Supported Platforms
- iOS
----------------------------------------------------
#### MobileAccessibility.isSpeakScreenEnabled(callback)
Makes an asynchronous call to native `MobileAccessibility` to determine if speak screen is enabled.
##### Parameters
- __callback__ (Function) A callback method to receive the boolean result asynchronously from the native `MobileAccessibility` plugin.
##### Usage
```javascript
function isSpeakScreenEnabledCallback(boolean) {
if (boolean) {
console.log("Speak Screen: ON");
// Do something to improve the behavior of the application when Speak Screen is enabled.
} else {
console.log("Speak Screen: OFF");
}
}
MobileAccessibility.isSpeakScreenEnabled(isSpeakScreenEnabledCallback);
```
##### Supported Platforms
- iOS
----------------------------------------------------
#### MobileAccessibility.isSpeakSelectionEnabled(callback)
Makes an asynchronous call to native `MobileAccessibility` to determine if speak selection is enabled.
##### Parameters
- __callback__ (Function) A callback method to receive the boolean result asynchronously from the native `MobileAccessibility` plugin.
##### Usage
```javascript
function isSpeakSelectionEnabledCallback(boolean) {
if (boolean) {
console.log("Speak Selection: ON");
// Do something to improve the behavior of the application when Speak Selection is enabled.
} else {
console.log("Speak Selection: OFF");
}
}
MobileAccessibility.isSpeakSelectionEnabled(isSpeakSelectionEnabledCallback);
```
##### Supported Platforms
- iOS
----------------------------------------------------
#### MobileAccessibility.isSwitchControlRunning(callback)
Makes an asynchronous call to native `MobileAccessibility` to determine if switch control is running.
##### Parameters
- __callback__ (Function) A callback method to receive the boolean result asynchronously from the native `MobileAccessibility` plugin.
##### Usage
```javascript
function isSwitchControlRunningCallback(boolean) {
if (boolean) {
console.log("Switch Control: ON");
// Do something to improve the behavior of the application when Switch Control is running.
} else {
console.log("Switch Control: OFF");
}
}
MobileAccessibility.isSwitchControlRunning(isSwitchControlRunningCallback);
```
##### Supported Platforms
- iOS
------------------------------------------------------------
#### MobileAccessibility.isTouchExplorationEnabled(callback)
@@ -498,13 +720,237 @@ Stops speech.
The following event constants are for `window` events, to which an application can listen for notification of changes in the status of the accessibility features on the device.
- MobileAccessibilityNotifications.SCREEN_READER_STATUS_CHANGED
- MobileAccessibilityNotifications.BOLD_TEXT_STATUS_CHANGED
- MobileAccessibilityNotifications.CLOSED_CAPTIONING_STATUS_CHANGED
- MobileAccessibilityNotifications.DARKER_SYSTEM_COLORS_STATUS_CHANGED
- MobileAccessibilityNotifications.GRAYSCALE_STATUS_CHANGED
- MobileAccessibilityNotifications.GUIDED_ACCESS_STATUS_CHANGED
- MobileAccessibilityNotifications.INVERT_COLORS_STATUS_CHANGED
- MobileAccessibilityNotifications.MONO_AUDIO_STATUS_CHANGED
- MobileAccessibilityNotifications.REDUCE_MOTION_STATUS_CHANGED
- MobileAccessibilityNotifications.REDUCE_TRANSPARENCY_STATUS_CHANGED
- MobileAccessibilityNotifications.SCREEN_READER_STATUS_CHANGED
- MobileAccessibilityNotifications.SPEAK_SCREEN_STATUS_CHANGED
- MobileAccessibilityNotifications.SPEAK_SELECTION_STATUS_CHANGED
- MobileAccessibilityNotifications.SWITCH_CONTROL_STATUS_CHANGED
- MobileAccessibilityNotifications.TOUCH_EXPLORATION_STATUS_CHANGED
----------------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.BOLD_TEXT_STATUS_CHANGED (boldtextstatuschanged)
The event fires when Bold Text has been enabled on an iOS device.
The event returns an object, `info`, with the current status of accessibility features on the device.
If Bold Text is active, `info.isBoldTextEnabled` will equal `true`.
```javascript
// Define a persistent callback method to handle the event
function onBoldTextStatusChanged(info) {
if (info && typeof info.isBoldTextEnabled !== "undefined") {
if (info.isBoldTextEnabled) {
console.log("Bold Text: ON");
// Do something to improve the behavior of the application while Bold Text is enabled.
} else {
console.log("Bold Text: OFF");
}
}
}
// Register the callback method to handle the event
window.addEventListener(MobileAccessibilityNotifications.BOLD_TEXT_STATUS_CHANGED, onBoldTextStatusChanged, false);
```
------------------------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.CLOSED_CAPTIONING_STATUS_CHANGED (closedcaptioningstatuschanged)
The event fires when system-level closed captioning on the device turns on or off.
The event returns an object, `info`, with the current status of accessibility features on the device.
If closed captioning is active, `info.isClosedCaptioningEnabled` will equal `true`.
```javascript
// Define a persistent callback method to handle the event
function onClosedCaptioningStatusChanged(info) {
if (info && typeof info.isClosedCaptioningEnabled !== "undefined") {
if (info.isClosedCaptioningEnabled) {
console.log("Closed Captioning: ON");
// Do something to improve the behavior of the application while closed captioning is enabled.
} else {
console.log("Closed Captioning: OFF");
}
}
}
// Register the callback method to handle the event
window.addEventListener(MobileAccessibilityNotifications.CLOSED_CAPTIONING_STATUS_CHANGED, onClosedCaptioningStatusChanged, false);
```
----------------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.DARKER_SYSTEM_COLORS_STATUS_CHANGED (darkersystemcolorsstatuschanged)
The event fires when Darker System Colors has been enabled on an iOS device.
The event returns an object, `info`, with the current status of accessibility features on the device.
If Darker System Colors is active, `info.isDarkerSystemColorsEnabled` will equal `true`.
```javascript
// Define a persistent callback method to handle the event
function onDarkerSystemColorsStatusChanged(info) {
if (info && typeof info.isDarkerSystemColorsEnabled !== "undefined") {
if (info.isDarkerSystemColorsEnabled) {
console.log("Darker System Colors: ON");
// Do something to improve the behavior of the application while Darker System Colors is enabled.
} else {
console.log("Darker System Colors: OFF");
}
}
}
// Register the callback method to handle the event
window.addEventListener(MobileAccessibilityNotifications.DARKER_SYSTEM_COLORS_STATUS_CHANGED, onDarkerSystemColorsStatusChanged, false);
```
----------------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.GRAYSCALE_STATUS_CHANGED (grayscalestatuschanged)
The event fires when Grayscale has been enabled on an iOS device.
The event returns an object, `info`, with the current status of accessibility features on the device.
If Grayscale is active, `info.isGrayscaleEnabled` will equal `true`.
```javascript
// Define a persistent callback method to handle the event
function onGrayscaleStatusChanged(info) {
if (info && typeof info.isGrayscaleEnabled !== "undefined") {
if (info.isGrayscaleEnabled) {
console.log("Grayscale: ON");
// Do something to improve the behavior of the application while Grayscale is enabled.
} else {
console.log("Grayscale: OFF");
}
}
}
// Register the callback method to handle the event
window.addEventListener(MobileAccessibilityNotifications.GRAYSCALE_STATUS_CHANGED, onGrayscaleStatusChanged, false);
```
----------------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.GUIDED_ACCESS_STATUS_CHANGED (guidedaccessstatuschanged)
The event fires when Guided Access has been enabled on an iOS device.
The event returns an object, `info`, with the current status of accessibility features on the device.
If Guided Access is active, `info.isGuidedAccessEnabled` will equal `true`.
```javascript
// Define a persistent callback method to handle the event
function onGuidedAccessStatusChanged(info) {
if (info && typeof info.isGuidedAccessEnabled !== "undefined") {
if (info.isGuidedAccessEnabled) {
console.log("Guided Access: ON");
// Do something to improve the behavior of the application while Guided Access is enabled.
} else {
console.log("Guided Access: OFF");
}
}
}
// Register the callback method to handle the event
window.addEventListener(MobileAccessibilityNotifications.GUIDED_ACCESS_STATUS_CHANGED, onGuidedAccessStatusChanged, false);
```
----------------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.INVERT_COLORS_STATUS_CHANGED (invertcolorsstatuschanged)
The event fires when Invert Colors has been enabled on an iOS device.
The event returns an object, `info`, with the current status of accessibility features on the device.
If Invert Colors is active, `info.isInvertColorsEnabled` will equal `true`.
```javascript
// Define a persistent callback method to handle the event
function onInvertColorsStatusChanged(info) {
if (info && typeof info.isInvertColorsEnabled !== "undefined") {
if (info.isInvertColorsEnabled) {
console.log("Invert Colors: ON");
// Do something to improve the behavior of the application while Invert Colors is enabled.
} else {
console.log("Invert Colors: OFF");
}
}
}
// Register the callback method to handle the event
window.addEventListener(MobileAccessibilityNotifications.INVERT_COLORS_STATUS_CHANGED, onInvertColorsStatusChanged, false);
```
----------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.MONO_AUDIO_STATUS_CHANGED (monoaudiostatuschanged)
The event fires when Mono Audio has been enabled on an iOS device.
The event returns an object, `info`, with the current status of accessibility features on the device.
If Mono Audio is active, `info.isMonoAudioEnabled` will equal `true`.
```javascript
// Define a persistent callback method to handle the event
function onMonoAudioStatusChanged(info) {
if (info && typeof info.isMonoAudioEnabled !== "undefined") {
if (info.isMonoAudioEnabled) {
console.log("Mono Audio: ON");
// Do something to improve the behavior of the application while Mono Audio is enabled.
} else {
console.log("Mono Audio: OFF");
}
}
}
// Register the callback method to handle the event
window.addEventListener(MobileAccessibilityNotifications.MONO_AUDIO_STATUS_CHANGED, onMonoAudioStatusChanged, false);
```
----------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.REDUCE_MOTION_STATUS_CHANGED (reducemotionstatuschanged)
The event fires when Reduce Motion has been enabled on an iOS device.
The event returns an object, `info`, with the current status of accessibility features on the device.
If Reduce Motion is active, `info.isReduceMotionEnabled` will equal `true`.
```javascript
// Define a persistent callback method to handle the event
function onReduceMotionStatusChanged(info) {
if (info && typeof info.isReduceMotionEnabled !== "undefined") {
if (info.isReduceMotionEnabled) {
console.log("Reduce Motion: ON");
// Do something to improve the behavior of the application while Reduce Motion is enabled.
} else {
console.log("Reduce Motion: OFF");
}
}
}
// Register the callback method to handle the event
window.addEventListener(MobileAccessibilityNotifications.REDUCE_MOTION_STATUS_CHANGED, onMReduceMotionStatusChanged, false);
```
----------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.REDUCE_TRANSPARENCY_STATUS_CHANGED (reducetransparencystatuschanged)
The event fires when Reduce Transparency has been enabled on an iOS device.
The event returns an object, `info`, with the current status of accessibility features on the device.
If Reduce Transparency is active, `info.isReduceTransparencyEnabled` will equal `true`.
```javascript
// Define a persistent callback method to handle the event
function onReduceTransparencyStatusChanged(info) {
if (info && typeof info.isReduceTransparencyEnabled !== "undefined") {
if (info.isReduceTransparencyEnabled) {
console.log("Reduce Transparency: ON");
// Do something to improve the behavior of the application while Reduce Transparency is enabled.
} else {
console.log("Reduce Transparency: OFF");
}
}
}
// Register the callback method to handle the event
window.addEventListener(MobileAccessibilityNotifications.REDUCE_TRANSPARENCY_STATUS_CHANGED, onReduceTransparencyStatusChanged, false);
```
----------------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.SCREEN_READER_STATUS_CHANGED (screenreaderstatuschanged)
@@ -529,100 +975,77 @@ If a screen reader is active, `info.isScreenReaderRunning` will equal `true`.
window.addEventListener(MobileAccessibilityNotifications.SCREEN_READER_STATUS_CHANGED, onScreenReaderStatusChanged, false);
```
------------------------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.CLOSED_CAPTIONING_STATUS_CHANGED (closedcaptioningstatuschanged)
----------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.SPEAK_SCREEN_STATUS_CHANGED (speakscreenstatuschanged)
The event fires when system-level closed captioning on the device turns on or off.
The event fires when Speak Screen has been enabled on an iOS device.
The event returns an object, `info`, with the current status of accessibility features on the device.
If a screen reader is active, `info.isClosedCaptioningEnabled` will equal `true`.
If Speak Screen is active, `info.isSpeakScreenEnabled` will equal `true`.
```javascript
// Define a persistent callback method to handle the event
function onClosedCaptioningStatusChanged(info) {
if (info && typeof info.isClosedCaptioningEnabled !== "undefined") {
if (info.isClosedCaptioningEnabled) {
console.log("Closed Captioning: ON");
// Do something to improve the behavior of the application while closed captioning is enabled.
function onSpeakScreenStatusChanged(info) {
if (info && typeof info.isSpeakScreenEnabled !== "undefined") {
if (info.isSpeakScreenEnabled) {
console.log("Speak Screen: ON");
// Do something to improve the behavior of the application while Speak Screen is enabled.
} else {
console.log("Closed Captioning: OFF");
console.log("Speak Screen: OFF");
}
}
}
// Register the callback method to handle the event
window.addEventListener(MobileAccessibilityNotifications.CLOSED_CAPTIONING_STATUS_CHANGED, onClosedCaptioningStatusChanged, false);
```
----------------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.GUIDED_ACCESS_STATUS_CHANGED (guidedaccessstatuschanged)
The event fires when Guided Access has been enabled on an iOS device.
The event returns an object, `info`, with the current status of accessibility features on the device.
If a screen reader is active, `info.isGuidedAccessEnabled` will equal `true`.
```javascript
// Define a persistent callback method to handle the event
function onGuidedAccessStatusChanged(info) {
if (info && typeof info.isGuidedAccessEnabled !== "undefined") {
if (info.isGuidedAccessEnabled) {
console.log("Guided Access: ON");
// Do something to improve the behavior of the application while Guided Access is enabled.
} else {
console.log("Guided Access: OFF");
}
}
}
// Register the callback method to handle the event
window.addEventListener(MobileAccessibilityNotifications.GUIDED_ACCESS_STATUS_CHANGED, onGuidedAccessStatusChanged, false);
```
----------------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.INVERT_COLORS_STATUS_CHANGED (invertcolorsstatuschanged)
The event fires when Invert Colors has been enabled on an iOS device.
The event returns an object, `info`, with the current status of accessibility features on the device.
If a screen reader is active, `info.isInvertColorsEnabled` will equal `true`.
```javascript
// Define a persistent callback method to handle the event
function onInvertColorsStatusChanged(info) {
if (info && typeof info.isInvertColorsEnabled !== "undefined") {
if (info.isInvertColorsEnabled) {
console.log("Invert Colors: ON");
// Do something to improve the behavior of the application while Invert Colors is enabled.
} else {
console.log("Invert Colors: OFF");
}
}
}
// Register the callback method to handle the event
window.addEventListener(MobileAccessibilityNotifications.INVERT_COLORS_STATUS_CHANGED, onInvertColorsStatusChanged, false);
window.addEventListener(MobileAccessibilityNotifications.SPEAK_SCREEN_STATUS_CHANGED, onSpeakScreenStatusChanged, false);
```
----------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.MONO_AUDIO_STATUS_CHANGED (monoaudiostatuschanged)
#### MobileAccessibilityNotifications.SPEAK_SELECTION_STATUS_CHANGED (speakselectionstatuschanged)
The event fires when Mono Audio has been enabled on an iOS device.
The event fires when Speak Selection has been enabled on an iOS device.
The event returns an object, `info`, with the current status of accessibility features on the device.
If a screen reader is active, `info.isMonoAudioEnabled` will equal `true`.
If Speak Selection is active, `info.isSpeakSelectionEnabled` will equal `true`.
```javascript
// Define a persistent callback method to handle the event
function onMonoAudioStatusChanged(info) {
if (info && typeof info.isMonoAudioEnabled !== "undefined") {
if (info.isMonoAudioEnabled) {
console.log("Mono Audio: ON");
// Do something to improve the behavior of the application while Mono Audio is enabled.
function onSpeakSelectionStatusChanged(info) {
if (info && typeof info.isSpeakSelectionEnabled !== "undefined") {
if (info.isSpeakSelectionEnabled) {
console.log("Speak Selection: ON");
// Do something to improve the behavior of the application while Speak Selection is enabled.
} else {
console.log("Mono Audio: OFF");
console.log("Speak Selection: OFF");
}
}
}
// Register the callback method to handle the event
window.addEventListener(MobileAccessibilityNotifications.MONO_AUDIO_STATUS_CHANGED, onMonoAudioStatusChanged, false);
window.addEventListener(MobileAccessibilityNotifications.SPEAK_SELECTION_STATUS_CHANGED, onSpeakSelectionStatusChanged, false);
```
----------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.SWITCH_CONTROL_STATUS_CHANGED (switchcontrolstatuschanged)
The event fires when Switch Control is running on an iOS device.
The event returns an object, `info`, with the current status of accessibility features on the device.
If Switch Control is running, `info.isSwitchControlRunning` will equal `true`.
```javascript
// Define a persistent callback method to handle the event
function onSwitchControlStatusChanged(info) {
if (info && typeof info.isSwitchControlRunning !== "undefined") {
if (info.isSwitchControlRunning) {
console.log("Switch Control: ON");
// Do something to improve the behavior of the application while Switch Control is running.
} else {
console.log("Switch Control: OFF");
}
}
}
// Register the callback method to handle the event
window.addEventListener(MobileAccessibilityNotifications.SWITCH_CONTROL_STATUS_CHANGED, onSwitchControlStatusChanged, false);
```
------------------------------------------------------------------------------------------------------
@@ -630,7 +1053,7 @@ If a screen reader is active, `info.isMonoAudioEnabled` will equal `true`.
The event fires when Touch Exploration has been enabled on an Android device.
The event returns an object, `info`, with the current status of accessibility features on the device.
If a screen reader is active, `info.isTouchExplorationEnabled` will equal `true`.
If Touch Exploration is active, `info.isTouchExplorationEnabled` will equal `true`.
```javascript
// Define a persistent callback method to handle the event

View File

@@ -1,7 +1,7 @@
{
"name": "phonegap-plugin-mobile-accessibility",
"description": "PhoneGap Mobile Accessibility Plugin",
"version": "1.0.1",
"version": "1.0.5",
"homepage": "http://github.com/phonegap/phonegap-mobile-accessibility#readme",
"repository": {
"type": "git",

View File

@@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="phonegap-plugin-mobile-accessibility"
version="1.0.1">
version="1.0.5-dev">
<name>Mobile Accessibility</name>
<description>PhoneGap Mobile Accessibility Plugin</description>
<license>Apache 2.0</license>
@@ -20,8 +20,8 @@
<clobbers target="MobileAccessibilityNotifications" />
</js-module>
<dependency id="cordova-plugin-device" url="https://github.com/apache/cordova-plugin-device.git" />
<dependency id="cordova-plugin-network-information" url="https://github.com/apache/cordova-plugin-network-information.git" />
<dependency id="cordova-plugin-device" />
<dependency id="cordova-plugin-network-information"/>
<!-- ios -->
<platform name="ios">

View File

@@ -23,9 +23,9 @@ package com.phonegap.plugin.mobileaccessibility;
import android.view.ViewParent;
public abstract class AbstractMobileAccessibilityHelper {
protected MobileAccessibility mMobileAccessibility;
protected ViewParent mParent;
abstract class AbstractMobileAccessibilityHelper {
MobileAccessibility mMobileAccessibility;
ViewParent mParent;
public abstract void initialize(MobileAccessibility mobileAccessibility);
public abstract boolean isClosedCaptioningEnabled();
public abstract boolean isScreenReaderRunning();

View File

@@ -26,6 +26,7 @@ import android.content.Context;
import android.os.Build;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
@@ -36,19 +37,20 @@ import java.lang.reflect.Method;
@TargetApi(Build.VERSION_CODES.DONUT)
public class DonutMobileAccessibilityHelper extends
AbstractMobileAccessibilityHelper {
protected AccessibilityManager mAccessibilityManager;
protected WebView mWebView;
AccessibilityManager mAccessibilityManager;
View mView;
@Override
public void initialize(MobileAccessibility mobileAccessibility) {
mMobileAccessibility = mobileAccessibility;
WebView view;
try {
mWebView = (WebView) mobileAccessibility.webView;
view = (WebView) mobileAccessibility.webView;
mView = view;
} catch(ClassCastException ce) { // cordova-android 4.0+
try {
Method getView = mobileAccessibility.webView.getClass().getMethod("getView");
mWebView = (WebView) getView.invoke(mobileAccessibility.webView);
mView = (View) getView.invoke(mobileAccessibility.webView);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
@@ -108,9 +110,9 @@ public class DonutMobileAccessibilityHelper extends
final int eventType = AccessibilityEvent.TYPE_VIEW_FOCUSED;
final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
event.getText().add(text);
event.setEnabled(mWebView.isEnabled());
event.setClassName(mWebView.getClass().getName());
event.setPackageName(mWebView.getContext().getPackageName());
event.setEnabled(mView.isEnabled());
event.setClassName(mView.getClass().getName());
event.setPackageName(mView.getContext().getPackageName());
event.setContentDescription(null);
mAccessibilityManager.sendAccessibilityEvent(event);
@@ -120,7 +122,23 @@ public class DonutMobileAccessibilityHelper extends
@Override
public double getTextZoom() {
double zoom = 100;
WebSettings.TextSize wTextSize = mWebView.getSettings().getTextSize();
WebSettings.TextSize wTextSize = WebSettings.TextSize.NORMAL;
try {
Method getSettings = mView.getClass().getMethod("getSettings");
Object wSettings = getSettings.invoke(mView);
Method getTextSize = wSettings.getClass().getMethod("getTextSize");
wTextSize = (WebSettings.TextSize) getTextSize.invoke(wSettings);
} catch(ClassCastException ce) {
ce.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
switch (wTextSize) {
case LARGEST:
zoom = 200;
@@ -128,39 +146,42 @@ public class DonutMobileAccessibilityHelper extends
case LARGER:
zoom = 150;
break;
case NORMAL:
zoom = 100;
break;
case SMALLER:
zoom = 75;
break;
case SMALLEST:
zoom = 50;
break;
default:
zoom = 100;
break;
}
return zoom;
}
@SuppressWarnings("deprecation")
@Override
public void setTextZoom(double textZoom) {
final double zoom = textZoom;
WebSettings.TextSize wTextSize = WebSettings.TextSize.NORMAL;
if (zoom > 115) {
WebSettings.TextSize wTextSize = WebSettings.TextSize.SMALLEST;
if (textZoom > 115) {
wTextSize = WebSettings.TextSize.LARGEST;
} else if (zoom > 100) {
} else if (textZoom > 100) {
wTextSize = WebSettings.TextSize.LARGER;
} else if (zoom == 100) {
} else if (textZoom == 100) {
wTextSize = WebSettings.TextSize.NORMAL;
} else if (zoom > 50) {
} else if (textZoom > 50) {
wTextSize = WebSettings.TextSize.SMALLER;
} else {
wTextSize = WebSettings.TextSize.SMALLEST;
}
//Log.i("MobileAccessibility", "fontScale = " + zoom + ", WebSettings.TextSize = " + wTextSize.toString());
mWebView.getSettings().setTextSize(wTextSize);
try {
Method getSettings = mView.getClass().getMethod("getSettings");
Object wSettings = getSettings.invoke(mView);
Method setTextSize = wSettings.getClass().getMethod("setTextSize", WebSettings.TextSize.class);
setTextSize.invoke(wSettings, wTextSize);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}

View File

@@ -26,10 +26,14 @@ import android.annotation.TargetApi;
import android.os.Build;
import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener;
import java.lang.IllegalAccessException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public class IceCreamSandwichMobileAccessibilityHelper extends
DonutMobileAccessibilityHelper {
protected AccessibilityStateChangeListener mAccessibilityStateChangeListener;
private AccessibilityStateChangeListener mAccessibilityStateChangeListener;
@Override
public boolean isScreenReaderRunning() {
@@ -52,17 +56,44 @@ public class IceCreamSandwichMobileAccessibilityHelper extends
@Override
public double getTextZoom() {
return mWebView.getSettings().getTextZoom();
double zoom = 100;
try {
Method getSettings = mView.getClass().getMethod("getSettings");
Object wSettings = getSettings.invoke(mView);
Method getTextZoom = wSettings.getClass().getMethod("getTextZoom");
zoom = Double.valueOf(getTextZoom.invoke(wSettings).toString());
} catch (ClassCastException ce) {
ce.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return zoom;
}
@Override
public void setTextZoom(double textZoom) {
final double zoom = textZoom;
//Log.i("MobileAccessibility", "setTextZoom(" + zoom + ")");
mWebView.getSettings().setTextZoom((int) zoom);
try {
Method getSettings = mView.getClass().getMethod("getSettings");
Object wSettings = getSettings.invoke(mView);
Method setTextZoom = wSettings.getClass().getMethod("setTextZoom", Integer.TYPE);
setTextZoom.invoke(wSettings, (int) textZoom);
} catch (ClassCastException ce) {
ce.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
protected class InternalAccessibilityStateChangeListener
private class InternalAccessibilityStateChangeListener
implements AccessibilityStateChangeListener {
@Override

View File

@@ -26,11 +26,6 @@ import com.phonegap.plugin.mobileaccessibility.MobileAccessibility;
import android.annotation.TargetApi;
import android.os.Build;
import android.view.accessibility.AccessibilityEvent;
import android.webkit.WebView;
import java.lang.IllegalAccessException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public class JellyBeanMobileAccessibilityHelper extends
@@ -38,26 +33,8 @@ public class JellyBeanMobileAccessibilityHelper extends
@Override
public void initialize(MobileAccessibility mobileAccessibility) {
WebView view;
super.initialize(mobileAccessibility);
try {
view = (WebView) mobileAccessibility.webView;
mParent = view.getParentForAccessibility();
} catch(ClassCastException ce) { // cordova-android 4.0+
try {
Method getView = mobileAccessibility.webView.getClass().getMethod("getView");
view = (WebView) getView.invoke(mobileAccessibility.webView);
mParent = view.getParentForAccessibility();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
mParent = mView.getParentForAccessibility();
}
@Override
@@ -66,10 +43,10 @@ public class JellyBeanMobileAccessibilityHelper extends
mAccessibilityManager.interrupt();
AccessibilityEvent event = AccessibilityEvent.obtain(
AccessibilityEvent.TYPE_ANNOUNCEMENT);
mWebView.onInitializeAccessibilityEvent(event);
mView.onInitializeAccessibilityEvent(event);
event.getText().add(text);
event.setContentDescription(null);
mParent.requestSendAccessibilityEvent(mWebView, event);
mParent.requestSendAccessibilityEvent(mView, event);
}
}
}

View File

@@ -31,9 +31,9 @@ import android.view.accessibility.CaptioningManager.CaptioningChangeListener;
@TargetApi(19)
public class KitKatMobileAccessibilityHelper extends
JellyBeanMobileAccessibilityHelper {
protected CaptioningManager mCaptioningManager;
protected CaptioningChangeListener mCaptioningChangeListener;
protected TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
private CaptioningManager mCaptioningManager;
private CaptioningChangeListener mCaptioningChangeListener;
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
@Override
public void initialize(MobileAccessibility mobileAccessibility) {
@@ -61,7 +61,6 @@ public class KitKatMobileAccessibilityHelper extends
super.addStateChangeListeners();
if (mCaptioningChangeListener == null) {
mCaptioningChangeListener = new CaptioningChangeListener() {
/** @hide */
@Override
public void onEnabledChanged(boolean enabled) {
onCaptioningEnabledChanged(enabled);
@@ -89,7 +88,7 @@ public class KitKatMobileAccessibilityHelper extends
}
}
protected class InternalTouchExplorationStateChangeListener
private class InternalTouchExplorationStateChangeListener
implements TouchExplorationStateChangeListener {
@Override

View File

@@ -41,13 +41,13 @@ import java.lang.reflect.Method;
* This class provides information on the status of native accessibility services to JavaScript.
*/
public class MobileAccessibility extends CordovaPlugin {
protected AbstractMobileAccessibilityHelper mMobileAccessibilityHelper;
protected CallbackContext mCallbackContext = null;
protected boolean mIsScreenReaderRunning = false;
protected boolean mClosedCaptioningEnabled = false;
protected boolean mTouchExplorationEnabled = false;
protected boolean mCachedIsScreenReaderRunning = false;
protected float mFontScale = 1;
private AbstractMobileAccessibilityHelper mMobileAccessibilityHelper;
private CallbackContext mCallbackContext = null;
private boolean mIsScreenReaderRunning = false;
private boolean mClosedCaptioningEnabled = false;
private boolean mTouchExplorationEnabled = false;
private boolean mCachedIsScreenReaderRunning = false;
private float mFontScale = 1;
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
@@ -144,8 +144,8 @@ public class MobileAccessibility extends CordovaPlugin {
} catch(ClassCastException ce) { // cordova-android 4.0+
try { // cordova-android 4.0+
Method getView = webView.getClass().getMethod("getView");
view = (WebView) getView.invoke(webView);
view.reload();
Method reload = getView.invoke(webView).getClass().getMethod("reload");
reload.invoke(webView);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
@@ -166,14 +166,13 @@ public class MobileAccessibility extends CordovaPlugin {
stop();
}
protected boolean isScreenReaderRunning(final CallbackContext callbackContext) {
private void isScreenReaderRunning(final CallbackContext callbackContext) {
mIsScreenReaderRunning = mMobileAccessibilityHelper.isScreenReaderRunning();
cordova.getThreadPool().execute(new Runnable() {
public void run() {
callbackContext.success(mIsScreenReaderRunning ? 1 : 0);
}
});
return mIsScreenReaderRunning;
}
protected boolean isScreenReaderRunning() {
@@ -181,14 +180,13 @@ public class MobileAccessibility extends CordovaPlugin {
return mIsScreenReaderRunning;
}
protected boolean isClosedCaptioningEnabled(final CallbackContext callbackContext) {
private void isClosedCaptioningEnabled(final CallbackContext callbackContext) {
mClosedCaptioningEnabled = mMobileAccessibilityHelper.isClosedCaptioningEnabled();
cordova.getThreadPool().execute(new Runnable() {
public void run() {
callbackContext.success(mClosedCaptioningEnabled ? 1 : 0);
}
});
return mClosedCaptioningEnabled;
}
protected boolean isClosedCaptioningEnabled() {
@@ -196,14 +194,13 @@ public class MobileAccessibility extends CordovaPlugin {
return mClosedCaptioningEnabled;
}
protected boolean isTouchExplorationEnabled(final CallbackContext callbackContext) {
private void isTouchExplorationEnabled(final CallbackContext callbackContext) {
mTouchExplorationEnabled= mMobileAccessibilityHelper.isTouchExplorationEnabled();
cordova.getThreadPool().execute(new Runnable() {
public void run() {
callbackContext.success(mTouchExplorationEnabled ? 1 : 0);
}
});
return mTouchExplorationEnabled;
}
protected boolean isTouchExplorationEnabled() {
@@ -211,7 +208,7 @@ public class MobileAccessibility extends CordovaPlugin {
return mTouchExplorationEnabled;
}
protected void announceForAccessibility(CharSequence text, final CallbackContext callbackContext) {
private void announceForAccessibility(CharSequence text, final CallbackContext callbackContext) {
mMobileAccessibilityHelper.announceForAccessibility(text);
if (callbackContext != null) {
JSONObject info = new JSONObject();
@@ -252,7 +249,7 @@ public class MobileAccessibility extends CordovaPlugin {
});
}
public void getTextZoom(final CallbackContext callbackContext) {
private void getTextZoom(final CallbackContext callbackContext) {
cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
final double textZoom = mMobileAccessibilityHelper.getTextZoom();
@@ -263,13 +260,13 @@ public class MobileAccessibility extends CordovaPlugin {
});
}
public void setTextZoom(final double textZoom, final CallbackContext callbackContext) {
private void setTextZoom(final double textZoom, final CallbackContext callbackContext) {
cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
mMobileAccessibilityHelper.setTextZoom(textZoom);
if (callbackContext != null) {
callbackContext.success((int) mMobileAccessibilityHelper.getTextZoom());
};
}
}
});
}
@@ -282,7 +279,7 @@ public class MobileAccessibility extends CordovaPlugin {
});
}
public void updateTextZoom(final CallbackContext callbackContext) {
private void updateTextZoom(final CallbackContext callbackContext) {
float fontScale = cordova.getActivity().getResources().getConfiguration().fontScale;
if (fontScale != mFontScale) {
mFontScale = fontScale;
@@ -291,7 +288,7 @@ public class MobileAccessibility extends CordovaPlugin {
setTextZoom(textZoom, callbackContext);
}
protected void sendMobileAccessibilityStatusChangedCallback() {
private void sendMobileAccessibilityStatusChangedCallback() {
if (this.mCallbackContext != null) {
PluginResult result = new PluginResult(PluginResult.Status.OK, getMobileAccessibilityStatus());
result.setKeepCallback(true);
@@ -300,7 +297,7 @@ public class MobileAccessibility extends CordovaPlugin {
}
/* Get the current mobile accessibility status. */
protected JSONObject getMobileAccessibilityStatus() {
private JSONObject getMobileAccessibilityStatus() {
JSONObject status = new JSONObject();
try {
status.put("isScreenReaderRunning", mIsScreenReaderRunning);
@@ -315,14 +312,14 @@ public class MobileAccessibility extends CordovaPlugin {
return status;
}
protected void start(CallbackContext callbackContext) {
private void start(CallbackContext callbackContext) {
//Log.i("MobileAccessibility", "MobileAccessibility.start");
mCallbackContext = callbackContext;
mMobileAccessibilityHelper.addStateChangeListeners();
sendMobileAccessibilityStatusChangedCallback();
}
protected void stop() {
private void stop() {
//Log.i("MobileAccessibility", "MobileAccessibility.stop");
if (mCallbackContext != null) {
sendMobileAccessibilityStatusChangedCallback();

View File

@@ -26,28 +26,52 @@ static const int BASE_UI_FONT_TEXT_STYLE_BODY_POINT_SIZE = 16;
@interface CDVMobileAccessibility : CDVPlugin {
NSString* callbackId;
NSString* commandCallbackId;
BOOL voiceOverRunning;
BOOL boldTextEnabled;
BOOL closedCaptioningEnabled;
BOOL darkerSystemColorsEnabled;
BOOL grayscaleEnabled;
BOOL guidedAccessEnabled;
BOOL invertColorsEnabled;
BOOL monoAudioEnabled;
BOOL reduceMotionEnabled;
BOOL reduceTransparencyEnabled;
BOOL speakScreenEnabled;
BOOL speakSelectionEnabled;
BOOL switchControlRunning;
BOOL voiceOverRunning;
}
@property (strong) NSString* callbackId;
@property (strong) NSString* commandCallbackId;
@property BOOL voiceOverRunning;
@property BOOL boldTextEnabled;
@property BOOL closedCaptioningEnabled;
@property BOOL darkerSystemColorsEnabled;
@property BOOL grayscaleEnabled;
@property BOOL guidedAccessEnabled;
@property BOOL invertColorsEnabled;
@property BOOL monoAudioEnabled;
@property BOOL reduceMotionEnabled;
@property BOOL reduceTransparencyEnabled;
@property BOOL speakScreenEnabled;
@property BOOL speakSelectionEnabled;
@property BOOL switchControlRunning;
@property BOOL voiceOverRunning;
@property double mFontScale;
- (void) isScreenReaderRunning:(CDVInvokedUrlCommand*)command;
- (void) isBoldTextEnabled:(CDVInvokedUrlCommand*)command;
- (void) isClosedCaptioningEnabled:(CDVInvokedUrlCommand*)command;
- (void) isDarkerSystemColorsEnabled:(CDVInvokedUrlCommand*)command;
- (void) isGrayscaleEnabled:(CDVInvokedUrlCommand*)command;
- (void) isGuidedAccessEnabled:(CDVInvokedUrlCommand*)command;
- (void) isInvertColorsEnabled:(CDVInvokedUrlCommand*)command;
- (void) isMonoAudioEnabled:(CDVInvokedUrlCommand*)command;
- (void) isReduceMotionEnabled:(CDVInvokedUrlCommand*)command;
- (void) isReduceTransparencyEnabled:(CDVInvokedUrlCommand*)command;
- (void) isScreenReaderRunning:(CDVInvokedUrlCommand*)command;
- (void) isSpeakScreenEnabled:(CDVInvokedUrlCommand*)command;
- (void) isSpeakSelectionEnabled:(CDVInvokedUrlCommand*)command;
- (void) isSwitchControlRunning:(CDVInvokedUrlCommand*)command;
- (void) getTextZoom:(CDVInvokedUrlCommand*)command;
- (void) setTextZoom:(CDVInvokedUrlCommand*)command;
- (void) updateTextZoom:(CDVInvokedUrlCommand*)command;
@@ -55,6 +79,4 @@ static const int BASE_UI_FONT_TEXT_STYLE_BODY_POINT_SIZE = 16;
- (void) start:(CDVInvokedUrlCommand*)command;
- (void) stop:(CDVInvokedUrlCommand*)command;
@end
@end

View File

@@ -33,14 +33,23 @@
@synthesize callbackId;
@synthesize commandCallbackId;
@synthesize voiceOverRunning;
@synthesize boldTextEnabled;
@synthesize closedCaptioningEnabled;
@synthesize darkerSystemColorsEnabled;
@synthesize grayscaleEnabled;
@synthesize guidedAccessEnabled;
@synthesize invertColorsEnabled;
@synthesize monoAudioEnabled;
@synthesize reduceMotionEnabled;
@synthesize reduceTransparencyEnabled;
@synthesize speakScreenEnabled;
@synthesize speakSelectionEnabled;
@synthesize switchControlRunning;
@synthesize voiceOverRunning;
@synthesize mFontScale;
#define iOS7Delta (([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 ) ? 20 : 0 )
#define iOS8Delta (([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0 ) ? 30 : 0 )
// //////////////////////////////////////////////////
@@ -104,11 +113,15 @@
#pragma Plugin interface
- (void)isScreenReaderRunning:(CDVInvokedUrlCommand*)command
- (void)isBoldTextEnabled:(CDVInvokedUrlCommand*)command
{
[self.commandDelegate runInBackground:^{
self.voiceOverRunning = UIAccessibilityIsVoiceOverRunning();
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.voiceOverRunning];
if (iOS8Delta) {
self.boldTextEnabled = UIAccessibilityIsBoldTextEnabled();
} else {
self.boldTextEnabled = false;
}
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.boldTextEnabled];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}];
}
@@ -122,6 +135,32 @@
}];
}
- (void)isDarkerSystemColorsEnabled:(CDVInvokedUrlCommand*)command
{
[self.commandDelegate runInBackground:^{
if (iOS8Delta) {
self.darkerSystemColorsEnabled = UIAccessibilityDarkerSystemColorsEnabled();
} else {
self.darkerSystemColorsEnabled = false;
}
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.darkerSystemColorsEnabled];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}];
}
- (void)isGrayscaleEnabled:(CDVInvokedUrlCommand*)command
{
[self.commandDelegate runInBackground:^{
if (iOS8Delta) {
self.grayscaleEnabled = UIAccessibilityIsGrayscaleEnabled();
} else {
self.grayscaleEnabled = false;
}
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.grayscaleEnabled];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}];
}
- (void)isGuidedAccessEnabled:(CDVInvokedUrlCommand*)command
{
[self.commandDelegate runInBackground:^{
@@ -149,6 +188,80 @@
}];
}
- (void)isReduceMotionEnabled:(CDVInvokedUrlCommand*)command
{
[self.commandDelegate runInBackground:^{
if (iOS8Delta) {
self.reduceMotionEnabled = UIAccessibilityIsReduceMotionEnabled();
} else {
self.reduceMotionEnabled = false;
}
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.reduceMotionEnabled];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}];
}
- (void)isReduceTransparencyEnabled:(CDVInvokedUrlCommand*)command
{
[self.commandDelegate runInBackground:^{
if (iOS8Delta) {
self.reduceTransparencyEnabled = UIAccessibilityIsReduceTransparencyEnabled();
} else {
self.reduceTransparencyEnabled = false;
}
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.reduceTransparencyEnabled];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}];
}
- (void)isScreenReaderRunning:(CDVInvokedUrlCommand*)command
{
[self.commandDelegate runInBackground:^{
self.voiceOverRunning = UIAccessibilityIsVoiceOverRunning();
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.voiceOverRunning];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}];
}
- (void)isSpeakScreenEnabled:(CDVInvokedUrlCommand*)command
{
[self.commandDelegate runInBackground:^{
if (iOS8Delta) {
self.speakScreenEnabled = UIAccessibilityIsSpeakScreenEnabled();
} else {
self.speakScreenEnabled = false;
}
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.speakScreenEnabled];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}];
}
- (void)isSpeakSelectionEnabled:(CDVInvokedUrlCommand*)command
{
[self.commandDelegate runInBackground:^{
if (iOS8Delta) {
self.speakSelectionEnabled = UIAccessibilityIsSpeakSelectionEnabled();
} else {
self.speakSelectionEnabled = false;
}
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.speakSelectionEnabled];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}];
}
- (void)isSwitchControlRunning:(CDVInvokedUrlCommand*)command
{
[self.commandDelegate runInBackground:^{
if (iOS8Delta) {
self.switchControlRunning = UIAccessibilityIsSwitchControlRunning();
} else {
self.switchControlRunning = false;
}
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.switchControlRunning];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}];
}
-(double) mGetFontScale
{
double fontScale = 1;
@@ -180,7 +293,7 @@
mFontScale = zoom/100;
if (iOS7Delta) {
NSString *jsString = [[NSString alloc] initWithFormat:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '%f%%'", zoom];
[[self webView] stringByEvaluatingJavaScriptFromString:jsString];
[self.commandDelegate evalJs:jsString];
}
}
@@ -215,7 +328,6 @@
}
}
- (void)postNotification:(CDVInvokedUrlCommand *)command
{
CDVPluginResult* result = nil;
@@ -225,7 +337,6 @@
if (notificationString == nil) {
notificationString = @"";
}
if (UIAccessibilityIsVoiceOverRunning() &&
[self isValidNotificationType:notificationType]) {
[self.commandDelegate runInBackground:^{
@@ -304,18 +415,34 @@
/* Get the current mobile accessibility status. */
- (NSDictionary*)getMobileAccessibilityStatus
{
self.voiceOverRunning = UIAccessibilityIsVoiceOverRunning();
self.boldTextEnabled = UIAccessibilityIsBoldTextEnabled();
self.closedCaptioningEnabled = [self getClosedCaptioningEnabledStatus];
self.darkerSystemColorsEnabled = UIAccessibilityDarkerSystemColorsEnabled();
self.grayscaleEnabled = UIAccessibilityIsGrayscaleEnabled();
self.guidedAccessEnabled = UIAccessibilityIsGuidedAccessEnabled();
self.invertColorsEnabled = UIAccessibilityIsInvertColorsEnabled();
self.monoAudioEnabled = UIAccessibilityIsMonoAudioEnabled();
self.reduceMotionEnabled = UIAccessibilityIsReduceMotionEnabled();
self.reduceTransparencyEnabled = UIAccessibilityIsReduceTransparencyEnabled();
self.speakScreenEnabled = UIAccessibilityIsSpeakScreenEnabled();
self.speakSelectionEnabled = UIAccessibilityIsSpeakSelectionEnabled();
self.switchControlRunning = UIAccessibilityIsSwitchControlRunning();
self.voiceOverRunning = UIAccessibilityIsVoiceOverRunning();
NSMutableDictionary* mobileAccessibilityData = [NSMutableDictionary dictionaryWithCapacity:5];
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.voiceOverRunning] forKey:@"isScreenReaderRunning"];
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.boldTextEnabled] forKey:@"isBoldTextEnabled"];
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.closedCaptioningEnabled] forKey:@"isClosedCaptioningEnabled"];
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.darkerSystemColorsEnabled] forKey:@"isDarkerSystemColorsEnabled"];
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.grayscaleEnabled] forKey:@"isGrayscaleEnabled"];
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.guidedAccessEnabled] forKey:@"isGuidedAccessEnabled"];
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.invertColorsEnabled] forKey:@"isInvertColorsEnabled"];
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.monoAudioEnabled] forKey:@"isMonoAudioEnabled"];
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.reduceMotionEnabled] forKey:@"isReduceMotionEnabled"];
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.reduceTransparencyEnabled] forKey:@"isReduceTransparencyEnabled"];
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.speakScreenEnabled] forKey:@"isSpeakScreenEnabled"];
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.speakSelectionEnabled] forKey:@"isSpeakSelectionEnabled"];
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.switchControlRunning] forKey:@"isSwitchControlRunning"];
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.voiceOverRunning] forKey:@"isScreenReaderRunning"];
return mobileAccessibilityData;
}
@@ -325,11 +452,22 @@
{
[self.commandDelegate runInBackground:^{
self.callbackId = command.callbackId;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilityVoiceOverStatusChanged object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilityClosedCaptioningStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilityGuidedAccessStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilityInvertColorsStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilityMonoAudioStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilityVoiceOverStatusChanged object:nil];
if (iOS8Delta) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilityBoldTextStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilityDarkerSystemColorsStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilityGrayscaleStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilityReduceMotionStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilityReduceTransparencyStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilitySpeakScreenStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilitySpeakSelectionStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilitySwitchControlStatusDidChangeNotification object:nil];
}
// Update the callback on start
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self getMobileAccessibilityStatus]];
@@ -350,12 +488,23 @@
[self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
}
self.callbackId = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityVoiceOverStatusChanged object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityClosedCaptioningStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityGuidedAccessStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityInvertColorsStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityAnnouncementDidFinishNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityMonoAudioStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityVoiceOverStatusChanged object:nil];
if (iOS8Delta) {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityBoldTextStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityDarkerSystemColorsStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityGrayscaleStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityReduceMotionStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityReduceTransparencyStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilitySpeakScreenStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilitySpeakSelectionStatusDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilitySwitchControlStatusDidChangeNotification object:nil];
}
}];
}

View File

@@ -29,7 +29,15 @@ module.exports = {
GUIDED_ACCESS_STATUS_CHANGED : "guidedaccessstatuschanged",
INVERT_COLORS_STATUS_CHANGED : "invertcolorsstatuschanged",
MONO_AUDIO_STATUS_CHANGED : "monoaudiostatuschanged",
REDUCE_MOTION_STATUS_CHANGED : "reducemotionstatuschanged",
TOUCH_EXPLORATION_STATUS_CHANGED : "touchexplorationstatechanged",
BOLD_TEXT_STATUS_CHANGED : "boldtextstatuschanged",
DARKER_SYSTEM_COLORS_STATUS_CHANGED : "darkersystemcolorsstatuschanged",
GRAYSCALE_STATUS_CHANGED : "grayscalestatuschanged",
REDUCE_TRANSPARENCY_STATUS_CHANGED : "reducetransparencystatuschanged",
SPEAK_SCREEN_STATUS_CHANGED : "speakscreenstatuschanged",
SPEAK_SELECTION_STATUS_CHANGED : "speakselectionstatuschanged",
SWITCH_CONTROL_STATUS_CHANGED : "switchcontrolstatuschanged",
/* iOS specific UIAccessibilityNotifications */
SCREEN_CHANGED : 1000,

View File

@@ -28,11 +28,19 @@ var argscheck = require('cordova/argscheck'),
MobileAccessibilityNotifications = require('phonegap-plugin-mobile-accessibility.MobileAccessibilityNotifications');
var MobileAccessibility = function() {
this._isScreenReaderRunning = false;
this._isBoldTextEnabled = false;
this._isClosedCaptioningEnabled = false;
this._isDarkerSystemColorsEnabled = false;
this._isGrayscaleEnabled = false;
this._isGuidedAccessEnabled = false;
this._isInvertColorsEnabled = false;
this._isMonoAudioEnabled = false;
this._isReduceMotionEnabled = false;
this._isReduceTransparencyEnabled = false;
this._isScreenReaderRunning = false;
this._isSpeakScreenEnabled = false;
this._isSpeakSelectionEnabled = false;
this._isSwitchControlRunning = false;
this._isTouchExplorationEnabled = false;
this._usePreferredTextZoom = false;
this._isHighContrastEnabled = false;
@@ -40,11 +48,19 @@ var MobileAccessibility = function() {
// Create new event handlers on the window (returns a channel instance)
this.channels = {
screenreaderstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.SCREEN_READER_STATUS_CHANGED),
boldtextstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.BOLD_TEXT_STATUS_CHANGED),
closedcaptioningstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.CLOSED_CAPTIONING_STATUS_CHANGED),
darkersystemcolorsstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.DARKER_SYSTEM_COLORS_STATUS_CHANGED),
grayscalestatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.GRAYSCALE_STATUS_CHANGED),
guidedaccessstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.GUIDED_ACCESS_STATUS_CHANGED),
invertcolorsstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.INVERT_COLORS_STATUS_CHANGED),
monoaudiostatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.MONO_AUDIO_STATUS_CHANGED),
reducemotionstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.REDUCE_MOTION_STATUS_CHANGED),
reducetransparencystatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.REDUCE_TRANSPARENCY_STATUS_CHANGED),
screenreaderstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.SCREEN_READER_STATUS_CHANGED),
speakscreenstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.SPEAK_SCREEN_STATUS_CHANGED),
speakselectionstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.SPEAK_SELECTION_STATUS_CHANGED),
switchcontrolstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.SWITCH_CONTROL_STATUS_CHANGED),
touchexplorationstatechanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.TOUCH_EXPLORATION_STATUS_CHANGED),
highcontrastchanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.HIGH_CONTRAST_CHANGED)
};
@@ -58,11 +74,19 @@ var MobileAccessibility = function() {
* @ignore
*/
function handlers() {
return mobileAccessibility.channels.screenreaderstatuschanged.numHandlers +
return mobileAccessibility.channels.boldtextstatuschanged.numHandlers +
mobileAccessibility.channels.closedcaptioningstatuschanged.numHandlers +
mobileAccessibility.channels.darkersystemcolorsstatuschanged.numHandlers +
mobileAccessibility.channels.grayscalestatuschanged.numHandlers +
mobileAccessibility.channels.guidedaccessstatuschanged.numHandlers +
mobileAccessibility.channels.invertcolorsstatuschanged.numHandlers +
mobileAccessibility.channels.monoaudiostatuschanged.numHandlers +
mobileAccessibility.channels.guidedaccessstatuschanged.numHandlers +
mobileAccessibility.channels.reducemotionstatuschanged.numHandlers +
mobileAccessibility.channels.reducetransparencystatuschanged.numHandlers +
mobileAccessibility.channels.screenreaderstatuschanged.numHandlers +
mobileAccessibility.channels.speakscreenstatuschanged.numHandlers +
mobileAccessibility.channels.speakselectionstatuschanged.numHandlers +
mobileAccessibility.channels.switchcontrolstatuschanged.numHandlers +
mobileAccessibility.channels.touchexplorationstatechanged.numHandlers +
mobileAccessibility.channels.highcontrastchanged.numHandlers;
};
@@ -172,13 +196,45 @@ MobileAccessibility.prototype.injectLocalAndroidVoxScript = function() {
};
/**
* Asynchronous call to native MobileAccessibility to determine if closed captioning is enabled.
* Asynchronous call to native MobileAccessibility to determine if Bold Text is enabled.
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility.
*/
MobileAccessibility.prototype.isBoldTextEnabled = function(callback) {
exec(callback, null, "MobileAccessibility", "isBoldTextEnabled", []);
};
/**
* Asynchronous call to native MobileAccessibility to determine if Closed Captioning is enabled.
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility.
*/
MobileAccessibility.prototype.isClosedCaptioningEnabled = function(callback) {
exec(callback, null, "MobileAccessibility", "isClosedCaptioningEnabled", []);
};
/**
* Asynchronous call to native MobileAccessibility to determine if Darker System Colors are enabled.
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility.
*/
MobileAccessibility.prototype.isDarkerSystemColorsEnabled = function(callback) {
exec(callback, null, "MobileAccessibility", "isDarkerSystemColorsEnabled", []);
};
/**
* Asynchronous call to native MobileAccessibility to determine if Grayscale is enabled.
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility.
*/
MobileAccessibility.prototype.isGrayscaleEnabled = function(callback) {
exec(callback, null, "MobileAccessibility", "isGrayscaleEnabled", []);
};
/**
* Asynchronous call to native MobileAccessibility to determine if Guided Access is enabled.
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility.
*/
MobileAccessibility.prototype.isGuidedAccessEnabled = function(callback) {
exec(callback, null, "MobileAccessibility", "isGuidedAccessEnabled", []);
};
/**
* Asynchronous call to native MobileAccessibility to determine if the display colors have been inverted.
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility.
@@ -188,7 +244,7 @@ MobileAccessibility.prototype.isInvertColorsEnabled = function(callback) {
};
/**
* Asynchronous call to native MobileAccessibility to determine if mono audio is enabled.
* Asynchronous call to native MobileAccessibility to determine if Mono Audio is enabled.
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility.
*/
MobileAccessibility.prototype.isMonoAudioEnabled = function(callback) {
@@ -196,11 +252,43 @@ MobileAccessibility.prototype.isMonoAudioEnabled = function(callback) {
};
/**
* Asynchronous call to native MobileAccessibility to determine if Guided Access is enabled.
* Asynchronous call to native MobileAccessibility to determine if Reduce Motion is enabled.
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility.
*/
MobileAccessibility.prototype.isGuidedAccessEnabled = function(callback) {
exec(callback, null, "MobileAccessibility", "isGuidedAccessEnabled", []);
MobileAccessibility.prototype.isReduceMotionEnabled = function(callback) {
exec(callback, null, "MobileAccessibility", "isReduceMotionEnabled", []);
};
/**
* Asynchronous call to native MobileAccessibility to determine if Reduce Transparency is enabled.
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility.
*/
MobileAccessibility.prototype.isReduceTransparencyEnabled = function(callback) {
exec(callback, null, "MobileAccessibility", "isReduceTransparencyEnabled", []);
};
/**
* Asynchronous call to native MobileAccessibility to determine if Speak Screen is enabled.
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility.
*/
MobileAccessibility.prototype.isSpeakScreenEnabled = function(callback) {
exec(callback, null, "MobileAccessibility", "isSpeakScreenEnabled", []);
};
/**
* Asynchronous call to native MobileAccessibility to determine if Speak Selection is enabled.
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility.
*/
MobileAccessibility.prototype.isSpeakSelectionEnabled = function(callback) {
exec(callback, null, "MobileAccessibility", "isSpeakSelectionEnabled", []);
};
/**
* Asynchronous call to native MobileAccessibility to determine if Switch Control is running.
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility.
*/
MobileAccessibility.prototype.isSwitchControlRunning = function(callback) {
exec(callback, null, "MobileAccessibility", "isSwitchControlRunning", []);
};
/**
@@ -255,11 +343,19 @@ MobileAccessibility.prototype.usePreferredTextZoom = function(bool) {
window.localStorage.setItem("MobileAccessibility.usePreferredTextZoom", bool);
}
document.removeEventListener("resume", mobileAccessibility.updateTextZoom);
var callback = function(){
// Wrapping updateTextZoom call in a function to stop
// the event parameter propagation. This fixes an error
// on resume where cordova tried to call apply() on the
// event, expecting a function.
mobileAccessibility.updateTextZoom();
};
document.removeEventListener("resume", callback);
if (bool) {
// console.log("We should update the text zoom at this point: " + bool)
document.addEventListener("resume", mobileAccessibility.updateTextZoom, false);
document.addEventListener("resume", callback, false);
mobileAccessibility.updateTextZoom();
} else {
mobileAccessibility.setTextZoom(100);
@@ -309,24 +405,40 @@ MobileAccessibility.prototype.stop = function() {
* Callback from native MobileAccessibility returning an object which describes the status of MobileAccessibility features.
*
* @param {Object} info
* @config {Boolean} [isScreenReaderRunning] Boolean to indicate screen reader status.
* @config {Boolean} [isBoldTextEnabled] Boolean to indicate bold text status (ios).
* @config {Boolean} [isClosedCaptioningEnabled] Boolean to indicate closed captioning status.
* @config {Boolean} [isDarkerSystemColorsEnabled] Boolean to indicate darker system colors status (ios).
* @config {Boolean} [isGrayscaleEnabled] Boolean to indicate grayscale status (ios).
* @config {Boolean} [isGuidedAccessEnabled] Boolean to indicate guided access status (ios).
* @config {Boolean} [isInvertColorsEnabled] Boolean to indicate invert colors status (ios).
* @config {Boolean} [isMonoAudioEnabled] Boolean to indicate mono audio status (ios).
* @config {Boolean} [isReduceMotionEnabled] Boolean to indicate reduce motion status (ios).
* @config {Boolean} [isReduceTransparencyEnabled] Boolean to indicate reduce transparency status (ios).
* @config {Boolean} [isScreenReaderRunning] Boolean to indicate screen reader status.
* @config {Boolean} [isSpeakScreenEnabled] Boolean to indicate speak screen status (ios).
* @config {Boolean} [isSpeakSelectionEnabled] Boolean to indicate speak selection status (ios).
* @config {Boolean} [isSwitchControlRunning] Boolean to indicate switch control status (ios).
* @config {Boolean} [isTouchExplorationEnabled] Boolean to indicate touch exploration status (android).
*/
MobileAccessibility.prototype._status = function(info) {
if (info) {
mobileAccessibility.activateOrDeactivateChromeVox(info.isScreenReaderRunning);
if (mobileAccessibility._isScreenReaderRunning !== info.isScreenReaderRunning) {
mobileAccessibility._isScreenReaderRunning = info.isScreenReaderRunning;
cordova.fireWindowEvent(MobileAccessibilityNotifications.SCREEN_READER_STATUS_CHANGED, info);
if (mobileAccessibility._isBoldTextEnabled !== info.isBoldTextEnabled) {
mobileAccessibility._isBoldTextEnabled = info.isBoldTextEnabled;
cordova.fireWindowEvent(MobileAccessibilityNotifications.BOLD_TEXT_STATUS_CHANGED, info);
}
if (mobileAccessibility._isClosedCaptioningEnabled !== info.isClosedCaptioningEnabled) {
mobileAccessibility._isClosedCaptioningEnabled = info.isClosedCaptioningEnabled;
cordova.fireWindowEvent(MobileAccessibilityNotifications.CLOSED_CAPTIONING_STATUS_CHANGED, info);
}
if (mobileAccessibility._isDarkerSystemColorsEnabled !== info.isDarkerSystemColorsEnabled) {
mobileAccessibility._isDarkerSystemColorsEnabled = info.isDarkerSystemColorsEnabled;
cordova.fireWindowEvent(MobileAccessibilityNotifications.DARKER_SYSTEM_COLORS_STATUS_CHANGED, info);
}
if (mobileAccessibility._isGrayscaleEnabled !== info.isGrayscaleEnabled) {
mobileAccessibility._isGrayscaleEnabled = info.isGrayscaleEnabled;
cordova.fireWindowEvent(MobileAccessibilityNotifications.GRAYSCALE_STATUS_CHANGED, info);
}
if (mobileAccessibility._isGuidedAccessEnabled !== info.isGuidedAccessEnabled) {
mobileAccessibility._isGuidedAccessEnabled = info.isGuidedAccessEnabled;
cordova.fireWindowEvent(MobileAccessibilityNotifications.GUIDED_ACCESS_STATUS_CHANGED, info);
@@ -339,6 +451,30 @@ MobileAccessibility.prototype._status = function(info) {
mobileAccessibility._isMonoAudioEnabled = info.isMonoAudioEnabled;
cordova.fireWindowEvent(MobileAccessibilityNotifications.MONO_AUDIO_STATUS_CHANGED, info);
}
if (mobileAccessibility._isReduceMotionEnabled !== info.isReduceMotionEnabled) {
mobileAccessibility._isReduceMotionEnabled = info.isReduceMotionEnabled;
cordova.fireWindowEvent(MobileAccessibilityNotifications.REDUCE_MOTION_STATUS_CHANGED, info);
}
if (mobileAccessibility._isReduceTransparencyEnabled !== info.isReduceTransparencyEnabled) {
mobileAccessibility._isReduceTransparencyEnabled = info.isReduceTransparencyEnabled;
cordova.fireWindowEvent(MobileAccessibilityNotifications.REDUCE_TRANSPARENCY_STATUS_CHANGED, info);
}
if (mobileAccessibility._isScreenReaderRunning !== info.isScreenReaderRunning) {
mobileAccessibility._isScreenReaderRunning = info.isScreenReaderRunning;
cordova.fireWindowEvent(MobileAccessibilityNotifications.SCREEN_READER_STATUS_CHANGED, info);
}
if (mobileAccessibility._isSpeakScreenEnabled !== info.isSpeakScreenEnabled) {
mobileAccessibility._isSpeakScreenEnabled = info.isSpeakScreenEnabled;
cordova.fireWindowEvent(MobileAccessibilityNotifications.SPEAK_SCREEN_STATUS_CHANGED, info);
}
if (mobileAccessibility._isSpeakSelectionEnabled !== info.isSpeakSelectionEnabled) {
mobileAccessibility._isSpeakSelectionEnabled = info.isSpeakSelectionEnabled;
cordova.fireWindowEvent(MobileAccessibilityNotifications.SPEAK_SELECTION_STATUS_CHANGED, info);
}
if (mobileAccessibility._isSwitchControlRunning !== info.isSwitchControlRunning) {
mobileAccessibility._isSwitchControlRunning = info.isSwitchControlRunning;
cordova.fireWindowEvent(MobileAccessibilityNotifications.SWITCH_CONTROL_STATUS_CHANGED, info);
}
if (mobileAccessibility._isTouchExplorationEnabled !== info.isTouchExplorationEnabled) {
mobileAccessibility._isTouchExplorationEnabled = info.isTouchExplorationEnabled;
cordova.fireWindowEvent(MobileAccessibilityNotifications.TOUCH_EXPLORATION_STATUS_CHANGED, info);