Skip to content

Commit 98fbd39

Browse files
dkhawkkikoso
andauthored
feat: navigation compose and delegation pattern (#670)
* experimenting with navcompose * feature: creates a delegate that can wrap a MapView. * feat(navigation-app): Add Navigation support to Maps Compose Adds support for the Navigation SDK to Maps Compose. It just allows the user to replace a standard MapView with a NavigationView within a GoogleMap composable. The following changes were made: Added a new NavigationViewDelegate class to handle the integration between NavigationView and Maps Compose. Added a new NavigationScreen composable function to display the navigation view. Added a new MovableMarker composable function to display a draggable marker on the map. Updated the GoogleMap composable function to support the use of NavigationView. Added a new NavigationApplication class to initialize the Places SDK. Added a new ApiKeyProvider class to provide API keys for the Maps and Places SDKs. Added a new LocationProvider class to provide location data. Added a new PermissionChecker class to check for location permissions. Updated the build.gradle.kts files to include the necessary dependencies. Updated the local.defaults.properties file to include the Places API key. * feat: Add NavigationViewDelegate Adds NavigationViewDelegate to support NavigationView in the navigation sample app. This change allows the navigation sample app to use NavigationView, which provides turn-by-turn navigation functionality. The NavigationViewDelegate handles the lifecycle and rendering of the NavigationView, ensuring that it is properly integrated into the Jetpack Compose UI. Uses a MarkerComposable to demonstrate the map really is a composable * experimenting with navcompose * feature: creates a delegate that can wrap a MapView. * feat(navigation-app): Add Navigation support to Maps Compose Adds support for the Navigation SDK to Maps Compose. It just allows the user to replace a standard MapView with a NavigationView within a GoogleMap composable. The following changes were made: Added a new NavigationViewDelegate class to handle the integration between NavigationView and Maps Compose. Added a new NavigationScreen composable function to display the navigation view. Added a new MovableMarker composable function to display a draggable marker on the map. Updated the GoogleMap composable function to support the use of NavigationView. Added a new NavigationApplication class to initialize the Places SDK. Added a new ApiKeyProvider class to provide API keys for the Maps and Places SDKs. Added a new LocationProvider class to provide location data. Added a new PermissionChecker class to check for location permissions. Updated the build.gradle.kts files to include the necessary dependencies. Updated the local.defaults.properties file to include the Places API key. * feat: Add NavigationViewDelegate Adds NavigationViewDelegate to support NavigationView in the navigation sample app. This change allows the navigation sample app to use NavigationView, which provides turn-by-turn navigation functionality. The NavigationViewDelegate handles the lifecycle and rendering of the NavigationView, ensuring that it is properly integrated into the Jetpack Compose UI. Uses a MarkerComposable to demonstrate the map really is a composable * chore: merge agpVersion with apg in the version catalog file * feat: added LeakCanary, code clean * feat: added some documentation * build(deps): Upgrade navigation library to v6.1.0 Updates the navigation library dependency from v6.0.1 to v6.1.0. This commit also the wording of the comment in `navigation-app/build.gradle.kts` to clarify the reason for excluding `play-services-maps`. * feat: renamed app module to maps-app * feat: updated lint config --------- Co-authored-by: Enrique López Mañas <[email protected]>
1 parent 0ecc362 commit 98fbd39

File tree

95 files changed

+1360
-40
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1360
-40
lines changed

.github/workflows/lint-report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141

4242
- name: Merge SARIF files
4343
run: |
44-
jq -s '{ "$schema": "https://json.schemastore.org/sarif-2.1.0", "version": "2.1.0", "runs": map(.runs) | add }' maps-compose/build/reports/lint-results.sarif maps-compose-utils/build/reports/lint-results.sarif maps-compose-widgets/build/reports/lint-results.sarif app/build/reports/lint-results.sarif > merged.sarif
44+
jq -s '{ "$schema": "https://json.schemastore.org/sarif-2.1.0", "version": "2.1.0", "runs": map(.runs) | add }' maps-compose/build/reports/lint-results.sarif maps-compose-utils/build/reports/lint-results.sarif maps-compose-widgets/build/reports/lint-results.sarif maps-app/build/reports/lint-results.sarif navigation-app/build/reports/lint-results.sarif > merged.sarif
4545
4646
- name: Upload SARIF file
4747
uses: github/codeql-action/upload-sarif@v3

README.md

Lines changed: 20 additions & 2 deletions

build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ plugins {
1919
alias(libs.plugins.dokka) apply true
2020
alias(libs.plugins.compose.compiler) apply false
2121
id("com.autonomousapps.dependency-analysis") version "2.0.0"
22+
alias(libs.plugins.android.application) apply false
23+
alias(libs.plugins.kotlin.android) apply false
2224

2325
}
2426

gradle.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
1717
android.useAndroidX=true
1818
# Automatically convert third-party libraries to use AndroidX
1919
# (not needed, since no requested libraries are pre-AndroidX)
20-
android.enableJetifier=false
20+
#android.enableJetifier=false
21+
# This is needed for the navigation SDK library. It needs the recycler view.
22+
android.enableJetifier=true
2123
# Kotlin code style for this project: "official" or "obsolete":
2224
kotlin.code.style=official
2325

gradle/libs.versions.toml

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
11
[versions]
2+
accompanistPermissions = "0.37.0"
23
activitycompose = "1.9.3"
34
agp = "8.7.2"
4-
androidxtest = "1.6.2"
55
androidCore = "1.6.1"
6+
androidx-core = "1.15.0"
7+
androidxtest = "1.6.2"
68
compose-bom = "2024.11.00"
79
dokka = "1.9.20"
810
espresso = "3.6.1"
911
jacoco-plugin = "0.2.1"
10-
junitktx = "1.2.1"
1112
junit = "4.13.2"
13+
junitVersion = "1.2.1"
14+
junitktx = "1.2.1"
1215
kotlin = "2.0.21"
1316
kotlinxCoroutines = "1.9.0"
14-
mapsktx = "5.1.1"
17+
leakcanaryAndroid = "2.12"
18+
lifecycleRuntimeKtx = "2.8.7"
1519
mapsecrets = "2.0.1"
20+
mapsktx = "5.1.1"
21+
navigation = "6.1.0"
1622
org-jacoco-core = "0.8.11"
17-
androidx-core = "1.15.0"
23+
places = "4.1.0"
24+
playServicesLocation = "21.3.0"
25+
robolectric = "4.14.1"
1826
screenshot = "0.0.1-alpha08"
27+
secretsGradlePlugin = "2.0.1"
28+
truth = "1.4.4"
1929

2030
[libraries]
31+
# robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
32+
accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "accompanistPermissions" }
2133
android-gradle-plugin = { module = "com.android.tools.build:gradle", version.ref = "agp" }
2234
androidx-compose-activity = { module = "androidx.activity:activity-compose", version.ref = "activitycompose" }
2335
androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "compose-bom" }
@@ -27,25 +39,40 @@ androidx-compose-ui = { module = "androidx.compose.ui:ui" }
2739
androidx-compose-ui-preview-tooling = { module = "androidx.compose.ui:ui-tooling-preview" }
2840
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
2941
androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core" }
42+
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
43+
androidx-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "lifecycleRuntimeKtx" }
44+
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
45+
androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycleRuntimeKtx" }
46+
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
3047
androidx-test-compose-ui = { module = "androidx.compose.ui:ui-test-junit4" }
3148
androidx-test-core = { module = "androidx.test:core", version.ref = "androidCore" }
3249
androidx-test-espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" }
3350
androidx-test-junit-ktx = { module = "androidx.test.ext:junit-ktx", version.ref = "junitktx" }
3451
androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidCore" }
3552
androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidxtest" }
53+
androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
54+
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
3655
dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
3756
jacoco-android-plugin = { module = "com.mxalbert.gradle:jacoco-android", version.ref = "jacoco-plugin", version.require = "0.2.1" }
3857
kotlin = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk7", version.ref = "kotlin" }
3958
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
40-
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinxCoroutines" }
4159
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" }
60+
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinxCoroutines" }
61+
leakcanary-android = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "leakcanaryAndroid" }
4262
maps-ktx-std = { module = "com.google.maps.android:maps-ktx", version.ref = "mapsktx" }
4363
maps-ktx-utils = { module = "com.google.maps.android:maps-utils-ktx", version.ref = "mapsktx" }
4464
maps-secrets-plugin = { module = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin", version.ref = "mapsecrets" }
65+
navigation = { module = "com.google.android.libraries.navigation:navigation", version.ref = "navigation" }
4566
org-jacoco-core = { module = "org.jacoco:org.jacoco.core", version.ref = "org-jacoco-core" }
67+
places = { group = "com.google.android.libraries.places", name = "places", version.ref = "places" }
68+
play-services-location = { module = "com.google.android.gms:play-services-location", version.ref = "playServicesLocation" }
4669
test-junit = { module = "junit:junit", version.ref = "junit" }
70+
truth = { module = "com.google.truth:truth", version.ref = "truth" }
4771

4872
[plugins]
49-
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
73+
android-application = { id = "com.android.application", version.ref = "agp" }
5074
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
51-
screenshot = { id = "com.android.compose.screenshot", version.ref = "screenshot"}
75+
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
76+
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
77+
screenshot = { id = "com.android.compose.screenshot", version.ref = "screenshot"}
78+
secrets-gradle-plugin = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version.ref = "secretsGradlePlugin" }

local.defaults.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
# Location of the SDK. This is only used by Gradle.
88
# For customization when using a Version Control System, please read the
99
# header note.
10-
MAPS_API_KEY=YOUR_API_KEY
10+
MAPS_API_KEY=YOUR_API_KEY
11+
PLACES_API_KEY=DEFAULT_API_KEY
File renamed without changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ dependencies {
6666
implementation(libs.kotlinx.coroutines.android)
6767
implementation(libs.androidx.compose.ui.preview.tooling)
6868
debugImplementation(libs.androidx.compose.ui.tooling)
69+
debugImplementation(libs.leakcanary.android)
70+
6971

7072
androidTestImplementation(platform(libs.androidx.compose.bom))
7173
androidTestImplementation(libs.androidx.test.core)

app/src/androidTest/java/com/google/maps/android/compose/GoogleMapViewTests.kt renamed to maps-app/src/androidTest/java/com/google/maps/android/compose/GoogleMapViewTests.kt

File renamed without changes.

0 commit comments

Comments
 (0)