Skip to content

Commit 020a57c

Browse files
committed
Rename to getRegisteredInstance
1 parent 8300e2f commit 020a57c

File tree

9 files changed

+15
-13
lines changed

9 files changed

+15
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Mapbox welcomes participation and contributions from everyone.
1313
- Fixed an issue with restricted road visualization on the route line that occurred during route refreshes. [#6399](https://github.com/mapbox/mapbox-navigation-android/pull/6399)
1414
- Improved precision of restricted sections visualization, especially for long routes. [#6399](https://github.com/mapbox/mapbox-navigation-android/pull/6399)
1515
- 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)
16+
- Renamed `MapboxAudioGuidance.getInstance()` to `getRegisteredInstance`. [#6445](https://github.com/mapbox/mapbox-navigation-android/pull/6445)
1617

1718
## Mapbox Navigation SDK 2.9.0-alpha.4 - 30 September, 2022
1819
### Changelog

libnavui-androidauto/src/main/java/com/mapbox/androidauto/navigation/audioguidance/AppAudioGuidanceUi.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fun Fragment.attachAudioGuidance(
1919
mapboxSoundButton: MapboxSoundButton
2020
) {
2121
val lifecycleOwner = viewLifecycleOwner
22-
val flow = MapboxAudioGuidance.getInstance().stateFlow()
22+
val flow = MapboxAudioGuidance.getRegisteredInstance().stateFlow()
2323
lifecycleOwner.lifecycleScope.launch {
2424
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
2525
flow.collect { state ->
@@ -33,7 +33,7 @@ fun Fragment.attachAudioGuidance(
3333
}
3434
}
3535
mapboxSoundButton.setOnClickListener {
36-
MapboxAudioGuidance.getInstance().toggle()
36+
MapboxAudioGuidance.getRegisteredInstance().toggle()
3737
}
3838
}
3939

@@ -45,15 +45,15 @@ fun Lifecycle.muteAudioGuidance() {
4545
addObserver(object : DefaultLifecycleObserver {
4646
lateinit var initialState: MapboxAudioGuidanceState
4747
override fun onResume(owner: LifecycleOwner) {
48-
with(MapboxAudioGuidance.getInstance()) {
48+
with(MapboxAudioGuidance.getRegisteredInstance()) {
4949
initialState = stateFlow().value
5050
mute()
5151
}
5252
}
5353

5454
override fun onPause(owner: LifecycleOwner) {
5555
if (!initialState.isMuted) {
56-
MapboxAudioGuidance.getInstance().unMute()
56+
MapboxAudioGuidance.getRegisteredInstance().unMute()
5757
}
5858
}
5959
})

libnavui-androidauto/src/main/java/com/mapbox/androidauto/navigation/audioguidance/CarAudioGuidanceUi.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class CarAudioGuidanceUi : MapboxActionProvider.ScreenActionProvider {
2828
* Attach this to the screen while navigating.
2929
*/
3030
private fun buildSoundButtonAction(screen: Screen): Action {
31-
val audioGuidance = MapboxAudioGuidance.getInstance()
31+
val audioGuidance = MapboxAudioGuidance.getRegisteredInstance()
3232
val state = audioGuidance.stateFlow().value
3333
return if (!state.isMuted) {
3434
buildIconAction(screen, R.drawable.mapbox_car_ic_volume_on) {
@@ -45,7 +45,7 @@ class CarAudioGuidanceUi : MapboxActionProvider.ScreenActionProvider {
4545
screen.lifecycle.apply {
4646
coroutineScope.launch {
4747
repeatOnLifecycle(Lifecycle.State.STARTED) {
48-
MapboxAudioGuidance.getInstance().stateFlow()
48+
MapboxAudioGuidance.getRegisteredInstance().stateFlow()
4949
.distinctUntilChanged { old, new ->
5050
old.isMuted == new.isMuted && old.isPlayable == new.isPlayable
5151
}

libnavui-app/src/main/java/com/mapbox/navigation/ui/app/internal/controller/AudioGuidanceStateController.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class AudioGuidanceStateController(
4646
override fun onAttached(mapboxNavigation: MapboxNavigation) {
4747
super.onAttached(mapboxNavigation)
4848

49-
val audioGuidance = MapboxAudioGuidance.getInstance()
49+
val audioGuidance = MapboxAudioGuidance.getRegisteredInstance()
5050
audioGuidance.stateFlow().observe {
5151
if (it.isMuted != store.state.value.audio.isMuted) {
5252
val newState = AudioGuidanceState(it.isMuted)

libnavui-app/src/test/java/com/mapbox/navigation/ui/app/internal/controller/AudioGuidanceStateControllerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class AudioGuidanceStateControllerTest {
4444
mockAudioGuidance = mockk(relaxed = true) {
4545
every { stateFlow() } returns audioGuidanceState
4646
}
47-
every { MapboxAudioGuidance.getInstance() } returns mockAudioGuidance
47+
every { MapboxAudioGuidance.getRegisteredInstance() } returns mockAudioGuidance
4848

4949
testStore = spyk(TestStore())
5050
}

libnavui-voice/api/current.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ package com.mapbox.navigation.ui.voice.api {
2323

2424
public final class MapboxAudioGuidance implements com.mapbox.navigation.core.lifecycle.MapboxNavigationObserver {
2525
method public static com.mapbox.navigation.ui.voice.api.MapboxAudioGuidance create();
26-
method public static com.mapbox.navigation.ui.voice.api.MapboxAudioGuidance getInstance();
26+
method public static com.mapbox.navigation.ui.voice.api.MapboxAudioGuidance getRegisteredInstance();
2727
method public void mute();
2828
method public void onAttached(com.mapbox.navigation.core.MapboxNavigation mapboxNavigation);
2929
method public void onDetached(com.mapbox.navigation.core.MapboxNavigation mapboxNavigation);
@@ -35,7 +35,7 @@ package com.mapbox.navigation.ui.voice.api {
3535

3636
public static final class MapboxAudioGuidance.Companion {
3737
method public com.mapbox.navigation.ui.voice.api.MapboxAudioGuidance create();
38-
method public com.mapbox.navigation.ui.voice.api.MapboxAudioGuidance getInstance();
38+
method public com.mapbox.navigation.ui.voice.api.MapboxAudioGuidance getRegisteredInstance();
3939
}
4040

4141
public final class MapboxAudioGuidanceState {

libnavui-voice/src/main/java/com/mapbox/navigation/ui/voice/api/MapboxAudioGuidance.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ internal constructor(
209209
* Get the registered instance or create one and register it to [MapboxNavigationApp].
210210
*/
211211
@JvmStatic
212-
fun getInstance(): MapboxAudioGuidance = MapboxNavigationApp
212+
fun getRegisteredInstance(): MapboxAudioGuidance = MapboxNavigationApp
213213
.getObservers(MapboxAudioGuidance::class)
214214
.firstOrNull() ?: create().also { MapboxNavigationApp.registerObserver(it) }
215215
}

libnavui-voice/src/main/java/com/mapbox/navigation/ui/voice/internal/ui/AudioGuidanceButtonComponent.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class AudioGuidanceButtonComponent(
5252

5353
init {
5454
this.contractProvider = contractProvider ?: Provider {
55-
MapboxAudioComponentContract(coroutineScope, MapboxAudioGuidance.getInstance())
55+
val mapboxAudioGuidance = MapboxAudioGuidance.getRegisteredInstance()
56+
MapboxAudioComponentContract(coroutineScope, mapboxAudioGuidance)
5657
}
5758
}
5859

qa-test-app/src/main/java/com/mapbox/navigation/qa_test_app/testing/JavaInterfaceChecker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class JavaInterfaceChecker {
1010
void MapboxAudioGuidance(
1111
CoroutineScope coroutineScope
1212
) {
13-
MapboxAudioGuidance sut = MapboxAudioGuidance.getInstance();
13+
MapboxAudioGuidance sut = MapboxAudioGuidance.getRegisteredInstance();
1414
sut.mute();
1515
sut.unMute();
1616
sut.toggle();

0 commit comments

Comments
 (0)