Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 53 additions & 12 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,43 @@
import com.android.build.api.variant.FilterConfiguration
import java.net.URL
import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction

abstract class DownloadTFLiteModelTask : DefaultTask() {
@get:OutputDirectory
abstract val outputDirectory: DirectoryProperty

@TaskAction
fun download() {
val modelVersion = "v1.2.0"
val modelFileName = "fairscan-segmentation-model.tflite"
val modelUrl = "https://github.com/pynicolas/fairscan-segmentation-model/releases/download/$modelVersion/$modelFileName"

val outputFile = outputDirectory.file(modelFileName).get().asFile

if (!outputFile.exists()) {
println("Downloading $modelFileName from $modelUrl")
outputFile.parentFile.mkdirs()

URL(modelUrl).openStream().use { input ->
outputFile.outputStream().use { output ->
input.copyTo(output)
}
}
} else {
println("Model already downloaded: ${outputFile.absolutePath}")
}
}
}

val downloadTFLiteModel = tasks.register<DownloadTFLiteModelTask>("downloadTFLiteModel") {
outputDirectory.set(layout.buildDirectory.dir("downloads/tflite"))
}

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.aboutLibrariesAndroid)
alias(libs.plugins.kotlin.serialization)
Expand All @@ -15,7 +52,6 @@ val abiCodes = mapOf(
android {
namespace = "org.fairscan.app"
compileSdk = 36
sourceSets["main"].assets.srcDir(layout.buildDirectory.dir("generated/assets"))

defaultConfig {
applicationId = "org.fairscan.app"
Expand Down Expand Up @@ -74,15 +110,6 @@ android {
isUniversalApk = false
}
}
applicationVariants.all {
val variant = this
variant.outputs
.map { it as com.android.build.gradle.internal.api.BaseVariantOutputImpl }
.forEach { output ->
val abi = output.getFilter("ABI")
output.outputFileName = "FairScan-${variant.versionName}-${abi}.apk"
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
Expand All @@ -99,7 +126,20 @@ android {
}
}

apply(from = file("download-tflite.gradle.kts"))
androidComponents {
onVariants { variant ->
variant.sources.assets?.addGeneratedSourceDirectory(
downloadTFLiteModel,
DownloadTFLiteModelTask::outputDirectory,
)
variant.outputs.forEach { output ->
val abi = output.filters
.find { it.filterType == FilterConfiguration.FilterType.ABI }
?.identifier
output.outputFileName = "FairScan-${output.versionName.get()}-${abi}.apk"
}
}
}

dependencies {

Expand Down Expand Up @@ -136,6 +176,7 @@ dependencies {
implementation(libs.reorderable)
implementation(libs.aboutlibraries.compose.m3)
implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.collections.immutable)
implementation(libs.tesseract4android)

testImplementation(libs.junit)
Expand Down
38 changes: 0 additions & 38 deletions app/download-tflite.gradle.kts

This file was deleted.

5 changes: 3 additions & 2 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
-dontwarn com.gemalto.jp2.JP2Encoder
-dontwarn org.bouncycastle.**

-keep class org.fairscan.app.RecentDocument* { *; }
-keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite { *; }
# to have at least org.opencv.core.CvException
-keep class org.opencv.core.** { *; }
# to avoid crashes with LiteRT
-keep class org.tensorflow.lite.support.image.** { *; }
-keep class org.tensorflow.lite.support.common.** { *; }
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.compose) apply false
alias(libs.plugins.aboutLibrariesAndroid) apply false
alias(libs.plugins.license)
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true
# LiteRT 1.4.1 has duplicate namespace org.tensorflow.lite.support
android.uniquePackageNames=false
7 changes: 4 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
agp = "8.10.1"
agp = "9.4.1"
kotlin = "2.3.10"
license = "0.16.1"
coreKtx = "1.18.0"
Expand All @@ -18,10 +18,11 @@ opencv_java = "4.9.0-0"
assertj = "3.27.7"
pdfbox = "2.0.27.0"
zoomable = "2.11.1"
aboutLibraries = "13.2.1"
aboutLibraries = "14.2.0"
kotlinSerialization = "1.10.0"
reorderable = "3.0.0"
jetbrainsKotlinJvm = "2.3.10"
kt-coll-immutable = "0.5.2"
coroutines-test = "1.10.2"
tesseract4android = "4.9.0"

Expand Down Expand Up @@ -59,6 +60,7 @@ pdfbox = { group = "com.tom-roush", name = "pdfbox-android", version.ref = "pdfb
zoomable = { group = "net.engawapg.lib", name = "zoomable", version.ref = "zoomable" }
reorderable = { module = "sh.calvin.reorderable:reorderable", version.ref = "reorderable" }
aboutlibraries-compose-m3 = { module = "com.mikepenz:aboutlibraries-compose-m3", version.ref = "aboutLibraries" }
kotlinx-collections-immutable = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version.ref = "kt-coll-immutable" }
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinSerialization" }
kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutines-test" }
tesseract4android = { group = "cz.adaptech.tesseract4android", name = "tesseract4android-openmp", version.ref = "tesseract4android" }
Expand All @@ -67,7 +69,6 @@ assertj = { group="org.assertj", name="assertj-core", version.ref = "assertj" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
license = { id = "com.github.hierynomus.license", version.ref = "license" }
Expand Down
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Fri May 09 12:08:17 CEST 2025
#Mon Oct 05 15:53:29 CEST 2026
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionSha256Sum=bbaeb2fef8710818cf0e261201dab964c572f92b942812df0c3620d62a529a01
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading