From 8fb2fda086d7645cdc493dd8d2abd0d6f27295f4 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Thu, 8 Aug 2024 22:06:06 -0700 Subject: [PATCH 1/3] Update target --- app/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 913d316..495caf4 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -17,13 +17,13 @@ apply { } android { - compileSdk = 34 + compileSdk = 35 namespace = "f.cking.software" defaultConfig { applicationId = "f.cking.software" minSdk = 29 - targetSdk = 34 + targetSdk = 35 versionCode = 1708536357 versionName = "0.26.1-beta" From ec7d937199f78f75b31fae61a119cd4f4b47ea3a Mon Sep 17 00:00:00 2001 From: Konstantin Date: Thu, 8 Aug 2024 22:27:23 -0700 Subject: [PATCH 2/3] Disable pagination, downgrade java version --- app/build.gradle.kts | 12 ++++++------ .../software/ui/devicelist/DeviceListScreen.kt | 11 ++++++----- .../software/ui/devicelist/DeviceListViewModel.kt | 13 ++++++++----- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 495caf4..98ec9cd 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -25,8 +25,8 @@ android { minSdk = 29 targetSdk = 35 - versionCode = 1708536357 - versionName = "0.26.1-beta" + versionCode = 1708536358 + versionName = "0.26.2-beta" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" @@ -108,16 +108,16 @@ android { } compileOptions { - sourceCompatibility = JavaVersion.VERSION_22 - targetCompatibility = JavaVersion.VERSION_22 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } kotlin { - jvmToolchain(22) + jvmToolchain(21) } kotlinOptions { - jvmTarget = "22" + jvmTarget = "21" } buildFeatures.apply { diff --git a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt index b4cbd49..7fc27fa 100644 --- a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt @@ -158,8 +158,10 @@ object DeviceListScreen { } } - viewModel.devicesViewState.mapIndexed { index, deviceData -> - item(contentType = ListContentType.DEVICE, key = "device_${deviceData.address}") { + val devices = viewModel.devicesViewState + + items(devices.size, key = { "device_${devices[it]}" }, contentType = { ListContentType.DEVICE}) { index -> + val deviceData = devices[index] DeviceListItem( modifier = Modifier.animateItemPlacement(), device = deviceData, @@ -167,10 +169,9 @@ object DeviceListScreen { onTagSelected = { viewModel.onTagSelected(it) }, ) - } val showDivider = viewModel.devicesViewState.getOrNull(index + 1)?.lastDetectTimeMs != deviceData.lastDetectTimeMs if (showDivider) { - item(contentType = ListContentType.DIVIDER, key = "${deviceData.lastDetectTimeMs}") { Divider(Modifier.animateItemPlacement()) } + Divider(Modifier.animateItemPlacement()) } } @@ -193,7 +194,7 @@ object DeviceListScreen { } enum class ListContentType { - ENJOY_THE_APP, CURRENT_BATCH, DEVICE, DIVIDER, PAGINATION_PROGRESS, BOTTOM_SPACER, + ENJOY_THE_APP, CURRENT_BATCH, DEVICE, PAGINATION_PROGRESS, BOTTOM_SPACER, } @Composable diff --git a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListViewModel.kt b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListViewModel.kt index 24bc70c..4f08e60 100644 --- a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListViewModel.kt +++ b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListViewModel.kt @@ -114,11 +114,14 @@ class DeviceListViewModel( val anyFilterApplyed = isSearchMode || appliedFilter.isNotEmpty() scannerObservingJob?.cancel() - if (isScannerEnabled || anyFilterApplyed) { - disablePagination() - } else { - enablePagination() - } + disablePagination() + + // TODO fix realtime items observing before enabling pagination +// if (isScannerEnabled || anyFilterApplyed) { +// disablePagination() +// } else { +// enablePagination() +// } if (invalidateCurrentBatch) { lastBatchJob?.cancel() From 9b30f68bfc1405f498fa09d8431c6b0fcc66685c Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 20 Aug 2024 15:21:46 -0700 Subject: [PATCH 3/3] Chose JVM property from the current env --- app/build.gradle.kts | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 98ec9cd..fc6f42c 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -19,6 +19,7 @@ apply { android { compileSdk = 35 namespace = "f.cking.software" + val javaConfig: JavaConfig = JavaConfig.getByString(getEnvJavaConfigVersion()) defaultConfig { applicationId = "f.cking.software" @@ -108,16 +109,16 @@ android { } compileOptions { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = javaConfig.javaVersion + targetCompatibility = javaConfig.javaVersion } kotlin { - jvmToolchain(21) + jvmToolchain(javaConfig.jdkVersion) } kotlinOptions { - jvmTarget = "21" + jvmTarget = javaConfig.jvmTarget } buildFeatures.apply { @@ -195,4 +196,30 @@ dependencies { // tests testImplementation(libs.junit) androidTestImplementation(libs.ktx.testing) +} + +private fun getEnvJavaConfigVersion(): String { + val version = gradleLocalProperties(rootDir, providers).getProperty("JAVA_CONFIG_VERSION", System.getenv("JAVA_CONFIG_VERSION") ?: "UNSPECIFIED") + println("Environment JDK version selected is ${version}. To override it define JAVA_CONFIG_VERSION environment variable or local properties.") + return version +} + +enum class JavaConfig(val jvmTarget: String, val jdkVersion: Int, val javaVersion: JavaVersion) { + JAVA_21("21", 21, JavaVersion.VERSION_21), + JAVA_22("22", 22, JavaVersion.VERSION_22); + + companion object { + fun getByString(versionStr: String?): JavaConfig { + return when (versionStr) { + "21" -> JAVA_21 + "22" -> JAVA_22 + else -> { + println("Java version ${versionStr} is not recognized. The default one will be used instead for this project: ${DEFAULT.jvmTarget}") + DEFAULT + } + } + } + + private val DEFAULT = JAVA_22 + } } \ No newline at end of file