-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
184 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...dias/lib/android/plugins/phonegap-plugin-mobile-accessibility/www/mobile-accessibility.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
cordova.define("phonegap-plugin-mobile-accessibility.mobile-accessibility", function(require, exports, module) { | ||
var exec = require('cordova/exec'); | ||
|
||
var MobileAccessibility = function() { | ||
this._usePreferredTextZoom = false; | ||
}; | ||
|
||
/** | ||
* Asynchronous call to native MobileAccessibility to return the current text zoom percent value for the WebView. | ||
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. | ||
*/ | ||
MobileAccessibility.prototype.getTextZoom = function(callback) { | ||
exec(callback, null, "MobileAccessibility", "getTextZoom", []); | ||
}; | ||
|
||
MobileAccessibility.prototype.setFontScaleToOne = function(callback) { | ||
exec(callback, null, "MobileAccessibility", "setFontScaleToOne", []); | ||
}; | ||
|
||
/** | ||
* Asynchronous call to native MobileAccessibility to set the current text zoom percent value for the WebView. | ||
* @param {Number} textZoom A percentage value by which text in the WebView should be scaled. | ||
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. | ||
*/ | ||
MobileAccessibility.prototype.setTextZoom = function(textZoom, callback) { | ||
exec(callback, null, "MobileAccessibility", "setTextZoom", [textZoom]); | ||
}; | ||
|
||
/** | ||
* Asynchronous call to native MobileAccessibility to retrieve the user's preferred text zoom from system settings and apply it to the application WebView. | ||
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. | ||
*/ | ||
MobileAccessibility.prototype.updateTextZoom = function(callback) { | ||
exec(callback, 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); | ||
} | ||
|
||
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", callback, false); | ||
mobileAccessibility.updateTextZoom(); | ||
} else { | ||
mobileAccessibility.setTextZoom(100); | ||
mobileAccessibility.setFontScaleToOne(); | ||
} | ||
|
||
return Boolean(bool); | ||
}; | ||
|
||
var mobileAccessibility = new MobileAccessibility(); | ||
|
||
module.exports = mobileAccessibility; | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...p/medias/lib/ios/plugins/phonegap-plugin-mobile-accessibility/www/mobile-accessibility.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
cordova.define("phonegap-plugin-mobile-accessibility.mobile-accessibility", function(require, exports, module) { | ||
var exec = require('cordova/exec'); | ||
|
||
var MobileAccessibility = function() { | ||
this._usePreferredTextZoom = false; | ||
}; | ||
|
||
/** | ||
* Asynchronous call to native MobileAccessibility to return the current text zoom percent value for the WebView. | ||
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. | ||
*/ | ||
MobileAccessibility.prototype.getTextZoom = function(callback) { | ||
exec(callback, null, "MobileAccessibility", "getTextZoom", []); | ||
}; | ||
|
||
MobileAccessibility.prototype.setFontScaleToOne = function(callback) { | ||
exec(callback, null, "MobileAccessibility", "setFontScaleToOne", []); | ||
}; | ||
|
||
/** | ||
* Asynchronous call to native MobileAccessibility to set the current text zoom percent value for the WebView. | ||
* @param {Number} textZoom A percentage value by which text in the WebView should be scaled. | ||
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. | ||
*/ | ||
MobileAccessibility.prototype.setTextZoom = function(textZoom, callback) { | ||
exec(callback, null, "MobileAccessibility", "setTextZoom", [textZoom]); | ||
}; | ||
|
||
/** | ||
* Asynchronous call to native MobileAccessibility to retrieve the user's preferred text zoom from system settings and apply it to the application WebView. | ||
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. | ||
*/ | ||
MobileAccessibility.prototype.updateTextZoom = function(callback) { | ||
exec(callback, 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); | ||
} | ||
|
||
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", callback, false); | ||
mobileAccessibility.updateTextZoom(); | ||
} else { | ||
mobileAccessibility.setTextZoom(100); | ||
mobileAccessibility.setFontScaleToOne(); | ||
} | ||
|
||
return Boolean(bool); | ||
}; | ||
|
||
var mobileAccessibility = new MobileAccessibility(); | ||
|
||
module.exports = mobileAccessibility; | ||
|
||
}); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
onOpenMethodID:"B620101F-7C53-471B-AE3B-CBFD16D05767", | ||
typeid:43, | ||
uuid:"DA9286A0-7C85-4E70-B306-22ED1E9E9B93", | ||
version:"1.1.8" | ||
version:"1.2.0" |