Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Mapbox welcomes participation and contributions from everyone.
- Fixed a rare issue where alternative route would not be vanished until deviation point for `MapboxRouteLineApi#setNavigationRoutes(routes, metadata)` when the route's geometry contained duplicate points. [#6399](https://github.com/mapbox/mapbox-navigation-android/pull/6399)
- Introduced `ViewStyleCutomization.compassButtonParams` property to configure compass. [#6395](https://github.com/mapbox/mapbox-navigation-android/pull/6395)
- Introduced `MapboxExtendableButtonParams.enabled` property to enable/disable a button. [#6395](https://github.com/mapbox/mapbox-navigation-android/pull/6395)
- Renamed `MapboxAudioGuidance.getInstance()` to `getRegisteredInstance`. Rename `unMute` to `unmute` for audio guidance classes. [#6445](https://github.com/mapbox/mapbox-navigation-android/pull/6445)

## Mapbox Navigation SDK 2.9.0-alpha.4 - 30 September, 2022
### Changelog
Expand Down
346 changes: 1 addition & 345 deletions LICENSE.md

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions libnavui-androidauto/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ dependencies {

// This defines the minimum version of Navigation which is included in this SDK. To upgrade the
// Navigation versions, you can specify a newer version in your downstream build.gradle.
releaseApi("com.mapbox.navigation:android:2.9.0-alpha.4")
debugApi project(":libnavigation-android")
// TODO reset to a specific version when the release is ready (and make license)
api project(":libnavigation-android")
// releaseApi("com.mapbox.navigation:android:2.9.0-beta.1")
// debugApi project(":libnavigation-android")

// Search is currently in beta so it is not included in this SDK. The functionality of search
// is included behind this library's api.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ internal constructor(
val signFormat = speedLimitOptions.forcedSignFormat
?: locationMatcherResult.speedLimit?.speedLimitSign
val threshold = speedLimitOptions.warningThreshold
when (distanceFormatterOptions?.unitType) {
when (distanceFormatterOptions!!.unitType) {
UnitType.IMPERIAL -> {
val speedLimit =
locationMatcherResult.speedLimit?.speedKmph?.let { speedLimitKmph ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fun Fragment.attachAudioGuidance(
mapboxSoundButton: MapboxSoundButton
) {
val lifecycleOwner = viewLifecycleOwner
val flow = MapboxAudioGuidance.getInstance().stateFlow()
val flow = MapboxAudioGuidance.getRegisteredInstance().stateFlow()
lifecycleOwner.lifecycleScope.launch {
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
flow.collect { state ->
Expand All @@ -33,7 +33,7 @@ fun Fragment.attachAudioGuidance(
}
}
mapboxSoundButton.setOnClickListener {
MapboxAudioGuidance.getInstance().toggle()
MapboxAudioGuidance.getRegisteredInstance().toggle()
}
}

Expand All @@ -45,15 +45,15 @@ fun Lifecycle.muteAudioGuidance() {
addObserver(object : DefaultLifecycleObserver {
lateinit var initialState: MapboxAudioGuidanceState
override fun onResume(owner: LifecycleOwner) {
with(MapboxAudioGuidance.getInstance()) {
with(MapboxAudioGuidance.getRegisteredInstance()) {
initialState = stateFlow().value
mute()
}
}

override fun onPause(owner: LifecycleOwner) {
if (!initialState.isMuted) {
MapboxAudioGuidance.getInstance().unMute()
MapboxAudioGuidance.getRegisteredInstance().unmute()
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ class CarAudioGuidanceUi : MapboxActionProvider.ScreenActionProvider {
* Attach this to the screen while navigating.
*/
private fun buildSoundButtonAction(screen: Screen): Action {
val audioGuidance = MapboxAudioGuidance.getInstance()
val audioGuidance = MapboxAudioGuidance.getRegisteredInstance()
val state = audioGuidance.stateFlow().value
return if (!state.isMuted) {
buildIconAction(screen, R.drawable.mapbox_car_ic_volume_on) {
audioGuidance.mute()
}
} else {
buildIconAction(screen, R.drawable.mapbox_car_ic_volume_off) {
audioGuidance.unMute()
audioGuidance.unmute()
}
}
}
Expand All @@ -45,7 +45,7 @@ class CarAudioGuidanceUi : MapboxActionProvider.ScreenActionProvider {
screen.lifecycle.apply {
coroutineScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
MapboxAudioGuidance.getInstance().stateFlow()
MapboxAudioGuidance.getRegisteredInstance().stateFlow()
.distinctUntilChanged { old, new ->
old.isMuted == new.isMuted && old.isPlayable == new.isPlayable
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class AudioGuidanceStateController(
override fun onAttached(mapboxNavigation: MapboxNavigation) {
super.onAttached(mapboxNavigation)

val audioGuidance = MapboxAudioGuidance.getInstance()
val audioGuidance = MapboxAudioGuidance.getRegisteredInstance()
audioGuidance.stateFlow().observe {
if (it.isMuted != store.state.value.audio.isMuted) {
val newState = AudioGuidanceState(it.isMuted)
Expand All @@ -58,7 +58,7 @@ class AudioGuidanceStateController(
if (it.isMuted) {
audioGuidance.mute()
} else {
audioGuidance.unMute()
audioGuidance.unmute()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AudioGuidanceStateControllerTest {
mockAudioGuidance = mockk(relaxed = true) {
every { stateFlow() } returns audioGuidanceState
}
every { MapboxAudioGuidance.getInstance() } returns mockAudioGuidance
every { MapboxAudioGuidance.getRegisteredInstance() } returns mockAudioGuidance

testStore = spyk(TestStore())
}
Expand Down
24 changes: 12 additions & 12 deletions libnavui-voice/api/current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ package com.mapbox.navigation.ui.voice.api {

public final class MapboxAudioGuidance implements com.mapbox.navigation.core.lifecycle.MapboxNavigationObserver {
method public static com.mapbox.navigation.ui.voice.api.MapboxAudioGuidance create();
method public static com.mapbox.navigation.ui.voice.api.MapboxAudioGuidance getInstance();
method public static com.mapbox.navigation.ui.voice.api.MapboxAudioGuidance getRegisteredInstance();
method public void mute();
method public void onAttached(com.mapbox.navigation.core.MapboxNavigation mapboxNavigation);
method public void onDetached(com.mapbox.navigation.core.MapboxNavigation mapboxNavigation);
method public kotlinx.coroutines.flow.StateFlow<com.mapbox.navigation.ui.voice.api.MapboxAudioGuidanceState> stateFlow();
method public void toggle();
method public void unMute();
method public void unmute();
field public static final com.mapbox.navigation.ui.voice.api.MapboxAudioGuidance.Companion Companion;
}

public static final class MapboxAudioGuidance.Companion {
method public com.mapbox.navigation.ui.voice.api.MapboxAudioGuidance create();
method public com.mapbox.navigation.ui.voice.api.MapboxAudioGuidance getInstance();
method public com.mapbox.navigation.ui.voice.api.MapboxAudioGuidance getRegisteredInstance();
}

public final class MapboxAudioGuidanceState {
Expand Down Expand Up @@ -199,26 +199,26 @@ package com.mapbox.navigation.ui.voice.view {
method public int getMuteIconResId();
method public String? getMuteText();
method public androidx.appcompat.widget.AppCompatTextView getTextView();
method public int getUnMuteIconResId();
method public String? getUnMuteText();
method public int getUnmuteIconResId();
method public String? getUnmuteText();
method @UiThread public void mute();
method @UiThread public void muteAndExtend(long duration = 2000L);
method @UiThread public void muteAndExtend();
method public void setMuteIconResId(int);
method public void setMuteText(String?);
method public void setUnMuteIconResId(int);
method public void setUnMuteText(String?);
method @UiThread public void unMute();
method @UiThread public void unMuteAndExtend(long duration = 2000L);
method @UiThread public void unMuteAndExtend();
method public void setUnmuteIconResId(int);
method public void setUnmuteText(String?);
method @UiThread public void unmute();
method @UiThread public void unmuteAndExtend(long duration = 2000L);
method @UiThread public void unmuteAndExtend();
method public void updateStyle(@StyleRes int style);
property public final androidx.constraintlayout.widget.ConstraintLayout containerView;
property public final androidx.appcompat.widget.AppCompatImageView iconImage;
property public final int muteIconResId;
property public final String? muteText;
property public final androidx.appcompat.widget.AppCompatTextView textView;
property public final int unMuteIconResId;
property public final String? unMuteText;
property public final int unmuteIconResId;
property public final String? unmuteText;
}

public final class MapboxSoundButton extends androidx.constraintlayout.widget.ConstraintLayout {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ internal constructor(
* In order to enable voice guidance, you must call [MapboxNavigation.startTripSession]
* and set a route for active guidance through [MapboxNavigation.setRoutes].
*
* You can also control audio guidance by calling [mute], [unMute] or [toggle]
* You can also control audio guidance by calling [mute], [unmute] or [toggle]
*/
fun stateFlow(): StateFlow<MapboxAudioGuidanceState> = internalStateFlow

Expand All @@ -94,7 +94,7 @@ internal constructor(
/**
* Explicit call to unmute the audio guidance state.
*/
fun unMute() {
fun unmute() {
scope.launch {
setMutedState(false)
}
Expand All @@ -106,7 +106,7 @@ internal constructor(
fun toggle() {
scope.launch {
if (mutedStateFlow.value) {
unMute()
unmute()
} else {
mute()
}
Expand Down Expand Up @@ -209,7 +209,7 @@ internal constructor(
* Get the registered instance or create one and register it to [MapboxNavigationApp].
*/
@JvmStatic
fun getInstance(): MapboxAudioGuidance = MapboxNavigationApp
fun getRegisteredInstance(): MapboxAudioGuidance = MapboxNavigationApp
.getObservers(MapboxAudioGuidance::class)
.firstOrNull() ?: create().also { MapboxNavigationApp.registerObserver(it) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal class MapboxAudioComponentContract(
}

override fun unMute() {
audioGuidance.unMute()
audioGuidance.unmute()
}
}

Expand All @@ -52,7 +52,8 @@ class AudioGuidanceButtonComponent(

init {
this.contractProvider = contractProvider ?: Provider {
MapboxAudioComponentContract(coroutineScope, MapboxAudioGuidance.getInstance())
val mapboxAudioGuidance = MapboxAudioGuidance.getRegisteredInstance()
MapboxAudioComponentContract(coroutineScope, mapboxAudioGuidance)
}
}

Expand All @@ -64,7 +65,7 @@ class AudioGuidanceButtonComponent(
if (it) {
audioGuidanceButton.mute()
} else {
audioGuidanceButton.unMute()
audioGuidanceButton.unmute()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class MapboxAudioGuidanceButton : FrameLayout {
* Icon Drawable Resource Id for UNMUTE audio guidance.
*/
@DrawableRes
var unMuteIconResId: Int = 0
var unmuteIconResId: Int = 0

/**
* Extended mode Text for MUTE audio guidance.
Expand All @@ -68,15 +68,15 @@ class MapboxAudioGuidanceButton : FrameLayout {
/**
* Extended mode Text for UNMUTE audio guidance.
*/
var unMuteText: String? = null
var unmuteText: String? = null

/**
* Default button that allows user to mute and un-mute audio guidance.
* Default button that allows user to mute and unmute audio guidance.
*/
constructor(context: Context) : this(context, null)

/**
* Default button that allows user to mute and un-mute audio guidance.
* Default button that allows user to mute and unmute audio guidance.
*/
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)

Expand Down Expand Up @@ -125,8 +125,8 @@ class MapboxAudioGuidanceButton : FrameLayout {
* @param state new camera state
*/
@UiThread
fun unMute() {
iconImage.setImageResource(unMuteIconResId)
fun unmute() {
iconImage.setImageResource(unmuteIconResId)
}

/**
Expand All @@ -148,18 +148,18 @@ class MapboxAudioGuidanceButton : FrameLayout {

/**
* Update this button to represent audio guidance state in un-muted state.
* Extend button for the [duration] and show [unMuteText].
* Extend button for the [duration] and show [unmuteText].
* This method does nothing if button is already in given state.
*
* @param duration duration in milliseconds. Defaults to [EXTEND_DURATION].
*/
@UiThread
@JvmOverloads
fun unMuteAndExtend(duration: Long = EXTEND_DURATION) {
iconImage.setImageResource(unMuteIconResId)
fun unmuteAndExtend(duration: Long = EXTEND_DURATION) {
iconImage.setImageResource(unmuteIconResId)

if (unMuteText != null && !helper.isAnimationRunning) {
helper.showTextAndExtend(unMuteText!!, duration)
if (unmuteText != null && !helper.isAnimationRunning) {
helper.showTextAndExtend(unmuteText!!, duration)
}
}

Expand All @@ -182,7 +182,7 @@ class MapboxAudioGuidanceButton : FrameLayout {
R.styleable.MapboxAudioGuidanceButton_audioGuidanceButtonMuteIcon,
R.drawable.mapbox_ic_sound_off
)
unMuteIconResId = typedArray.getResourceId(
unmuteIconResId = typedArray.getResourceId(
R.styleable.MapboxAudioGuidanceButton_audioGuidanceButtonUnmuteIcon,
R.drawable.mapbox_ic_sound_on
)
Expand All @@ -206,7 +206,7 @@ class MapboxAudioGuidanceButton : FrameLayout {
}
muteText =
typedArray.getString(R.styleable.MapboxAudioGuidanceButton_audioGuidanceButtonMuteText)
unMuteText =
unmuteText =
typedArray.getString(
R.styleable.MapboxAudioGuidanceButton_audioGuidanceButtonUnmuteText
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class AudioGuidanceButtonComponentTest {
testContract.isMuted.value = true

verifyOrder {
button.unMute()
button.unmute()
button.mute()
}
}
Expand Down Expand Up @@ -110,7 +110,7 @@ class AudioGuidanceButtonComponentTest {
val mockAudioGuidance = mockk<MapboxAudioGuidance> {
every { stateFlow() } returns testState
every { mute() } returns Unit
every { unMute() } returns Unit
every { unmute() } returns Unit
every { toggle() } returns Unit
}
every {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class JavaInterfaceChecker {
void MapboxAudioGuidance(
CoroutineScope coroutineScope
) {
MapboxAudioGuidance sut = MapboxAudioGuidance.getInstance();
MapboxAudioGuidance sut = MapboxAudioGuidance.getRegisteredInstance();
sut.mute();
sut.unMute();
sut.unmute();
sut.toggle();
MapboxNavigationApp.registerObserver(sut);
MapboxNavigationApp.unregisterObserver(sut);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class DropInButtonsActivity : BaseNavigationActivity() {
binding.audioButton.mute()
binding.circleAudioButton.mute()
} else {
binding.audioButton.unMute()
binding.circleAudioButton.unMute()
binding.audioButton.unmute()
binding.circleAudioButton.unmute()
}
}
}
Expand All @@ -71,7 +71,7 @@ class DropInButtonsActivity : BaseNavigationActivity() {

if (muted.value == true) {
muted.value = false
button.unMuteAndExtend()
button.unmuteAndExtend()
} else {
muted.value = true
button.muteAndExtend()
Expand Down