+1
-0
@@ -27,2 +27,3 @@ #include <assert.h> | ||
| V("webViewDebuggingEnabled", bare_ndk_web_view_debugging_enabled) | ||
| V("webViewJavaScriptEnabled", bare_ndk_web_view_javascript_enabled) | ||
| V("webViewLoadURL", bare_ndk_web_view_load_url) | ||
@@ -29,0 +30,0 @@ V("webViewLoadData", bare_ndk_web_view_load_data) |
+1
-5
@@ -18,4 +18,2 @@ #pragma once | ||
| java_global_ref_t<java_class_t<"android/app/Activity">> init; | ||
| java_env_t java; | ||
@@ -32,4 +30,2 @@ }; | ||
| activity->init = java_class_t<"android/app/Activity">(activity->java); | ||
| activity->handle = java_object_t<"android/app/Activity">(activity->java, bare_native_activity->clazz); | ||
@@ -64,3 +60,3 @@ | ||
| auto set_content_view = activity->init.get_method<void(java_object_t<"android/view/View">)>("setContentView"); | ||
| auto set_content_view = activity->handle.get_class().get_method<void(java_object_t<"android/view/View">)>("setContentView"); | ||
@@ -67,0 +63,0 @@ set_content_view(activity->handle, view->handle); |
+35
-6
@@ -14,4 +14,2 @@ #pragma once | ||
| java_global_ref_t<java_class_t<"android/webkit/WebView">> init; | ||
| js_env_t *env; | ||
@@ -51,5 +49,5 @@ js_ref_t *ctx; | ||
| web_view->init = java_class_t<"android/webkit/WebView">(activity->java); | ||
| auto init = java_class_t<"android/webkit/WebView">(activity->java); | ||
| web_view->handle = web_view->init(java_object_t<"android/content/Context">(activity->java, activity->handle)); | ||
| web_view->handle = init(java_object_t<"android/content/Context">(activity->java, activity->handle)); | ||
@@ -96,2 +94,33 @@ err = js_create_reference(env, argv[1], 1, &web_view->ctx); | ||
| static js_value_t * | ||
| bare_ndk_web_view_javascript_enabled(js_env_t *env, js_callback_info_t *info) { | ||
| int err; | ||
| size_t argc = 2; | ||
| js_value_t *argv[2]; | ||
| err = js_get_callback_info(env, info, &argc, argv, nullptr, nullptr); | ||
| assert(err == 0); | ||
| assert(argc == 2); | ||
| bare_ndk_web_view_t *web_view; | ||
| err = js_get_value(env, js_external_t<bare_ndk_web_view_t>(argv[0]), web_view); | ||
| assert(err == 0); | ||
| bool enabled; | ||
| err = js_get_value(env, js_boolean_t(argv[1]), enabled); | ||
| assert(err == 0); | ||
| auto get_settings = web_view->handle.get_class().get_method<java_object_t<"android/webkit/WebSettings">()>("getSettings"); | ||
| auto settings = get_settings(web_view->handle); | ||
| auto set_javascript_enabled = settings.get_class().get_method<void(bool)>("setJavaScriptEnabled"); | ||
| set_javascript_enabled(settings, enabled); | ||
| return nullptr; | ||
| } | ||
| static js_value_t * | ||
| bare_ndk_web_view_load_url(js_env_t *env, js_callback_info_t *info) { | ||
@@ -116,3 +145,3 @@ int err; | ||
| auto load_url = web_view->init.get_method<void(std::string)>("loadUrl"); | ||
| auto load_url = web_view->handle.get_class().get_method<void(std::string)>("loadUrl"); | ||
@@ -160,3 +189,3 @@ load_url(web_view->handle, url); | ||
| auto load_data = web_view->init.get_method<void(std::string, std::string, std::string, std::string, std::string)>("loadDataWithBaseURL"); | ||
| auto load_data = web_view->handle.get_class().get_method<void(std::string, std::string, std::string, std::string, std::string)>("loadDataWithBaseURL"); | ||
@@ -163,0 +192,0 @@ load_data(web_view->handle, base_url, data, mime_type, encoding, history_url); |
+5
-0
@@ -17,2 +17,7 @@ const binding = require('../binding') | ||
| javaScriptEnabled(enabled = true) { | ||
| binding.webViewJavaScriptEnabled(this._handle, enabled) | ||
| return this | ||
| } | ||
| loadURL(url) { | ||
@@ -19,0 +24,0 @@ binding.webViewLoadURL(this._handle, url) |
+1
-1
| { | ||
| "name": "bare-ndk", | ||
| "version": "0.1.1", | ||
| "version": "0.1.2", | ||
| "description": "Android NDK bindings and runtime for Bare", | ||
@@ -5,0 +5,0 @@ "exports": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
102
4.08%343457787
0