[Libreoffice-commits] online.git: android/app
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Feb 13 20:57:16 UTC 2019
android/app/src/main/cpp/androidapp.cpp | 18 +++++-----
android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java | 16 +++++---
2 files changed, 18 insertions(+), 16 deletions(-)
New commits:
commit 95827f3c1cf0f6b94820a78ae457b44f53dc1236
Author: Jan Holesovsky <kendy at collabora.com>
AuthorDate: Wed Feb 13 21:52:19 2019 +0100
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Wed Feb 13 21:52:43 2019 +0100
android: Actually attempt to load the file for real.
Hits an assert, no LOK is available.
Change-Id: I86b46ea2fcee41966f46ae7f54fe5a506aa7769a
diff --git a/android/app/src/main/cpp/androidapp.cpp b/android/app/src/main/cpp/androidapp.cpp
index 45aefd63d..f8e13260f 100644
--- a/android/app/src/main/cpp/androidapp.cpp
+++ b/android/app/src/main/cpp/androidapp.cpp
@@ -127,13 +127,13 @@ static char *js_result_as_gstring(WebKitJavascriptResult *js_result)
return nullptr;
#endif
}
+#endif
-// TODO handle the message from JS here
-static void handle_lool_message(WebKitUserContentManager *manager,
- WebKitJavascriptResult *js_result,
- gpointer user_data)
+/// Handle a message from JavaScript.
+extern "C" JNIEXPORT void JNICALL
+Java_org_libreoffice_androidapp_MainActivity_postMobileMessage(JNIEnv *env, jobject, jstring message)
{
- gchar *string_value = js_result_as_gstring(js_result);
+ const char *string_value = env->GetStringUTFChars(message, nullptr);
if (string_value)
{
@@ -188,7 +188,7 @@ static void handle_lool_message(WebKitUserContentManager *manager,
return;
std::vector<char> buf(n);
n = fakeSocketRead(fakeClientFd, buf.data(), n);
- send2JS(buf);
+ // TODO send2JS(buf);
}
}
else
@@ -234,17 +234,17 @@ static void handle_lool_message(WebKitUserContentManager *manager,
free(string_copy);
}).detach();
}
- g_free(string_value);
}
else
LOG_TRC_NOFILE("From JS: lool: some object");
}
-#endif
/// Create the LOOLWSD instance.
extern "C" JNIEXPORT void JNICALL
-Java_org_libreoffice_androidapp_MainActivity_createLOOLWSD(JNIEnv*, jobject)
+Java_org_libreoffice_androidapp_MainActivity_createLOOLWSD(JNIEnv *env, jobject, jstring loadFileURL)
{
+ fileURL = std::string(env->GetStringUTFChars(loadFileURL, nullptr));
+
Log::initialize("Mobile", "trace", false, false, {});
Util::setThreadName("main");
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java b/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java
index ae27334c6..dc594b924 100644
--- a/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java
+++ b/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java
@@ -28,7 +28,8 @@ public class MainActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
- createLOOLWSD();
+ String urlToLoad = "file:///android_asset/dist/hello-world.odt";
+ createLOOLWSD(urlToLoad);
final WebView browser = findViewById(R.id.browser);
browser.setWebViewClient(new WebViewClient());
@@ -38,7 +39,7 @@ public class MainActivity extends AppCompatActivity {
browser.addJavascriptInterface(this, "LOOLMessageHandler");
browser.loadUrl("file:///android_asset/dist/loleaflet.html?file_path=" +
- "file:///android_asset/dist/hello-world.odt" + // TODO the real URL here
+ urlToLoad +
"&closebutton=1&permission=edit" +
"&debug=true"); // TODO remove later?
@@ -55,19 +56,19 @@ public class MainActivity extends AppCompatActivity {
static {
System.loadLibrary("androidapp");
}
- public native void createLOOLWSD();
+
+ /** Initialize the LOOLWSD to load 'loadFileURL'. */
+ public native void createLOOLWSD(String loadFileURL);
/** Passing messages from JS (instead of the websocket communication). */
@JavascriptInterface
- public void postMobileMessage(String message)
- {
- Log.d(TAG, "postMobileMessage: " + message);
- }
+ public native void postMobileMessage(String message);
/** Passing messages from JS (instead of the websocket communication). */
@JavascriptInterface
public void postMobileError(String message)
{
+ // TODO handle this
Log.d(TAG, "postMobileError: " + message);
}
@@ -75,6 +76,7 @@ public class MainActivity extends AppCompatActivity {
@JavascriptInterface
public void postMobileDebug(String message)
{
+ // TODO handle this
Log.d(TAG, "postMobileDebug: " + message);
}
}
More information about the Libreoffice-commits
mailing list