diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts index f2399c9b..c02f178c 100644 --- a/build-logic/convention/build.gradle.kts +++ b/build-logic/convention/build.gradle.kts @@ -12,17 +12,25 @@ repositories { dependencies { implementation(libs.kotlin.gradle.plugin) implementation(libs.android.gradle.plugin) + compileOnly(libs.compose.gradle.plugin) implementation(libs.dokka.plugin) implementation(libs.org.jacoco.core) implementation(libs.gradle.maven.publish.plugin) - } gradlePlugin { plugins { register("publishingConventionPlugin") { - id = "android.maps.compose.PublishingConventionPlugin" + id = "android.maps.compose.publish" implementationClass = "PublishingConventionPlugin" } + register("androidLibraryConventionPlugin") { + id = "android.maps.compose.library" + implementationClass = "AndroidLibraryConventionPlugin" + } + register("androidApplicationConventionPlugin") { + id = "android.maps.compose.application" + implementationClass = "AndroidApplicationConventionPlugin" + } } } \ No newline at end of file diff --git a/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt new file mode 100644 index 00000000..19ace840 --- /dev/null +++ b/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt @@ -0,0 +1,22 @@ +import com.android.build.api.dsl.ApplicationExtension +import internal.configureAndroidCompose +import internal.configureKotlinAndroid +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure + +class AndroidApplicationConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + apply(plugin = "com.android.application") + apply(plugin = "org.jetbrains.kotlin.android") + + extensions.configure { + configureKotlinAndroid(this, isLibrary = false) + defaultConfig.targetSdk = 36 + configureAndroidCompose(this) + } + } + } +} \ No newline at end of file diff --git a/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt new file mode 100644 index 00000000..a2d06009 --- /dev/null +++ b/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt @@ -0,0 +1,22 @@ +import com.android.build.api.dsl.LibraryExtension +import internal.configureAndroidCompose +import internal.configureKotlinAndroid +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure + +class AndroidLibraryConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + apply(plugin = "com.android.library") + apply(plugin = "org.jetbrains.kotlin.android") + + extensions.configure { + configureKotlinAndroid(this) + defaultConfig.targetSdk = 36 + configureAndroidCompose(this) + } + } + } +} \ No newline at end of file diff --git a/build-logic/convention/src/main/kotlin/PublishingConventionPlugin.kt b/build-logic/convention/src/main/kotlin/PublishingConventionPlugin.kt index 0ea4f542..45868ec8 100644 --- a/build-logic/convention/src/main/kotlin/PublishingConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/PublishingConventionPlugin.kt @@ -28,7 +28,6 @@ class PublishingConventionPlugin : Plugin { private fun Project.configureJacoco() { configure { toolVersion = "0.8.7" - } tasks.withType().configureEach { diff --git a/build-logic/convention/src/main/kotlin/internal/AndroidCompose.kt b/build-logic/convention/src/main/kotlin/internal/AndroidCompose.kt new file mode 100644 index 00000000..cb5e9483 --- /dev/null +++ b/build-logic/convention/src/main/kotlin/internal/AndroidCompose.kt @@ -0,0 +1,52 @@ +package internal + +import com.android.build.api.dsl.CommonExtension +import org.gradle.api.Project +import org.gradle.api.provider.Provider +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies +import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension + +/** + * Configure Compose-specific options + */ +internal fun Project.configureAndroidCompose( + commonExtension: CommonExtension<*, *, *, *, *, *>, +) { + apply(plugin = "org.jetbrains.kotlin.plugin.compose") + + commonExtension.apply { + buildFeatures { + compose = true + } + + dependencies { + val bom = libs.findLibrary("androidx-compose-bom").get() + "implementation"(platform(bom)) + "androidTestImplementation"(platform(bom)) + "implementation"(libs.findLibrary("androidx-compose-ui-preview-tooling").get()) + "debugImplementation"(libs.findLibrary("androidx-compose-ui-tooling").get()) + } + } + +// extensions.configure { +// fun Provider.onlyIfTrue() = flatMap { provider { it.takeIf(String::toBoolean) } } +// fun Provider<*>.relativeToRootProject(dir: String) = map { +// isolated.rootProject.projectDirectory +// .dir("build") +// .dir(projectDir.toRelativeString(rootDir)) +// }.map { it.dir(dir) } +// +// project.providers.gradleProperty("composeCompilerMetrics").onlyIfTrue() +// .relativeToRootProject("compose-metrics") +// .let(metricsDestination::set) +// +// project.providers.gradleProperty("composeCompilerReports").onlyIfTrue() +// .relativeToRootProject("compose-reports") +// .let(reportsDestination::set) +// +// stabilityConfigurationFiles +// .add(isolated.rootProject.projectDirectory.file("compose_compiler_config.conf")) +// } +} diff --git a/build-logic/convention/src/main/kotlin/internal/KotlinAndroid.kt b/build-logic/convention/src/main/kotlin/internal/KotlinAndroid.kt new file mode 100644 index 00000000..db7ac6b2 --- /dev/null +++ b/build-logic/convention/src/main/kotlin/internal/KotlinAndroid.kt @@ -0,0 +1,93 @@ +package internal + +import com.android.build.api.dsl.CommonExtension +import org.gradle.api.JavaVersion +import org.gradle.api.Project +import org.gradle.api.plugins.JavaPluginExtension +import org.gradle.kotlin.dsl.assign +import org.gradle.kotlin.dsl.configure +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinBaseExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension + +/** + * Configure base Kotlin with Android options + */ +internal fun Project.configureKotlinAndroid( + commonExtension: CommonExtension<*, *, *, *, *, *>, + isLibrary: Boolean = true +) { + commonExtension.apply { + lint { + targetSdk = 36 + sarifOutput = layout.buildDirectory.file("reports/lint-results.sarif").get().asFile + } + + compileSdk = 36 + + defaultConfig { + minSdk = 21 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + testOptions { + targetSdk = 36 + animationsDisabled = true + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + buildFeatures { + buildConfig = false + } + } + + configureKotlin(isLibrary) +} + +/** + * Configure base Kotlin options for JVM (non-Android) + */ +internal fun Project.configureKotlinJvm() { + extensions.configure { + targetCompatibility = JavaVersion.VERSION_1_8 + } + + configureKotlin() +} + +/** + * Configure base Kotlin options + */ +private inline fun Project.configureKotlin(isLibrary: Boolean = true) = configure { + // Treat all Kotlin warnings as errors (disabled by default) + // Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties + val warningsAsErrors = providers.gradleProperty("warningsAsErrors").map { + it.toBoolean() + }.orElse(false) + when (this) { + is KotlinAndroidProjectExtension -> compilerOptions + is KotlinJvmProjectExtension -> compilerOptions + else -> TODO("Unsupported project extension $this ${T::class}") + }.apply { + jvmTarget = JvmTarget.JVM_1_8 + allWarningsAsErrors = warningsAsErrors + freeCompilerArgs.add( + "-Xopt-in=kotlin.RequiresOptIn" + ) + if (isLibrary) { + freeCompilerArgs.add( + "-Xexplicit-api=strict" + ) + } + freeCompilerArgs.add( + // Enable experimental coroutines APIs, including Flow + "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", + ) + } +} diff --git a/build-logic/convention/src/main/kotlin/internal/ProjectExtensions.kt b/build-logic/convention/src/main/kotlin/internal/ProjectExtensions.kt new file mode 100644 index 00000000..aa62b404 --- /dev/null +++ b/build-logic/convention/src/main/kotlin/internal/ProjectExtensions.kt @@ -0,0 +1,9 @@ +package internal + +import org.gradle.api.Project +import org.gradle.api.artifacts.VersionCatalog +import org.gradle.api.artifacts.VersionCatalogsExtension +import org.gradle.kotlin.dsl.getByType + +val Project.libs + get(): VersionCatalog = extensions.getByType().named("libs") diff --git a/build.gradle.kts b/build.gradle.kts index f7312805..2a707b11 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,27 +1,12 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - val kotlinVersion by extra(libs.versions.kotlin.get()) - val androidxTestVersion by extra(libs.versions.androidxtest.get()) - repositories { - google() - mavenCentral() - } - dependencies { - classpath(libs.android.gradle.plugin) - classpath(libs.maps.secrets.plugin) - classpath(libs.kotlin.gradle.plugin) - classpath(libs.dokka.plugin) - classpath(libs.jacoco.android.plugin) - } -} - plugins { alias(libs.plugins.dokka) apply true alias(libs.plugins.compose.compiler) apply false id("com.autonomousapps.dependency-analysis") version "2.0.0" alias(libs.plugins.android.application) apply false + alias(libs.plugins.android.library) apply false alias(libs.plugins.kotlin.android) apply false - + alias(libs.plugins.maps.secrets.gradle.plugin) apply false + alias(libs.plugins.jacoco.android) apply false } val projectArtifactId by extra { project: Project -> diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f4bf46c5..b33d9eb3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -43,15 +43,14 @@ androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidCo androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidxtest" } dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" } gradle-maven-publish-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "gradleMavenPublishPlugin" } -jacoco-android-plugin = { module = "com.mxalbert.gradle:jacoco-android", version.ref = "jacoco-plugin", version.require = "0.2.1" } +compose-gradle-plugin = { module = "org.jetbrains.kotlin:compose-compiler-gradle-plugin", version.ref = "kotlin" } kotlin = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk7", version.ref = "kotlin" } -kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } +kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version = "2.2.0" } kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" } kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinxCoroutines" } leakcanary-android = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "leakcanaryAndroid" } maps-ktx-std = { module = "com.google.maps.android:maps-ktx", version.ref = "mapsktx" } maps-ktx-utils = { module = "com.google.maps.android:maps-utils-ktx", version.ref = "mapsktx" } -maps-secrets-plugin = { module = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin", version.ref = "mapsecrets" } org-jacoco-core = { module = "org.jacoco:org.jacoco.core", version.ref = "org-jacoco-core" } test-junit = { module = "junit:junit", version.ref = "junit" } androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } @@ -62,7 +61,10 @@ truth = { module = "com.google.truth:truth", version.ref = "truth" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" } +android-library = { id = "com.android.library", version.ref = "agp" } compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } screenshot = { id = "com.android.compose.screenshot", version.ref = "screenshot"} +maps-secrets-gradle-plugin = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version.ref = "mapsecrets" } +jacoco-android = { id = "com.mxalbert.gradle.jacoco-android", version.ref = "jacoco-plugin" } diff --git a/maps-app/build.gradle.kts b/maps-app/build.gradle.kts index 01234fd9..85db1059 100644 --- a/maps-app/build.gradle.kts +++ b/maps-app/build.gradle.kts @@ -1,18 +1,12 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { - id("com.android.application") - id("kotlin-android") - id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin") - alias(libs.plugins.compose.compiler) + id("android.maps.compose.application") + alias(libs.plugins.maps.secrets.gradle.plugin) alias(libs.plugins.screenshot) } android { - lint { - sarifOutput = layout.buildDirectory.file("reports/lint-results.sarif").get().asFile - } - buildTypes { getByName("debug") { enableUnitTestCoverage = true @@ -25,34 +19,15 @@ android { } namespace = "com.google.maps.android.compose" - compileSdk = 36 defaultConfig { - minSdk = 21 - targetSdk = 36 versionCode = 1 versionName = "1.0" - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } buildFeatures { buildConfig = true - compose = true - } - - - kotlin { - compilerOptions { - jvmTarget.set(JvmTarget.JVM_1_8) - freeCompilerArgs.addAll( - "-opt-in=kotlin.RequiresOptIn" - ) - } } experimentalProperties["android.experimental.enableScreenshotTest"] = true @@ -65,7 +40,6 @@ android { } dependencies { - implementation(platform(libs.androidx.compose.bom)) implementation(libs.androidx.compose.activity) implementation(libs.androidx.compose.foundation) implementation(libs.androidx.compose.material) @@ -79,7 +53,6 @@ dependencies { debugImplementation(libs.androidx.compose.ui.tooling) debugImplementation(libs.leakcanary.android) - androidTestImplementation(platform(libs.androidx.compose.bom)) androidTestImplementation(libs.androidx.test.core) androidTestImplementation(libs.androidx.test.rules) androidTestImplementation(libs.androidx.test.runner) diff --git a/maps-app/src/androidTest/java/com/google/maps/android/compose/MapsInLazyColumnTest.kt b/maps-app/src/androidTest/java/com/google/maps/android/compose/MapsInLazyColumnTest.kt index 2e501e0c..43c3beea 100644 --- a/maps-app/src/androidTest/java/com/google/maps/android/compose/MapsInLazyColumnTest.kt +++ b/maps-app/src/androidTest/java/com/google/maps/android/compose/MapsInLazyColumnTest.kt @@ -108,6 +108,6 @@ class MapsInLazyColumnTests { initMaps() composeTestRule.onRoot().performTouchInput { swipeUp(durationMillis = 1000) } composeTestRule.waitForIdle() - //We do not need to check anything on the test, just to make sure the scroll down doesnt crash + //We do not need to check anything on the test, just to make sure the scroll down doesn't crash } } diff --git a/maps-compose-utils/build.gradle.kts b/maps-compose-utils/build.gradle.kts index d0583c13..e67f18f6 100644 --- a/maps-compose-utils/build.gradle.kts +++ b/maps-compose-utils/build.gradle.kts @@ -1,49 +1,16 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - plugins { - id("kotlin-android") - alias(libs.plugins.compose.compiler) - id("android.maps.compose.PublishingConventionPlugin") + id("android.maps.compose.library") + id("android.maps.compose.publish") } android { - lint { - sarifOutput = layout.buildDirectory.file("reports/lint-results.sarif").get().asFile - } - namespace = "com.google.maps.android.compose.utils" - compileSdk = 36 - - defaultConfig { - minSdk = 21 - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - - buildFeatures { - buildConfig = false - compose = true - } - - kotlin { - compilerOptions { - jvmTarget.set(JvmTarget.JVM_1_8) - freeCompilerArgs.addAll( - "-Xexplicit-api=strict", - "-Xopt-in=kotlin.RequiresOptIn" - ) - } - } } dependencies { api(project(":maps-compose")) - implementation(libs.androidx.core) - implementation(platform(libs.androidx.compose.bom)) +// implementation(libs.androidx.core) implementation(libs.androidx.compose.ui) implementation(libs.kotlin) implementation(libs.kotlinx.coroutines.android) diff --git a/maps-compose-utils/src/main/java/com/google/maps/android/compose/clustering/ClusterRenderer.kt b/maps-compose-utils/src/main/java/com/google/maps/android/compose/clustering/ClusterRenderer.kt index b96cf469..267cadd0 100644 --- a/maps-compose-utils/src/main/java/com/google/maps/android/compose/clustering/ClusterRenderer.kt +++ b/maps-compose-utils/src/main/java/com/google/maps/android/compose/clustering/ClusterRenderer.kt @@ -1,7 +1,6 @@ package com.google.maps.android.compose.clustering import android.content.Context -import android.graphics.Bitmap import android.graphics.Canvas import android.view.View import android.view.ViewGroup @@ -27,6 +26,7 @@ import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch +import androidx.core.graphics.createBitmap /** * Implementation of [ClusterRenderer] that renders marker bitmaps from Compose UI content. @@ -173,18 +173,14 @@ internal class ComposeUiClusterRenderer( so trigger a draw to an empty canvas to force that */ view.draw(fakeCanvas) val viewParent = - view.parent as? ViewGroup ?: return Bitmap.createBitmap(20, 20, Bitmap.Config.ARGB_8888) + view.parent as? ViewGroup ?: return createBitmap(20, 20) .let(BitmapDescriptorFactory::fromBitmap) view.measure( View.MeasureSpec.makeMeasureSpec(viewParent.width, View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(viewParent.height, View.MeasureSpec.AT_MOST), ) view.layout(0, 0, view.measuredWidth, view.measuredHeight) - val bitmap = Bitmap.createBitmap( - view.measuredWidth.takeIf { it > 0 } ?: 1, - view.measuredHeight.takeIf { it > 0 } ?: 1, - Bitmap.Config.ARGB_8888 - ) + val bitmap = createBitmap(view.measuredWidth.takeIf { it > 0 } ?: 1, view.measuredHeight.takeIf { it > 0 } ?: 1) bitmap.applyCanvas { view.draw(this) } diff --git a/maps-compose-widgets/build.gradle.kts b/maps-compose-widgets/build.gradle.kts index 8ec76cea..1e6048a7 100644 --- a/maps-compose-widgets/build.gradle.kts +++ b/maps-compose-widgets/build.gradle.kts @@ -1,58 +1,24 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - plugins { - id("kotlin-android") - alias (libs.plugins.compose.compiler) - id("android.maps.compose.PublishingConventionPlugin") + id("android.maps.compose.library") + id("android.maps.compose.publish") } android { - lint { - sarifOutput = layout.buildDirectory.file("reports/lint-results.sarif").get().asFile - } - namespace = "com.google.maps.android.compose.widgets" - compileSdk = 36 - - defaultConfig { - minSdk = 21 - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - - buildFeatures { - buildConfig = false - compose = true - } - - kotlin { - compilerOptions { - jvmTarget.set(JvmTarget.JVM_1_8) - freeCompilerArgs.addAll( - "-Xexplicit-api=strict", - "-Xopt-in=kotlin.RequiresOptIn" - ) - } - } } dependencies { implementation(project(":maps-compose")) - implementation(platform(libs.androidx.compose.bom)) implementation(libs.androidx.compose.foundation) implementation(libs.androidx.compose.material) - implementation(libs.androidx.core) +// implementation(libs.androidx.core) implementation(libs.kotlin) implementation(libs.kotlinx.coroutines.android) api(libs.maps.ktx.std) api(libs.maps.ktx.utils) testImplementation(libs.test.junit) - androidTestImplementation(platform(libs.androidx.compose.bom)) androidTestImplementation(libs.androidx.test.espresso) androidTestImplementation(libs.androidx.test.junit.ktx) } diff --git a/maps-compose/build.gradle.kts b/maps-compose/build.gradle.kts index ad2b7599..a5bad523 100644 --- a/maps-compose/build.gradle.kts +++ b/maps-compose/build.gradle.kts @@ -1,43 +1,10 @@ -import org.gradle.kotlin.dsl.sourceSets -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - plugins { - id("org.jetbrains.kotlin.android") - alias(libs.plugins.compose.compiler) - id("android.maps.compose.PublishingConventionPlugin") + id("android.maps.compose.library") + id("android.maps.compose.publish") } android { - lint { - sarifOutput = layout.buildDirectory.file("reports/lint-results.sarif").get().asFile - } - namespace = "com.google.maps.android.compose" - compileSdk = 36 - - defaultConfig { - minSdk = 21 - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - - buildFeatures { - buildConfig = false - compose = true - } - - kotlin { - compilerOptions { - jvmTarget.set(JvmTarget.JVM_1_8) - freeCompilerArgs.addAll( - "-Xexplicit-api=strict", - "-Xopt-in=kotlin.RequiresOptIn" - ) - } - } sourceSets["main"].java.srcDir("build/generated/source/artifactId") } @@ -57,7 +24,6 @@ composeCompiler { dependencies { - implementation(platform(libs.androidx.compose.bom)) implementation(libs.androidx.core) implementation(libs.androidx.compose.foundation) implementation(libs.kotlin) @@ -66,7 +32,6 @@ dependencies { testImplementation(libs.test.junit) - androidTestImplementation(platform(libs.androidx.compose.bom)) androidTestImplementation(libs.androidx.test.espresso) androidTestImplementation(libs.androidx.test.junit.ktx) } diff --git a/maps-compose/src/main/java/com/google/maps/android/compose/CameraPositionState.kt b/maps-compose/src/main/java/com/google/maps/android/compose/CameraPositionState.kt index e6e9096c..08a65a8f 100644 --- a/maps-compose/src/main/java/com/google/maps/android/compose/CameraPositionState.kt +++ b/maps-compose/src/main/java/com/google/maps/android/compose/CameraPositionState.kt @@ -221,7 +221,7 @@ public class CameraPositionState private constructor( public suspend fun animate(update: CameraUpdate, durationMs: Int = MAX_VALUE) { val myJob = currentCoroutineContext()[Job] try { - suspendCancellableCoroutine { continuation -> + suspendCancellableCoroutine { continuation -> synchronized(lock) { movementOwner = myJob val map = map diff --git a/maps-compose/src/main/java/com/google/maps/android/compose/ComposeInfoWindowAdapter.kt b/maps-compose/src/main/java/com/google/maps/android/compose/ComposeInfoWindowAdapter.kt index cfaf370b..318ce017 100644 --- a/maps-compose/src/main/java/com/google/maps/android/compose/ComposeInfoWindowAdapter.kt +++ b/maps-compose/src/main/java/com/google/maps/android/compose/ComposeInfoWindowAdapter.kt @@ -42,7 +42,7 @@ internal class ComposeInfoWindowAdapter( override fun getInfoContents(marker: Marker): View? { val markerNode = markerNodeFinder(marker) ?: return null - val content = markerNode.infoContent + val content = markerNode.infoContent if (content == null) { return null } @@ -55,7 +55,7 @@ internal class ComposeInfoWindowAdapter( override fun getInfoWindow(marker: Marker): View? { val markerNode = markerNodeFinder(marker) ?: return null - val infoWindow = markerNode.infoWindow + val infoWindow = markerNode.infoWindow if (infoWindow == null) { return null } diff --git a/maps-compose/src/main/java/com/google/maps/android/compose/MapClickListeners.kt b/maps-compose/src/main/java/com/google/maps/android/compose/MapClickListeners.kt index 42b3ee6e..00da0f7e 100644 --- a/maps-compose/src/main/java/com/google/maps/android/compose/MapClickListeners.kt +++ b/maps-compose/src/main/java/com/google/maps/android/compose/MapClickListeners.kt @@ -84,7 +84,6 @@ internal class MapClickListenerNode( private fun setListener(listenerOrNull: L?) = map.setter(listenerOrNull) } -@Suppress("ComplexRedundantLet") @Composable internal fun MapClickListenerUpdater() { // The mapClickListeners container object is not allowed to ever change diff --git a/maps-compose/src/main/java/com/google/maps/android/compose/MapEffect.kt b/maps-compose/src/main/java/com/google/maps/android/compose/MapEffect.kt index 6cac92b7..80672d9d 100644 --- a/maps-compose/src/main/java/com/google/maps/android/compose/MapEffect.kt +++ b/maps-compose/src/main/java/com/google/maps/android/compose/MapEffect.kt @@ -1,10 +1,10 @@ package com.google.maps.android.compose import androidx.compose.runtime.Composable -import androidx.compose.runtime.ExperimentalComposeApi import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.currentComposer import com.google.android.gms.maps.GoogleMap +import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.CoroutineScope /** @@ -13,7 +13,7 @@ import kotlinx.coroutines.CoroutineScope * re-launched when a different [key1] is provided. * * Note: This effect should be used with caution as the [GoogleMap]'s properties is managed by the - * [_root_ide_package_.com.google.maps.android.compose.GoogleMap()] composable function. However, + * [com.google.maps.android.compose.GoogleMap] composable function. However, * there are use cases when obtaining a raw reference to the map is desirable for extensibility * (e.g. using the utility library for clustering). */ @@ -33,7 +33,7 @@ public fun MapEffect(key1: Any?, block: suspend CoroutineScope.(GoogleMap) -> Un * re-launched when a different [key1] or [key2] is provided. * * Note: This effect should be used with caution as the [GoogleMap]'s properties is managed by the - * [_root_ide_package_.com.google.maps.android.compose.GoogleMap()] composable function. However, + * [com.google.maps.android.compose.GoogleMap] composable function. However, * there are use cases when obtaining a raw reference to the map is desirable for extensibility * (e.g. using the utility library for clustering). */ @@ -53,7 +53,7 @@ public fun MapEffect(key1: Any?, key2: Any?, block: suspend CoroutineScope.(Goog * re-launched when a different [key1], [key2], or [key3] is provided. * * Note: This effect should be used with caution as the [GoogleMap]'s properties is managed by the - * [_root_ide_package_.com.google.maps.android.compose.GoogleMap()] composable function. However, + * [com.google.maps.android.compose.GoogleMap] composable function. However, * there are use cases when obtaining a raw reference to the map is desirable for extensibility * (e.g. using the utility library for clustering). */ @@ -78,7 +78,7 @@ public fun MapEffect( * re-launched with any different [keys]. * * Note: This effect should be used with caution as the [GoogleMap]'s properties is managed by the - * [_root_ide_package_.com.google.maps.android.compose.GoogleMap()] composable function. However, + * [com.google.maps.android.compose.GoogleMap] composable function. However, * there are use cases when obtaining a raw reference to the map is desirable for extensibility * (e.g. using the utility library for clustering). */ diff --git a/maps-compose/src/main/java/com/google/maps/android/compose/Polygon.kt b/maps-compose/src/main/java/com/google/maps/android/compose/Polygon.kt index 147d1833..07a14755 100644 --- a/maps-compose/src/main/java/com/google/maps/android/compose/Polygon.kt +++ b/maps-compose/src/main/java/com/google/maps/android/compose/Polygon.kt @@ -46,7 +46,7 @@ internal class PolygonNode( * @param strokeJointType the joint type for all vertices of the polygon's outline * @param strokePattern the stroke pattern for the polygon's outline * @param strokeWidth specifies the polygon's stroke width, in display pixels - * @param tag optional tag to associate wiht the polygon + * @param tag optional tag to associate with the polygon * @param visible the visibility of the polygon * @param zIndex the z-index of the polygon * @param onClick a lambda invoked when the polygon is clicked diff --git a/maps-compose/src/main/java/com/google/maps/android/compose/RememberComposeBitmapDescriptor.kt b/maps-compose/src/main/java/com/google/maps/android/compose/RememberComposeBitmapDescriptor.kt index c61e2805..33e91194 100644 --- a/maps-compose/src/main/java/com/google/maps/android/compose/RememberComposeBitmapDescriptor.kt +++ b/maps-compose/src/main/java/com/google/maps/android/compose/RememberComposeBitmapDescriptor.kt @@ -51,14 +51,13 @@ private fun renderComposableToBitmapDescriptor( composeView.measure(measureSpec, measureSpec) if (composeView.measuredWidth == 0 || composeView.measuredHeight == 0) { - throw IllegalStateException("The ComposeView was measured to have a width or height of " + + error("The ComposeView was measured to have a width or height of " + "zero. Make sure that the content has a non-zero size.") } composeView.layout(0, 0, composeView.measuredWidth, composeView.measuredHeight) - val bitmap = - createBitmap(composeView.measuredWidth, composeView.measuredHeight) + val bitmap = createBitmap(composeView.measuredWidth, composeView.measuredHeight) bitmap.applyCanvas { composeView.draw(this) } diff --git a/maps-compose/src/main/java/com/google/maps/android/compose/streetview/StreetView.kt b/maps-compose/src/main/java/com/google/maps/android/compose/streetview/StreetView.kt index c9d398a6..d844a92f 100644 --- a/maps-compose/src/main/java/com/google/maps/android/compose/streetview/StreetView.kt +++ b/maps-compose/src/main/java/com/google/maps/android/compose/streetview/StreetView.kt @@ -14,7 +14,6 @@ package com.google.maps.android.compose.streetview -import android.content.ComponentCallbacks import android.content.ComponentCallbacks2 import android.content.res.Configuration import android.os.Bundle diff --git a/maps-compose/src/main/java/com/google/maps/android/compose/streetview/StreetViewPanoramaEventListeners.kt b/maps-compose/src/main/java/com/google/maps/android/compose/streetview/StreetViewPanoramaEventListeners.kt index 7b15e6b9..abdaa8ad 100644 --- a/maps-compose/src/main/java/com/google/maps/android/compose/streetview/StreetViewPanoramaEventListeners.kt +++ b/maps-compose/src/main/java/com/google/maps/android/compose/streetview/StreetViewPanoramaEventListeners.kt @@ -3,7 +3,7 @@ package com.google.maps.android.compose.streetview import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue -import com.google.android.gms.maps.model.StreetViewPanoramaCamera +import com.google.android.gms.maps.StreetViewPanorama import com.google.android.gms.maps.model.StreetViewPanoramaOrientation /**