Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.26.2-beta #155

Merged
merged 4 commits into from
Aug 20, 2024
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
43 changes: 35 additions & 8 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ apply {
}

android {
compileSdk = 34
compileSdk = 35
namespace = "f.cking.software"
val javaConfig: JavaConfig = JavaConfig.getByString(getEnvJavaConfigVersion())

defaultConfig {
applicationId = "f.cking.software"
minSdk = 29
targetSdk = 34
targetSdk = 35

versionCode = 1708536357
versionName = "0.26.1-beta"
versionCode = 1708536358
versionName = "0.26.2-beta"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down Expand Up @@ -108,16 +109,16 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_22
targetCompatibility = JavaVersion.VERSION_22
sourceCompatibility = javaConfig.javaVersion
targetCompatibility = javaConfig.javaVersion
}

kotlin {
jvmToolchain(22)
jvmToolchain(javaConfig.jdkVersion)
}

kotlinOptions {
jvmTarget = "22"
jvmTarget = javaConfig.jvmTarget
}

buildFeatures.apply {
Expand Down Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,20 @@ 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,
onClick = { viewModel.onDeviceClick(deviceData) },
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())
}
}

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading