use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.
the class GeneralProfileSettingsFragment method setupUnitsOfLengthPref.
private void setupUnitsOfLengthPref() {
MetricsConstants[] metricsConstants = MetricsConstants.values();
String[] entries = new String[metricsConstants.length];
Integer[] entryValues = new Integer[metricsConstants.length];
for (int i = 0; i < entries.length; i++) {
entries[i] = metricsConstants[i].toHumanString(app);
entryValues[i] = metricsConstants[i].ordinal();
}
ListPreferenceEx unitsOfLength = (ListPreferenceEx) findPreference(settings.METRIC_SYSTEM.getId());
unitsOfLength.setEntries(entries);
unitsOfLength.setEntryValues(entryValues);
unitsOfLength.setIcon(getActiveIcon(R.drawable.ic_action_ruler_unit));
}
use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.
the class LiveMonitoringFragment method setupLiveMonitoringBufferPref.
private void setupLiveMonitoringBufferPref() {
Integer[] entryValues = new Integer[MAX_INTERVAL_TO_SEND_MINUTES.length];
String[] entries = new String[entryValues.length];
for (int i = 0; i < MAX_INTERVAL_TO_SEND_MINUTES.length; i++) {
int minute = MAX_INTERVAL_TO_SEND_MINUTES[i];
entryValues[i] = (minute * 60) * 1000;
entries[i] = OsmAndFormatter.getFormattedDuration(minute * 60, app);
}
ListPreferenceEx liveMonitoringBuffer = findPreference(settings.LIVE_MONITORING_MAX_INTERVAL_TO_SEND.getId());
liveMonitoringBuffer.setEntries(entries);
liveMonitoringBuffer.setEntryValues(entryValues);
liveMonitoringBuffer.setIcon(getPersistentPrefIcon(R.drawable.ic_action_time_span));
liveMonitoringBuffer.setDescription(R.string.live_monitoring_max_interval_to_send_desrc);
}
use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.
the class LiveMonitoringFragment method setupLiveMonitoringIntervalPref.
private void setupLiveMonitoringIntervalPref() {
Integer[] entryValues = new Integer[SECONDS.length + MINUTES.length];
String[] entries = new String[entryValues.length];
int k = 0;
for (int second : SECONDS) {
entryValues[k] = second * 1000;
entries[k] = second + " " + getString(R.string.int_seconds);
k++;
}
for (int minute : MINUTES) {
entryValues[k] = (minute * 60) * 1000;
entries[k] = minute + " " + getString(R.string.int_min);
k++;
}
ListPreferenceEx liveMonitoringInterval = (ListPreferenceEx) findPreference(settings.LIVE_MONITORING_INTERVAL.getId());
liveMonitoringInterval.setEntries(entries);
liveMonitoringInterval.setEntryValues(entryValues);
liveMonitoringInterval.setIcon(getPersistentPrefIcon(R.drawable.ic_action_time_span));
liveMonitoringInterval.setDescription(R.string.live_monitoring_interval_descr);
}
use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.
the class MultimediaNotesFragment method setupCameraPictureSizePref.
private void setupCameraPictureSizePref(Camera cam, AudioVideoNotesPlugin plugin) {
ListPreferenceEx cameraPictureSize = (ListPreferenceEx) findPreference(plugin.AV_CAMERA_PICTURE_SIZE.getId());
cameraPictureSize.setDescription(R.string.av_camera_pic_size_descr);
cameraPictureSize.setIcon(getPersistentPrefIcon(R.drawable.ic_action_picture_size));
if (cam == null) {
cameraPictureSize.setEnabled(false);
return;
}
Camera.Parameters parameters = cam.getParameters();
// Photo picture size
// get supported sizes
List<Camera.Size> psps = parameters.getSupportedPictureSizes();
if (psps == null) {
cameraPictureSize.setVisible(false);
return;
}
// 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]);
if (entries.length > 0) {
cameraPictureSize.setEntries(entries);
cameraPictureSize.setEntryValues(entryValues);
} else {
cameraPictureSize.setVisible(false);
}
}
use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.
the class MultimediaNotesFragment method setupAudioBitratePref.
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[] { getString(R.string.shared_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);
}
Aggregations