book-reader/app/build.gradle.kts
Aryan 83dcafa4b6
Windows ga (#358)
* Enhance Cloud TTS with navigation controls and shared UI overlay in desktop app

* Refactor Cloud TTS voice settings and remove standalone settings overlay on desktop app

* Persist reader window state and improve slider interaction in desktop app

* Improve PDF page transitions and refine focus management in desktop app

* Refactor scrollbar interaction and adjust desktop modal focus handling

* Improve PDF sidecar synchronization and cross-platform metadata compatibility

* Refactor PDF annotation comment logic to shared module and implement Desktop UI

* Refactor reader screen to use tap-to-toggle and full-width styling in desktop app

* Refactor reader workspace layout and chrome-panel interactions

* Implement global search keyboard shortcuts and focusable chrome layers

* Implement flavor-specific legal links and update the About UI

* Refactor reader UI controls on desktop app

* Enhance desktop folder sync with background metadata extraction and improved error handling

* Refactor Library UI and remove redundant Home tab in desktop app

* Add custom tooltips to reader icon buttons in desktop app

* Integrate app theme controls into reader interfaces on desktop

* Add right-to-left pagination support and improve focus restoration on desktop app

* Improve EPUB pagination geometry and diagnostic logging for layout cutoffs on desktop app

* Update desktop reader defaults and implement settings migration

* Implement block-based position tracking in ReaderLocator

* Enhance EPUB highlighting reliability in desktop app

* Add support for custom reader themes and update highlight palette logic in desktop app

* Replace the Tools panel with a "More" dropdown menu and refactor account UI

* Implement account profile header in desktop sidebar

* Implement cloud sync reliability improvements and sidebar toggle on desktop app

* Improve EPUB annotation synchronization and highlight mapping accuracy in desktop app

* Integrate WebView2 for EPUB vertical rendering on Windows

* Refactor reader layout logic and enhance WebView2 diagnostics

* Improve vertical reading layout and WebView2 resizing on Desktop

* Refine vertical reading mode layout and margin handling

* Enhance reader locator precision and Desktop mode-switching reliability

* Implement chapter-level caching and warm-start pagination in desktop app

* Replace bundled KCEF with native system webviews via SWT

* Refactor EPUB page info bar visibility and layout logic

* Improve PDF toolbar persistence and fix tab reactivation logic

* Enable multi-selection and bulk operations for custom fonts

* Refactor instrumentation tests

* Add EPUB UI test fixture and initial instrumentation tests

* Expand EpubReader UI tests and improve accessibility

* Add instrumentation tests and test tags for library and reader screens

* Enhance OPDS parser logic and catalog integration

* Add support for toggling local synchronization on a per-folder basis.

* Implement tri-state sizing for the TTS overlay

* Persist TTS overlay size across sessions

* Refactor reader brightness control and add incremental step buttons

* Improve CSS support, pagination control, and style-aware semantic caching

* Improve link handling, interaction, and diagnostics in the paginated reader

* crash fixes

* Implement persistent pending removal for external files

* Implement book-specific word replacements

* Add native vertical reading mode with custom renderer

* Implement text selection and navigation improvements for the native vertical reader

* Implement locator-based navigation and improved vertical scrolling in native vertical mode in epub

* Implement lazy loading and chapter prefetching for native vertical reader

* Improve window lifecycle and disposal handling on Desktop

* Optimize vertical reading performance in desktop app

* Enhance TTS start accuracy and diagnostic logging on desktop

* Refactor AI settings visibility on desktop

* Improve pagination height measurement and enhance cutoff diagnostics

* Implement lifecycle management and improve justified text splitting for pagination

* Refine AI usage tracking and force AI feature visibility on Desktop

* Add descriptive context comments and usage examples to string and plural resources.

* Optimize performance and memory usage in search and state mapping

* Replace reader page sliders with minimal slider and navigation controls

* Add support for CBT comic archives

* Harden file path validation and XML parsing to prevent security vulnerabilities

* Implement local account profile caching and optimize desktop performance

* Improve desktop persistence reliability and add Linux secure storage support

* Improved PDF zoom stability and layout prediction during zoom commits

* Improved PDF spread layout prediction, reader focus restoration, and account profile caching

* Enhance highlight precision and scoping using block-local offsets and CFIs

* Enhance cloud book content synchronization and background downloads

* Implement granular timestamp tracking for reading positions and PDF annotations

* Restrict diagnostic logging and stack traces to debug builds

* Refine PDF page gaps and reader chrome interaction logic

* Refactor PDF highlight rendering and overhaul Desktop sidebar UI

* Implement a new interaction dock and undo/redo history for PDF annotations in desktop

* Enhance PDF color picker and improve navigation scroll restoration

* Add highlight palette customization and improve selection menu UI in desktop app epub reader

* Enhance desktop shelf management and library organization
2026-06-02 00:51:42 +05:30

323 lines
11 KiB
Kotlin

@file:Suppress("UnstableApiUsage")
import java.util.Properties
import java.io.StringReader
import javax.xml.parsers.DocumentBuilderFactory
import org.xml.sax.InputSource
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.kotlin.ksp)
id("com.diffplug.spotless") version "8.2.1"
alias(libs.plugins.kover)
}
val localProperties = Properties()
val localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
localPropertiesFile.inputStream().use { localProperties.load(it) }
}
fun configuredAppLocaleTags(): Set<String> {
val localesConfigXml = providers
.fileContents(layout.projectDirectory.file("src/main/res/xml/locales_config.xml"))
.asText
.get()
val androidNamespace = "http://schemas.android.com/apk/res/android"
val document = DocumentBuilderFactory.newInstance()
.apply { isNamespaceAware = true }
.newDocumentBuilder()
.parse(InputSource(StringReader(localesConfigXml)))
val localeNodes = document.getElementsByTagName("locale")
return buildSet {
for (index in 0 until localeNodes.length) {
val name = localeNodes.item(index)
.attributes
?.getNamedItemNS(androidNamespace, "name")
?.nodeValue
?.takeIf { it.isNotBlank() }
if (name != null) add(name)
}
}
}
kotlin {
jvmToolchain(21)
}
android {
namespace = "com.aryan.reader"
compileSdk = 36
defaultConfig {
applicationId = "com.aryan.reader"
minSdk = 26
targetSdk = 35
versionCode = 53
versionName = "1.0.49"
resourceConfigurations += configuredAppLocaleTags()
.map { it.toAndroidResourceConfiguration() }
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags += ""
}
}
buildConfigField("boolean", "IS_PRO", "false")
buildConfigField("boolean", "IS_OFFLINE", "false")
}
flavorDimensions += "version"
productFlavors {
create("oss") {
dimension = "version"
applicationIdSuffix = ".oss"
versionNameSuffix = "-oss"
buildConfigField("String", "AI_WORKER_URL", "\"\"")
buildConfigField("String", "VERIFIER_WORKER_URL", "\"\"")
buildConfigField("String", "FEEDBACK_WORKER_URL", "\"\"")
buildConfigField("boolean", "IS_PRO", "false")
buildConfigField("String", "TTS_WORKER_URL", "\"\"")
}
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
jniLibs {
excludes += "**/libbrotlicommon.so"
excludes += "**/libbrotlidec.so"
excludes += "**/libbrotlienc.so"
}
}
signingConfigs {
create("release") {
val storePath = localProperties.getProperty("MYAPP_RELEASE_STORE_FILE")
if (!storePath.isNullOrEmpty()) {
storeFile = file(storePath)
storePassword = localProperties.getProperty("MYAPP_RELEASE_STORE_PASSWORD")
keyAlias = localProperties.getProperty("MYAPP_RELEASE_KEY_ALIAS")
keyPassword = localProperties.getProperty("MYAPP_RELEASE_KEY_PASSWORD")
}
}
}
buildTypes {
release {
val storePath = localProperties.getProperty("MYAPP_RELEASE_STORE_FILE")
if (!storePath.isNullOrEmpty()) {
signingConfig = signingConfigs.getByName("release")
}
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
create("releaseOffline") {
initWith(getByName("release"))
matchingFallbacks += listOf("release")
buildConfigField("boolean", "IS_OFFLINE", "true")
buildConfigField("String", "TTS_WORKER_URL", "\"\"")
}
}
applicationVariants.all {
val variant = this
outputs.all {
val output = this as com.android.build.gradle.internal.api.ApkVariantOutputImpl
val flavor = variant.productFlavors.getOrNull(0)?.name ?: ""
val buildType = variant.buildType.name
val version = variant.versionName
output.outputFileName = "Episteme-$flavor-v$version-$buildType.apk"
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
kotlinOptions {
jvmTarget = "21"
}
buildFeatures {
compose = true
buildConfig = true
}
dependenciesInfo {
includeInApk = false
includeInBundle = false
}
publishing {
singleVariant("release") {
}
}
externalNativeBuild {
cmake {
path = file("src/main/cpp/CMakeLists.txt")
version = "3.22.1"
}
}
testOptions {
unitTests.isReturnDefaultValues = true
unitTests.all {
it.jvmArgs("-Xss2m")
}
}
configurations {
named("testImplementation") {
exclude(group = "org.slf4j", module = "slf4j-android")
}
}
}
fun String.toAndroidResourceConfiguration(): String {
if (this == "id") return "in"
val languageTagParts = split("-")
return if (languageTagParts.size == 2 && languageTagParts[1].length == 2) {
"${languageTagParts[0]}-r${languageTagParts[1].uppercase()}"
} else {
this
}
}
kover {
reports {
filters {
excludes {
classes(
"*.BuildConfig",
"*.ComposableSingletons*",
"*_Impl",
"*Database_Impl",
"*Dao_Impl"
)
}
}
}
}
//noinspection UseTomlInstead
dependencies {
implementation(project(":shared"))
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
implementation(libs.androidx.material3.window.size.class1.android)
implementation(libs.androidx.credentials)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
androidTestImplementation("androidx.test:rules:1.7.0")
androidTestImplementation("androidx.test.espresso:espresso-web:3.7.0")
androidTestImplementation("com.google.truth:truth:1.4.2")
androidTestImplementation("androidx.navigation:navigation-testing:2.9.6")
androidTestImplementation("io.mockk:mockk-android:1.13.11") {
exclude(group = "org.junit.jupiter")
}
androidTestImplementation(libs.kotlinx.coroutines.test)
debugImplementation(libs.androidx.ui.test.manifest)
implementation(libs.androidx.room.runtime)
implementation(libs.androidx.room.ktx)
ksp(libs.androidx.room.compiler)
implementation("androidx.appcompat:appcompat:1.7.1")
//noinspection GradleDependency (Updating these might cause the custom toolbox in pagination to break)
implementation("androidx.navigation:navigation-compose:2.9.6")
//noinspection GradleDependency
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.9.2")
//noinspection GradleDependency
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.9.2")
//noinspection GradleDependency
implementation("androidx.compose.material3.adaptive:adaptive:1.2.0-alpha11")
implementation("org.jsoup:jsoup:1.17.2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:1.7.3")
implementation("io.coil-kt:coil-compose:2.7.0")
implementation("io.coil-kt:coil-svg:2.6.0")
implementation("androidx.media3:media3-exoplayer:1.8.0")
implementation("androidx.media3:media3-session:1.8.0")
implementation("androidx.media3:media3-ui:1.8.0")
implementation("androidx.work:work-runtime-ktx:2.10.5")
implementation("androidx.compose.runtime:runtime-livedata:1.9.3")
implementation("org.slf4j:slf4j-android:1.7.36")
implementation("org.commonmark:commonmark:0.22.0")
implementation("com.jakewharton.timber:timber:5.0.1")
implementation("me.zhanghai.android.libarchive:library:1.1.6")
implementation("androidx.paging:paging-runtime-ktx:3.3.6")
implementation("androidx.paging:paging-compose:3.3.6")
implementation("androidx.room:room-paging:2.7.1")
// Flexmark for Markdown parsing (MD -> HTML)
implementation("com.vladsch.flexmark:flexmark:0.64.8")
implementation("com.vladsch.flexmark:flexmark-ext-tables:0.64.8")
implementation("com.vladsch.flexmark:flexmark-ext-gfm-strikethrough:0.64.8")
implementation("com.vladsch.flexmark:flexmark-ext-gfm-tasklist:0.64.8")
implementation("com.vladsch.flexmark:flexmark-ext-autolink:0.64.8")
implementation("androidx.documentfile:documentfile:1.0.1")
implementation("androidx.browser:browser:1.8.0")
implementation("io.legere:pdfiumandroid:2.0.0")
implementation("org.zwobble.mammoth:mammoth:1.4.2")
implementation("com.materialkolor:material-kolor:5.0.0-alpha07")
debugImplementation("org.tensorflow:tensorflow-lite:2.17.0")
debugImplementation("org.tensorflow:tensorflow-lite-support:0.5.0")
debugImplementation("org.tensorflow:tensorflow-lite-gpu:2.17.0")
debugImplementation("org.tensorflow:tensorflow-lite-gpu-api:2.17.0")
implementation("androidx.core:core-splashscreen:1.2.0")
testImplementation("junit:junit:4.13.2")
testImplementation("io.mockk:mockk-android:1.14.9")
testImplementation(libs.kotlinx.coroutines.test)
testImplementation("org.json:json:20251224")
testImplementation("org.robolectric:robolectric:4.16.1")
testImplementation("org.slf4j:slf4j-nop:2.0.17")
}
spotless {
kotlin {
target("src/main/java/**/*.kt", "src/main/kotlin/**/*.kt")
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
}
cpp {
target("src/main/cpp/mobi_jni_bridge.c", "src/main/cpp/Woff2Converter.cpp")
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
}
}