Minor tweaks

This commit is contained in:
soraefir
2026-09-03 01:43:00 +02:00
parent 8c7dfd8568
commit 741e3cf861
4 changed files with 28 additions and 3 deletions
+21
View File
@@ -2,6 +2,7 @@ plugins {
id 'com.android.application' version '9.3.2'
id 'org.jetbrains.kotlin.plugin.serialization' version '2.4.10'
id 'org.jetbrains.kotlin.plugin.compose' version '2.4.10'
id 'jacoco'
}
android {
@@ -40,6 +41,7 @@ android {
debuggable true
initWith(buildTypes.release)
signingConfig = signingConfigs.debug
enableUnitTestCoverage true
}
release {
minifyEnabled true
@@ -135,3 +137,22 @@ dependencies {
testImplementation 'androidx.test:core:1.7.0'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.11.0'
}
tasks.register('jacocoTestReport', JacocoReport) {
dependsOn 'testDebugUnitTest'
reports {
xml.required = true
html.required = true
}
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*']
def debugTree = fileTree(dir: "${project.layout.buildDirectory.asFile.get()}/intermediates/built_in_kotlinc/debug/compileDebugKotlin/classes", excludes: fileFilter)
def mainSrc = "${project.projectDir}/src/main/java"
sourceDirectories.from = files([mainSrc])
classDirectories.from = files([debugTree])
executionData.from = fileTree(dir: project.layout.buildDirectory.asFile.get(), includes: [
'jacoco/testDebugUnitTest.exec', 'outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec'
])
}
@@ -88,6 +88,7 @@ object BillsListUtils {
shareIntent,
context.getString(R.string.title_settle)
)
chooserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(chooserIntent)
}
@@ -85,7 +85,8 @@ class CowspentServerSyncHelper private constructor(private val dbHelper: Cowspen
val isSyncPossible: Boolean
get() {
updateNetworkStatus()
return networkConnected
val offlineMode = preferences.getBoolean(appContext.getString(R.string.pref_key_offline_mode), false)
return networkConnected && !offlineMode
}
fun addCallbackPull(callback: ICallback) {
@@ -1214,7 +1215,7 @@ class CowspentServerSyncHelper private constructor(private val dbHelper: Cowspen
}
}
private fun hasChanged(localBill: DBBill, remoteBill: DBBill): Boolean {
internal fun hasChanged(localBill: DBBill, remoteBill: DBBill): Boolean {
if (localBill.payerId == remoteBill.payerId &&
localBill.amount == remoteBill.amount &&
localBill.timestamp == remoteBill.timestamp &&
@@ -5,9 +5,11 @@ fun evalMath(expression: String): Double {
var result = 0.0
var db: SQLiteDatabase? = null
try {
// Force floating point division by replacing / with * 1.0 /
val forcedRealExpr = expression.replace("/", "* 1.0 /")
// Opens a temporary, in-memory system database block
db = SQLiteDatabase.create(null)
val cursor = db.rawQuery("SELECT ($expression);", null)
val cursor = db.rawQuery("SELECT ($forcedRealExpr);", null)
if (cursor.moveToFirst()) {
result = cursor.getDouble(0)
}