Skip to content

Commit

Permalink
update core, raise version
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Taschauer committed Nov 15, 2020
1 parent 8ae53c6 commit e54f830
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 16 deletions.
2 changes: 1 addition & 1 deletion OpenDocument.core
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'

firebaseCrashlytics.nativeSymbolUploadEnabled true
ndk.debugSymbolLevel = "full"
}
}

Expand Down
83 changes: 83 additions & 0 deletions app/src/androidTest/java/at/tomtasche/reader/test/CoreTest.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto"
android:versionCode="136"
android:versionName="3.3.6"
android:versionCode="137"
android:versionName="3.3.7"
package="at.tomtasche.reader"
tools:ignore="GoogleAppIndexingWarning">

Expand Down
24 changes: 12 additions & 12 deletions app/src/main/java/at/tomtasche/reader/background/CoreWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> pageNames = new LinkedList<>();
public List<String> pageNames = new LinkedList<>();

String outputPath;
public String outputPath;

String extension;
public String extension;
}

public class CoreCouldNotOpenException extends RuntimeException {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
Expand Down
3 changes: 2 additions & 1 deletion upload-symbols.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash

./gradlew app:uploadCrashlyticsSymbolFileRelease
./gradlew app:uploadCrashlyticsSymbolFileLiteRelease
./gradlew app:uploadCrashlyticsSymbolFileProRelease

0 comments on commit e54f830

Please sign in to comment.