Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

returns scale and nativescale values to define which type of zoom it is using #54

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "phonegap-plugin-mobile-accessibility",
"description": "PhoneGap Mobile Accessibility Plugin",
"version": "1.0.5",
"version": "1.0.10",
"homepage": "http://github.com/phonegap/phonegap-mobile-accessibility#readme",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Expand Up @@ -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.5-dev">
version="1.0.10-dev">
<name>Mobile Accessibility</name>
<description>PhoneGap Mobile Accessibility Plugin</description>
<license>Apache 2.0</license>
Expand Down
2 changes: 2 additions & 0 deletions src/ios/CDVMobileAccessibility.h
Expand Up @@ -78,5 +78,7 @@ static const int BASE_UI_FONT_TEXT_STYLE_BODY_POINT_SIZE = 16;
- (void) postNotification:(CDVInvokedUrlCommand*)command;
- (void) start:(CDVInvokedUrlCommand*)command;
- (void) stop:(CDVInvokedUrlCommand*)command;
- (void) getUIScreenNativeScale:(CDVInvokedUrlCommand*)command;
- (void) getUIScreenScale:(CDVInvokedUrlCommand*)command;

@end
20 changes: 20 additions & 0 deletions src/ios/CDVMobileAccessibility.m
Expand Up @@ -412,6 +412,26 @@ - (void)sendMobileAccessibilityStatusChangedCallback
}
}

- (void) getUIScreenNativeScale:(CDVInvokedUrlCommand *)command
{
double nativeScale = UIScreen.mainScreen.nativeScale;

[self.commandDelegate runInBackground:^{
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble: nativeScale];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}];
}

- (void) getUIScreenScale:(CDVInvokedUrlCommand *)command
{
double scale = UIScreen.mainScreen.scale;

[self.commandDelegate runInBackground:^{
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble: scale];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}];
}

/* Get the current mobile accessibility status. */
- (NSDictionary*)getMobileAccessibilityStatus
{
Expand Down
18 changes: 17 additions & 1 deletion www/mobile-accessibility.js
Expand Up @@ -307,11 +307,27 @@ MobileAccessibility.prototype.isHighContrastEnabled = function(callback) {
exec(callback, null, "MobileAccessibility", "isHighContrastEnabled", []);
};

/**
* Asynchronous call to native MobileAccessibility to return the current UIScreen.main.nativeScale value for the WebView.
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility.
*/
MobileAccessibility.prototype.getUIScreenNativeScale = function(callback) {
exec(callback, null, "MobileAccessibility", "getUIScreenNativeScale", []);
};

/**
* Asynchronous call to native MobileAccessibility to return the current UIScreen.main.scale value for the WebView.
* @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility.
*/
MobileAccessibility.prototype.getUIScreenScale = function(callback) {
exec(callback, null, "MobileAccessibility", "getUIScreenScale", []);
};

/**
* 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) {
MobileAccessibility.prototype.getTextZoom = function(callback) {
exec(callback, null, "MobileAccessibility", "getTextZoom", []);
};

Expand Down