Commit 5249e353 authored by hanriaca's avatar hanriaca

resolve conflicts between files + fix submode description in the...

resolve conflicts between files + fix submode description in the sharedPreferences used at the session interruption
parents e6cc5bf9 b2a15e7a
......@@ -136,5 +136,6 @@
<string name="currentPCMSample">currentPCMSample</string>
<string name="sampleRate">sampleRate</string>
<string name="currentLine">currentLine</string>
<string name="elicitTextFile">elicitTextFile</string>
<string name="recordDuration">duration</string>
<string name="translation">translation</string>
</resources>
......@@ -259,8 +259,8 @@ public class ModeSelection extends Activity implements OnClickListener{
else if (submode.compareToIgnoreCase("image") == 0) { submodeDialog = "image"; }
else if (submode.compareToIgnoreCase("video") == 0) { submodeDialog = "video"; }
} else if (mode.compareToIgnoreCase(ThumbRespeakActivityLig.TAG) == 0) {
if (submode.compareToIgnoreCase("respeaking") == 0) { modeDialog = "Respeaking"; }
else if (submode.compareToIgnoreCase("translation") == 0) { modeDialog = "Translation"; }
if (submode.compareToIgnoreCase(getString(R.string.respeak)) == 0) { modeDialog = "Respeaking"; }
else if (submode.compareToIgnoreCase(getString(R.string.translation)) == 0) { modeDialog = "Translation"; }
submodeDialog = "None";
}
((TextView) ll.findViewById(R.id.session_mode)).setText(modeDialog);
......@@ -276,7 +276,7 @@ public class ModeSelection extends Activity implements OnClickListener{
((TextView) ll.findViewById(R.id.session_date)).setText(prefsUserSession.getString(getString(R.string.sessionDate), "undefined"));
}
((TextView) ll.findViewById(R.id.session_progress)).setText("" + prefsUserSession.getInt(getString(R.string.sessionProgress), 0));
((TextView) ll.findViewById(R.id.session_progress)).setText("" + prefsUserSession.getString(getString(R.string.sessionProgress), "0"));
// display only filename
String file = new File(prefsUserSession.getString(getString(R.string.sessionInputFile), "undefined")).getName();
......
......@@ -259,7 +259,7 @@ public class Recorder implements AudioHandler, MicrophoneListener, Sampler {
*/
public void save() {
file.write(audioBuffer, audioBufLength);
Log.d("DDaudioBufLength", "audioBufferLength = "+audioBufLength);
totalAudioLength += audioBufLength;
Log.d("DDtotalAudioLength", "totalAudioLength = "+totalAudioLength);
if (this.type == 0 &&
......
......@@ -105,6 +105,14 @@ public class Recording extends FileModel {
setFileType(sourceVerId, languages);
}
public void setRecordingUUID(UUID recordingUUID) {
this.recordingUUID = recordingUUID;
}
/**
* The constructor used when first creating a Recording.
*
......@@ -1222,7 +1230,7 @@ public class Recording extends FileModel {
this.speakersIds.add(speaker.getId());
}
private void setDeviceName(String deviceName) {
public void setDeviceName(String deviceName) {
if (deviceName == null) {
throw new IllegalArgumentException(
"The model name cannot be null");
......@@ -1428,7 +1436,7 @@ public class Recording extends FileModel {
}
return starFiles.length;
}
/**
* Gives the number of flags this recording has received.
*
......
package org.lp20.aikuma.model;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.lp20.aikuma.Aikuma;
......@@ -121,6 +123,7 @@ public class RecordingLig extends Recording {
this.speakerGender = spkrGndr;
}
/**
* Public constructor from super class Recording
* for existing recordings
......@@ -133,6 +136,7 @@ public class RecordingLig extends Recording {
r.respeakingId, r.sampleRate, r.durationMsec, r.format, r.fileType);
}
// Moves a WAV file with a temporary UUID from a no-sync directory to
// its rightful place in the connected world of Aikuma, with a proper name
// and where it will find it's best friend - a JSON metadata file.
......@@ -204,12 +208,7 @@ public class RecordingLig extends Recording {
File metadataFile = new File(getIndividualRecordingPath(),
this.name + METADATA_SUFFIX);
FileIO.writeJSONObject(metadataFile,encodedRecording);
Log.i(TAG, "Saved metadata file to " + metadataFile.getAbsolutePath());
// FileIO.writeJSONObject(new File(
// getRecordingsPath(), getGroupId() + "/" +
// id + METADATA_SUFFIX),
// encodedRecording);
Log.i(TAG, "Saved metadata file to " + metadataFile.getAbsolutePath());
}
/**
......@@ -224,14 +223,21 @@ public class RecordingLig extends Recording {
JSONObject jsonObj = FileIO.readJSONObject(metadataFile);
RecordingLig recording = new RecordingLig(read(jsonObj));
String code = (String) jsonObj.get(RecordingMetadataLig.metaRecordLang);
recording.recordLang = code.isEmpty() ? new Language(Aikuma.getLanguageCodeMap().get(code), code) : null;
recording.recordLang = code.isEmpty() ? null : new Language(Aikuma.getLanguageCodeMap().get(code), code);
JSONArray jsonArray = (JSONArray) jsonObj.get("languages");
recording.languages = Language.decodeJSONArray(jsonArray);
code = (String) jsonObj.get(RecordingMetadataLig.metaMotherTong);
recording.motherTong = code.isEmpty() ? new Language(Aikuma.getLanguageCodeMap().get(code), code) : null;
if (code != null)
recording.motherTong = code.isEmpty() ? null : new Language(Aikuma.getLanguageCodeMap().get(code), code);
recording.regionOrigin = (String) jsonObj.get(RecordingMetadataLig.metaOrigin);
recording.speakerName = (String) jsonObj.get(RecordingMetadataLig.metaSpkrName);
long age = (Long) jsonObj.get(RecordingMetadataLig.metaSpkrBirthYr);
recording.speakerBirthYear= (int) age;
recording.speakerGender = (String) jsonObj.get(RecordingMetadataLig.metaSpkrGender);
Long i = (Long)jsonObj.get("BitsPerSample");
recording.bitsPerSample = i.intValue();
i = (Long)jsonObj.get("NumChannels");
recording.numChannels = i.intValue();
return recording;
}
......@@ -248,7 +254,8 @@ public class RecordingLig extends Recording {
encodedRecording.put(RecordingMetadataLig.metaSpkrBirthYr, speakerBirthYear);
encodedRecording.put(RecordingMetadataLig.metaSpkrGender, speakerGender);
encodedRecording.put(RecordingMetadataLig.metaRecordLang, this.recordLang.getCode());
encodedRecording.put(RecordingMetadataLig.metaMotherTong, this.motherTong.getCode());
if (this.motherTong != null)
encodedRecording.put(RecordingMetadataLig.metaMotherTong, this.motherTong.getCode());
Log.i(TAG, "encoding metadata into json format");
return encodedRecording;
}
......
......@@ -422,14 +422,13 @@ public class ThumbRespeakFragment extends Fragment {
*
* @param respeaker The ThumbRespeaker to use.
*/
public void setThumbRespeaker(ThumbRespeaker respeaker, Boolean isNotNewSession) {
public void setThumbRespeaker(ThumbRespeaker respeaker, Boolean newSession) {
this.respeaker = respeaker;
Log.d("respeaker", "currentDuration : " + respeaker.getCurrentMsec());
Log.d("MapperSize : ", "tmp=> setUpThumbRespeaker from FRAG-> mapper size : " + getRespeaker().getMapper().getSegments().getSegmentMap().size());
respeaker.getSimplePlayer().setOnCompletionListener(onCompletionListener);
updateDurationTextView();
if (isNotNewSession) {
Log.d("update evolution", "update evolution");
if (!newSession) {
updateEvolution();
}
}
......
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