Skip to content

Commit

Permalink
[android-auto] Improve dependency management and documentation. (#1267)
Browse files Browse the repository at this point in the history
* [android-auto] Improve dependency management.

* Wire up compass widget.

* Update README.

* Add docs to CarMapWidgets example.

* Update README to include compatibility table.

* Update README.md

* Fix the scroll gesture with Android Auto app.

* Address review comments.

* Update extension-androidauto/README.md

Co-authored-by: Kyle Madsen <kyle.mdsn@gmail.com>

Co-authored-by: Kyle Madsen <kyle.mdsn@gmail.com>
  • Loading branch information
pengdev and kmadsen authored Apr 7, 2022
1 parent c5533a3 commit 63c7a2a
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class CarCameraController : MapboxCarMapObserver {
distanceX: Float,
distanceY: Float
) {
super.onScroll(mapboxCarMapSurface, visibleCenter, distanceX, distanceY)
isTrackingPuck = false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,39 @@ import com.mapbox.maps.extension.androidauto.MapboxCarMapObserver
import com.mapbox.maps.extension.androidauto.MapboxCarMapSurface
import com.mapbox.maps.extension.androidauto.widgets.CompassWidget
import com.mapbox.maps.extension.androidauto.widgets.LogoWidget
import com.mapbox.maps.plugin.delegates.listeners.OnCameraChangeListener

/**
* Note that the Widgets are only available when using android auto extension together with the
* Android Maps SDK v10.4.0 and above, otherwise you will get compilation errors.
*/
@OptIn(MapboxExperimental::class)
class CarMapWidgets : MapboxCarMapObserver {
private lateinit var logoWidget: LogoWidget
private lateinit var compassWidget: CompassWidget
private lateinit var onCameraChangeListener: OnCameraChangeListener
override fun onAttached(mapboxCarMapSurface: MapboxCarMapSurface) {
super.onAttached(mapboxCarMapSurface)
with(mapboxCarMapSurface) {
mapSurface.addWidget(LogoWidget(carContext))
mapSurface.addWidget(
CompassWidget(
carContext,
marginX = 26f,
marginY = 120f,
)
logoWidget = LogoWidget(carContext)
compassWidget = CompassWidget(
carContext,
marginX = 26f,
marginY = 120f,
)
onCameraChangeListener = OnCameraChangeListener { compassWidget.setRotation(-mapSurface.getMapboxMap().cameraState.bearing.toFloat()) }
mapSurface.addWidget(logoWidget)
mapSurface.addWidget(compassWidget)
mapSurface.getMapboxMap().addOnCameraChangeListener(onCameraChangeListener)
}
}

override fun onDetached(mapboxCarMapSurface: MapboxCarMapSurface) {
super.onDetached(mapboxCarMapSurface)
with(mapboxCarMapSurface) {
mapSurface.getMapboxMap().removeOnCameraChangeListener(onCameraChangeListener)
mapSurface.removeWidget(logoWidget)
mapSurface.removeWidget(compassWidget)
}
}
}
29 changes: 24 additions & 5 deletions extension-androidauto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ allprojects {
// In your build.gradle, add the extension with your other dependencies.
dependencies {
implementation 'com.mapbox.extension:maps-androidauto:10.4.+'
implementation 'com.mapbox.extension:maps-androidauto:0.1.0'
// Pick your versions of mapbox map and android auto.
implementation 'androidx.car.app:app:1.+'
implementation 'com.mapbox.maps:android:10.4.+'
// Pick your versions of Android Mapbox Map SDK
// Note that Android Auto extenison is compatibile with Maps SDK v10.0+, however some Android Auto features like Widgets requires Map SDK v10.4.0+
// See the detailed feature compatibility table below
implementation 'com.mapbox.maps:android:10.4.0'
}
```

Expand Down Expand Up @@ -131,6 +132,24 @@ class MyCustomMapExperience : MapboxCarMapObserver {
}
```

#### Dependencies
## Compatibility with Maps SDK v10
The Android Auto extension is released separately from the Android Maps SDK v10 and has a compileOnly dependency. When using the Android Auto extension you need to include a compatible Maps SDK. The feature compatibility checklist can be found below.

Below is the full feature compatibility table:

Features | Supported? | Compatible Maps SDK version
------------- | ------------- | -------------
Map rendering | ✅ | v10.0+
Runtime styling | ✅ | v10.0+
Camera animation | ✅ | v10.0+
Viewport plugin | ✅ | v10.0+
Location Component plugin | ✅ | v10.0+
Gestures(scroll and scale) | ✅ | v10.0+
Annotation plugin | ✅ | v10.0+
Logo Widget | ✅ | v10.4+
Compass Widget | ✅ | v10.4+
View annotation plugin | ❌ | -
Scale bar plugin | ❌ | -
Attribution | ❌ | -

View [LICENSE.md](LICENSE.md) for all dependencies used by this extension.
2 changes: 1 addition & 1 deletion extension-androidauto/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
compileOnly(project(":sdk"))
testImplementation(project(":sdk"))

implementation(Dependencies.googleCarAppLibrary)
api(Dependencies.googleCarAppLibrary)
implementation(Dependencies.kotlin)
implementation(Dependencies.androidxCoreKtx)
implementation(Dependencies.androidxAnnotations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import com.mapbox.maps.renderer.widget.WidgetPosition
/**
* Widget shows compass. Positioned in the top right corner by default.
*
* Note: This feature is only available for Android Maps SDK v10.4.0 and above
*
* @since Maps SDK v10.4.0
*
* @param position position of compass
* @param marginX horizontal margin in pixels
* @param marginY vertical margin in pixels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import com.mapbox.maps.renderer.widget.WidgetPosition
/**
* Widget shows compass. Positioned in the bottom left corner by default.
*
* Note: This feature is only available for Android Maps SDK v10.4.0 and above
*
* @since Maps SDK v10.4.0
*
* @param position position of logo
* @param marginX horizontal margin in pixels
* @param marginY vertical margin in pixels
Expand Down

0 comments on commit 63c7a2a

Please sign in to comment.