book-reader/app/build.gradle.kts
Atte149 1b43c9c1ec feat(ui): Myne-style UI overhaul — 4 tabs, API fixes, theme
Phase 1: API fixes
- Removed health() endpoint (404 on server), replaced with getLibraries()-based check
- ProgressUpdateRequest/PlaybackProgressUpdateRequest already have required fields
- Fixed ServerStatusMonitor to use getLibraries() instead of health()
- cover_url passes through as full URL (no resolveCoverUrl needed)

Phase 2: Theme (Myne blue-teal palette)
- Replaced Color.kt with Myne palette (primary #0D6681, dark #89D0EE)
- Simplified Theme.kt: dynamic color (Android 12+), fallback to static, no custom fonts
- Added material-icons-extended dependency

Phase 3-4: Navigation + Common components
- 4 tabs: Books, Audiobooks, Search, Settings
- CustomBottomNavigationItem: pill-shaped, animated text, primary.copy(alpha=0.1f)
- CustomTopAppBar: bold 28sp title, divider 2dp, circle back button
- BookItemCard: horizontal card, cover + text, surfaceColorAtElevation(3dp), RoundedCornerShape(6dp)
- ProgressDots: animated dots loader

Phase 5-8: Screens
- BooksScreen: loads ebooks from bookshelf-api, LazyVerticalGrid adaptive
- AudiobooksScreen: loads audiobooks, shows duration
- SearchScreen: OutlinedTextField with RoundedCornerShape(24dp), search via POST /api/v1/search
- SettingsScreen: sections (Appearance, Server, About) with toggles and click items

Phase 11: NavGraph
- NavHost with 4 bottom bar routes

':app:assembleOssDebug' passes. APK deployed.
2026-06-27 07:09:47 +03:00

340 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)
alias(libs.plugins.hilt)
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 {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
android {
namespace = "org.dueattendant149.bookreader"
compileSdk = 36
defaultConfig {
applicationId = "org.dueattendant149.bookreader"
minSdk = 26
targetSdk = 35
versionCode = 54
versionName = "1.0.50"
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.maxHeapSize = "4g"
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(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("androidx.compose.material:material-icons-extended:1.7.8")
implementation(libs.androidx.material3.window.size.class1.android)
implementation(libs.androidx.credentials)
// Hilt
implementation(libs.hilt.android)
ksp(libs.hilt.compiler)
implementation(libs.hilt.navigation.compose)
// Networking
implementation(libs.retrofit)
implementation(libs.retrofit.kotlinx.serialization)
implementation(libs.okhttp.logging)
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"))
}
}