Skip to content

Commit 88be670

Browse files
committed
detect click listener on speed info view
1 parent b97c2f0 commit 88be670

File tree

27 files changed

+194
-114
lines changed

27 files changed

+194
-114
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Mapbox welcomes participation and contributions from everyone.
2626
- Added guarantees that route progress with `RouteProgress#currentState == OFF_ROUTE` arrives earlier than `NavigationRerouteController#reroute` is called. [#6764](https://github.com/mapbox/mapbox-navigation-android/pull/6764)
2727
- Fixed a rare `java.lang.NullPointerException: Attempt to read from field 'SpeechAnnouncement PlayCallback.announcement' on a null object reference` crash in `PlayCallback.getAnnouncement`. [#6760](https://github.com/mapbox/mapbox-navigation-android/pull/6760)
2828
- Fixed standalone `MapboxManeuverView` appearance when the app also integrates Drop-In UI. [#6774](https://github.com/mapbox/mapbox-navigation-android/pull/6774)
29+
- Introduced `NavigationViewListener.onSpeedInfoClicked` that would be triggered when `MapboxSpeedInfoView` is clicked upon. [#6770](https://github.com/mapbox/mapbox-navigation-android/pull/6770)
2930

3031
## Mapbox Navigation SDK 2.10.0-rc.1 - 16 December, 2022
3132
### Changelog

libnavui-dropin/api/current.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ package com.mapbox.navigation.dropin.navigationview {
444444
method public void onRouteFetchSuccessful(java.util.List<com.mapbox.navigation.base.route.NavigationRoute> routes);
445445
method public void onRouteFetching(long requestId);
446446
method public void onRoutePreview();
447+
method public void onSpeedInfoClicked(com.mapbox.navigation.ui.speedlimit.model.SpeedInfoValue? speedInfo);
447448
}
448449

449450
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.mapbox.navigation.dropin
2+
3+
import kotlinx.coroutines.channels.BufferOverflow
4+
import kotlinx.coroutines.flow.MutableSharedFlow
5+
import kotlinx.coroutines.flow.asSharedFlow
6+
7+
internal class ClickBehavior<T> {
8+
9+
private val _onViewClicked = MutableSharedFlow<T>(
10+
extraBufferCapacity = 1,
11+
onBufferOverflow = BufferOverflow.DROP_OLDEST,
12+
)
13+
val onViewClicked = _onViewClicked.asSharedFlow()
14+
15+
fun onClicked(value: T) {
16+
_onViewClicked.tryEmit(value)
17+
}
18+
}

libnavui-dropin/src/main/java/com/mapbox/navigation/dropin/infopanel/InfoPanelComponent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ internal class InfoPanelComponent(
2323

2424
val navigationView = findNavigationView()
2525
combine(
26-
context.infoPanelBehavior.slideOffset,
26+
context.behavior.infoPanelBehavior.slideOffset,
2727
context.systemBarsInsets
2828
) { slideOffset, insets ->
2929
slideOffset to insets

libnavui-dropin/src/main/java/com/mapbox/navigation/dropin/infopanel/InfoPanelCoordinator.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ internal class InfoPanelCoordinator(
3535

3636
private val updateGuideline = object : BottomSheetBehavior.BottomSheetCallback() {
3737
override fun onStateChanged(bottomSheet: View, newState: Int) {
38-
context.infoPanelBehavior.updateBottomSheetState(newState)
38+
context.behavior.infoPanelBehavior.updateBottomSheetState(newState)
3939
updateGuidelinePosition()
4040
}
4141

4242
override fun onSlide(bottomSheet: View, slideOffset: Float) {
43-
context.infoPanelBehavior.updateSlideOffset(slideOffset)
43+
context.behavior.infoPanelBehavior.updateSlideOffset(slideOffset)
4444
updateGuidelinePosition()
4545
}
4646
}
@@ -176,7 +176,7 @@ internal class InfoPanelCoordinator(
176176
BottomSheetBehavior.STATE_HIDDEN -> -1.0f
177177
else -> null
178178
}?.also { slideOffset ->
179-
context.infoPanelBehavior.updateSlideOffset(slideOffset)
179+
context.behavior.infoPanelBehavior.updateSlideOffset(slideOffset)
180180
}
181181
}
182182
}

libnavui-dropin/src/main/java/com/mapbox/navigation/dropin/maneuver/ManeuverBehavior.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ import kotlinx.coroutines.flow.asStateFlow
66

77
internal class ManeuverBehavior {
88

9-
private val _maneuverBehavior = MutableStateFlow<MapboxManeuverViewState>(
9+
private val _maneuverViewState = MutableStateFlow<MapboxManeuverViewState>(
1010
MapboxManeuverViewState.COLLAPSED
1111
)
1212
private val _maneuverViewVisibility = MutableStateFlow(false)
1313

14-
val maneuverBehavior = _maneuverBehavior.asStateFlow()
14+
val maneuverViewState = _maneuverViewState.asStateFlow()
1515
val maneuverViewVisibility = _maneuverViewVisibility.asStateFlow()
1616

1717
fun updateBehavior(newState: MapboxManeuverViewState) {
18-
_maneuverBehavior.value = newState
18+
_maneuverViewState.value = newState
1919
}
2020

2121
fun updateViewVisibility(visibility: Boolean) {

libnavui-dropin/src/main/java/com/mapbox/navigation/dropin/maneuver/ManeuverComponentContractImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ internal class ManeuverComponentContractImpl(
99
) : ManeuverComponentContract {
1010

1111
override fun onManeuverViewStateChanged(state: MapboxManeuverViewState) {
12-
context.maneuverBehavior.updateBehavior(state)
12+
context.behavior.maneuverBehavior.updateBehavior(state)
1313
}
1414

1515
override fun onManeuverViewVisibilityChanged(isVisible: Boolean) {
16-
context.maneuverBehavior.updateViewVisibility(isVisible)
16+
context.behavior.maneuverBehavior.updateViewVisibility(isVisible)
1717
}
1818
}

libnavui-dropin/src/main/java/com/mapbox/navigation/dropin/map/MapClickBehavior.kt

Lines changed: 0 additions & 19 deletions
This file was deleted.

libnavui-dropin/src/main/java/com/mapbox/navigation/dropin/map/MapViewBinder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ abstract class MapViewBinder : UIBinder {
108108

109109
private fun routeLineComponent(lineOptions: MapboxRouteLineOptions, mapView: MapView) =
110110
RouteLineComponent(mapView.getMapboxMap(), mapView, lineOptions, contractProvider = {
111-
RouteLineComponentContractImpl(context.store, context.mapClickBehavior)
111+
RouteLineComponentContractImpl(context.store, context.behavior.mapClickBehavior)
112112
})
113113

114114
private fun longPressMapComponent(navigationState: NavigationState, mapView: MapView) =

libnavui-dropin/src/main/java/com/mapbox/navigation/dropin/map/RouteLineComponentContractImpl.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.mapbox.navigation.dropin.map
33
import com.mapbox.geojson.Point
44
import com.mapbox.navigation.base.route.NavigationRoute
55
import com.mapbox.navigation.core.MapboxNavigation
6+
import com.mapbox.navigation.dropin.ClickBehavior
67
import com.mapbox.navigation.ui.app.internal.Store
78
import com.mapbox.navigation.ui.app.internal.navigation.NavigationState
89
import com.mapbox.navigation.ui.app.internal.routefetch.RoutePreviewAction
@@ -14,7 +15,7 @@ import kotlinx.coroutines.flow.combine
1415

1516
internal class RouteLineComponentContractImpl(
1617
private val store: Store,
17-
private val mapClickBehavior: MapClickBehavior,
18+
private val mapClickBehavior: ClickBehavior<Point>,
1819
) : RouteLineComponentContract {
1920
override fun setRoutes(mapboxNavigation: MapboxNavigation, routes: List<NavigationRoute>) {
2021
when (store.state.value.navigation) {
@@ -48,6 +49,6 @@ internal class RouteLineComponentContractImpl(
4849
}
4950

5051
override fun onMapClicked(point: Point) {
51-
mapClickBehavior.onMapClicked(point)
52+
mapClickBehavior.onClicked(point)
5253
}
5354
}

0 commit comments

Comments
 (0)