Commit 7592455b authored by CallisteHanriat's avatar CallisteHanriat

Fixing save path to rspk or trsl and adding some comments above functions

parent 3a2c808b
......@@ -28,7 +28,7 @@ public class RecordingLig extends Recording {
private Language motherTong;
private String regionOrigin;
private String speakerName;
private int speakerAge = 0;
private int speakerBirthYear = 0;
private String speakerGender;
public RecordingLig(UUID recordingUUID, String name, Date date,
......@@ -44,7 +44,7 @@ public class RecordingLig extends Recording {
bitsPerSample, latitude, longitude);
this.regionOrigin = region;
this.speakerName = spkrName;
this.speakerAge = spkrAge;
this.speakerBirthYear = spkrAge;
this.speakerGender = spkrGndr;
this.recordLang = recordLang != null ? new Language(recordLang.getName(),recordLang.getCode())
: new Language("", "");
......@@ -66,7 +66,7 @@ public class RecordingLig extends Recording {
bitsPerSample, latitude, longitude);
this.regionOrigin = region;
this.speakerName = spkrName;
this.speakerAge = spkrAge;
this.speakerBirthYear = spkrAge;
this.speakerGender = spkrGndr;
}
......@@ -169,18 +169,23 @@ public class RecordingLig extends Recording {
recording.motherTong = code.isEmpty() ? new Language(Aikuma.getLanguageCodeMap().get(code), code) : null;
recording.regionOrigin = (String) jsonObj.get(RecordingMetadataLig.metaOrigin);
recording.speakerName = (String) jsonObj.get(RecordingMetadataLig.metaSpkrName);
long age = (Long) jsonObj.get(RecordingMetadataLig.metaSpkrAge);
recording.speakerAge= (int) age;
long age = (Long) jsonObj.get(RecordingMetadataLig.metaSpkrBirthYr);
recording.speakerBirthYear= (int) age;
recording.speakerGender = (String) jsonObj.get(RecordingMetadataLig.metaSpkrGender);
return recording;
}
/**
* Fill a json object to permit to create a metadata file containing it.
*
* @return the encoded json object
*/
public JSONObject encode() {
JSONObject encodedRecording = super.encode();
// TODO complete with new metadata
encodedRecording.put(RecordingMetadataLig.metaOrigin, regionOrigin);
encodedRecording.put(RecordingMetadataLig.metaSpkrName, speakerName);
encodedRecording.put(RecordingMetadataLig.metaSpkrAge, speakerAge);
encodedRecording.put(RecordingMetadataLig.metaSpkrBirthYr, speakerBirthYear);
encodedRecording.put(RecordingMetadataLig.metaSpkrGender, speakerGender);
encodedRecording.put(RecordingMetadataLig.metaRecordLang, this.recordLang.getCode());
encodedRecording.put(RecordingMetadataLig.metaMotherTong, this.motherTong.getCode());
......@@ -204,17 +209,23 @@ public class RecordingLig extends Recording {
File path = new File(
FileIO.getOwnerPath(), RECORDINGS);
path.mkdirs();
Log.d("recordingPath", path.toString());
return path;
}
/**
* This function gives us the RecordingPath
* @return a recording path
*/
public File getIndividualRecordingPath() {
File path;
if (this.name.contains("respeak") || this.name.contains("translate")) {
if (this.name.contains("rspk") || this.name.contains("trsl")) {
String[] dir = this.name.split("_");
path = new File(getRecordingsPath(),
dir[0] + "_" + dir[1] + "_" + dir[2] + "/");
} else { path = new File(getRecordingsPath(), this.name + "/"); }
path.mkdirs();
Log.d("destPath", path.toString());
return path;
}
......
......@@ -67,7 +67,7 @@ public class RecordActivityLig extends RecordActivity {
selectedLanguages = bundle.getParcelableArrayList(RecordingMetadataLig.metaLanguages);
regionOrigin = bundle.getString(RecordingMetadataLig.metaOrigin);
speakerName = bundle.getString(RecordingMetadataLig.metaSpkrName);
speakerAge = bundle.getInt(RecordingMetadataLig.metaSpkrAge, 0);
speakerAge = bundle.getInt(RecordingMetadataLig.metaSpkrBirthYr, 0);
speakerGender = bundle.getInt(RecordingMetadataLig.metaSpkrGender, 0);
DateFormat dateformat = DateFormat.getDateTimeInstance();
try {
......
......@@ -74,7 +74,7 @@ public class RecordElicitation extends AikumaActivity {
selectedLanguages = bundle.getParcelableArrayList(RecordingMetadataLig.metaLanguages);
regionOrigin = bundle.getString(RecordingMetadataLig.metaOrigin);
speakerName = bundle.getString(RecordingMetadataLig.metaSpkrName);
speakerAge = bundle.getInt(RecordingMetadataLig.metaSpkrAge, 0);
speakerAge = bundle.getInt(RecordingMetadataLig.metaSpkrBirthYr, 0);
speakerGender = bundle.getInt(RecordingMetadataLig.metaSpkrGender, 0);
try {
date = new SimpleDateFormat().parse(bundle.getString(RecordingMetadataLig.metaDate));
......
......@@ -71,11 +71,21 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
public static final String metaMotherTong = "mother_tongue";
public static final String metaOrigin = "origin";
public static final String metaSpkrName = "speaker_name";
public static final String metaSpkrAge = "speaker_age";
public static final String metaSpkrBirthYr = "speaker_birth_year";
public static final String metaSpkrGender = "speaker_gender";
public static final String metaDate = "date";
public static final String metaBundle = "metadataBundle";
/**
* the minimal speaker age
*/
public static final int AGE_MIN = 3;
/**
* the maximal speaker age
*/
public static final int AGE_MAX = 130;
private boolean respeak = false;
private boolean elicitation = false;
private UUID importWavUUID;
......@@ -402,9 +412,10 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
if (!age.isEmpty()) {
speakerAge = Integer.parseInt(age);
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
if (speakerAge < 1880 || speakerAge > currentYear - 3) {
msgError = "Input birth year is implausible... interval [1880 -> " +
Integer.toString(currentYear-3) + "]";
if (speakerAge < currentYear - RecordingMetadataLig.AGE_MAX ||
speakerAge > currentYear - RecordingMetadataLig.AGE_MIN) {
msgError = "Input birth year is implausible... interval [" + Integer.toString(currentYear - RecordingMetadataLig.AGE_MAX) +
" -> " + Integer.toString(currentYear-RecordingMetadataLig.AGE_MIN) + "]";
new AlertDialog.Builder(this)
.setMessage(msgError)
.setPositiveButton("Ok", null)
......@@ -488,7 +499,7 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
metadataBundle.putParcelableArrayList(metaLanguages, selectedLanguages);
metadataBundle.putString(metaOrigin, regionOrigin);
metadataBundle.putString(metaSpkrName, speakerName);
metadataBundle.putInt(metaSpkrAge, speakerAge);
metadataBundle.putInt(metaSpkrBirthYr, speakerAge);
metadataBundle.putInt(metaSpkrGender, speakerGender);
metadataBundle.putString(RecordingMetadataLig.metaDate, metaDate);
intent = new Intent(RecordingMetadataLig.this, RecordActivityLig.class);
......@@ -503,7 +514,7 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
metadataBundle.putParcelableArrayList(metaLanguages, selectedLanguages);
metadataBundle.putString(metaOrigin, regionOrigin);
metadataBundle.putString(metaSpkrName, speakerName);
metadataBundle.putInt(metaSpkrAge, speakerAge);
metadataBundle.putInt(metaSpkrBirthYr, speakerAge);
metadataBundle.putInt(metaSpkrGender, speakerGender);
metadataBundle.putString(RecordingMetadataLig.metaDate, metaDate);
intent.putExtra(metaBundle, metadataBundle);
......
......@@ -108,7 +108,7 @@ public class RespeakingMetadataLig extends AikumaActivity implements OnClickList
tv.setText((String)metaJSON.get(RecordingMetadataLig.metaSpkrName));
tv = (TextView) findViewById(R.id.record_edit_spkr_age);
// Integer age = (Integer)metaJSON.get(RecordingMetadataLig.metaSpkrAge);
tv.setText(Long.toString((Long)metaJSON.get(RecordingMetadataLig.metaSpkrAge)));
tv.setText(Long.toString((Long)metaJSON.get(RecordingMetadataLig.metaSpkrBirthYr)));
tv = (TextView) findViewById(R.id.record_edit_spkr_gender);
tv.setText((String)metaJSON.get(RecordingMetadataLig.metaSpkrGender));
tv = (TextView) findViewById(R.id.record_edit_spkr_region_orig);
......@@ -246,7 +246,7 @@ public class RespeakingMetadataLig extends AikumaActivity implements OnClickList
//speakerAge = new Integer(age);
speakerAge = Integer.parseInt(age);
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
if (speakerAge < 1880 || speakerAge > currentYear - 3) {
if (speakerAge < RecordingMetadataLig.AGE_MAX || speakerAge > currentYear - RecordingMetadataLig.AGE_MIN) {
msgError = "Input birth year is implausible... interval [1880 -> " +
Integer.toString(currentYear-3) + "]";
new AlertDialog.Builder(this)
......@@ -319,7 +319,7 @@ public class RespeakingMetadataLig extends AikumaActivity implements OnClickList
metadataBundle.putParcelableArrayList(RecordingMetadataLig.metaLanguages, languages);
metadataBundle.putString(RecordingMetadataLig.metaOrigin, regionOrigin);
metadataBundle.putString(RecordingMetadataLig.metaSpkrName, speakerName);
metadataBundle.putInt(RecordingMetadataLig.metaSpkrAge, speakerAge);
metadataBundle.putInt(RecordingMetadataLig.metaSpkrBirthYr, speakerAge);
metadataBundle.putString(RecordingMetadataLig.metaSpkrGender, speakerGender);
Intent intent = new Intent(RespeakingMetadataLig.this, ThumbRespeakActivityLig.class);
......
......@@ -133,7 +133,7 @@ public class ThumbRespeakActivityLig extends AikumaActivity {
ArrayList<Language> rspkLanguages = respeakingBundle.getParcelableArrayList(RecordingMetadataLig.metaLanguages);
String regionOrigin = respeakingBundle.getString(RecordingMetadataLig.metaOrigin);
String speakerName = respeakingBundle.getString(RecordingMetadataLig.metaSpkrName);
int speakerAge = respeakingBundle.getInt(RecordingMetadataLig.metaSpkrAge);
int speakerAge = respeakingBundle.getInt(RecordingMetadataLig.metaSpkrBirthYr);
String mode = translateMode ? "_trsl" : "_rspk";
String name = metadataIntent.getStringExtra("dirname")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment