return whether ace is supported or not

This commit is contained in:
Frederik Bosch 2016-05-09 10:49:33 +02:00
Родитель ba5578f0c4
Коммит ecaa871119
4 изменённых файлов: 22 добавлений и 3 удалений

Просмотреть файл

@ -176,11 +176,11 @@ public class NativeHost extends CordovaPlugin {
// Do an Android version check
//
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
callbackContext.error("Unable to initialize the Ace plugin: Android version " +
android.os.Build.VERSION.RELEASE +
callbackContext.error("Unable to initialize the Ace plugin: Android version " +
android.os.Build.VERSION.RELEASE +
" is not yet supported. Marshmallow (6.0) or later is recommended, " +
" although KitKat (4.4) or later will also work.");
return true;
return true;
}
OutgoingMessages.setCallbackContext(callbackContext);
@ -205,6 +205,10 @@ public class NativeHost extends CordovaPlugin {
else if (action.equals("setPopupsCloseOnHtmlNavigation")) {
this.setPopupsCloseOnHtmlNavigation(args.getBoolean(0), callbackContext);
}
else if (action.equals("isSupported")) {
boolean supported = android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.KITKAT;
callbackContext.success(supported);
}
else {
return false;
}

Просмотреть файл

@ -282,6 +282,13 @@ BOOL _initialized;
}
}
// Returns if there is support for ace plugin
- (void)isSupported:(CDVInvokedUrlCommand*)command {
BOOL isSupported = true;
CDVPluginResult* r = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:isSupported];
[self.commandDelegate sendPluginResult:r callbackId:command.callbackId];
}
- (void) sendOutgoingMessage:(NSArray*)data {
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:data];
[pluginResult setKeepCallbackAsBool:YES];

Просмотреть файл

@ -291,6 +291,10 @@ ToNative.getAndroidId = function (name, onSuccess, onError) {
exec(onSuccess, onError, "NativeHost", "getAndroidId", [name]);
};
ToNative.isSupported = function (onSuccess, onError) {
exec(onSuccess, onError, "NativeHost", "isSupported", []);
};
ToNative.navigate = function (root, onSuccess, onError) {
exec(onSuccess, onError, "NativeHost", "navigate", [root.handle]);
};

Просмотреть файл

@ -42,6 +42,10 @@ module.exports = {
return platformValues[ace.platform.toLowerCase()];
},
isSupported: function (onSuccess, onError) {
return ace.ToNative.isSupported(onSuccess, onError);
},
navigate: function (urlOrUIElement, onNavigated, onNavigatingAway, onError) {
if (_oldNavigatingAwayHandler) {
_oldNavigatingAwayHandler(_oldRoot);