android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java | 31 +++++----- 1 file changed, 17 insertions(+), 14 deletions(-)
New commits: commit 68b33ba7f28dff5d5a315638dad91b2ecc303caf Author: Jan Holesovsky <ke...@collabora.com> AuthorDate: Tue Jul 23 14:17:34 2019 +0200 Commit: Jan Holesovsky <ke...@collabora.com> CommitDate: Tue Jul 23 14:20:25 2019 +0200 android: Load the document only after we've got the permission. Without this, the first start was failing, there was only a black screen and the request for permission. Change-Id: I7929048ca51b044dcb574f48bd2b7bc9a27e0ec8 diff --git a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java index ce1243348..2258a78a2 100644 --- a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java +++ b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java @@ -86,6 +86,7 @@ public class LOActivity extends AppCompatActivity { private boolean isDocEditable = false; private boolean isDocDebuggable = BuildConfig.DEBUG; + private boolean documentLoaded = false; private ClipboardManager clipboardManager; private ClipData clipData; @@ -218,19 +219,8 @@ public class LOActivity extends AppCompatActivity { setContentView(R.layout.lolib_activity_main); - AssetManager assetManager = getResources().getAssets(); - isDocDebuggable = sPrefs.getBoolean(KEY_ENABLE_SHOW_DEBUG_INFO, false) && BuildConfig.DEBUG; - 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(); - if (getIntent().getData() != null) { if (getIntent().getData().getScheme().equals(ContentResolver.SCHEME_CONTENT)) { @@ -274,8 +264,6 @@ public class LOActivity extends AppCompatActivity { finish(); } - createLOOLWSD(dataDir, cacheDir, apkFile, assetManager, urlToLoad); - mWebView = findViewById(R.id.browser); WebSettings webSettings = mWebView.getSettings(); @@ -421,7 +409,8 @@ public class LOActivity extends AppCompatActivity { Log.d(TAG, "onPause() - hinting to save, we might need to return to the doc"); // A Save similar to an autosave - postMobileMessageNative("save dontTerminateEdit=true dontSaveIfUnmodified=true"); + if (documentLoaded) + postMobileMessageNative("save dontTerminateEdit=true dontSaveIfUnmodified=true"); } @Override @@ -445,6 +434,18 @@ public class LOActivity extends AppCompatActivity { } private void loadDocument() { + // setup the LOOLWSD + ApplicationInfo applicationInfo = getApplicationInfo(); + String dataDir = applicationInfo.dataDir; + Log.i(TAG, String.format("Initializing LibreOfficeKit, dataDir=%s\n", dataDir)); + + String cacheDir = getApplication().getCacheDir().getAbsolutePath(); + String apkFile = getApplication().getPackageResourcePath(); + AssetManager assetManager = getResources().getAssets(); + + createLOOLWSD(dataDir, cacheDir, apkFile, assetManager, urlToLoad); + + // trigger the load of the document String finalUrlToLoad = "file:///android_asset/dist/loleaflet.html?file_path=" + urlToLoad + "&closebutton=1"; if (isDocEditable) { @@ -456,6 +457,8 @@ public class LOActivity extends AppCompatActivity { finalUrlToLoad += "&debug=true"; } mWebView.loadUrl(finalUrlToLoad); + + documentLoaded = true; } static { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits