From c99d8e8275438474deb274f50ef91a7cdee5ecf9 Mon Sep 17 00:00:00 2001 From: FooIbar <118464521+FooIbar@users.noreply.github.com> Date: Mon, 1 Jan 2024 19:59:15 +0800 Subject: [PATCH] [Marshmallow] Support crop image borders --- app/build.gradle.kts | 2 +- app/src/main/cpp/CMakeLists.txt | 11 +++++++---- .../kotlin/com/hippo/ehviewer/EhApplication.kt | 4 +--- .../setting/ReaderColorFilterSettings.kt | 18 ++++++++---------- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index fc685d39c..f570715f5 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -103,7 +103,7 @@ android { versionNameSuffix = "-M" externalNativeBuild { cmake { - targets += "noop" + arguments("-DMARSHMALLOW=1") } } compileOptions { diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index e138abecb..236679c95 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -76,7 +76,10 @@ FetchContent_MakeAvailable(libarchive) include_directories(${libarchive_SOURCE_DIR}/libarchive) # Build and link our app's native lib -add_library(${PROJECT_NAME} SHARED archive.c border.c gifutils.c natsort/strnatcmp.c) -target_link_libraries(${PROJECT_NAME} archive_static log jnigraphics) - -add_custom_target("noop") +if (MARSHMALLOW) + add_library(${PROJECT_NAME} SHARED border.c) + target_link_libraries(${PROJECT_NAME} jnigraphics) +else () + add_library(${PROJECT_NAME} SHARED archive.c border.c gifutils.c natsort/strnatcmp.c) + target_link_libraries(${PROJECT_NAME} archive_static log jnigraphics) +endif () diff --git a/app/src/main/kotlin/com/hippo/ehviewer/EhApplication.kt b/app/src/main/kotlin/com/hippo/ehviewer/EhApplication.kt index 6e137e113..2d1374e82 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/EhApplication.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/EhApplication.kt @@ -101,9 +101,7 @@ class EhApplication : Application(), SingletonImageLoader.Factory { handler?.uncaughtException(t, e) } super.onCreate() - if (isAtLeastP) { - System.loadLibrary("ehviewer") - } + System.loadLibrary("ehviewer") System.loadLibrary("ehviewer_rust") ReadableTime.initialize(this) lifecycleScope.launchIO { diff --git a/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/setting/ReaderColorFilterSettings.kt b/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/setting/ReaderColorFilterSettings.kt index 9bb5080f6..9d93f5d45 100644 --- a/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/setting/ReaderColorFilterSettings.kt +++ b/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/setting/ReaderColorFilterSettings.kt @@ -37,6 +37,12 @@ class ReaderColorFilterSettings @JvmOverloads constructor(context: Context, attr init { addView(binding.root) + context as ReaderActivity + + readerPreferences.cropBorders().asHotFlow { + context.restartGalleryProvider() + }.launchIn(context.lifecycleScope) + if (isAtLeastO) { binding.wideColorGamut.isEnabled = Image.isWideColorGamut if (!Image.isWideColorGamut) { @@ -44,28 +50,20 @@ class ReaderColorFilterSettings @JvmOverloads constructor(context: Context, attr } binding.wideColorGamut.bindToPreference(readerPreferences.wideColorGamut()) - val activity = context as ReaderActivity - - readerPreferences.cropBorders().asHotFlow { - activity.restartGalleryProvider() - }.launchIn(activity.lifecycleScope) - readerPreferences.wideColorGamut().asHotFlow { Image.colorSpace = ColorSpace.get(if (Image.isWideColorGamut && it) ColorSpace.Named.DISPLAY_P3 else ColorSpace.Named.SRGB) val colorMode = if (Image.isWideColorGamut && it) ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT else ActivityInfo.COLOR_MODE_DEFAULT - with(activity) { + with(context) { if (window.colorMode != colorMode) { window.colorMode = colorMode restartGalleryProvider() } } - }.launchIn(activity.lifecycleScope) + }.launchIn(context.lifecycleScope) } else { binding.wideColorGamut.isVisible = false } - context as ReaderActivity - readerPreferences.colorFilter().changes() .onEach { setColorFilter(it) } .launchIn(context.lifecycleScope)