A fully functional Android app built entirely with Kotlin and Jetpack Compose
bug: fixed bug #534 of multiple clicks on the interests screen
vishesha4eddf6fa37f
diff --git a/build.gradle.kts b/build.gradle.ktsindex 6f6d375d7..fe4cad4d5 100644--- a/build.gradle.kts+++ b/build.gradle.kts@@ -26,6 +26,8 @@ buildscript {}plugins {+ java+ applicationalias(libs.plugins.android.application) apply falsealias(libs.plugins.kotlin.jvm) apply falsealias(libs.plugins.kotlin.serialization) apply falsediff --git a/feature/interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/TabContent.kt b/feature/interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/TabContent.ktindex 0cff8c82c..bad2c1220 100644--- a/feature/interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/TabContent.kt+++ b/feature/interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/TabContent.kt@@ -25,9 +25,12 @@ import androidx.compose.foundation.layout.windowInsetsBottomHeightimport androidx.compose.foundation.lazy.LazyColumnimport androidx.compose.runtime.Composableimport androidx.compose.ui.Modifier+import androidx.compose.ui.input.pointer.PointerEventPass+import androidx.compose.ui.input.pointer.pointerInputimport androidx.compose.ui.platform.testTagimport androidx.compose.ui.unit.dpimport com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic+import kotlinx.coroutines.coroutineScope@Composablefun TopicsTabContent(@@ -39,7 +42,8 @@ fun TopicsTabContent(LazyColumn(modifier = modifier.padding(horizontal = 16.dp)- .testTag("interests:topics"),+ .testTag("interests:topics")+ .disableSplitMotionEvents(),contentPadding = PaddingValues(top = 8.dp)) {topics.forEach { followableTopic ->@@ -61,3 +65,22 @@ fun TopicsTabContent(}}}++fun Modifier.disableSplitMotionEvents() =+ pointerInput(Unit) {+ coroutineScope {+ var currentId: Long = -1L+ awaitPointerEventScope {+ while (true) {+ awaitPointerEvent(PointerEventPass.Initial).changes.forEach { pointerInfo ->+ when {+ pointerInfo.pressed && currentId == -1L -> currentId = pointerInfo.id.value+ pointerInfo.pressed.not() && currentId == pointerInfo.id.value -> currentId = -1+ pointerInfo.id.value != currentId && currentId != -1L -> pointerInfo.consume()+ else -> Unit+ }+ }+ }+ }+ }+ }