diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index e4864b4f9d..46d1a17780 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -1322,6 +1322,8 @@ Постоянная фокусировка Звук затвора Проигрывать звук при фотографировании + Размер фото + Размер изображения для встроенного приложения фотографирования Сообщать о превышении скорости Сообщать о камерах diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 755164e655..fa68d7609b 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -1938,6 +1938,8 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A The camera continuously tries to focus Play sound on photo shot Choose whether to play a sound when shooting photos + Camera Picture Size + Select internal camera Picture Size Invalid format: %s Remove all Announce nearby favorites diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index b477a2cc53..b70017d007 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -113,6 +113,10 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { public static final int AV_DEFAULT_ACTION_TAKEPICTURE = 2; public static final int AV_DEFAULT_ACTION_CHOOSE = -1; + // camera picture size: + public static final int AV_PHOTO_SIZE_DEFAULT = -1; + public static int cameraPictureSizeDefault = 0; + // camera focus type public static final int AV_CAMERA_FOCUS_AUTO = 0; public static final int AV_CAMERA_FOCUS_HIPERFOCAL = 1; @@ -124,10 +128,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { private static int shotId = 0; private SoundPool sp = null; + public final CommonPreference AV_CAMERA_PICTURE_SIZE; public final CommonPreference AV_CAMERA_FOCUS_TYPE; - public final CommonPreference AV_DEFAULT_ACTION; - public final OsmandPreference SHOW_RECORDINGS; private DataTileManager recordings = new DataTileManager(14); @@ -341,6 +344,8 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { AV_EXTERNAL_PHOTO_CAM = settings.registerBooleanPreference("av_external_cam", true).makeGlobal(); AV_VIDEO_FORMAT = settings.registerIntPreference("av_video_format", VIDEO_OUTPUT_MP4).makeGlobal(); AV_DEFAULT_ACTION = settings.registerIntPreference("av_default_action", AV_DEFAULT_ACTION_CHOOSE).makeGlobal(); + // camera picture size: + AV_CAMERA_PICTURE_SIZE = settings.registerIntPreference("av_camera_picture_size", AV_PHOTO_SIZE_DEFAULT).makeGlobal(); // camera focus type: AV_CAMERA_FOCUS_TYPE = settings.registerIntPreference("av_camera_focus_type", AV_CAMERA_FOCUS_AUTO).makeGlobal(); // camera sound: @@ -758,8 +763,34 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { @Override public void surfaceCreated(SurfaceHolder holder) { try { + // load sound befor shot: + if (AV_PHOTO_PLAY_SOUND.get()) { + if (sp == null) + sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0); + log.info("Play sound on photo"); + if (shotId == 0) { + shotId = sp.load(app.getAssets().openFd("sounds/camera_click.ogg"), 1); + log.debug("loaded file sound ID: " + shotId); + } + } + Parameters parameters = cam.getParameters(); + // camera picture size: + List psps = parameters.getSupportedPictureSizes(); + int index = AV_CAMERA_PICTURE_SIZE.get(); + log.debug("takePhotoWithCamera() index=" + index ); + if(index == AV_PHOTO_SIZE_DEFAULT) + { + index = cameraPictureSizeDefault; + log.debug("takePhotoWithCamera() Default value of picture size. Set index to cameraPictureSizeDefault. Now index=" + + index ); + } + Camera.Size selectedCamPicSize = psps.get(index); + parameters.setPictureSize(selectedCamPicSize.width, selectedCamPicSize.height); + log.debug("takePhotoWithCamera() set Picture size: width=" + selectedCamPicSize.width + + " height=" + selectedCamPicSize.height ); + // camera focus type: boolean autofocus = true; // boolean autofocus = !Boolean.parseBoolean(parameters.get("auto-exposure-lock-supported")); @@ -797,16 +828,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { // parameters.setFocusMode(Parameters.FOCUS_MODE_FIXED); // parameters.set("auto-exposure-lock", "true"); // } - // load sound befor shot: - if (AV_PHOTO_PLAY_SOUND.get()) { - if (sp == null) - sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0); - log.info("Play sound on photo"); - if (shotId == 0) { - shotId = sp.load(app.getAssets().openFd("sounds/camera_click.ogg"), 1); - log.debug("loaded file sound ID: " + shotId); - } - } parameters.setWhiteBalance(Parameters.WHITE_BALANCE_AUTO); parameters.setFlashMode(Parameters.FLASH_MODE_AUTO); diff --git a/OsmAnd/src/net/osmand/plus/audionotes/SettingsAudioVideoActivity.java b/OsmAnd/src/net/osmand/plus/audionotes/SettingsAudioVideoActivity.java index 2622fef45b..dee0b2ebd3 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/SettingsAudioVideoActivity.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/SettingsAudioVideoActivity.java @@ -6,6 +6,9 @@ import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_DEFAULT_ACTION import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_DEFAULT_ACTION_VIDEO; import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.VIDEO_OUTPUT_3GP; import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.VIDEO_OUTPUT_MP4; +// camera picture size: +import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.cameraPictureSizeDefault; +import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_PHOTO_SIZE_DEFAULT; // support camera focus select: import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_AUTO; import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_HIPERFOCAL; @@ -52,10 +55,80 @@ public class SettingsAudioVideoActivity extends SettingsBaseActivity { // camera type settings: grp.addPreference(createCheckBoxPreference(p.AV_EXTERNAL_PHOTO_CAM, R.string.av_use_external_camera, R.string.av_use_external_camera_descr)); - // focus mode settings: - // show in menu only suppoted modes: Parameters parameters = cam.getParameters(); + + // Photo picture size + // get supported sizes: + List psps = parameters.getSupportedPictureSizes(); + // list of megapixels of each resolution: + List mpix = new ArrayList(); + // list of index each resolution in list, returned by getSupportedPictureSizes(): + List picSizesValues = new ArrayList(); + // fill lists for sort: + for (int index = 0; index < psps.size(); index++) { + mpix.add( (psps.get(index)).width*(psps.get(index)).height ); + picSizesValues.add(index); + } + // sort list for max resolution in begining of list: + for (int i=0; i < mpix.size(); i++ ) + { + for (int j=0; j < mpix.size() - i - 1; j++ ) + { + if ( mpix.get(j) < mpix.get( j + 1 ) ) + { + // change elements: + int tmp=mpix.get( j + 1 ); + mpix.set( j + 1, mpix.get( j ) ); + mpix.set( j, tmp ); + + tmp=picSizesValues.get( j + 1 ); + picSizesValues.set( j + 1, picSizesValues.get( j ) ); + picSizesValues.set( j, tmp ); + } + } + } + // set default photo size to max resolution (set index of element with max resolution in List, returned by getSupportedPictureSizes() ): + cameraPictureSizeDefault = picSizesValues.get(0); + log.debug("onCreate() set cameraPictureSizeDefault=" + cameraPictureSizeDefault); + + List itemsPicSizes = new ArrayList(); + String prefix; + for (int index = 0; index < psps.size(); index++) { + float px=(float)((psps.get( picSizesValues.get(index) )).width*(psps.get( picSizesValues.get(index) )).height); + if(px>102400) // 100 K + { + px=px/1048576; + prefix="Mpx"; + } + else + { + px=px/1024; + prefix="Kpx"; + } + + itemsPicSizes.add( (psps.get( picSizesValues.get(index) )).width + + "x" + + (psps.get( picSizesValues.get(index) )).height + + " ( " + + String.format("%.2f", px ) + + " " + + prefix + + " )"); + } + log.debug("onCreate() set default size: width=" + psps.get( cameraPictureSizeDefault ).width + " height=" + + psps.get( cameraPictureSizeDefault ).height + " index in ps=" + cameraPictureSizeDefault ); + + entries = itemsPicSizes.toArray(new String[itemsPicSizes.size()]); + intValues = picSizesValues.toArray(new Integer[picSizesValues.size()]); + if (entries.length > 0) { + ListPreference camSizes = createListPreference(p.AV_CAMERA_PICTURE_SIZE, entries, intValues, R.string.av_camera_pic_size, + R.string.av_camera_pic_size_descr); + grp.addPreference(camSizes); + } + + // focus mode settings: + // show in menu only suppoted modes: List sfm = parameters.getSupportedFocusModes(); List items = new ArrayList(); List itemsValues = new ArrayList(); @@ -88,9 +161,11 @@ public class SettingsAudioVideoActivity extends SettingsBaseActivity { R.string.av_camera_focus_descr); grp.addPreference(camFocus); } + // play sound on success photo: grp.addPreference(createCheckBoxPreference(p.AV_PHOTO_PLAY_SOUND, R.string.av_photo_play_sound, R.string.av_photo_play_sound_descr)); + cam.release(); } // video settings: