Skip to content

Commit

Permalink
Merge pull request #1 from googlemaps/main
Browse files Browse the repository at this point in the history
merge latest
  • Loading branch information
philip-segerfast authored Oct 5, 2023
2 parents a745600 + 8c6c3b0 commit 1421dc7
Show file tree
Hide file tree
Showing 28 changed files with 460 additions and 159 deletions.
28 changes: 14 additions & 14 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@

version: 2
updates:
- package-ecosystem: gradle
directory: "/./app"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
commit-message:
prefix: chore(deps)
- package-ecosystem: gradle
directory: "/./maps-compose"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
commit-message:
prefix: chore(deps)
- package-ecosystem: "gradle" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
open-pull-requests-limit: 10
commit-message:
prefix: chore(deps)
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
open-pull-requests-limit: 10
commit-message:
prefix: chore(deps)
8 changes: 4 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ jobs:
- name: Gradle Wrapper Validation
uses: gradle/[email protected]

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/[email protected]
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'

# Run dokka and create tar
- name: Generate documentation
run: |
./gradlew dokkaHtml
./gradlew dokkaHtmlMultiModule
echo "Creating tar for generated docs"
cd $GITHUB_WORKSPACE/maps-compose/build/dokka/html && tar cvf ~/maps-compose-docs.tar .
cd $GITHUB_WORKSPACE/build/dokka/htmlMultiModule && tar cvf ~/maps-compose-docs.tar .
echo "Unpacking tar into gh-pages branch"
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/instrumentation-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ jobs:
- name: Gradle Wrapper Validation
uses: gradle/[email protected]

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/[email protected]
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'

- name: Inject Maps API Key
run: |
echo MAPS_API_KEY=$MAPS_API_KEY >> ./local.properties
env:
MAPS_API_KEY: ${{ secrets.ACTIONS_API_KEY }}
run: |
[ -z "$MAPS_API_KEY" ] && MAPS_API_KEY="YOUR_API_KEY"; echo "MAPS_API_KEY=$MAPS_API_KEY" >> ./local.properties
- name: Build debug
run: ./gradlew assembleDebug
Expand Down
27 changes: 20 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ jobs:
with:
token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }}
- uses: gradle/[email protected]
- name: Set up JDK 17
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'adopt'
- name: Create .gpg key
run: |
echo $GPG_KEY_ARMOR | base64 --decode > ./release.asc
Expand All @@ -45,15 +50,23 @@ jobs:
GPG_PASSWORD: ${{ secrets.SYNCED_GPG_KEY_PASSWORD }}
SONATYPE_PASSWORD: ${{ secrets.SYNCED_SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SYNCED_SONATYPE_USERNAME }}

- uses: actions/setup-node@v2
with:
node-version: '14'

- name: Install conventionalcommits
run: npm i -D conventional-changelog-conventionalcommits

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@v3.4.1
with:
extra_plugins: |
"@semantic-release/commit-analyzer"
"@semantic-release/release-notes-generator"
"@google/semantic-release-replace-plugin"
"@semantic-release/exec"
"@semantic-release/git
"@semantic-release/github
"@semantic-release/commit-analyzer@8.0.1"
"@semantic-release/release-notes-generator@9.0.3"
"@google/semantic-release-replace-plugin@1.2.0"
"@semantic-release/exec@5.0.0"
"@semantic-release/git@9.0.1"
"@semantic-release/github@7.2.3"
env:
GH_TOKEN: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }}
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ on:
pull_request:
branches-ignore: ['gh-pages']
workflow_dispatch:
workflow_call:

jobs:
test:
Expand All @@ -36,10 +37,10 @@ jobs:
- name: Gradle Wrapper Validation
uses: gradle/[email protected]

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'

- name: Build modules
Expand Down
2 changes: 1 addition & 1 deletion .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins:
to: "version = '${nextRelease.version}'"
- files:
- "README.md"
from: ":[0-9].[0-9].[0-9]"
from: ":([0-9]+).([0-9]+).([0-9]+)"
to: ":${nextRelease.version}"
- - "@semantic-release/exec"
- prepareCmd: "./gradlew build --warn --stacktrace"
Expand Down
63 changes: 47 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@ This repository contains [Jetpack Compose][jetpack-compose] components for the [

## Installation

You no longer need to specify the Maps SDK for Android or its Utility Library as separate dependencies, since `maps-compose` and `maps-compose-utils` pull in the appropriate versions of these respectively.

```groovy
dependencies {
implementation 'com.google.maps.android:maps-compose:2.11.2'
// Make sure to also include the latest version of the Maps SDK for Android
implementation 'com.google.android.gms:play-services-maps:18.0.2'
implementation 'com.google.maps.android:maps-compose:3.0.0'
// Optionally, you can include the Compose utils library for Clustering, etc.
implementation 'com.google.maps.android:maps-compose-utils:2.11.2'
implementation 'com.google.maps.android:maps-compose-utils:3.0.0'
// Optionally, you can include the widgets library for ScaleBar, etc.
implementation 'com.google.maps.android:maps-compose-widgets:2.11.2'
implementation 'com.google.maps.android:maps-compose-widgets:3.0.0'
}
```

Expand Down Expand Up @@ -172,6 +171,26 @@ GoogleMap(
}
```

You can also customize the marker you want to add by using `MarkerComposable`.

```kotlin
val state = MyState()

GoogleMap(
//...
) {
MarkerComposable(
keys = arrayOf(state),
state = MarkerState(position = LatLng(-34, 151)),
) {
MyCustomMarker(state)
}
}
```
As this Composable is backed by a rendering of your Composable into a Bitmap, it will not render
your Composable every recomposition. So to trigger a new render of your Composable, you can pass
all variables that your Composable depends on to trigger a render whenever one of them change.

</details>

<details>
Expand Down Expand Up @@ -214,7 +233,7 @@ You can add a Street View given a location using the `StreetView` composable.
To use it, provide a `StreetViewPanoramaOptions` object as follows:

```kotlin
val singapore = LatLng(1.35, 103.87)
val singapore = LatLng(1.3588227, 103.8742114)
StreetView(
streetViewPanoramaOptionsFactory = {
StreetViewPanoramaOptions().position(singapore)
Expand Down Expand Up @@ -285,19 +304,31 @@ The [ScaleBarActivity](app/src/main/java/com/google/maps/android/compose/ScaleBa
Both versions of this widget leverage the `CameraPositionState` in `maps-compose` and therefore are very simple to configure with their defaults:

```kotlin
ScaleBar(
modifier = Modifier
Box(Modifier.fillMaxSize()) {

GoogleMap(
modifier = Modifier.fillMaxSize(),
cameraPositionState = cameraPositionState
) {
// ... your map composables ...
}

ScaleBar(
modifier = Modifier
.padding(top = 5.dp, end = 15.dp)
.align(Alignment.TopEnd),
cameraPositionState = cameraPositionState
)
cameraPositionState = cameraPositionState
)

// OR

DisappearingScaleBar(
modifier = Modifier
DisappearingScaleBar(
modifier = Modifier
.padding(top = 5.dp, end = 15.dp)
.align(Alignment.TopStart),
cameraPositionState = cameraPositionState
)
cameraPositionState = cameraPositionState
)
}
```

The colors of the text, line, and shadow are also all configurable (e.g., based on `isSystemInDarkTheme()` on a dark map). Similarly, the `DisappearingScaleBar` animations can be configured.
Expand Down
5 changes: 2 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ plugins {

android {
namespace "com.google.maps.android.compose"
compileSdk 33
compileSdk 34

defaultConfig {
minSdk 21
targetSdk 33
targetSdk 34
versionCode 1
versionName "1.0"

Expand Down Expand Up @@ -45,7 +45,6 @@ dependencies {
implementation libs.kotlin
implementation libs.material
implementation libs.maps.ktx.std
implementation libs.maps.utils
implementation libs.androidx.compose.ui.preview.tooling
debugImplementation libs.androidx.compose.ui.tooling

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

package com.google.maps.android.compose

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.test.assertIsDisplayed
Expand Down Expand Up @@ -210,6 +212,29 @@ class GoogleMapViewTests {
}
}

@Test(expected = IllegalStateException::class)
fun testMarkerStateInsideMarkerComposableCannotBeReused() {
initMap {
val markerState = rememberMarkerState()
MarkerComposable(
keys = arrayOf("marker1"),
state = markerState,
) {
Box {
Text(text = "marker1")
}
}
MarkerComposable(
keys = arrayOf("marker2"),
state = markerState,
) {
Box {
Text(text = "marker2")
}
}
}
}

@Test
fun testCameraPositionStateMapClears() {
initMap()
Expand All @@ -234,4 +259,4 @@ class GoogleMapViewTests {

assertionBlock()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 Google LLC
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -130,18 +130,17 @@ class MapInColumnTests {
startingPosition.assertEquals(cameraPositionState.position.target)
}

// @Test
// fun testPanMapUp_MapCameraChangesColumnDoesNotScroll() {
// initMap()
// // Swipe the map up
// // FIXME - for some reason this scrolls the entire column instead of just the map
// composeTestRule.onNodeWithTag("Map").performTouchInput { swipeUp() }
// composeTestRule.waitForIdle()
//
// // Make sure that the map changed (i.e., we can scroll the map in the column)
// startingPosition.assertNotEquals(cameraPositionState.position.target)
//
// // Check to make sure column didn't scroll
// composeTestRule.onNodeWithTag("Item 1").assertIsDisplayed()
// }
@Test
fun testPanMapUp_MapCameraChangesColumnDoesNotScroll() {
initMap()
//Swipe the map up
composeTestRule.onNodeWithTag("Map").performTouchInput { swipeUp() }
composeTestRule.waitForIdle()

//Make sure that the map changed (i.e., we can scroll the map in the column)
assertNotEquals(startingPosition, cameraPositionState.position.target)

//Check to make sure column didn't scroll
composeTestRule.onNodeWithTag("Item 1").assertIsDisplayed()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class StreetViewTests {
onClick = onClick
)
}
composeTestRule.waitUntil(8000) {
composeTestRule.waitUntil(10000) {
cameraPositionState.location.position.latitude != 0.0 &&
cameraPositionState.location.position.longitude != 0.0
}
Expand Down
Loading

0 comments on commit 1421dc7

Please sign in to comment.