Add multimedia notes preferences screen
This commit is contained in:
parent
0f9ad9502b
commit
d246bb6adf
5 changed files with 535 additions and 15 deletions
|
@ -11,6 +11,10 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="multimedia_notes_view_descr">You can find all your notes in Menu — My places — Notes</string>
|
||||
<string name="audio_notes">Audio notes</string>
|
||||
<string name="video_notes">Video notes</string>
|
||||
<string name="photo_notes">Photo notes</string>
|
||||
<string name="route_recalculation">Route recalculation</string>
|
||||
<string name="accessibility_announce">Announce</string>
|
||||
<string name="login_and_pass">Username and password</string>
|
||||
|
|
146
OsmAnd/res/xml/multimedia_notes.xml
Normal file
146
OsmAnd/res/xml/multimedia_notes.xml
Normal file
|
@ -0,0 +1,146 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:title="@string/audionotes_plugin_name">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="photo_notes"
|
||||
android:layout="@layout/preference_category_with_descr"
|
||||
android:title="@string/photo_notes" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
|
||||
android:key="av_external_cam"
|
||||
android:layout="@layout/preference_with_descr_dialog_and_switch"
|
||||
android:summaryOff="@string/shared_string_disabled"
|
||||
android:summaryOn="@string/shared_string_enabled"
|
||||
android:title="@string/av_use_external_camera"
|
||||
tools:icon="@drawable/ic_action_photo_dark" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.ListPreferenceEx
|
||||
android:icon="@drawable/ic_action_picture_size"
|
||||
android:key="av_camera_picture_size"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:title="@string/av_camera_pic_size"
|
||||
tools:summary="4128x3096 (12.19 Mpx)" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.ListPreferenceEx
|
||||
android:icon="@drawable/ic_action_camera_focus"
|
||||
android:key="av_camera_focus_type"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:title="@string/av_camera_focus"
|
||||
tools:summary="@string/av_camera_focus_descr" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
|
||||
android:key="av_photo_play_sound"
|
||||
android:layout="@layout/preference_with_descr_dialog_and_switch"
|
||||
android:summaryOff="@string/shared_string_disabled"
|
||||
android:summaryOn="@string/shared_string_enabled"
|
||||
android:title="@string/av_photo_play_sound"
|
||||
tools:icon="@drawable/ic_action_music_off" />
|
||||
|
||||
<Preference
|
||||
android:layout="@layout/simple_divider_item"
|
||||
android:selectable="false" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="audio_notes"
|
||||
android:layout="@layout/preference_category_with_descr"
|
||||
android:title="@string/audio_notes" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.ListPreferenceEx
|
||||
android:key="av_audio_format"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:title="@string/av_audio_format"
|
||||
tools:summary="@string/av_audio_format_descr" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.ListPreferenceEx
|
||||
android:key="av_audio_bitrate"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:title="@string/av_audio_bitrate"
|
||||
tools:summary="@string/av_audio_bitrate_descr" />
|
||||
|
||||
<Preference
|
||||
android:layout="@layout/simple_divider_item"
|
||||
android:selectable="false" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="video_notes"
|
||||
android:layout="@layout/preference_category_with_descr"
|
||||
android:title="@string/video_notes" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
|
||||
android:key="av_external_recorder"
|
||||
android:layout="@layout/preference_with_descr_dialog_and_switch"
|
||||
android:summaryOff="@string/shared_string_disabled"
|
||||
android:summaryOn="@string/shared_string_enabled"
|
||||
android:title="@string/av_use_external_recorder"
|
||||
tools:icon="@drawable/ic_action_video_dark" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.ListPreferenceEx
|
||||
android:icon="@drawable/ic_action_picture_size"
|
||||
android:key="av_video_quality"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:title="@string/av_video_quality"
|
||||
tools:summary="4128x3096 (12.19 Mpx)" />
|
||||
|
||||
<Preference
|
||||
android:layout="@layout/simple_divider_item"
|
||||
android:selectable="false" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
|
||||
android:key="av_recorder_split"
|
||||
android:layout="@layout/preference_with_descr_dialog_and_switch"
|
||||
android:summaryOff="@string/shared_string_disabled"
|
||||
android:summaryOn="@string/shared_string_enabled"
|
||||
android:title="@string/rec_split_title" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.ListPreferenceEx
|
||||
android:key="av_rs_clip_length"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:title="@string/rec_split_clip_length"
|
||||
tools:summary="5 min" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.ListPreferenceEx
|
||||
android:key="av_rs_storage_size"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:title="@string/rec_split_storage_size"
|
||||
tools:icon="@drawable/ic_sdcard"
|
||||
tools:summary="5 GB" />
|
||||
|
||||
<Preference
|
||||
android:layout="@layout/simple_divider_item"
|
||||
android:selectable="false" />
|
||||
|
||||
<Preference
|
||||
android:key="open_notes_description"
|
||||
android:layout="@layout/preference_info"
|
||||
android:persistent="false"
|
||||
android:selectable="false"
|
||||
android:title="@string/multimedia_notes_view_descr" />
|
||||
|
||||
<Preference
|
||||
android:key="open_notes"
|
||||
android:layout="@layout/preference_button"
|
||||
android:persistent="false"
|
||||
android:title="@string/notes"
|
||||
tools:icon="@drawable/ic_action_folder" />
|
||||
|
||||
<Preference
|
||||
android:layout="@layout/simple_divider_item"
|
||||
android:selectable="false" />
|
||||
|
||||
<Preference
|
||||
android:key="reset_to_default"
|
||||
android:layout="@layout/preference_button"
|
||||
android:persistent="false"
|
||||
android:title="@string/reset_to_default"
|
||||
tools:icon="@drawable/ic_action_reset_to_default_dark" />
|
||||
|
||||
<Preference
|
||||
android:key="copy_plugin_settings"
|
||||
android:layout="@layout/preference_button"
|
||||
android:persistent="false"
|
||||
android:title="@string/copy_from_other_profile"
|
||||
tools:icon="@drawable/ic_action_copy" />
|
||||
|
||||
</PreferenceScreen>
|
|
@ -64,6 +64,7 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
|||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||
import net.osmand.plus.settings.MultimediaNotesFragment;
|
||||
import net.osmand.plus.settings.BaseSettingsFragment;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
@ -539,25 +540,25 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
this.app = app;
|
||||
OsmandSettings settings = app.getSettings();
|
||||
ApplicationMode.regWidgetVisibility("audionotes", (ApplicationMode[]) null);
|
||||
AV_EXTERNAL_RECORDER = settings.registerBooleanPreference("av_external_recorder", false).makeGlobal();
|
||||
AV_EXTERNAL_PHOTO_CAM = settings.registerBooleanPreference("av_external_cam", true).makeGlobal();
|
||||
AV_VIDEO_FORMAT = settings.registerIntPreference("av_video_format", VIDEO_OUTPUT_MP4).makeGlobal();
|
||||
AV_VIDEO_QUALITY = settings.registerIntPreference("av_video_quality", VIDEO_QUALITY_DEFAULT).makeGlobal();
|
||||
AV_AUDIO_FORMAT = settings.registerIntPreference("av_audio_format", AUDIO_FORMAT_DEFAULT).makeGlobal();
|
||||
AV_AUDIO_BITRATE = settings.registerIntPreference("av_audio_bitrate", AUDIO_BITRATE_DEFAULT).makeGlobal();
|
||||
AV_DEFAULT_ACTION = settings.registerIntPreference("av_default_action", AV_DEFAULT_ACTION_CHOOSE).makeGlobal();
|
||||
AV_EXTERNAL_RECORDER = settings.registerBooleanPreference("av_external_recorder", false);
|
||||
AV_EXTERNAL_PHOTO_CAM = settings.registerBooleanPreference("av_external_cam", true);
|
||||
AV_VIDEO_FORMAT = settings.registerIntPreference("av_video_format", VIDEO_OUTPUT_MP4);
|
||||
AV_VIDEO_QUALITY = settings.registerIntPreference("av_video_quality", VIDEO_QUALITY_DEFAULT);
|
||||
AV_AUDIO_FORMAT = settings.registerIntPreference("av_audio_format", AUDIO_FORMAT_DEFAULT);
|
||||
AV_AUDIO_BITRATE = settings.registerIntPreference("av_audio_bitrate", AUDIO_BITRATE_DEFAULT);
|
||||
AV_DEFAULT_ACTION = settings.registerIntPreference("av_default_action", AV_DEFAULT_ACTION_CHOOSE);
|
||||
// camera picture size:
|
||||
AV_CAMERA_PICTURE_SIZE = settings.registerIntPreference("av_camera_picture_size", AV_PHOTO_SIZE_DEFAULT).makeGlobal();
|
||||
AV_CAMERA_PICTURE_SIZE = settings.registerIntPreference("av_camera_picture_size", AV_PHOTO_SIZE_DEFAULT);
|
||||
// camera focus type:
|
||||
AV_CAMERA_FOCUS_TYPE = settings.registerIntPreference("av_camera_focus_type", AV_CAMERA_FOCUS_AUTO).makeGlobal();
|
||||
AV_CAMERA_FOCUS_TYPE = settings.registerIntPreference("av_camera_focus_type", AV_CAMERA_FOCUS_AUTO);
|
||||
// camera sound:
|
||||
AV_PHOTO_PLAY_SOUND = settings.registerBooleanPreference("av_photo_play_sound", true).makeGlobal();
|
||||
AV_PHOTO_PLAY_SOUND = settings.registerBooleanPreference("av_photo_play_sound", true);
|
||||
|
||||
SHOW_RECORDINGS = settings.registerBooleanPreference("show_recordings", true).makeGlobal();
|
||||
SHOW_RECORDINGS = settings.registerBooleanPreference("show_recordings", true);
|
||||
|
||||
AV_RECORDER_SPLIT = settings.registerBooleanPreference("av_recorder_split", false).makeGlobal();
|
||||
AV_RS_CLIP_LENGTH = settings.registerIntPreference("av_rs_clip_length", CLIP_LENGTH_DEFAULT).makeGlobal();
|
||||
AV_RS_STORAGE_SIZE = settings.registerIntPreference("av_rs_storage_size", STORAGE_SIZE_DEFAULT).makeGlobal();
|
||||
AV_RECORDER_SPLIT = settings.registerBooleanPreference("av_recorder_split", false);
|
||||
AV_RS_CLIP_LENGTH = settings.registerIntPreference("av_rs_clip_length", CLIP_LENGTH_DEFAULT);
|
||||
AV_RS_STORAGE_SIZE = settings.registerIntPreference("av_rs_storage_size", STORAGE_SIZE_DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1791,7 +1792,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
|
||||
@Override
|
||||
public Class<? extends BaseSettingsFragment> getSettingsFragment() {
|
||||
return null;
|
||||
return MultimediaNotesFragment.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -96,6 +96,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
SCREEN_ALERTS(ScreenAlertsFragment.class.getName(), true, R.xml.screen_alerts, R.layout.profile_preference_toolbar_with_switch),
|
||||
VOICE_ANNOUNCES(VoiceAnnouncesFragment.class.getName(), true, R.xml.voice_announces, R.layout.profile_preference_toolbar_with_switch),
|
||||
ACCESSIBILITY_SETTINGS(AccessibilitySettingsFragment.class.getName(), true, R.xml.accessibility_settings, R.layout.profile_preference_toolbar_big),
|
||||
MULTIMEDIA_NOTES(MultimediaNotesFragment.class.getName(), true, R.xml.multimedia_notes, R.layout.profile_preference_toolbar_big),
|
||||
VEHICLE_PARAMETERS(VehicleParametersFragment.class.getName(), true, R.xml.vehicle_parameters, R.layout.profile_preference_toolbar),
|
||||
MAP_DURING_NAVIGATION(MapDuringNavigationFragment.class.getName(), true, R.xml.map_during_navigation, R.layout.profile_preference_toolbar),
|
||||
TURN_SCREEN_ON(TurnScreenOnFragment.class.getName(), true, R.xml.turn_screen_on, R.layout.profile_preference_toolbar_with_switch),
|
||||
|
|
368
OsmAnd/src/net/osmand/plus/settings/MultimediaNotesFragment.java
Normal file
368
OsmAnd/src/net/osmand/plus/settings/MultimediaNotesFragment.java
Normal file
|
@ -0,0 +1,368 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.hardware.Camera;
|
||||
import android.media.CamcorderProfile;
|
||||
import android.media.MediaRecorder;
|
||||
import android.os.Build;
|
||||
import android.os.StatFs;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||
import net.osmand.plus.settings.preferences.ListPreferenceEx;
|
||||
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AUDIO_BITRATE_DEFAULT;
|
||||
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_AUTO;
|
||||
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_CONTINUOUS;
|
||||
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_EDOF;
|
||||
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_HIPERFOCAL;
|
||||
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_INFINITY;
|
||||
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_MACRO;
|
||||
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.NOTES_TAB;
|
||||
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.cameraPictureSizeDefault;
|
||||
|
||||
public class MultimediaNotesFragment extends BaseSettingsFragment {
|
||||
|
||||
private static final Log log = PlatformUtil.getLog(MultimediaNotesFragment.class);
|
||||
|
||||
private static final String COPY_PLUGIN_SETTINGS = "copy_plugin_settings";
|
||||
private static final String RESET_TO_DEFAULT = "reset_to_default";
|
||||
private static final String OPEN_NOTES = "open_notes";
|
||||
|
||||
@Override
|
||||
protected void setupPreferences() {
|
||||
AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
|
||||
|
||||
if (plugin != null) {
|
||||
|
||||
Camera cam = openCamera();
|
||||
if (cam != null) {
|
||||
setupExternalPhotoCamPref(plugin);
|
||||
setupCameraPictureSizePref(cam, plugin);
|
||||
setupCameraFocusTypePref(cam, plugin);
|
||||
setupPhotoPlaySoundPref(plugin);
|
||||
cam.release();
|
||||
}
|
||||
|
||||
setupAudioFormatPref(plugin);
|
||||
setupAudioBitratePref(plugin);
|
||||
|
||||
setupExternalRecorderPref(plugin);
|
||||
setupVideoQualityPref(plugin);
|
||||
|
||||
setupRecorderSplitPref(plugin);
|
||||
setupClipLengthPref(plugin);
|
||||
setupStorageSizePref(plugin);
|
||||
|
||||
setupOpenNotesDescrPref();
|
||||
setupOpenNotesPref();
|
||||
|
||||
setupCopyProfileSettingsPref();
|
||||
setupResetToDefaultPref();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupExternalPhotoCamPref(AudioVideoNotesPlugin plugin) {
|
||||
SwitchPreferenceEx externalPhotoCam = (SwitchPreferenceEx) findPreference(plugin.AV_EXTERNAL_PHOTO_CAM.getId());
|
||||
externalPhotoCam.setDescription(getString(R.string.av_use_external_camera_descr));
|
||||
externalPhotoCam.setIcon(getActiveIcon(R.drawable.ic_action_photo_dark));
|
||||
}
|
||||
|
||||
private void setupCameraPictureSizePref(Camera cam, AudioVideoNotesPlugin plugin) {
|
||||
Camera.Parameters parameters = cam.getParameters();
|
||||
|
||||
// Photo picture size
|
||||
// get supported sizes
|
||||
List<Camera.Size> psps = parameters.getSupportedPictureSizes();
|
||||
// list of megapixels of each resolution
|
||||
List<Integer> mpix = new ArrayList<Integer>();
|
||||
// list of index each resolution in list, returned by getSupportedPictureSizes()
|
||||
List<Integer> picSizesValues = new ArrayList<Integer>();
|
||||
// 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<String> itemsPicSizes = new ArrayList<String>();
|
||||
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);
|
||||
|
||||
String[] entries = itemsPicSizes.toArray(new String[0]);
|
||||
Integer[] entryValues = picSizesValues.toArray(new Integer[0]);
|
||||
|
||||
ListPreferenceEx cameraPictureSize = (ListPreferenceEx) findPreference(plugin.AV_CAMERA_PICTURE_SIZE.getId());
|
||||
if (entries.length > 0) {
|
||||
cameraPictureSize.setEntries(entries);
|
||||
cameraPictureSize.setEntryValues(entryValues);
|
||||
cameraPictureSize.setDescription(R.string.av_camera_pic_size_descr);
|
||||
cameraPictureSize.setIcon(getActiveIcon(R.drawable.ic_action_picture_size));
|
||||
} else {
|
||||
cameraPictureSize.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupCameraFocusTypePref(Camera cam, AudioVideoNotesPlugin plugin) {
|
||||
Camera.Parameters parameters = cam.getParameters();
|
||||
|
||||
// focus mode settings
|
||||
// show in menu only suppoted modes
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
String[] entries = items.toArray(new String[0]);
|
||||
Integer[] entryValues = itemsValues.toArray(new Integer[0]);
|
||||
|
||||
ListPreferenceEx cameraFocusType = (ListPreferenceEx) findPreference(plugin.AV_CAMERA_FOCUS_TYPE.getId());
|
||||
if (entries.length > 0) {
|
||||
cameraFocusType.setEntries(entries);
|
||||
cameraFocusType.setEntryValues(entryValues);
|
||||
cameraFocusType.setDescription(R.string.av_camera_focus_descr);
|
||||
cameraFocusType.setIcon(getActiveIcon(R.drawable.ic_action_camera_focus));
|
||||
} else {
|
||||
cameraFocusType.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupPhotoPlaySoundPref(AudioVideoNotesPlugin plugin) {
|
||||
SwitchPreferenceEx photoPlaySound = (SwitchPreferenceEx) findPreference(plugin.AV_PHOTO_PLAY_SOUND.getId());
|
||||
photoPlaySound.setDescription(getString(R.string.av_photo_play_sound_descr));
|
||||
photoPlaySound.setIcon(getContentIcon(R.drawable.ic_action_music_off));
|
||||
}
|
||||
|
||||
private void setupAudioFormatPref(AudioVideoNotesPlugin plugin) {
|
||||
Integer[] entryValues = new Integer[] {MediaRecorder.AudioEncoder.DEFAULT, MediaRecorder.AudioEncoder.AAC};
|
||||
String[] entries = new String[] {"Default", "AAC"};
|
||||
|
||||
ListPreferenceEx audioFormat = (ListPreferenceEx) findPreference(plugin.AV_AUDIO_FORMAT.getId());
|
||||
audioFormat.setEntries(entries);
|
||||
audioFormat.setEntryValues(entryValues);
|
||||
audioFormat.setDescription(R.string.av_audio_format_descr);
|
||||
}
|
||||
|
||||
private void setupAudioBitratePref(AudioVideoNotesPlugin plugin) {
|
||||
Integer[] entryValues = new Integer[] {AUDIO_BITRATE_DEFAULT, 16 * 1024, 32 * 1024, 48 * 1024, 64 * 1024, 96 * 1024, 128 * 1024};
|
||||
String[] entries = new String[] {"Default", "16 kbps", "32 kbps", "48 kbps", "64 kbps", "96 kbps", "128 kbps"};
|
||||
|
||||
ListPreferenceEx audioBitrate = (ListPreferenceEx) findPreference(plugin.AV_AUDIO_BITRATE.getId());
|
||||
audioBitrate.setEntries(entries);
|
||||
audioBitrate.setEntryValues(entryValues);
|
||||
audioBitrate.setDescription(R.string.av_audio_bitrate_descr);
|
||||
}
|
||||
|
||||
private void setupExternalRecorderPref(AudioVideoNotesPlugin plugin) {
|
||||
SwitchPreferenceEx externalRecorder = (SwitchPreferenceEx) findPreference(plugin.AV_EXTERNAL_RECORDER.getId());
|
||||
externalRecorder.setDescription(getString(R.string.av_use_external_recorder_descr));
|
||||
externalRecorder.setIcon(getContentIcon(R.drawable.ic_action_video_dark));
|
||||
}
|
||||
|
||||
private void setupVideoQualityPref(AudioVideoNotesPlugin plugin) {
|
||||
List<String> qNames = new ArrayList<>();
|
||||
List<Integer> qValues = new ArrayList<>();
|
||||
if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_LOW)) {
|
||||
qNames.add(getString(R.string.av_video_quality_low));
|
||||
qValues.add(CamcorderProfile.QUALITY_LOW);
|
||||
}
|
||||
if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_480P)) {
|
||||
qNames.add("720 x 480 (480p)");
|
||||
qValues.add(CamcorderProfile.QUALITY_480P);
|
||||
}
|
||||
if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_720P)) {
|
||||
qNames.add("1280 x 720 (720p)");
|
||||
qValues.add(CamcorderProfile.QUALITY_720P);
|
||||
}
|
||||
if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_1080P)) {
|
||||
qNames.add("1920 x 1080 (1080p)");
|
||||
qValues.add(CamcorderProfile.QUALITY_1080P);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 21 && CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_2160P)) {
|
||||
qNames.add("3840x2160 (2160p)");
|
||||
qValues.add(CamcorderProfile.QUALITY_2160P);
|
||||
}
|
||||
if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_HIGH)) {
|
||||
qNames.add(getString(R.string.av_video_quality_high));
|
||||
qValues.add(CamcorderProfile.QUALITY_HIGH);
|
||||
}
|
||||
|
||||
String[] entries = qNames.toArray(new String[0]);
|
||||
Integer[] entryValues = qValues.toArray(new Integer[0]);
|
||||
|
||||
ListPreferenceEx videoQuality = (ListPreferenceEx) findPreference(plugin.AV_VIDEO_QUALITY.getId());
|
||||
videoQuality.setEntries(entries);
|
||||
videoQuality.setEntryValues(entryValues);
|
||||
videoQuality.setDescription(R.string.av_video_quality_descr);
|
||||
videoQuality.setIcon(getContentIcon(R.drawable.ic_action_picture_size));
|
||||
}
|
||||
|
||||
private void setupRecorderSplitPref(AudioVideoNotesPlugin plugin) {
|
||||
SwitchPreferenceEx recorderSplit = (SwitchPreferenceEx) findPreference(plugin.AV_RECORDER_SPLIT.getId());
|
||||
recorderSplit.setDescription(getString(R.string.rec_split_desc));
|
||||
}
|
||||
|
||||
private void setupClipLengthPref(AudioVideoNotesPlugin plugin) {
|
||||
Integer[] entryValues = new Integer[] {1, 2, 3, 4, 5, 7, 10, 15, 20, 25, 30};
|
||||
String[] entries = new String[entryValues.length];
|
||||
int i = 0;
|
||||
String minStr = getString(R.string.int_min);
|
||||
for (int v : entryValues) {
|
||||
entries[i++] = v + " " + minStr;
|
||||
}
|
||||
|
||||
ListPreferenceEx clipLength = (ListPreferenceEx) findPreference(plugin.AV_RS_CLIP_LENGTH.getId());
|
||||
clipLength.setEntries(entries);
|
||||
clipLength.setEntryValues(entryValues);
|
||||
clipLength.setDescription(R.string.rec_split_clip_length_desc);
|
||||
}
|
||||
|
||||
private void setupStorageSizePref(AudioVideoNotesPlugin plugin) {
|
||||
ListPreferenceEx storageSize = (ListPreferenceEx) findPreference(plugin.AV_RS_STORAGE_SIZE.getId());
|
||||
|
||||
File dir = app.getAppPath("").getParentFile();
|
||||
long size = 0;
|
||||
if (dir.canRead()) {
|
||||
StatFs fs = new StatFs(dir.getAbsolutePath());
|
||||
size = ((long) fs.getBlockSize() * (long) fs.getBlockCount()) / (1 << 30);
|
||||
}
|
||||
if (size > 0) {
|
||||
int value = 1;
|
||||
ArrayList<Integer> gbList = new ArrayList<>();
|
||||
while (value < size) {
|
||||
gbList.add(value);
|
||||
if (value < 5) {
|
||||
value++;
|
||||
} else {
|
||||
value += 5;
|
||||
}
|
||||
}
|
||||
if (value != size) {
|
||||
gbList.add((int) size);
|
||||
}
|
||||
MessageFormat formatGb = new MessageFormat("{0, number,#.##} GB", Locale.US);
|
||||
String[] entries = new String[gbList.size()];
|
||||
Integer[] entryValues = new Integer[gbList.size()];
|
||||
int i = 0;
|
||||
for (int v : gbList) {
|
||||
entryValues[i] = v;
|
||||
entries[i] = formatGb.format(new Object[] {(float) v});
|
||||
i++;
|
||||
}
|
||||
|
||||
storageSize.setEntries(entries);
|
||||
storageSize.setEntryValues(entryValues);
|
||||
storageSize.setDescription(R.string.rec_split_storage_size_desc);
|
||||
} else {
|
||||
storageSize.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupOpenNotesDescrPref() {
|
||||
Preference nameAndPasswordPref = findPreference("open_notes_description");
|
||||
nameAndPasswordPref.setTitle(getText(R.string.multimedia_notes_view_descr));
|
||||
}
|
||||
|
||||
private void setupOpenNotesPref() {
|
||||
Preference openNotes = findPreference(OPEN_NOTES);
|
||||
openNotes.setIcon(getActiveIcon(R.drawable.ic_action_folder));
|
||||
}
|
||||
|
||||
private void setupCopyProfileSettingsPref() {
|
||||
Preference copyProfilePrefs = findPreference(COPY_PLUGIN_SETTINGS);
|
||||
copyProfilePrefs.setIcon(getActiveIcon(R.drawable.ic_action_copy));
|
||||
}
|
||||
|
||||
private void setupResetToDefaultPref() {
|
||||
Preference resetToDefault = findPreference(RESET_TO_DEFAULT);
|
||||
resetToDefault.setIcon(getActiveIcon(R.drawable.ic_action_reset_to_default_dark));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (OPEN_NOTES.equals(preference.getKey())) {
|
||||
OsmAndAppCustomization appCustomization = app.getAppCustomization();
|
||||
Intent favorites = new Intent(preference.getContext(), appCustomization.getFavoritesActivity());
|
||||
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
app.getSettings().FAVORITES_TAB.set(NOTES_TAB);
|
||||
startActivity(favorites);
|
||||
return true;
|
||||
}
|
||||
return super.onPreferenceClick(preference);
|
||||
}
|
||||
|
||||
private Camera openCamera() {
|
||||
try {
|
||||
return Camera.open();
|
||||
} catch (Exception e) {
|
||||
log.error("Error open camera", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue