Minor tweaks
This commit is contained in:
@@ -2,6 +2,7 @@ plugins {
|
|||||||
id 'com.android.application' version '9.3.2'
|
id 'com.android.application' version '9.3.2'
|
||||||
id 'org.jetbrains.kotlin.plugin.serialization' version '2.4.10'
|
id 'org.jetbrains.kotlin.plugin.serialization' version '2.4.10'
|
||||||
id 'org.jetbrains.kotlin.plugin.compose' version '2.4.10'
|
id 'org.jetbrains.kotlin.plugin.compose' version '2.4.10'
|
||||||
|
id 'jacoco'
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
@@ -40,6 +41,7 @@ android {
|
|||||||
debuggable true
|
debuggable true
|
||||||
initWith(buildTypes.release)
|
initWith(buildTypes.release)
|
||||||
signingConfig = signingConfigs.debug
|
signingConfig = signingConfigs.debug
|
||||||
|
enableUnitTestCoverage true
|
||||||
}
|
}
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
@@ -135,3 +137,22 @@ dependencies {
|
|||||||
testImplementation 'androidx.test:core:1.7.0'
|
testImplementation 'androidx.test:core:1.7.0'
|
||||||
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.11.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,
|
shareIntent,
|
||||||
context.getString(R.string.title_settle)
|
context.getString(R.string.title_settle)
|
||||||
)
|
)
|
||||||
|
chooserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
context.startActivity(chooserIntent)
|
context.startActivity(chooserIntent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ class CowspentServerSyncHelper private constructor(private val dbHelper: Cowspen
|
|||||||
val isSyncPossible: Boolean
|
val isSyncPossible: Boolean
|
||||||
get() {
|
get() {
|
||||||
updateNetworkStatus()
|
updateNetworkStatus()
|
||||||
return networkConnected
|
val offlineMode = preferences.getBoolean(appContext.getString(R.string.pref_key_offline_mode), false)
|
||||||
|
return networkConnected && !offlineMode
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addCallbackPull(callback: ICallback) {
|
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 &&
|
if (localBill.payerId == remoteBill.payerId &&
|
||||||
localBill.amount == remoteBill.amount &&
|
localBill.amount == remoteBill.amount &&
|
||||||
localBill.timestamp == remoteBill.timestamp &&
|
localBill.timestamp == remoteBill.timestamp &&
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ fun evalMath(expression: String): Double {
|
|||||||
var result = 0.0
|
var result = 0.0
|
||||||
var db: SQLiteDatabase? = null
|
var db: SQLiteDatabase? = null
|
||||||
try {
|
try {
|
||||||
|
// Force floating point division by replacing / with * 1.0 /
|
||||||
|
val forcedRealExpr = expression.replace("/", "* 1.0 /")
|
||||||
// Opens a temporary, in-memory system database block
|
// Opens a temporary, in-memory system database block
|
||||||
db = SQLiteDatabase.create(null)
|
db = SQLiteDatabase.create(null)
|
||||||
val cursor = db.rawQuery("SELECT ($expression);", null)
|
val cursor = db.rawQuery("SELECT ($forcedRealExpr);", null)
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
result = cursor.getDouble(0)
|
result = cursor.getDouble(0)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user