Commit 00cc5c41 authored by mistermad's avatar mistermad

- Add waveform visualization of the original audio file in the Elicitation and Traslating mode

parent 6e7e27b7
...@@ -53,4 +53,5 @@ dependencies { ...@@ -53,4 +53,5 @@ dependencies {
compile 'com.android.support:multidex:1.0.1' compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
compile 'javax.annotation:javax.annotation-api:1.2' compile 'javax.annotation:javax.annotation-api:1.2'
compile project(path: ':library')
} }
...@@ -53,30 +53,31 @@ public class ModeSelection extends Activity implements OnClickListener{ ...@@ -53,30 +53,31 @@ public class ModeSelection extends Activity implements OnClickListener{
/** Called when the activity is first created. */ /** Called when the activity is first created. */
@Override @Override
@SuppressLint("CommitPrefEdits")
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.mode_selection); setContentView(R.layout.mode_selection);
// set owner id with gmail account first but replaced with a random id now // set owner id with gmail account first but replaced with a random id now
SharedPreferences settings = SharedPreferences settings =
PreferenceManager.getDefaultSharedPreferences(this); PreferenceManager.getDefaultSharedPreferences(this);
//AikumaSettings.setUserId(settings.getString(AikumaSettings.SETTING_OWNER_ID_KEY, null)); //AikumaSettings.setUserId(settings.getString(AikumaSettings.SETTING_OWNER_ID_KEY, null));
if(AikumaSettings.getCurrentUserId() == null) { if(AikumaSettings.getCurrentUserId() == null) {
Random r = new Random(); Random r = new Random();
AikumaSettings.setUserId(Integer.toString(r.nextInt())); AikumaSettings.setUserId(Integer.toString(r.nextInt()));
if(BuildConfig.DEBUG)Log.i(TAG, AikumaSettings.getCurrentUserId()); if(BuildConfig.DEBUG)Log.i(TAG, AikumaSettings.getCurrentUserId());
} }
// DEBUG // DEBUG
Map<String,?> mapPrefs = settings.getAll(); Map<String,?> mapPrefs = settings.getAll();
for(String key : mapPrefs.keySet()) for(String key : mapPrefs.keySet())
if(BuildConfig.DEBUG)Log.i(TAG, "DEBUG - Shared Preferences - " + key + " -> " + mapPrefs.get(key)); if(BuildConfig.DEBUG)Log.i(TAG, "DEBUG - Shared Preferences - " + key + " -> " + mapPrefs.get(key));
// hides the action bar instead of removing it // hides the action bar instead of removing it
// getActionBar().hide(); // getActionBar().hide();
Aikuma.loadLanguages(this.getApplicationContext()); Aikuma.loadLanguages(this.getApplicationContext());
Button btn_rec = (Button) findViewById(R.id.button_mode_record); Button btn_rec = (Button) findViewById(R.id.button_mode_record);
btn_rec.setOnClickListener(this); btn_rec.setOnClickListener(this);
Button btn_respk = (Button) findViewById(R.id.button_mode_respeak); Button btn_respk = (Button) findViewById(R.id.button_mode_respeak);
...@@ -89,15 +90,15 @@ public class ModeSelection extends Activity implements OnClickListener{ ...@@ -89,15 +90,15 @@ public class ModeSelection extends Activity implements OnClickListener{
btn_check.setOnClickListener(this); btn_check.setOnClickListener(this);
// Button btn_old_aikuma = (Button) findViewById(R.id.button_mode_slct_old_aikuma); // Button btn_old_aikuma = (Button) findViewById(R.id.button_mode_slct_old_aikuma);
// btn_old_aikuma.setOnClickListener(this); // btn_old_aikuma.setOnClickListener(this);
// Start gathering location data // Start gathering location data
MainActivity.locationDetector = new LocationDetector(this); MainActivity.locationDetector = new LocationDetector(this);
// check the existing session and show popup to propose retrieving it // check the existing session and show popup to propose retrieving it
prefsUserSession = getSharedPreferences(getString(R.string.userSession), MODE_PRIVATE); prefsUserSession = getSharedPreferences("userSession", MODE_PRIVATE);
ed = prefsUserSession.edit(); ed = prefsUserSession.edit();
if(prefsUserSession.getBoolean(getString(R.string.sessionActive), false)) if(prefsUserSession.getBoolean("active", false))
showSessionDialog(); showSessionDialog();
} }
@Override @Override
...@@ -105,7 +106,7 @@ public class ModeSelection extends Activity implements OnClickListener{ ...@@ -105,7 +106,7 @@ public class ModeSelection extends Activity implements OnClickListener{
switch (v.getId()) { switch (v.getId()) {
// DONE add a button for respeaking and link to the corresponding activity // DONE add a button for respeaking and link to the corresponding activity
// DONE create a selection view with 2 buttons: one for recording and one for importing audio // DONE create a selection view with 2 buttons: one for recording and one for importing audio
// DONE link the "recording" button to existing recording structure // DONE link the "recording" button to existing recording structure
// (link to recordingMetadataLig activity and allow RecordActivityLig to link to Respeaking) // (link to recordingMetadataLig activity and allow RecordActivityLig to link to Respeaking)
// DONE study how resepaking is done and reuse it (only the respeaking view and its process) // DONE study how resepaking is done and reuse it (only the respeaking view and its process)
// (in particular, beware to check the storage location of the respeaking and mapping files) // (in particular, beware to check the storage location of the respeaking and mapping files)
...@@ -189,10 +190,9 @@ public class ModeSelection extends Activity implements OnClickListener{ ...@@ -189,10 +190,9 @@ public class ModeSelection extends Activity implements OnClickListener{
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
if(BuildConfig.DEBUG)Log.i(TAG,"no don't retrieve the session but keep files"); if(BuildConfig.DEBUG)Log.i(TAG,"no don't retrieve the session but keep files");
prefsUserSession = getSharedPreferences(getString(R.string.userSession), MODE_PRIVATE); prefsUserSession = getSharedPreferences("userSession", MODE_PRIVATE);
//clear sharedPrefs //clear sharedPrefs
ed.clear(); ed.clear().commit();
ed.commit();
} }
}) })
.setNeutralButton(R.string.no_and_erase_files, new DialogInterface.OnClickListener() { .setNeutralButton(R.string.no_and_erase_files, new DialogInterface.OnClickListener() {
...@@ -203,31 +203,27 @@ public class ModeSelection extends Activity implements OnClickListener{ ...@@ -203,31 +203,27 @@ public class ModeSelection extends Activity implements OnClickListener{
//remove files //remove files
eraseFiles(); eraseFiles();
//clear sharedPrefs //clear sharedPrefs
ed.clear();
// ed.putBoolean(getString(R.string.sessionActive), false); // ed.putBoolean(getString(R.string.sessionActive), false);
ed.commit(); ed.clear().commit();
} }
}); });
return builder.create(); return builder.create();
} }
public void retrieveSession() { public void retrieveSession() {
String mode = prefsUserSession.getString(getString(R.string.sessionMode), null); String mode = prefsUserSession.getString("mode", null);
if(BuildConfig.DEBUG)Log.d(TAG, "mode retrieval: "+mode); if(BuildConfig.DEBUG)Log.d(TAG, "mode retrieval: "+mode);
Intent intent; if(((mode != null)?mode.compareToIgnoreCase(CheckTranscription.TAG):0) == 0)
if (mode.compareToIgnoreCase(CheckTranscription.TAG) == 0) { startActivity(new Intent(getActivity(), CheckTranscription.class));
intent = new Intent(getActivity(), CheckTranscription.class); else if (mode.compareToIgnoreCase(CheckWordVariant.TAG) == 0)
} else if (mode.compareToIgnoreCase(CheckWordVariant.TAG) == 0) { startActivity(new Intent(getActivity(), CheckWordVariant.class));
intent = new Intent(getActivity(), CheckWordVariant.class); else if (mode.compareToIgnoreCase(ThumbRespeakActivityLig.TAG) == 0)
} else if (mode.compareToIgnoreCase(ThumbRespeakActivityLig.TAG) == 0) { startActivity(new Intent(getActivity(), ThumbRespeakActivityLig.class));
intent = new Intent(getActivity(), ThumbRespeakActivityLig.class); else if (mode.compareToIgnoreCase(RecordElicitation.TAG) == 0)
} else if (mode.compareToIgnoreCase(RecordElicitation.TAG) == 0) { startActivity(new Intent(getActivity(), RecordElicitation.class));
intent = new Intent(getActivity(), RecordElicitation.class); else
} else {
Toast.makeText(getActivity(), "An error ocurred. The session could not be retrieved", Toast.LENGTH_LONG).show(); Toast.makeText(getActivity(), "An error ocurred. The session could not be retrieved", Toast.LENGTH_LONG).show();
return;
}
startActivity(intent);
} }
public void setDialogDetails(LinearLayout ll) { public void setDialogDetails(LinearLayout ll) {
...@@ -244,20 +240,20 @@ public class ModeSelection extends Activity implements OnClickListener{ ...@@ -244,20 +240,20 @@ public class ModeSelection extends Activity implements OnClickListener{
* ThumbRespeakActivityLig / respeaking ----------> Respeaking / null * ThumbRespeakActivityLig / respeaking ----------> Respeaking / null
* "" / translation ----------> Translation / null * "" / translation ----------> Translation / null
*/ */
String mode = prefsUserSession.getString(getString(R.string.sessionMode), getString(R.string.undefined)); String mode = prefsUserSession.getString("mode", "undefined");
String submode = prefsUserSession.getString(getString(R.string.session_submode), getString(R.string.undefined)); String submode = prefsUserSession.getString("submode", "undefined");
String modeDialog = null, submodeDialog = null; String modeDialog = null, submodeDialog = null;
if (mode.compareToIgnoreCase(CheckWordVariant.TAG) == 0 || mode.compareTo(CheckTranscription.TAG) == 0) { if (mode.compareToIgnoreCase(CheckWordVariant.TAG) == 0 || mode.compareTo(CheckTranscription.TAG) == 0) {
modeDialog = getString(R.string.check_mode); modeDialog = getString(R.string.check_mode);
submodeDialog = (mode.compareToIgnoreCase(CheckWordVariant.TAG) == 0) ? CheckWordVariant.TAG : CheckTranscription.TAG; submodeDialog = (mode.compareToIgnoreCase(CheckWordVariant.TAG) == 0) ? CheckWordVariant.TAG : CheckTranscription.TAG;
} else if (mode.compareToIgnoreCase(RecordElicitation.TAG) == 0) { } else if (mode.compareToIgnoreCase(RecordElicitation.TAG) == 0) {
modeDialog = getString(R.string.elicitation); modeDialog = getString(R.string.elicitation);
if (submode.compareToIgnoreCase("text") == 0) { submodeDialog = "text"; } if (submode.compareToIgnoreCase("text") == 0) submodeDialog = "text";
else if (submode.compareToIgnoreCase("image") == 0) { submodeDialog = "image"; } else if (submode.compareToIgnoreCase("image") == 0) submodeDialog = "image";
else if (submode.compareToIgnoreCase("video") == 0) { submodeDialog = "video"; } else if (submode.compareToIgnoreCase("video") == 0) submodeDialog = "video";
} else if (mode.compareToIgnoreCase(ThumbRespeakActivityLig.TAG) == 0) { } else if (mode.compareToIgnoreCase(ThumbRespeakActivityLig.TAG) == 0) {
if (submode.compareToIgnoreCase(getString(R.string.respeak)) == 0) { modeDialog = "Respeaking"; } if (submode.compareToIgnoreCase(getString(R.string.respeak)) == 0) modeDialog = "Respeaking";
else if (submode.compareToIgnoreCase(getString(R.string.translation)) == 0) { modeDialog = "Translation"; } else if (submode.compareToIgnoreCase(getString(R.string.translation)) == 0) modeDialog = "Translation";
submodeDialog = "None"; submodeDialog = "None";
} }
((TextView) ll.findViewById(R.id.session_mode)).setText(modeDialog); ((TextView) ll.findViewById(R.id.session_mode)).setText(modeDialog);
...@@ -265,32 +261,32 @@ public class ModeSelection extends Activity implements OnClickListener{ ...@@ -265,32 +261,32 @@ public class ModeSelection extends Activity implements OnClickListener{
// display date in a more convenient way // display date in a more convenient way
try { try {
Date date = new SimpleDateFormat().parse(prefsUserSession.getString(getString(R.string.sessionDate), "undefined")); Date date = new SimpleDateFormat().parse(prefsUserSession.getString("date", "undefined"));
// TODO parsing fails... // TODO parsing fails...
((TextView) ll.findViewById(R.id.session_date)).setText(new SimpleDateFormat("dd/MM/yyyy at HH:mm",Locale.FRANCE).format(date)); ((TextView) ll.findViewById(R.id.session_date)).setText(new SimpleDateFormat("dd/MM/yyyy at HH:mm",Locale.FRANCE).format(date));
} catch (ParseException e) { } catch (ParseException e) {
if(BuildConfig.DEBUG)Log.e(TAG, ""+e); if(BuildConfig.DEBUG)Log.e(TAG, ""+e);
((TextView) ll.findViewById(R.id.session_date)).setText(prefsUserSession.getString(getString(R.string.sessionDate), "undefined")); ((TextView) ll.findViewById(R.id.session_date)).setText(prefsUserSession.getString("date", "undefined"));
} }
((TextView) ll.findViewById(R.id.session_progress)).setText("" + prefsUserSession.getString(getString(R.string.sessionProgress), "0")); ((TextView) ll.findViewById(R.id.session_progress)).setText("" + prefsUserSession.getString("progress", "0"));
// display only filename // display only filename
String file = new File(prefsUserSession.getString(getString(R.string.sessionInputFile), "undefined")).getName(); String file = new File(prefsUserSession.getString("inputFile", "undefined")).getName();
((TextView) ll.findViewById(R.id.session_input_file)).setText(file); ((TextView) ll.findViewById(R.id.session_input_file)).setText(file);
} }
} }
public void eraseFiles() { public void eraseFiles() {
File savedFile; File savedFile;
String savedMode = prefsUserSession.getString(getString(R.string.sessionMode), null); String savedMode = prefsUserSession.getString("mode", null);
String savedSubmode = prefsUserSession.getString(getString(R.string.session_submode), "undefined"); String savedSubmode = prefsUserSession.getString("submode", "undefined");
if(BuildConfig.DEBUG)Log.d(TAG, "saved mode: "+savedMode); if(BuildConfig.DEBUG)Log.d(TAG, "saved mode: "+savedMode);
if(BuildConfig.DEBUG)Log.d(TAG, "saved submode: "+savedSubmode); if(BuildConfig.DEBUG)Log.d(TAG, "saved submode: "+savedSubmode);
/*Check Mode*/ /*Check Mode*/
if (savedMode.compareToIgnoreCase(CheckWordVariant.TAG) == 0 || savedMode.compareTo(CheckTranscription.TAG) == 0) { if (savedMode.compareToIgnoreCase(CheckWordVariant.TAG) == 0 || savedMode.compareTo(CheckTranscription.TAG) == 0) {
savedFile = new File(prefsUserSession.getString(getString(R.string.sessionCheckExportFile),"undefined")); savedFile = new File(prefsUserSession.getString("checkExportFile","undefined"));
if(BuildConfig.DEBUG)Log.d(TAG, "saved file: "+savedFile); if(BuildConfig.DEBUG)Log.d(TAG, "saved file: "+savedFile);
savedFile.delete(); savedFile.delete();
if(BuildConfig.DEBUG)Log.i(TAG, "saved file erased: "+savedFile); if(BuildConfig.DEBUG)Log.i(TAG, "saved file erased: "+savedFile);
...@@ -299,9 +295,9 @@ public class ModeSelection extends Activity implements OnClickListener{ ...@@ -299,9 +295,9 @@ public class ModeSelection extends Activity implements OnClickListener{
} else if (savedMode.compareToIgnoreCase(RecordElicitation.TAG) == 0) { } else if (savedMode.compareToIgnoreCase(RecordElicitation.TAG) == 0) {
if(BuildConfig.DEBUG)Log.d(TAG, "saved submode: "+savedSubmode); if(BuildConfig.DEBUG)Log.d(TAG, "saved submode: "+savedSubmode);
String idDevice = Aikuma.getDeviceId(); String idDevice = Aikuma.getDeviceId();
String savedDate = prefsUserSession.getString(getString(R.string.sessionDate), ""); String savedDate = prefsUserSession.getString("date", "");
Language savedRecordLang = new Language(prefsUserSession.getString(getString(R.string.language_name), ""), Language savedRecordLang = new Language(prefsUserSession.getString("Language name", ""),
prefsUserSession.getString(getString(R.string.languageCode), "")); prefsUserSession.getString("LanguageCode", ""));
String name = savedDate + "_" + String name = savedDate + "_" +
savedRecordLang.getCode() + "_" + idDevice; savedRecordLang.getCode() + "_" + idDevice;
//erase linker //erase linker
...@@ -310,7 +306,7 @@ public class ModeSelection extends Activity implements OnClickListener{ ...@@ -310,7 +306,7 @@ public class ModeSelection extends Activity implements OnClickListener{
savedTextFile.delete(); savedTextFile.delete();
if(BuildConfig.DEBUG)Log.i(TAG, "saved file erased: "+savedTextFile); if(BuildConfig.DEBUG)Log.i(TAG, "saved file erased: "+savedTextFile);
//erase metadata and audio files //erase metadata and audio files
int savedProgress = prefsUserSession.getInt(getString(R.string.currentLine), 0); int savedProgress = prefsUserSession.getInt("currentLine", 0);
if(BuildConfig.DEBUG)Log.d(TAG, "saved progress: "+savedProgress); if(BuildConfig.DEBUG)Log.d(TAG, "saved progress: "+savedProgress);
for (int i=savedProgress; i>=0; i--) { for (int i=savedProgress; i>=0; i--) {
File savedMetadataFile = new File(FileIO.getOwnerPath()+"/recordings/"+name + "/" + name + "_" + i + RecordingLig.METADATA_SUFFIX); File savedMetadataFile = new File(FileIO.getOwnerPath()+"/recordings/"+name + "/" + name + "_" + i + RecordingLig.METADATA_SUFFIX);
...@@ -347,7 +343,7 @@ public class ModeSelection extends Activity implements OnClickListener{ ...@@ -347,7 +343,7 @@ public class ModeSelection extends Activity implements OnClickListener{
// } // }
//} //}
Toast.makeText(this, "Session and files erased.", Toast.LENGTH_LONG).show(); Toast.makeText(this, R.string.session_and_files_erased, Toast.LENGTH_LONG).show();
} }
} }
...@@ -8,6 +8,8 @@ import android.media.AudioManager; ...@@ -8,6 +8,8 @@ import android.media.AudioManager;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.util.Log; import android.util.Log;
import com.semantive.waveformandroid.waveform.MediaPlayerFactory;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.BuildConfig; import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.BuildConfig;
import org.getalp.ligaikuma.lig_aikuma.model.Recording; import org.getalp.ligaikuma.lig_aikuma.model.Recording;
...@@ -39,7 +41,7 @@ public class SimplePlayer extends Player implements Sampler ...@@ -39,7 +41,7 @@ public class SimplePlayer extends Player implements Sampler
*/ */
public SimplePlayer(Recording recording, boolean playThroughSpeaker) throws IOException { public SimplePlayer(Recording recording, boolean playThroughSpeaker) throws IOException {
setRecording(recording); setRecording(recording);
mediaPlayer = new MediaPlayer(); mediaPlayer = MediaPlayerFactory.getNewMediaPlayer();
mediaPlayer.setAudioStreamType((playThroughSpeaker)?AudioManager.STREAM_MUSIC:AudioManager.STREAM_VOICE_CALL); mediaPlayer.setAudioStreamType((playThroughSpeaker)?AudioManager.STREAM_MUSIC:AudioManager.STREAM_VOICE_CALL);
if(BuildConfig.DEBUG)Log.i("SimplePlayer", "Media Player - data source: " + recording.getFile().getCanonicalPath()); if(BuildConfig.DEBUG)Log.i("SimplePlayer", "Media Player - data source: " + recording.getFile().getCanonicalPath());
mediaPlayer.setDataSource(recording.getFile().getCanonicalPath()); mediaPlayer.setDataSource(recording.getFile().getCanonicalPath());
...@@ -190,7 +192,7 @@ public class SimplePlayer extends Player implements Sampler ...@@ -190,7 +192,7 @@ public class SimplePlayer extends Player implements Sampler
//Never use //Never use
//protected void setFinishedPlaying(boolean finished) {this.finishedPlaying = finished;} //protected void setFinishedPlaying(boolean finished) {this.finishedPlaying = finished;}
protected Recording getRecording() { public Recording getRecording() {
return recording; return recording;
} }
......
...@@ -151,17 +151,15 @@ public class Microphone { ...@@ -151,17 +151,15 @@ public class Microphone {
private static AudioRecord getListener( private static AudioRecord getListener(
int sampleRate, int audioFormat, int channelConfig) { int sampleRate, int audioFormat, int channelConfig) {
// Sample size. // Sample size and Channels.
int sampleSize = (audioFormat == AudioFormat.ENCODING_PCM_16BIT)? 16: 8; int sampleSize = (audioFormat == AudioFormat.ENCODING_PCM_16BIT)? 16: 8,
numberOfChannels = (channelConfig == AudioFormat.CHANNEL_IN_MONO)? 1: 2,
// Channels.
int numberOfChannels = (channelConfig == AudioFormat.CHANNEL_IN_MONO)? 1: 2;
// Calculate buffer size. // Calculate buffer size.
/** The period used for callbacks to onBufferFull. */ /** The period used for callbacks to onBufferFull. */
int framePeriod = sampleRate * 120 / 1000; framePeriod = sampleRate * 120 / 1000,
/** The buffer needed for the above period */ /** The buffer needed for the above period */
int bufferSize = framePeriod * 2 * sampleSize * numberOfChannels / 8; bufferSize = framePeriod * 2 * sampleSize * numberOfChannels / 8;
return new AudioRecord(MediaRecorder.AudioSource.MIC, return new AudioRecord(MediaRecorder.AudioSource.MIC,
sampleRate, AudioFormat.CHANNEL_IN_MONO, sampleRate, AudioFormat.CHANNEL_IN_MONO,
......
...@@ -274,8 +274,7 @@ public class Recorder implements AudioHandler, MicrophoneListener, Sampler { ...@@ -274,8 +274,7 @@ public class Recorder implements AudioHandler, MicrophoneListener, Sampler {
// Append all audio-values in srcBuffer to audioBuffer // Append all audio-values in srcBuffer to audioBuffer
private void storeBuffer(short[] srcBuffer) { private void storeBuffer(short[] srcBuffer) {
if(audioBuffer.length < audioBufLength + srcBuffer.length) { if(audioBuffer.length < audioBufLength + srcBuffer.length) {
int newBufLength = 2 * audioBuffer.length; short[] newBuffer = new short[(2 * audioBuffer.length)];
short[] newBuffer = new short[newBufLength];
System.arraycopy(audioBuffer, 0, newBuffer, 0, audioBufLength); System.arraycopy(audioBuffer, 0, newBuffer, 0, audioBufLength);
audioBuffer = newBuffer; audioBuffer = newBuffer;
} }
...@@ -303,9 +302,7 @@ public class Recorder implements AudioHandler, MicrophoneListener, Sampler { ...@@ -303,9 +302,7 @@ public class Recorder implements AudioHandler, MicrophoneListener, Sampler {
totalAudioLength += buffer.length; totalAudioLength += buffer.length;
if (this.type == 0 && if (this.type == 0 &&
Math.round((double) totalAudioLength / sampleRate) < Recording.SAMPLE_SEC) // 15sec sample Math.round((double) totalAudioLength / sampleRate) < Recording.SAMPLE_SEC) // 15sec sample
{
sampleFile.write(buffer); sampleFile.write(buffer);
}
} }
......
...@@ -41,8 +41,7 @@ public class ThumbRespeaker { ...@@ -41,8 +41,7 @@ public class ThumbRespeaker {
public ThumbRespeaker(Recording original, UUID respeakingUUID, public ThumbRespeaker(Recording original, UUID respeakingUUID,
int rewindAmount) throws Microphone.MicException, IOException { int rewindAmount) throws Microphone.MicException, IOException {
if(BuildConfig.DEBUG)Log.d("Rte-ThumbRespeaker", "smp : " + original.getSampleRate()); if(BuildConfig.DEBUG)Log.d("Rte-ThumbRespeaker", "smp : " + original.getSampleRate());
recorder = new Recorder(1, new File(Recording.getNoSyncRecordingsPath(), recorder = new Recorder(1, new File(Recording.getNoSyncRecordingsPath(), respeakingUUID + ".wav"), original.getSampleRate());
respeakingUUID + ".wav"), original.getSampleRate());
player = new SimplePlayer(original, true); player = new SimplePlayer(original, true);
mapper = new Mapper(respeakingUUID); mapper = new Mapper(respeakingUUID);
setFinishedPlaying(false); setFinishedPlaying(false);
...@@ -60,10 +59,9 @@ public class ThumbRespeaker { ...@@ -60,10 +59,9 @@ public class ThumbRespeaker {
* @throws MicException If the microphone couldn't be used. * @throws MicException If the microphone couldn't be used.
* @throws IOException If there is an I/O issue. * @throws IOException If there is an I/O issue.
*/ */
public ThumbRespeaker(RecordingLig original, UUID respeakingUUID, public ThumbRespeaker(RecordingLig original, UUID respeakingUUID, int rewindAmount)
int rewindAmount) throws MicException, IOException { throws MicException, IOException {
recorder = new Recorder(1, new File(Recording.getNoSyncRecordingsPath(), recorder = new Recorder(1, new File(Recording.getNoSyncRecordingsPath(), respeakingUUID + ".wav"), original.getSampleRate());
respeakingUUID + ".wav"), original.getSampleRate());
player = new SimplePlayer(original, true); player = new SimplePlayer(original, true);
mapper = new Mapper(respeakingUUID); mapper = new Mapper(respeakingUUID);
setFinishedPlaying(false); setFinishedPlaying(false);
......
...@@ -1410,8 +1410,8 @@ public class Recording extends FileModel { ...@@ -1410,8 +1410,8 @@ public class Recording extends FileModel {
*/ */
/* /*
public static void enableSync(String id) throws IOException { public static void enableSync(String id) throws IOException {
File wavFile = new File(getNoSyncRecordingsPath(), uuid + ".wav"); File WavFile = new File(getNoSyncRecordingsPath(), uuid + ".wav");
FileUtils.moveFileToDirectory(wavFile, getRecordingsPath(), false); FileUtils.moveFileToDirectory(WavFile, getRecordingsPath(), false);
} }
*/ */
......
...@@ -66,33 +66,31 @@ public class CheckTranscription extends AikumaActivity { ...@@ -66,33 +66,31 @@ public class CheckTranscription extends AikumaActivity {
initProgressBars(); initProgressBars();
if(BuildConfig.DEBUG)Log.d("dataPath", dataPath); if(BuildConfig.DEBUG)Log.d("dataPath", dataPath);
prefsUserSession = getSharedPreferences(getString(R.string.userSession), MODE_PRIVATE); prefsUserSession = getSharedPreferences("userSession", MODE_PRIVATE);
date = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.FRANCE).format(new Date()); date = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.FRANCE).format(new Date());
//case: session already exists //case: session already exists
boolean append; boolean append;
if (prefsUserSession.getBoolean(getString(R.string.sessionActive), false)) { if (prefsUserSession.getBoolean("active", false)) {
//retrieve selected file handled in the last session //retrieve selected file handled in the last session
transcripTextFile = prefsUserSession.getString(getString(R.string.sessionInputFile),null); transcripTextFile = prefsUserSession.getString("inputFile",null);
if(BuildConfig.DEBUG)Log.i(TAG, "Selected import file: " + transcripTextFile); if(BuildConfig.DEBUG)Log.i(TAG, "Selected import file: " + transcripTextFile);
//retrieve result file handled in the last session //retrieve result file handled in the last session
transcriptChecked = prefsUserSession.getString(getString(R.string.sessionCheckExportFile),null); transcriptChecked = prefsUserSession.getString("checkExportFile",null);
if(BuildConfig.DEBUG)Log.i(TAG, "Selected export file: " + transcriptChecked); if(BuildConfig.DEBUG)Log.i(TAG, "Selected export file: " + transcriptChecked);
//retrieve number of lines already handled in the last session //retrieve number of lines already handled in the last session
//nbReadLines = Integer.parseInt(prefsUserSession.getString(getString(R.string.sessionProgress),"0")); //nbReadLines = Integer.parseInt(prefsUserSession.getString(getString(R.string.sessionProgress),"0"));
nbReadLines = prefsUserSession.getInt(getString(R.string.currentLine), 0); nbReadLines = prefsUserSession.getInt("currentLine", 0);
if(BuildConfig.DEBUG)Log.i(TAG, "onCreate - #sentences treated: " + nbReadLines); if(BuildConfig.DEBUG)Log.i(TAG, "onCreate - #sentences treated: " + nbReadLines);
append = true; append = true;
// clear the current stored session // clear the current stored session
SharedPreferences.Editor ed = prefsUserSession.edit(); prefsUserSession.edit().clear().apply();
ed.clear();
ed.commit();
isNewSession = false; isNewSession = false;
if(BuildConfig.DEBUG)Log.i(TAG, "Is it a new session ? "+isNewSession); if(BuildConfig.DEBUG)Log.i(TAG, "Is it a new session ? "+ false);
//case: no session //case: no session
} else { } else {
transcripTextFile = getIntent().getStringExtra(CheckMode.importFileName); transcripTextFile = getIntent().getStringExtra(CheckMode.importFileName);
if(BuildConfig.DEBUG)Log.i(TAG, "Is it a new session ? "+isNewSession); if(BuildConfig.DEBUG){Log.i(TAG, "Is it a new session ? "+isNewSession);
if(BuildConfig.DEBUG)Log.i(TAG, "Selected file: " + transcripTextFile); Log.i(TAG, "Selected file: " + transcripTextFile);}
append = false; append = false;
//output filename //output filename
transcriptChecked = transcripTextFile.replace(".txt", "_"+date+"_CHECKED.txt"); transcriptChecked = transcripTextFile.replace(".txt", "_"+date+"_CHECKED.txt");
...@@ -307,13 +305,13 @@ public class CheckTranscription extends AikumaActivity { ...@@ -307,13 +305,13 @@ public class CheckTranscription extends AikumaActivity {
*/ */
date = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.FRANCE).format(new Date()); date = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.FRANCE).format(new Date());
SharedPreferences.Editor ed = prefsUserSession.edit(); SharedPreferences.Editor ed = prefsUserSession.edit();
ed.putBoolean(getString(R.string.sessionActive), true); //session activated ed.putBoolean("active", true); //session activated
ed.putInt(getString(R.string.currentLine), nbReadLines); //nb lines ed.putInt("currentLine", nbReadLines); //nb lines
ed.putString(getString(R.string.sessionProgress), nbReadLines + " / " + nb_total_lines); ed.putString("progress", nbReadLines + " / " + nb_total_lines);
ed.putString(getString(R.string.sessionInputFile), transcripTextFile); //handled file ed.putString("inputFile", transcripTextFile); //handled file
ed.putString(getString(R.string.sessionCheckExportFile), transcriptChecked); //resulting file ed.putString("checkExportFile", transcriptChecked); //resulting file
ed.putString(getString(R.string.sessionDate), date); //set date ed.putString("date", date); //set date
ed.putString(getString(R.string.sessionMode),TAG); //set mode ed.putString("mode",TAG); //set mode
// ed.putBoolean(getString(R.string.checkTranscript), true); //set submode // ed.putBoolean(getString(R.string.checkTranscript), true); //set submode
//save infos //save infos
ed.commit(); ed.commit();
...@@ -354,13 +352,12 @@ public class CheckTranscription extends AikumaActivity { ...@@ -354,13 +352,12 @@ public class CheckTranscription extends AikumaActivity {
try { try {
if(BuildConfig.DEBUG)Log.i("saveFile", "Writing on file"); if(BuildConfig.DEBUG)Log.i("saveFile", "Writing on file");
//if checked //if checked
if (transcriptOK.isChecked()) { if(transcriptOK.isChecked())
outputFile.write(transcriptID.getText()+" : "+transcriptOK.getText()+"\n"); outputFile.write(transcriptID.getText()+" : "+transcriptOK.getText()+"\n");
}
} catch (IOException e1) {e1.printStackTrace();} } catch (IOException e1) {e1.printStackTrace();}