Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
fb12aa2183
1 changed files with 33 additions and 0 deletions
|
@ -1118,6 +1118,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
public void recordAudio(double lat, double lon, final MapActivity mapActivity) {
|
public void recordAudio(double lat, double lon, final MapActivity mapActivity) {
|
||||||
if (ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.RECORD_AUDIO)
|
if (ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.RECORD_AUDIO)
|
||||||
== PackageManager.PERMISSION_GRANTED) {
|
== PackageManager.PERMISSION_GRANTED) {
|
||||||
|
muteStreamMusicAndOutputGuidance();
|
||||||
initRecMenu(AVActionType.REC_AUDIO, lat, lon);
|
initRecMenu(AVActionType.REC_AUDIO, lat, lon);
|
||||||
MediaRecorder mr = new MediaRecorder();
|
MediaRecorder mr = new MediaRecorder();
|
||||||
final File f = getBaseFileName(lat, lon, app, THREEGP_EXTENSION);
|
final File f = getBaseFileName(lat, lon, app, THREEGP_EXTENSION);
|
||||||
|
@ -1129,6 +1130,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
try {
|
try {
|
||||||
runMediaRecorder(mapActivity, mr, f);
|
runMediaRecorder(mapActivity, mr, f);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
unmuteStreamMusicAndOutputGuidance();
|
||||||
log.error("Error starting audio recorder ", e);
|
log.error("Error starting audio recorder ", e);
|
||||||
Toast.makeText(app, app.getString(R.string.recording_error) + " : "
|
Toast.makeText(app, app.getString(R.string.recording_error) + " : "
|
||||||
+ e.getMessage(), Toast.LENGTH_LONG).show();
|
+ e.getMessage(), Toast.LENGTH_LONG).show();
|
||||||
|
@ -1142,6 +1144,34 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void muteStreamMusicAndOutputGuidance() {
|
||||||
|
AudioManager am = (AudioManager)app.getSystemService(Context.AUDIO_SERVICE);
|
||||||
|
int voiceGuidanceOutput = app.getSettings().AUDIO_STREAM_GUIDANCE.get();
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
|
||||||
|
am.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_MUTE, 0);
|
||||||
|
if (voiceGuidanceOutput != AudioManager.STREAM_MUSIC)
|
||||||
|
am.adjustStreamVolume(voiceGuidanceOutput, AudioManager.ADJUST_MUTE, 0);
|
||||||
|
} else {
|
||||||
|
am.setStreamMute(AudioManager.STREAM_MUSIC, true);
|
||||||
|
if (voiceGuidanceOutput != AudioManager.STREAM_MUSIC)
|
||||||
|
am.setStreamMute(voiceGuidanceOutput, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unmuteStreamMusicAndOutputGuidance() {
|
||||||
|
AudioManager am = (AudioManager) app.getSystemService(Context.AUDIO_SERVICE);
|
||||||
|
int voiceGuidanceOutput = app.getSettings().AUDIO_STREAM_GUIDANCE.get();
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
|
||||||
|
am.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_UNMUTE, 0);
|
||||||
|
if (voiceGuidanceOutput != AudioManager.STREAM_MUSIC)
|
||||||
|
am.adjustStreamVolume(voiceGuidanceOutput, AudioManager.ADJUST_UNMUTE, 0);
|
||||||
|
} else {
|
||||||
|
am.setStreamMute(AudioManager.STREAM_MUSIC, false);
|
||||||
|
if (voiceGuidanceOutput != AudioManager.STREAM_MUSIC)
|
||||||
|
am.setStreamMute(voiceGuidanceOutput, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void takePhoto(final double lat, final double lon, final MapActivity mapActivity,
|
public void takePhoto(final double lat, final double lon, final MapActivity mapActivity,
|
||||||
final boolean forceInternal) {
|
final boolean forceInternal) {
|
||||||
if (ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.CAMERA)
|
if (ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.CAMERA)
|
||||||
|
@ -1528,6 +1558,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
recordControl.setExplicitlyVisible(false);
|
recordControl.setExplicitlyVisible(false);
|
||||||
mapActivity.getMapLayers().getMapInfoLayer().recreateControls();
|
mapActivity.getMapLayers().getMapInfoLayer().recreateControls();
|
||||||
}
|
}
|
||||||
|
if (currentRecording.type == AVActionType.REC_AUDIO) {
|
||||||
|
unmuteStreamMusicAndOutputGuidance();
|
||||||
|
}
|
||||||
stopCameraRecording(false);
|
stopCameraRecording(false);
|
||||||
if (recordControl != null) {
|
if (recordControl != null) {
|
||||||
setRecordListener(recordControl, mapActivity);
|
setRecordListener(recordControl, mapActivity);
|
||||||
|
|
Loading…
Reference in a new issue