Added Recorder Split settings UI

This commit is contained in:
Alexey Kulish 2015-12-24 19:56:49 +03:00
parent 9a27eac21a
commit 6a893e04ee
2 changed files with 71 additions and 4 deletions

View file

@ -9,6 +9,13 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="rec_split">Recorder Split</string>
<string name="rec_split_title">Use Recorder Split</string>
<string name="rec_split_desc">Rewrite clips when used space exceeds the storage size</string>
<string name="rec_split_clip_length">Clip length</string>
<string name="rec_split_clip_length_desc">Length of every recorded clip will not be longer specified time interval</string>
<string name="rec_split_storage_size">Storage size</string>
<string name="rec_split_storage_size_desc">Amount of space that can be occupied by all recorded clips</string>
<string name="live_updates">Live updates</string> <string name="live_updates">Live updates</string>
<string name="available_maps">Available maps</string> <string name="available_maps">Available maps</string>
<string name="select_voice_provider">Select voice guidance</string> <string name="select_voice_provider">Select voice guidance</string>

View file

@ -6,6 +6,7 @@ import android.media.CamcorderProfile;
import android.media.MediaRecorder; import android.media.MediaRecorder;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.StatFs;
import android.preference.ListPreference; import android.preference.ListPreference;
import android.preference.PreferenceCategory; import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
@ -18,8 +19,11 @@ import net.osmand.plus.activities.SettingsBaseActivity;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import java.io.File;
import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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.AUDIO_BITRATE_DEFAULT;
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_AUTO; import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_AUTO;
@ -228,6 +232,62 @@ public class SettingsAudioVideoActivity extends SettingsBaseActivity {
R.string.av_video_quality_descr); R.string.av_video_quality_descr);
video.addPreference(lp); video.addPreference(lp);
// Recorder Split settings
PreferenceCategory recSplit = new PreferenceCategory(this);
recSplit.setTitle(R.string.rec_split);
grp.addPreference(recSplit);
recSplit.addPreference(createCheckBoxPreference(p.AV_RECORDER_SPLIT, R.string.rec_split_title,
R.string.rec_split_desc));
intValues = new Integer[]{1, 2, 3, 4, 5, 7, 10, 15, 20, 25, 30};
entries = new String[intValues.length];
int i = 0;
String minStr = getString(R.string.int_min);
for (int v : intValues) {
entries[i++] = String.valueOf(v) + " " + minStr;
}
lp = createListPreference(p.AV_RS_CLIP_LENGTH, entries, intValues,
R.string.rec_split_clip_length,
R.string.rec_split_clip_length_desc);
recSplit.addPreference(lp);
File dir = getMyApplication().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);
entries = new String[gbList.size()];
intValues = new Integer[gbList.size()];
i = 0;
for (int v : gbList) {
intValues[i] = v;
entries[i] = formatGb.format(new Object[]{(float) v});
i++;
}
lp = createListPreference(p.AV_RS_STORAGE_SIZE, entries, intValues,
R.string.rec_split_storage_size,
R.string.rec_split_storage_size_desc);
recSplit.addPreference(lp);
}
// audio settings // audio settings
PreferenceCategory audio = new PreferenceCategory(this); PreferenceCategory audio = new PreferenceCategory(this);
audio.setTitle(R.string.shared_string_audio); audio.setTitle(R.string.shared_string_audio);