зеркало из https://github.com/microsoft/ace.git
Expose ace.android.startActivity to JS
Cutting down on the app code needed
This commit is contained in:
Родитель
39ba00b48d
Коммит
34199c4622
|
@ -71,8 +71,6 @@ public class NativeHost extends CordovaPlugin {
|
|||
return id;
|
||||
}
|
||||
|
||||
// Can be used by third-party JavaScript to start an activity
|
||||
// TODO: Or just expose JavaScript API using Class.forName, etc.
|
||||
public static void startActivity(String name) {
|
||||
Class c = null;
|
||||
try {
|
||||
|
@ -80,8 +78,8 @@ public class NativeHost extends CordovaPlugin {
|
|||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException("Unable to find a class named '" + name + "'");
|
||||
}
|
||||
android.content.Intent intent = new android.content.Intent(NativeHost._activity, c);
|
||||
NativeHost._activity.startActivity(intent);
|
||||
android.content.Intent intent = new android.content.Intent(_activity, c);
|
||||
_activity.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -198,6 +196,9 @@ public class NativeHost extends CordovaPlugin {
|
|||
else if (action.equals("getAndroidId")) {
|
||||
this.getAndroidId(args.getString(0), callbackContext);
|
||||
}
|
||||
else if (action.equals("startAndroidActivity")) {
|
||||
this.startAndroidActivity(args.getString(0), callbackContext);
|
||||
}
|
||||
else if (action.equals("setPopupsCloseOnHtmlNavigation")) {
|
||||
this.setPopupsCloseOnHtmlNavigation(args.getBoolean(0), callbackContext);
|
||||
}
|
||||
|
@ -406,6 +407,12 @@ public class NativeHost extends CordovaPlugin {
|
|||
callbackContext.success(id);
|
||||
}
|
||||
|
||||
// Exposed to JavaScript
|
||||
public void startAndroidActivity(String name, CallbackContext callbackContext) {
|
||||
NativeHost.startActivity(name);
|
||||
callbackContext.success();
|
||||
}
|
||||
|
||||
void setPopupsCloseOnHtmlNavigation(boolean value, CallbackContext callbackContext) {
|
||||
_setting_PopupsCloseOnHtmlNavigation = value;
|
||||
callbackContext.success();
|
||||
|
|
|
@ -281,10 +281,6 @@ ToNative.loadPlatformSpecificMarkup = function (uri, onSuccess, onError) {
|
|||
exec(onSuccess, onError, "NativeHost", "loadPlatformSpecificMarkup", [uri]);
|
||||
};
|
||||
|
||||
ToNative.getAndroidId = function (name, onSuccess, onError) {
|
||||
exec(onSuccess, onError, "NativeHost", "getAndroidId", [name]);
|
||||
};
|
||||
|
||||
ToNative.isSupported = function (onSuccess, onError) {
|
||||
exec(onSuccess, onError, "NativeHost", "isSupported", []);
|
||||
};
|
||||
|
@ -297,4 +293,15 @@ ToNative.setPopupsCloseOnHtmlNavigation = function (bool, onSuccess, onError) {
|
|||
exec(onSuccess, onError, "NativeHost", "setPopupsCloseOnHtmlNavigation", [bool]);
|
||||
};
|
||||
|
||||
//
|
||||
// Android-specific entry points:
|
||||
//
|
||||
ToNative.getAndroidId = function (name, onSuccess, onError) {
|
||||
exec(onSuccess, onError, "NativeHost", "getAndroidId", [name]);
|
||||
};
|
||||
|
||||
ToNative.startAndroidActivity = function (name, onSuccess, onError) {
|
||||
exec(onSuccess, onError, "NativeHost", "startAndroidActivity", [name]);
|
||||
};
|
||||
|
||||
module.exports = ToNative;
|
||||
|
|
|
@ -48,6 +48,10 @@ module.exports = {
|
|||
ace.ToNative.getAndroidId(name, onSuccess, ace.ToNative.errorHandler(onError));
|
||||
},
|
||||
|
||||
startActivity: function (name, onSuccess, onError) {
|
||||
ace.ToNative.startAndroidActivity(name, onSuccess, ace.ToNative.errorHandler(onError));
|
||||
},
|
||||
|
||||
appWidget: {
|
||||
clear: function() {
|
||||
ace.NativeObject.invoke("run.ace.AppWidgetData", "clear");
|
||||
|
|
Загрузка…
Ссылка в новой задаче