-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix voiceLanguage NPE and add tests for NavigationSpeechPlayer
- Loading branch information
1 parent
b99a0c7
commit 99d5a66
Showing
24 changed files
with
805 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...main/java/com/mapbox/services/android/navigation/ui/v5/voice/Api26AudioFocusDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.mapbox.services.android.navigation.ui.v5.voice; | ||
|
||
import android.media.AudioFocusRequest; | ||
import android.media.AudioManager; | ||
import android.os.Build; | ||
import android.support.annotation.RequiresApi; | ||
|
||
@RequiresApi(api = Build.VERSION_CODES.O) | ||
class Api26AudioFocusDelegate implements AudioFocusDelegate { | ||
|
||
private static final int FOCUS_GAIN = AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK; | ||
|
||
private final AudioManager audioManager; | ||
private final AudioFocusRequest audioFocusRequest; | ||
|
||
Api26AudioFocusDelegate(AudioManager audioManager) { | ||
this.audioManager = audioManager; | ||
audioFocusRequest = new AudioFocusRequest.Builder(FOCUS_GAIN).build(); | ||
} | ||
|
||
@Override | ||
public void requestFocus() { | ||
audioManager.requestAudioFocus(audioFocusRequest); | ||
} | ||
|
||
@Override | ||
public void abandonFocus() { | ||
audioManager.abandonAudioFocusRequest(audioFocusRequest); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
.../src/main/java/com/mapbox/services/android/navigation/ui/v5/voice/AudioFocusDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.mapbox.services.android.navigation.ui.v5.voice; | ||
|
||
interface AudioFocusDelegate { | ||
|
||
void requestFocus(); | ||
|
||
void abandonFocus(); | ||
} |
24 changes: 24 additions & 0 deletions
24
...n/java/com/mapbox/services/android/navigation/ui/v5/voice/AudioFocusDelegateProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.mapbox.services.android.navigation.ui.v5.voice; | ||
|
||
import android.media.AudioManager; | ||
import android.os.Build; | ||
|
||
class AudioFocusDelegateProvider { | ||
|
||
private final AudioFocusDelegate audioFocusDelegate; | ||
|
||
AudioFocusDelegateProvider(AudioManager audioManager) { | ||
audioFocusDelegate = buildAudioFocusDelegate(audioManager); | ||
} | ||
|
||
AudioFocusDelegate retrieveAudioFocusDelegate() { | ||
return audioFocusDelegate; | ||
} | ||
|
||
private AudioFocusDelegate buildAudioFocusDelegate(AudioManager audioManager) { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
return new Api26AudioFocusDelegate(audioManager); | ||
} | ||
return new SpeechAudioFocusDelegate(audioManager); | ||
} | ||
} |
51 changes: 0 additions & 51 deletions
51
...i/src/main/java/com/mapbox/services/android/navigation/ui/v5/voice/InstructionPlayer.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.