focus modes only supported by device

This commit is contained in:
progserega 2013-06-25 22:20:38 +11:00
parent 13723dabcc
commit aee090793f
3 changed files with 60 additions and 23 deletions

View file

@ -33,5 +33,5 @@
<asset source="voice/it-Chiara/config.p" destination="voice/it-Chiara/_config.p" mode="overwriteOnlyIfExists" />
<asset source="voice/sk-Ruzena/config.p" destination="voice/sk-Ruzena/_config.p" mode="overwriteOnlyIfExists" />
<asset source="sounds/camera_click.ogg" destination="sounds/camera_click.ogg" mode="overwriteOnlyIfExists" />
<asset source="sounds/camera_click.ogg" destination="sounds/camera_click.ogg" mode="copyOnlyIfDoesNotExist" />
</assets>

View file

@ -1202,7 +1202,7 @@
<string name="av_camera_focus">Режим фокусировки камеры</string>
<string name="av_camera_focus_descr">Режим фокусировки для встроенного приложения фотографирования</string>
<string name="av_camera_focus_auto">Автоматический фокус</string>
<string name="av_camera_focus_hiperfocal">Гиперфокальное (если поддерживается)</string>
<string name="av_camera_focus_hiperfocal">Гиперфокальное или фиксированное</string>
<string name="av_camera_focus_edof">Увеличенная глубина резкозти (EDOF)</string>
<string name="av_camera_focus_infinity">Фокус на бесконечность</string>
<string name="av_camera_focus_macro">Макро-режим</string>

View file

@ -1,7 +1,5 @@
package net.osmand.plus.audionotes;
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_DEFAULT_ACTION_AUDIO;
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_DEFAULT_ACTION_CHOOSE;
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_DEFAULT_ACTION_TAKEPICTURE;
@ -16,15 +14,21 @@ import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_I
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_MACRO;
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_CONTINUOUS;
////
import org.apache.commons.logging.Log;
import net.osmand.PlatformUtil;
import java.util.List;
import java.util.ArrayList;
import android.hardware.Camera.Parameters;
import android.hardware.Camera;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.SettingsBaseActivity;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.PreferenceScreen;
import android.util.Log;
public class SettingsAudioVideoActivity extends SettingsBaseActivity {
private static final Log log = PlatformUtil.getLog(AudioVideoNotesPlugin.class);
@Override
public void onCreate(Bundle savedInstanceState) {
@ -48,28 +52,55 @@ public class SettingsAudioVideoActivity extends SettingsBaseActivity {
grp.addPreference(createCheckBoxPreference(p.AV_EXTERNAL_PHOTO_CAM, R.string.av_use_external_camera,
R.string.av_use_external_camera_descr));
// focus mode settings:
entries = new String[] {
getString(R.string.av_camera_focus_auto),
getString(R.string.av_camera_focus_hiperfocal),
getString(R.string.av_camera_focus_edof),
getString(R.string.av_camera_focus_infinity),
getString(R.string.av_camera_focus_macro),
getString(R.string.av_camera_focus_continuous)
};
intValues = new Integer[] {
AV_CAMERA_FOCUS_AUTO,
AV_CAMERA_FOCUS_HIPERFOCAL,
AV_CAMERA_FOCUS_EDOF,
AV_CAMERA_FOCUS_INFINITY,
AV_CAMERA_FOCUS_MACRO,
AV_CAMERA_FOCUS_CONTINUOUS
};
// show in menu only suppoted modes:
final Camera cam = openCamera();
Parameters parameters = cam.getParameters();
List<String> sfm=parameters.getSupportedFocusModes ();
List<String> items=new ArrayList <String>();
List<Integer> itemsValues=new ArrayList <Integer>();
// filtering known types for translate and set index:
for(int index=0;index<sfm.size();index++)
{
if(sfm.get(index).equals("auto"))
{
items.add(getString(R.string.av_camera_focus_auto));
itemsValues.add(AV_CAMERA_FOCUS_AUTO);
}
else if(sfm.get(index).equals("fixed"))
{
items.add(getString(R.string.av_camera_focus_hiperfocal));
itemsValues.add(AV_CAMERA_FOCUS_HIPERFOCAL);
}
else if(sfm.get(index).equals("edof"))
{
items.add(getString(R.string.av_camera_focus_edof));
itemsValues.add(AV_CAMERA_FOCUS_EDOF);
}
else if(sfm.get(index).equals("infinity"))
{
items.add(getString(R.string.av_camera_focus_infinity));
itemsValues.add(AV_CAMERA_FOCUS_INFINITY);
}
else if(sfm.get(index).equals("macro"))
{
items.add(getString(R.string.av_camera_focus_macro));
itemsValues.add(AV_CAMERA_FOCUS_MACRO);
}
else if(sfm.get(index).equals("continuous-picture"))
{
items.add(getString(R.string.av_camera_focus_continuous));
itemsValues.add(AV_CAMERA_FOCUS_CONTINUOUS);
}
}
entries=items.toArray(entries);
intValues=itemsValues.toArray(intValues);
ListPreference camFocus = createListPreference(p.AV_CAMERA_FOCUS_TYPE, entries, intValues, R.string.av_camera_focus,
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:
@ -84,6 +115,12 @@ public class SettingsAudioVideoActivity extends SettingsBaseActivity {
}
}
protected Camera openCamera() {
try {
return Camera.open();
} catch (Exception e ){
log.error("Error open camera", e);
return null;
}
}
}