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

feat: navigation compose and delegation pattern #670

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

dkhawk
Copy link
Collaborator

@dkhawk dkhawk commented Jan 9, 2025

Thank you for opening a Pull Request!


Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open a GitHub issue as a bug/feature request before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

dkhawk added 4 commits January 6, 2025 16:47
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.
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
@dkhawk dkhawk marked this pull request as draft January 9, 2025 00:51
@googlemaps-bot
Copy link
Contributor

googlemaps-bot commented Jan 9, 2025

Code Coverage

Overall Project 17.52%

There is no coverage information present for the Files changed


override fun onLowMemory() {
// TODO(): what is the correct value here?
mapView.onTrimMemory(ComponentCallbacks2.TRIM_MEMORY_COMPLETE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There does not seem to be any reference to which value is the correct one, given that all of them are deprecated. The method does not really seem to be documented.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just removed the TODO since it is not actionable.

@@ -145,19 +150,31 @@ public fun GoogleMap(
var subcompositionJob by remember { mutableStateOf<Job?>(null) }
val parentCompositionScope = rememberCoroutineScope()

var delegate by remember {
// TODO: this could leak the view?
Copy link
Collaborator

@kikoso kikoso Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My two cents: if the AbstractMapViewDelegate is holding a reference to the Context it could leak. But I think we are directly not doing it, if we take a look at the mapViewDelegate, right? Not sure if using the java.lang.ref.WeakReference will make sense.

EDIT: Yeah, I think we are holding a reference in this file.

@kikoso kikoso force-pushed the navigation-compose branch from d3c6162 to 934fee6 Compare January 13, 2025 17:26
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.
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
@kikoso kikoso changed the title Navigation compose feat: navigation compose and delegation pattern Feb 18, 2025

configurations.all {
resolutionStrategy {
exclude(group = "com.google.android.gms", module = "play-services-maps")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: add a small comment about why we are doing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants