mirror of
https://gitee.com/shuto-github/phonegap-mobile-accessibility.git
synced 2026-04-19 00:01:32 +08:00
Add support for adjusting text in the WebView to the preferred zoom scale on Android.
More robust iOS support is forthcoming, but currently works with iOS7
Dynamic Type Fonts by setting the following css on the body and using
relatively sized fonts sizing for child containers, for example:
body {
font: -apple-system-body;
}
body > .app {
font-family: 'HelveticaNeue-Light', 'HelveticaNeue', Helvetica,
Arial, sans-serif;
font-size:0.75em;
font-weight: 200;
}
This commit is contained in:
@@ -33,6 +33,7 @@ var MobileAccessibility = function() {
|
||||
this._isInvertColorsEnabled = false;
|
||||
this._isMonoAudioEnabled = false;
|
||||
this._isTouchExplorationEnabled = false;
|
||||
this._usePreferredTextZoom = false;
|
||||
// Create new event handlers on the window (returns a channel instance)
|
||||
this.channels = {
|
||||
screenreaderstatuschanged:cordova.addWindowEventHandler("screenreaderstatuschanged"),
|
||||
@@ -109,6 +110,22 @@ MobileAccessibility.prototype.activateOrDeactivateChromeVox = function(bool) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
if (bool) {
|
||||
if (!mobileAccessibility.hasOrientationChangeListener) {
|
||||
window.addEventListener("orientationchange", mobileAccessibility.onOrientationChange);
|
||||
mobileAccessibility.hasOrientationChangeListener = true;
|
||||
}
|
||||
} else if(mobileAccessibility.hasOrientationChangeListener) {
|
||||
window.removeEventListener("orientationchange", mobileAccessibility.onOrientationChange);
|
||||
mobileAccessibility.hasOrientationChangeListener = false;
|
||||
}
|
||||
};
|
||||
|
||||
MobileAccessibility.prototype.hasOrientationChangeListener = false;
|
||||
MobileAccessibility.prototype.onOrientationChange = function(event) {
|
||||
if (!mobileAccessibility.isChromeVoxActive()) return;
|
||||
cvox.ChromeVox.navigationManager.updateIndicator();
|
||||
};
|
||||
|
||||
MobileAccessibility.prototype.scriptInjected = false;
|
||||
@@ -176,6 +193,42 @@ MobileAccessibility.prototype.isTouchExplorationEnabled = function(callback) {
|
||||
exec(callback, null, "MobileAccessibility", "isTouchExplorationEnabled", []);
|
||||
};
|
||||
|
||||
MobileAccessibility.prototype.getTextZoom = function(callback) {
|
||||
exec(callback, null, "MobileAccessibility", "getTextZoom", []);
|
||||
};
|
||||
|
||||
MobileAccessibility.prototype.setTextZoom = function(textZoom, callback) {
|
||||
exec(callback, null, "MobileAccessibility", "setTextZoom", [textZoom]);
|
||||
};
|
||||
|
||||
MobileAccessibility.prototype.updateTextZoom = function() {
|
||||
exec(null, null, "MobileAccessibility", "updateTextZoom", []);
|
||||
};
|
||||
|
||||
MobileAccessibility.prototype.usePreferredTextZoom = function(bool) {
|
||||
var currentValue = window.localStorage.getItem("MobileAccessibility.usePreferredTextZoom") === "true";
|
||||
|
||||
if (arguments.length === 0) {
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
if (currentValue != bool) {
|
||||
window.localStorage.setItem("MobileAccessibility.usePreferredTextZoom", bool);
|
||||
}
|
||||
|
||||
document.removeEventListener("resume", mobileAccessibility.updateTextZoom);
|
||||
|
||||
if (bool) {
|
||||
// console.log("We should update the text zoom at this point: " + bool)
|
||||
document.addEventListener("resume", mobileAccessibility.updateTextZoom, false);
|
||||
mobileAccessibility.updateTextZoom();
|
||||
} else {
|
||||
mobileAccessibility.setTextZoom(100);
|
||||
}
|
||||
|
||||
return Boolean(bool);
|
||||
};
|
||||
|
||||
MobileAccessibility.prototype.MobileAccessibilityNotifications = {
|
||||
SCREEN_CHANGED : 1000,
|
||||
LAYOUT_CHANGED : 1001,
|
||||
|
||||
Reference in New Issue
Block a user