Fix audio/video notes plugin

This commit is contained in:
Alexey Kulish 2015-12-04 15:37:42 +03:00
parent a9558bcec3
commit 65d66e51b4

View file

@ -767,7 +767,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
@Override
public void mapActivityPause(MapActivity activity) {
public void mapActivityDestroy(MapActivity activity) {
if (isRecording()) {
if (currentRecording.getType() == AVActionType.REC_PHOTO) {
recordingMenu.hide();
@ -825,7 +825,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
int cameraOrientation = getCamOrientation(mapActivity, Camera.CameraInfo.CAMERA_FACING_BACK);
cam.setDisplayOrientation(cameraOrientation);
parameters.set("rotation", cameraOrientation);
//parameters.setPreviewSize(recordingMenu.getViewfinderHeight(), recordingMenu.getViewfinderWidth());
cam.setParameters(parameters);
cam.setPreviewDisplay(holder);
cam.startPreview();
@ -835,7 +834,10 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
} catch (Exception e) {
logErr(e);
closeRecordingMenu();
closeCamera();
finishRecording();
return;
}
@ -1082,11 +1084,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
int cameraOrientation = getCamOrientation(mapActivity, Camera.CameraInfo.CAMERA_FACING_BACK);
cam.setDisplayOrientation(cameraOrientation);
parameters.set("rotation", cameraOrientation);
if (cameraOrientation == 0 || cameraOrientation == 180) {
parameters.setPreviewSize(recordingMenu.getViewfinderWidth(), recordingMenu.getViewfinderHeight());
} else {
parameters.setPreviewSize(recordingMenu.getViewfinderHeight(), recordingMenu.getViewfinderWidth());
}
// if (cameraOrientation == 0 || cameraOrientation == 180) {
// parameters.setPreviewSize(recordingMenu.getViewfinderWidth(), recordingMenu.getViewfinderHeight());
// } else {
// parameters.setPreviewSize(recordingMenu.getViewfinderHeight(), recordingMenu.getViewfinderWidth());
// }
cam.setParameters(parameters);
cam.setPreviewDisplay(holder);
cam.startPreview();
@ -1095,7 +1097,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
} catch (Exception e) {
logErr(e);
closeRecordingMenu();
closeCamera();
finishRecording();
e.printStackTrace();
}
}
@ -1156,7 +1160,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
try {
cam.takePicture(null, null, new AudioVideoPhotoHandler(lastTakingPhoto));
} catch (RuntimeException e) {
closeRecordingMenu();
closeCamera();
finishRecording();
}
}
}
@ -1213,9 +1219,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
SHOW_RECORDINGS.set(true);
mapActivity.getMapView().refreshMap();
updateWidgetIcon(recordControl);
recordingMenu.hide();
recordingMenu = null;
restoreScreenOrientation();
closeRecordingMenu();
}
}
@ -1448,6 +1452,21 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
});
}
private void closeRecordingMenu() {
if (mapActivity != null) {
mapActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (recordingMenu != null) {
recordingMenu.hide();
recordingMenu = null;
}
restoreScreenOrientation();
}
});
}
}
public void playRecording(final Context ctx, final Recording r) {
if (r.isVideo()) {
Intent vint = new Intent(Intent.ACTION_VIEW);
@ -1555,17 +1574,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
} catch (Exception error) {
logErr(error);
} finally {
if (mapActivity != null) {
mapActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
recordingMenu.hide();
recordingMenu = null;
restoreScreenOrientation();
}
});
}
closeRecordingMenu();
closeCamera();
finishRecording();
}
}
}