22 Commits

Author SHA1 Message Date
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
Michael Jordan
6fb09a600d Update version to 1.0.1 2015-10-07 13:28:50 -04:00
Michael Jordan
415b357e9a Issue 20: android 3.7.2 broken after android 4.0 fix
Use reflection to check for CordovaWebView.getView interface method so
that we can still compile using cordova-android 3.7.2.
2015-09-28 10:52:54 -04:00
Michael Jordan
382ba4a835 Update version after creating tag at 1.0.0 2015-09-25 09:15:22 -04:00
Michael Jordan
435745aa91 Remove licensing notice from README.md 2015-09-25 09:06:32 -04:00
Michael Jordan
3256a29085 Bump version and reorder package.json
Trying to ensure that README.md data appears on npmjs.com
2015-09-25 08:50:33 -04:00
Michael Jordan
e9af64bc44 Issue 22: Please add package.json
Add package.json file and rename package id to follow npm convention.
2015-09-25 08:10:39 -04:00
Michael Jordan
3efce21dfd Merge pull request #18 from ajyong/master
Restore compatibility with Cordova Android 4.0+
2015-06-26 09:23:37 -04:00
Aaron Yong
37a7d11251 Restore compatibility with Cordova Android 4.0+
Fixes #17 and #13.  The WebView object is now accessed via a `getView()` method call on `CordovaWebView` objects.
2015-06-25 15:29:49 -06:00
Michael Jordan
b35a21f724 Merge pull request #14 from rromerogar/master
Fix issue 13
2015-04-30 09:27:17 -04:00
Raúl Romero García
852cec5240 Fix issue 13 2015-04-30 15:22:33 +02:00
Shazron Abdullah
2fb3aa4c2b Updated version to 0.1.3
This is for the dependency plugin rename
2015-04-20 10:55:08 -07:00
Shazron Abdullah
b8f90d3841 Merge pull request #9 from EddyVerbruggen/dependency-failure
Failed to load dependent plugins
2015-04-20 00:20:18 -07:00
EddyVerbruggen
d0db5b05b5 Failed to load dependent plugins 2015-04-19 21:28:13 +02:00
EddyVerbruggen
c924261c26 Failed to load dependent plugins 2015-04-19 21:13:33 +02:00
11 changed files with 207 additions and 94 deletions

View File

@@ -1,23 +1,4 @@
<!--
The following copyright message should appear at the top of all
source files. This file can be removed from your repository.
Copyright (c) 2013-2014 Adobe Systems Incorporated. All rights reserved.
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.
-->
# com.phonegap.plugin.mobile-accessibility
# phonegap-plugin-mobile-accessibility
==========================================
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.

37
package.json Normal file
View File

@@ -0,0 +1,37 @@
{
"name": "phonegap-plugin-mobile-accessibility",
"description": "PhoneGap Mobile Accessibility Plugin",
"version": "1.0.3",
"homepage": "http://github.com/phonegap/phonegap-mobile-accessibility#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/phonegap/phonegap-mobile-accessibility.git"
},
"bugs": {
"url": "https://github.com/phonegap/phonegap-mobile-accessibility/issues"
},
"cordova": {
"id": "phonegap-plugin-mobile-accessibility",
"platforms": [
"ios",
"android",
"windows"
]
},
"keywords": [
"phonegap",
"mobile accessibility",
"ecosystem:cordova",
"cordova-ios",
"cordova-android",
"cordova-windows"
],
"engines": [
{
"name": "cordova",
"version": ">=3.0.0"
}
],
"author": "Adobe PhoneGap Team",
"license": "Apache 2.0"
}

View File

@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:rim="http://www.blackberry.com/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
id="com.phonegap.plugin.mobile-accessibility"
version="0.1.2">
id="phonegap-plugin-mobile-accessibility"
version="1.0.3">
<name>Mobile Accessibility</name>
<description>PhoneGap Mobile Accessibility Plugin</description>
<license>Apache 2.0</license>
@@ -21,8 +20,8 @@
<clobbers target="MobileAccessibilityNotifications" />
</js-module>
<dependency id="org.apache.cordova.device" url="https://github.com/apache/cordova-plugin-device.git" />
<dependency id="org.apache.cordova.network-information" url="https://github.com/apache/cordova-plugin-network-information.git" />
<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" />
<!-- 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,19 +26,40 @@ 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;
import java.lang.IllegalAccessException;
import java.lang.reflect.InvocationTargetException;
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;
mWebView = mobileAccessibility.webView;
WebView view;
try {
view = (WebView) mobileAccessibility.webView;
mView = view;
} catch(ClassCastException ce) { // cordova-android 4.0+
try {
Method getView = mobileAccessibility.webView.getClass().getMethod("getView");
mView = (View) getView.invoke(mobileAccessibility.webView);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
mAccessibilityManager = (AccessibilityManager) mMobileAccessibility.cordova.getActivity().getSystemService(Context.ACCESSIBILITY_SERVICE);
}
@@ -89,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);
@@ -101,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;
@@ -109,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

@@ -34,7 +34,7 @@ public class JellyBeanMobileAccessibilityHelper extends
@Override
public void initialize(MobileAccessibility mobileAccessibility) {
super.initialize(mobileAccessibility);
mParent = mobileAccessibility.webView.getParentForAccessibility();
mParent = mView.getParentForAccessibility();
}
@Override
@@ -43,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

@@ -31,18 +31,23 @@ import org.json.JSONException;
import org.json.JSONObject;
import android.os.Build;
import android.webkit.WebView;
import java.lang.IllegalAccessException;
import java.lang.reflect.InvocationTargetException;
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) {
@@ -132,9 +137,25 @@ public class MobileAccessibility extends CordovaPlugin {
stop();
cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
webView.reload();
WebView view;
try {
view = (WebView) webView;
view.reload();
} catch(ClassCastException ce) { // cordova-android 4.0+
try { // cordova-android 4.0+
Method getView = webView.getClass().getMethod("getView");
Method reload = getView.invoke(webView).getClass().getMethod("reload");
reload.invoke(webView);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
});
}
});
}
}
@@ -145,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() {
@@ -160,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() {
@@ -175,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() {
@@ -190,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();
@@ -231,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();
@@ -242,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());
};
}
}
});
}
@@ -261,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;
@@ -270,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);
@@ -279,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);
@@ -294,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

@@ -180,7 +180,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];
}
}

View File

@@ -22,10 +22,10 @@
var argscheck = require('cordova/argscheck'),
utils = require('cordova/utils'),
exec = require('cordova/exec'),
device = require('org.apache.cordova.device.device'),
network = require('org.apache.cordova.network-information.network'),
connection = require('org.apache.cordova.network-information.Connection'),
MobileAccessibilityNotifications = require('com.phonegap.plugin.mobile-accessibility.MobileAccessibilityNotifications');
device = require('cordova-plugin-device.device'),
network = require('cordova-plugin-network-information.network'),
connection = require('cordova-plugin-network-information.Connection'),
MobileAccessibilityNotifications = require('phonegap-plugin-mobile-accessibility.MobileAccessibilityNotifications');
var MobileAccessibility = function() {
this._isScreenReaderRunning = false;
@@ -255,11 +255,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);