From e54f830a0107b3dbc8b70c30219e26a9f62ce4d7 Mon Sep 17 00:00:00 2001 From: Thomas Taschauer Date: Sun, 15 Nov 2020 11:36:26 +0100 Subject: [PATCH] update core, raise version --- OpenDocument.core | 2 +- app/build.gradle | 1 + .../at/tomtasche/reader/test/CoreTest.java | 83 +++++++++++++++++++ app/src/main/AndroidManifest.xml | 4 +- .../reader/background/CoreWrapper.java | 24 +++--- .../reader/ui/activity/MainActivity.java | 2 + upload-symbols.sh | 3 +- 7 files changed, 103 insertions(+), 16 deletions(-) create mode 100644 app/src/androidTest/java/at/tomtasche/reader/test/CoreTest.java diff --git a/OpenDocument.core b/OpenDocument.core index 43a196d4e78a..1c30b9ed01fa 160000 --- a/OpenDocument.core +++ b/OpenDocument.core @@ -1 +1 @@ -Subproject commit 43a196d4e78a1e5ef9d45751df20d9a131b9d139 +Subproject commit 1c30b9ed01fad491cc9ba6356f5ec6e49562eebe diff --git a/app/build.gradle b/app/build.gradle index c33d7e1f75e1..b38904a1d75b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -30,6 +30,7 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt' firebaseCrashlytics.nativeSymbolUploadEnabled true + ndk.debugSymbolLevel = "full" } } diff --git a/app/src/androidTest/java/at/tomtasche/reader/test/CoreTest.java b/app/src/androidTest/java/at/tomtasche/reader/test/CoreTest.java new file mode 100644 index 000000000000..10761969262b --- /dev/null +++ b/app/src/androidTest/java/at/tomtasche/reader/test/CoreTest.java @@ -0,0 +1,83 @@ +package at.tomtasche.reader.test; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; + +import androidx.test.InstrumentationRegistry; +import androidx.test.core.app.ApplicationProvider; +import androidx.test.filters.LargeTest; +import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner; +import at.tomtasche.reader.background.CoreWrapper; + +@LargeTest +@RunWith(AndroidJUnit4ClassRunner.class) +public class CoreTest { + + private String testFilePath; + + @Before + public void setup() { + // TODO: fix for Android 29+ + + try { + File file = new File(ApplicationProvider.getApplicationContext().getCacheDir(), "test.odt"); + testFilePath = file.getAbsolutePath(); + + if (file.exists()) { + return; + } + + InputStream inputStream = new URL("https://api.libreoffice.org/examples/cpp/DocumentLoader/test.odt").openStream(); + copy(inputStream, file); + } catch (IOException e) { + e.printStackTrace(); + + throw new RuntimeException(e); + } + } + + private static void copy(InputStream src, File dst) throws IOException { + try (OutputStream out = new FileOutputStream(dst)) { + byte[] buf = new byte[1024]; + int len; + while ((len = src.read(buf)) > 0) { + out.write(buf, 0, len); + } + } finally { + src.close(); + } + } + + @Test + public void test() { + CoreWrapper core = new CoreWrapper(); + core.initialize(); + + File htmlFile = new File(ApplicationProvider.getApplicationContext().getCacheDir(),"html"); + + CoreWrapper.CoreOptions coreOptions = new CoreWrapper.CoreOptions(); + coreOptions.inputPath = testFilePath; + coreOptions.outputPath = htmlFile.getPath(); + coreOptions.editable = true; + + CoreWrapper.CoreResult coreResult = core.parse(coreOptions); + Assert.assertEquals(0, coreResult.errorCode); + + File resultFile = new File(ApplicationProvider.getApplicationContext().getCacheDir(),"result"); + coreOptions.outputPath = resultFile.getPath(); + + String htmlDiff = "{\"modifiedText\":{\"3\":\"This is a simple test document to demonstrate the DocumentLoadewwwwr example!\"}}"; + + CoreWrapper.CoreResult result = core.backtranslate(coreOptions, htmlDiff); + Assert.assertEquals(0, coreResult.errorCode); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 64a34ea36fbc..7f4dca63f0a8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,8 +2,8 @@ diff --git a/app/src/main/java/at/tomtasche/reader/background/CoreWrapper.java b/app/src/main/java/at/tomtasche/reader/background/CoreWrapper.java index dc0e2a751f77..e5597c8aa5ff 100644 --- a/app/src/main/java/at/tomtasche/reader/background/CoreWrapper.java +++ b/app/src/main/java/at/tomtasche/reader/background/CoreWrapper.java @@ -92,31 +92,31 @@ public void close() { public static class CoreOptions { - long nativePointer; + public long nativePointer; - boolean ooxml; + public boolean ooxml; - boolean editable; + public boolean editable; - String password; + public String password; - String inputPath; - String outputPath; + public String inputPath; + public String outputPath; } public static class CoreResult { - long nativePointer; + public long nativePointer; - int errorCode; + public int errorCode; - Exception exception; + public Exception exception; - List pageNames = new LinkedList<>(); + public List pageNames = new LinkedList<>(); - String outputPath; + public String outputPath; - String extension; + public String extension; } public class CoreCouldNotOpenException extends RuntimeException {} diff --git a/app/src/main/java/at/tomtasche/reader/ui/activity/MainActivity.java b/app/src/main/java/at/tomtasche/reader/ui/activity/MainActivity.java index f951302cf42b..34827a812b08 100644 --- a/app/src/main/java/at/tomtasche/reader/ui/activity/MainActivity.java +++ b/app/src/main/java/at/tomtasche/reader/ui/activity/MainActivity.java @@ -123,12 +123,14 @@ public void onCreate(Bundle savedInstanceState) { findViewById(R.id.landing_intro_open).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + analyticsManager.report("intro_open"); findDocument(); } }); findViewById(R.id.landing_open_fab).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + analyticsManager.report("fab_open"); findDocument(); } }); diff --git a/upload-symbols.sh b/upload-symbols.sh index 3f896a60c191..0754e68228ae 100644 --- a/upload-symbols.sh +++ b/upload-symbols.sh @@ -1,3 +1,4 @@ #!/bin/bash -./gradlew app:uploadCrashlyticsSymbolFileRelease +./gradlew app:uploadCrashlyticsSymbolFileLiteRelease +./gradlew app:uploadCrashlyticsSymbolFileProRelease