android/app/build.gradle | 13 ++ android/app/src/main/cpp/androidapp.cpp | 3 android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java | 54 +++++++++- android/templates/untitled.odp |binary loleaflet/Makefile.am | 3 loleaflet/html/loleaflet.html.m4 | 2 6 files changed, 72 insertions(+), 3 deletions(-)
New commits: commit b75adb8629e84f498731cc1094a8c9e278576c0e Author: Jan Holesovsky <ke...@collabora.com> AuthorDate: Tue Jul 9 17:12:08 2019 +0200 Commit: Jan Holesovsky <ke...@collabora.com> CommitDate: Thu Jul 11 08:34:03 2019 +0200 android: Corrected the .odp template. Change-Id: Iaea2e4f47dd2252ee1d736bd8d49ed1bffe37381 diff --git a/android/templates/untitled.odp b/android/templates/untitled.odp index 7fc84f8e8..767ac2d3c 100644 Binary files a/android/templates/untitled.odp and b/android/templates/untitled.odp differ commit 18ee97d9c888513efd385467e1a41f02cd4b6bc1 Author: Jan Holesovsky <ke...@collabora.com> AuthorDate: Tue Jul 9 14:48:41 2019 +0200 Commit: Jan Holesovsky <ke...@collabora.com> CommitDate: Thu Jul 11 08:33:52 2019 +0200 android: Copy also the branded images if any. Change-Id: I9f8ed9f726015f9a668bd0d6e8f6d934f60cd413 diff --git a/loleaflet/Makefile.am b/loleaflet/Makefile.am index 68d132e7c..2106a0846 100644 --- a/loleaflet/Makefile.am +++ b/loleaflet/Makefile.am @@ -155,6 +155,7 @@ if ENABLE_ANDROIDAPP @rm -rf $(abs_top_srcdir)/android/app/src/main/assets/dist @cp -a $(builddir)/dist $(abs_top_srcdir)/android/app/src/main/assets/ @if test -d "$(APP_BRANDING_DIR)" ; then cp -a "$(APP_BRANDING_DIR)/branding.css" "$(APP_BRANDING_DIR)/branding.js" $(abs_top_srcdir)/android/app/src/main/assets/dist/ ; else touch $(abs_top_srcdir)/android/app/src/main/assets/dist/branding.css ; fi + @if test -d "$(APP_BRANDING_DIR)" ; then cp -a "$(APP_BRANDING_DIR)"/*.svg $(abs_top_srcdir)/android/app/src/main/assets/dist/images/ ; fi @if test -d "$(APP_BRANDING_DIR)" ; then cp -a "$(APP_BRANDING_DIR)/toolbar-bg-logo.svg" $(abs_top_srcdir)/android/app/src/main/assets/dist/images/toolbar-bg.svg ; fi @echo @echo "Copied JS, HTML and CSS to the Android project (android/app/src/main/assets/dist)." commit 6f5290da0ee56030fba6f81978c54c125749112d Author: Jan Holesovsky <ke...@collabora.com> AuthorDate: Tue Jul 9 13:46:23 2019 +0200 Commit: Jan Holesovsky <ke...@collabora.com> CommitDate: Thu Jul 11 08:33:43 2019 +0200 android: Actually use the branding if it exists. Change-Id: Idd7136f0657452c5fb88f2a84b5c647ab8c2935b diff --git a/loleaflet/Makefile.am b/loleaflet/Makefile.am index 456400f64..68d132e7c 100644 --- a/loleaflet/Makefile.am +++ b/loleaflet/Makefile.am @@ -154,7 +154,7 @@ build-loleaflet: | $(LOLEAFLET_L10N_DST) \ if ENABLE_ANDROIDAPP @rm -rf $(abs_top_srcdir)/android/app/src/main/assets/dist @cp -a $(builddir)/dist $(abs_top_srcdir)/android/app/src/main/assets/ - @if test -d "$(APP_BRANDING_DIR)" ; then cp -a "$(APP_BRANDING_DIR)/branding.css" "$(APP_BRANDING_DIR)/branding.js" $(abs_top_srcdir)/android/app/src/main/assets/dist/ ; fi + @if test -d "$(APP_BRANDING_DIR)" ; then cp -a "$(APP_BRANDING_DIR)/branding.css" "$(APP_BRANDING_DIR)/branding.js" $(abs_top_srcdir)/android/app/src/main/assets/dist/ ; else touch $(abs_top_srcdir)/android/app/src/main/assets/dist/branding.css ; fi @if test -d "$(APP_BRANDING_DIR)" ; then cp -a "$(APP_BRANDING_DIR)/toolbar-bg-logo.svg" $(abs_top_srcdir)/android/app/src/main/assets/dist/images/toolbar-bg.svg ; fi @echo @echo "Copied JS, HTML and CSS to the Android project (android/app/src/main/assets/dist)." diff --git a/loleaflet/html/loleaflet.html.m4 b/loleaflet/html/loleaflet.html.m4 index 583851954..db9502090 100644 --- a/loleaflet/html/loleaflet.html.m4 +++ b/loleaflet/html/loleaflet.html.m4 @@ -88,6 +88,8 @@ ifelse(MOBILEAPP,[true], <!--%BRANDING_CSS%--> <!-- add your logo here --> ifelse(IOSAPP,[true], [<link rel="stylesheet" href="Branding/branding.css">]) +ifelse(ANDROIDAPP,[true], + [<link rel="stylesheet" href="branding.css">]) ifelse(MOBILEAPP,[true], [ ifelse(IOSAPP,[true], commit 55377739c66660d177d8922fd0110ac0ec23cee0 Author: Jan Holesovsky <ke...@collabora.com> AuthorDate: Thu Jun 27 12:04:15 2019 +0200 Commit: Jan Holesovsky <ke...@collabora.com> CommitDate: Thu Jul 11 08:33:34 2019 +0200 android: Avoid system fonts. They are huge and fontconfig has real trouble indexing / creating the cache on the 1st start. This reduces the startup time by nearly a minute (on my phone). Change-Id: I85abd541251ab949c3c29c4df5fb95ce28f5634c diff --git a/android/app/build.gradle b/android/app/build.gradle index ec472b91d..0ee8baabe 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -100,7 +100,18 @@ task copyUnpackAssets(type: Copy) { filter { String line -> line.replaceAll( - '@@APPLICATION_ID@@', new String("${android.defaultConfig.applicationId}") + '@@APPLICATION_ID@@', new String("${android.defaultConfig.applicationId}") + ).replaceAll( + // FIXME Avoid the Android system fonts for the moment, + // the huge Noto Sans fonts have terrible impact on the 1st + // start performance. + // The real solution would be to either make fontconfig + // faster, or at least find a way to avoid only the Noto + // Sans, or present a progressbar or something. + // For the moment, we just copy the Roboto font (needed + // for the dialogs; see MainActivity.copyFonts()) and + // remove the system fonts from the config. + '<dir>/system/fonts</dir>', new String("") ) } } diff --git a/android/app/src/main/cpp/androidapp.cpp b/android/app/src/main/cpp/androidapp.cpp index 5ff2f4dbb..7f5cf0f74 100644 --- a/android/app/src/main/cpp/androidapp.cpp +++ b/android/app/src/main/cpp/androidapp.cpp @@ -47,6 +47,9 @@ JNI_OnLoad(JavaVM* vm, void*) { setenv("SAL_LOK_OPTIONS", "unipoll", 0); + // Uncomment the following to see the logs from the core too + //setenv("SAL_LOG", "+WARN+INFO", 0); + Log::initialize("Mobile", "debug", false, false, {}); return JNI_VERSION_1_6; 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 78cd43010..c2897e304 100644 --- a/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java +++ b/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java @@ -35,9 +35,12 @@ import android.webkit.WebViewClient; import android.widget.Toast; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.net.URI; import java.net.URISyntaxException; import java.nio.ByteBuffer; @@ -136,9 +139,58 @@ public class MainActivity extends AppCompatActivity { } } + /** Copies fonts except the NotoSans from the system to our location. + * This is necessary because the NotoSans is huge and fontconfig needs + * ages to parse them. + */ + private static boolean copyFonts(String fromPath, String targetDir) { + try { + File target = new File(targetDir); + if (!target.exists()) + target.mkdirs(); + + File from = new File(fromPath); + File[] files = from.listFiles(); + for (File fontFile : files) { + String fontFileName = fontFile.getName(); + if (!fontFileName.equals("Roboto-Regular.ttf")) { + Log.i(TAG, "Ignored font file: " + fontFile); + continue; + } + else { + Log.i(TAG, "Copying font file: " + fontFile); + } + + // copy the font file over + InputStream in = new FileInputStream(fontFile); + try { + OutputStream out = new FileOutputStream(targetDir + "/" + fontFile.getName()); + try { + byte[] buffer = new byte[4096]; + int len; + while ((len = in.read(buffer)) > 0) { + out.write(buffer, 0, len); + } + } finally { + out.close(); + } + } finally { + in.close(); + } + } + } catch (Exception e) { + e.printStackTrace(); + Log.e(TAG, "copyFonts failed: " + e.getMessage()); + return false; + } + + return true; + } + private void updatePreferences() { if (sPrefs.getInt(ASSETS_EXTRACTED_PREFS_KEY, 0) != BuildConfig.VERSION_CODE) { - if (copyFromAssets(getAssets(), "unpack", getApplicationInfo().dataDir)) { + if (copyFromAssets(getAssets(), "unpack", getApplicationInfo().dataDir) && + copyFonts("/system/fonts", getApplicationInfo().dataDir + "/user/fonts")) { sPrefs.edit().putInt(ASSETS_EXTRACTED_PREFS_KEY, BuildConfig.VERSION_CODE).apply(); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits