android: Perform the android-specific setup before initializing the LOK.
Change-Id: I935e6849dd41c5e66b768c7f2a79c139265c901f
This commit is contained in:
parent
66ac62429c
commit
835bb3db35
3 changed files with 37 additions and 4 deletions
|
@ -239,10 +239,14 @@ Java_org_libreoffice_androidapp_MainActivity_postMobileMessage(JNIEnv *env, jobj
|
|||
LOG_TRC_NOFILE("From JS: lool: some object");
|
||||
}
|
||||
|
||||
extern "C" jboolean libreofficekit_initialize(JNIEnv* env, jstring dataDir, jstring cacheDir, jstring apkFile, jobject assetManager);
|
||||
|
||||
/// Create the LOOLWSD instance.
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_org_libreoffice_androidapp_MainActivity_createLOOLWSD(JNIEnv *env, jobject, jstring loadFileURL)
|
||||
Java_org_libreoffice_androidapp_MainActivity_createLOOLWSD(JNIEnv *env, jobject, jstring dataDir, jstring cacheDir, jstring apkFile, jobject assetManager, jstring loadFileURL)
|
||||
{
|
||||
libreofficekit_initialize(env, dataDir, cacheDir, apkFile, assetManager);
|
||||
|
||||
fileURL = std::string(env->GetStringUTFChars(loadFileURL, nullptr));
|
||||
|
||||
Log::initialize("Mobile", "trace", false, false, {});
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
package org.libreoffice.androidapp;
|
||||
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.res.AssetManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
@ -28,8 +30,35 @@ public class MainActivity extends AppCompatActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
AssetManager assetManager = getResources().getAssets();
|
||||
|
||||
ApplicationInfo applicationInfo = getApplicationInfo();
|
||||
String dataDir = applicationInfo.dataDir;
|
||||
Log.i(TAG, String.format("Initializing LibreOfficeKit, dataDir=%s\n", dataDir));
|
||||
|
||||
//redirectStdio(true);
|
||||
|
||||
String cacheDir = getApplication().getCacheDir().getAbsolutePath();
|
||||
String apkFile = getApplication().getPackageResourcePath();
|
||||
|
||||
/* TODO
|
||||
// If there is a fonts.conf file in the apk that can be extracted, automatically
|
||||
// set the FONTCONFIG_FILE env var.
|
||||
InputStream inputStream;
|
||||
try {
|
||||
inputStream = activity.getAssets().open("unpack/etc/fonts/fonts.conf");
|
||||
} catch (java.io.IOException exception) {
|
||||
inputStream = null;
|
||||
}
|
||||
|
||||
if (inputStream != null) {
|
||||
putenv("FONTCONFIG_FILE=" + dataDir + "/etc/fonts/fonts.conf");
|
||||
}
|
||||
*/
|
||||
|
||||
String urlToLoad = "file:///android_asset/dist/hello-world.odt";
|
||||
createLOOLWSD(urlToLoad);
|
||||
|
||||
createLOOLWSD(dataDir/*"/assets"*/, cacheDir, apkFile, assetManager, urlToLoad);
|
||||
|
||||
final WebView browser = findViewById(R.id.browser);
|
||||
browser.setWebViewClient(new WebViewClient());
|
||||
|
@ -58,7 +87,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
/** Initialize the LOOLWSD to load 'loadFileURL'. */
|
||||
public native void createLOOLWSD(String loadFileURL);
|
||||
public native void createLOOLWSD(String dataDir, String cacheDir, String apkFile, AssetManager assetManager, String loadFileURL);
|
||||
|
||||
/** Passing messages from JS (instead of the websocket communication). */
|
||||
@JavascriptInterface
|
||||
|
|
|
@ -2501,7 +2501,7 @@ void lokit_main(
|
|||
|
||||
#else // MOBILEAPP
|
||||
|
||||
#ifdef __linux
|
||||
#if defined(__linux) && !defined(__ANDROID__)
|
||||
Poco::URI userInstallationURI("file", LO_PATH);
|
||||
LibreOfficeKit *kit = lok_init_2(LO_PATH "/program", userInstallationURI.toString().c_str());
|
||||
#else
|
||||
|
|
Loading…
Reference in a new issue