Skip to content

Commit 83c09e5

Browse files
committed
solve colliding assets
1 parent 3168577 commit 83c09e5

6 files changed

Lines changed: 25 additions & 8 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ tasks.register('conanProfile', Copy) {
2121
tasks.named("conanInstall-" + architecture) {
2222
profile.set('build/conanprofile.txt')
2323
deployer.set('conandeployer.py')
24-
deployerFolder.set(outputDirectory.get().asFile.toString() + "/assets")
24+
deployerFolder.set(outputDirectory.get().asFile.toString() + "/assets/core")
2525
dependsOn(tasks.named('conanProfile'))
26+
conanExecutable.set('/Users/andreas/odr/venv/bin/conan')
2627
}
2728
}
2829

app/conanfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[requires]
2-
odrcore/5.0.0-pre9
2+
odrcore/5.0.0-pre11
33

44
[generators]
55
CMakeToolchain

app/src/main/cpp/CoreWrapper.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,21 @@ Java_at_tomtasche_reader_background_CoreWrapper_hostFile(JNIEnv *env, jclass cla
360360
}
361361
} catch (const std::exception &e) {
362362
__android_log_print(ANDROID_LOG_ERROR, "smn", "Unhandled C++ exception: %s", e.what());
363+
env->SetIntField(result, errorField, -1);
364+
return result;
365+
} catch (const std::string &s) {
366+
__android_log_print(ANDROID_LOG_ERROR, "smn", "Unhandled C++ string exception: %s", s.c_str());
367+
env->SetIntField(result, errorField, -1);
368+
return result;
369+
} catch (int i) {
370+
__android_log_print(ANDROID_LOG_ERROR, "smn", "Unhandled C++ int exception: %i", i);
371+
env->SetIntField(result, errorField, -1);
372+
return result;
363373
} catch (...) {
364374
__android_log_print(ANDROID_LOG_ERROR, "smn",
365375
"Unhandled C++ exception without further information");
376+
env->SetIntField(result, errorField, -1);
377+
return result;
366378
}
367379

368380
return result;

app/src/main/java/at/tomtasche/reader/background/CoreLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public CoreLoader(Context context, ConfigManager configManager, boolean doOoxml,
3737
public void initialize(FileLoaderListener listener, Handler mainHandler, Handler backgroundHandler, AnalyticsManager analyticsManager, CrashManager crashManager) {
3838
if (doHttp) {
3939
File serverCacheDir = new File(context.getCacheDir(), "core/server");
40-
if (!serverCacheDir.mkdirs()) {
40+
if (!serverCacheDir.isDirectory() && !serverCacheDir.mkdirs()) {
4141
Log.e("CoreLoader", "Failed to create cache directory for CoreWrapper server: " + serverCacheDir.getAbsolutePath());
4242
}
4343
CoreWrapper.createServer(serverCacheDir.getAbsolutePath());

app/src/main/java/at/tomtasche/reader/background/CoreWrapper.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ public static class GlobalParams {
2525
public static native void setGlobalParams(GlobalParams params);
2626

2727
public static void initialize(Context context) {
28-
File assetsDirectory = new File(context.getFilesDir(), "assets");
28+
File assetsDirectory = new File(context.getFilesDir(), "assets/core");
2929
File odrCoreDataDirectory = new File(assetsDirectory, "odrcore");
3030
File fontconfigDataDirectory = new File(assetsDirectory, "fontconfig");
3131
File popplerDataDirectory = new File(assetsDirectory, "poppler");
3232
File pdf2htmlexDataDirectory = new File(assetsDirectory, "pdf2htmlex");
3333

3434
AssetExtractor ae = new AssetExtractor(context.getAssets());
3535
ae.setOverwrite();
36-
ae.extract(assetsDirectory, "odrcore");
37-
ae.extract(assetsDirectory, "fontconfig");
38-
ae.extract(assetsDirectory, "poppler");
39-
ae.extract(assetsDirectory, "pdf2htmlex");
36+
ae.extract(assetsDirectory, "core/odrcore");
37+
ae.extract(assetsDirectory, "core/fontconfig");
38+
ae.extract(assetsDirectory, "core/poppler");
39+
ae.extract(assetsDirectory, "core/pdf2htmlex");
4040

4141
CoreWrapper.GlobalParams globalParams = new CoreWrapper.GlobalParams();
4242
globalParams.coreDataPath = odrCoreDataDirectory.getAbsolutePath();

app/src/main/java/at/tomtasche/reader/ui/widget/PageView.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ public void onDownloadStart(String url, String userAgent,
140140
public void toggleDarkMode(boolean isDarkEnabled) {
141141
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
142142
setForceDarkAllowed(isDarkEnabled);
143+
}
144+
145+
if (WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING)) {
146+
WebSettingsCompat.setAlgorithmicDarkeningAllowed(getSettings(), isDarkEnabled);
143147
} else if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
144148
WebSettingsCompat.setForceDark(getSettings(), isDarkEnabled ? WebSettingsCompat.FORCE_DARK_AUTO : WebSettingsCompat.FORCE_DARK_OFF);
145149
}

0 commit comments

Comments
 (0)