Commit 015288c5 authored by mistermad's avatar mistermad

- Add the possibility of respeak or translate an elicited file

- Corrects a bug that prevents the translation or respeaking from translated or respeaked file
- Minor bug fix on user interface
parent b11287c3
package org.getalp.ligaikuma.lig_aikuma;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
/**
* Instrumentation test, which will execute on an Android device.
*
......@@ -19,8 +15,5 @@ public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("org.getalp.ligaikuma.lig_aikuma", appContext.getPackageName());
}
}
......@@ -86,7 +86,7 @@ public class ModeSelection extends Activity implements OnClickListener{
prefsUserSession = getSharedPreferences("userSession", MODE_PRIVATE);
ed = prefsUserSession.edit();
File f = new File(FileIO.getAppRootPath()+"/example");
File f = new File(FileIO.getAppRootPath()+"/examples");
if(!f.exists())
{
f.mkdir();
......
......@@ -2,7 +2,10 @@ package org.getalp.ligaikuma.lig_aikuma.model;
import android.util.Log;
import com.semantive.waveformandroid.waveform.MediaPlayerFactory;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.getalp.ligaikuma.lig_aikuma.Aikuma;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.BuildConfig;
import org.getalp.ligaikuma.lig_aikuma.ui.RecordingMetadataLig;
......@@ -33,11 +36,11 @@ public class RecordingLig extends Recording {
/**
* The constructor used when we create a translation or respeaking
* @param recordingUUID The temporary UUID of the recording in question.
* @param recordingUUID The temporary UUID of the recording in question.
* (recording can be wav or movie(mp4))
* @param name The recording's name
* @param date The date of creation
* @param versionName The recording's version (v0x)
* @param name The recording's name
* @param date The date of creation
* @param versionName The recording's version (v0x)
* @param ownerId The recording owner's ID(Google account)
* @param recordLang The recording record language
* @param motherTong The recording mother language
......@@ -45,27 +48,27 @@ public class RecordingLig extends Recording {
* @param speakersIds The Ids of the speakers associated with the recording
* @param deviceName The model name of the device
* @param androidID The android ID of the device that created the recording
* (androidId is unique for one device)
* (androidId is unique for one device)
* @param groupId The ID of the group of recordings this recording
* @param sourceVerId The version-ID of the source recording of this recording
* @param respeakingId The original name of the file (without extension)
* @param sampleRate The sample rate of the recording
* @param durationMsec The duration of the recording in milliseconds
* @param format The mime type
* @param format The mime type
* @param numChannels The number of channels of the audio
* @param bitsPerSample The bits per sample of the audio
* @param bitsPerSample The bits per sample of the audio
* @param latitude The location data
* @param longitude The location data
* @param region The region where the recording has been done
* @param region The region where the recording has been done
* @param spkrName The name of the speaker who did the recording
* @param spkrAge The age of the speaker who did the recording
* @param spkrAge The age of the speaker who did the recording
* @param spkrGndr The gender of the speaker who did the recording
* @param spkrNote Optionnal additionnal note
*/
public RecordingLig(UUID recordingUUID, String name, Date date,
String versionName, String ownerId, Language recordLang, Language motherTong,
List<Language> languages, List<String> speakersIds,
String deviceName, String androidID, String groupId, String sourceVerId, String respeakingId,
List<Language> languages, List<String> speakersIds, String deviceName,
String androidID, String groupId, String sourceVerId, String respeakingId,
long sampleRate, int durationMsec, String format, int numChannels,
int bitsPerSample, Double latitude, Double longitude,
String region, String spkrName, int spkrAge, String spkrGndr, String spkrNote) {
......@@ -95,6 +98,7 @@ public class RecordingLig extends Recording {
languages, speakersIds, deviceName, androidID, groupId,
sourceVerId, sampleRate, durationMsec, format, numChannels,
bitsPerSample, latitude, longitude);
Log.d(TAG, "sourceVerId(2) (respeakingId) = "+sourceVerId);
this.regionOrigin = region;
this.speakerName = spkrName;
this.speakerBirthYear = spkrAge;
......@@ -106,7 +110,6 @@ public class RecordingLig extends Recording {
: new Language("", "");
}
// Never use
public RecordingLig(UUID recordingUUID, String name, Date date,
String versionName, String ownerId,
List<Language> languages, List<String> speakersIds,
......@@ -131,7 +134,6 @@ public class RecordingLig extends Recording {
* Public constructor from super class Recording
* for existing recordings
* @param r the original recording
* @return an instance of RecordingLig
*/
public RecordingLig(Recording r) {
super(r.name, r.date, r.versionName, r.ownerId, r.sourceVerId,
......@@ -181,14 +183,12 @@ public class RecordingLig extends Recording {
dir.mkdir();
if(BuildConfig.DEBUG)Log.i(TAG, "start write - iniate directory " + dir.getAbsolutePath());
// Import the wave file into the new recording directory.
Log.d(TAG, "A1");
if(this.isMovie())
// TODO update importMov
super.importMov(recordingUUID, getId());
else
this.importWav(recordingUUID, WAV_EXT);
Log.d(TAG, "A2");
// if the recording is original
if(isOriginal() || isElicit()) {
// Import the sample wave file into the new recording directory
......@@ -204,15 +204,49 @@ public class RecordingLig extends Recording {
}
JSONObject encodedRecording = this.encode();
Log.d(TAG, "A3");
// Write the json metadata.
File metadataFile = new File(dir.toString(), this.name + METADATA_SUFFIX);
FileIO.writeJSONObject(metadataFile,encodedRecording);
Log.i(TAG, "Saved metadata file to " + metadataFile.getAbsolutePath());
Log.d(TAG, "A4");
// To respeaking elicitation file, move it at right location
moveRespeakedElicitationFile();
}
/**
* Move all files at right location when respek an elicitation file.
* Edit matadate file with right data
*/
public void moveRespeakedElicitationFile() {
if(MediaPlayerFactory._elicit_source.isEmpty()||MediaPlayerFactory._elicit_rspk.isEmpty()) return;
String source = FileIO.getOwnerPath()+"/recordings/"+ MediaPlayerFactory._elicit_rspk+"/",
dest = "/"+FilenameUtils.getPath(MediaPlayerFactory._elicit_source),
num = new File(MediaPlayerFactory._elicit_source).getName().split("_")[4].replace(".wav","");
File f = new File(source);
try {
for(String s : f.list()) {
if(s.contains(METADATA_SUFFIX)&&(s.contains("_rspk")||s.contains("_trsl")))
{
File tf = new File(source+s);
String t = FileIO.read(tf);
FileIO.delete(tf);
FileIO.write(tf,t.replaceFirst(MediaPlayerFactory._elicit_rspk,FilenameUtils.getBaseName(MediaPlayerFactory._elicit_source)));
}
if(s.contains("_rspk"))
FileUtils.moveFile(new File(source+s), new File(dest+s.replace("_rspk", "_elicit_" + num + "_rspk")));
else if(s.contains("_trsl"))
FileUtils.moveFile(new File(source + s), new File(dest + s.replace("_trsl", "_elicit_" + num + "_trsl")));
}
// Delete "temporary" files and directory
FileUtils.deleteDirectory(f);
// Clear memory of path
MediaPlayerFactory._elicit_source = "";
MediaPlayerFactory._elicit_rspk = "";
} catch (IOException ignored) {}
}
/**
......@@ -251,7 +285,6 @@ public class RecordingLig extends Recording {
*/
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.metaSpkrNote, speakerNote);
......@@ -280,7 +313,7 @@ public class RecordingLig extends Recording {
* @return True if the recording is an elicitation.
*/
public boolean isElicit() {
return this.name.contains("_elicit_") && !this.name.contains("_rspk") && !this.name.contains("_trsl");
return this.name.contains("_elicit_") && !(this.name.contains("_rspk") || this.name.contains("_trsl"));
}
......@@ -297,28 +330,25 @@ public class RecordingLig extends Recording {
*/
public File getIndividualRecordingPath() {
File path = null;
Log.d(TAG, "getIndividualRecordingPath() base path: "+this.getRespeakingId());
String[] dir = this.getRespeakingId().split("_");
if (this.name.contains("rspk") || this.name.contains("trsl")) {
if (dir.length < 4) {
if(dir.length < 4) {
if(BuildConfig.DEBUG)Log.d(TAG, "path -> "+this.getRespeakingId());
path = new File(getRecordingsPath(),
dir[0] + "_" + dir[1] + "_" + dir[2] + "/");
} else {
if (dir[3].equals("elicit")) {
if(BuildConfig.DEBUG)Log.d(TAG, "elicitation path -> "+this.getRespeakingId());
path = new File(getRecordingsPath(),
dir[0] + "_" + dir[1] + "_" + dir[2] + "_" + dir[3] + "/");
}
path = new File(getRecordingsPath(), dir[0] + "_" + dir[1] + "_" + dir[2] + "/");
} else if(dir[3].equals("elicit")) {
if(BuildConfig.DEBUG)Log.d(TAG, "elicitation path -> "+this.getRespeakingId());
path = new File(getRecordingsPath(), dir[0] + "_" + dir[1] + "_" + dir[2] + "_" + dir[3] + "/");
}
} else if (isElicit()) {
if(BuildConfig.DEBUG)Log.d(TAG, "elicitation path -> "+this.getRespeakingId());
path = new File(getRecordingsPath(),
dir[0] + "_" + dir[1] + "_" + dir[2] + "_" + dir[3] + "/");
} else
path = new File(getRecordingsPath(), dir[0] + "_" + dir[1] + "_" + dir[2] + "_" + dir[3] + "/");
} else {
if(BuildConfig.DEBUG)Log.d(TAG, "other -> "+this.name);
path = new File(getRecordingsPath(), this.name + "/");
}
path.mkdirs();
if(BuildConfig.DEBUG)Log.d(TAG, "destPath: "+path.toString());
return path;
}
}
......@@ -56,14 +56,6 @@ public class AboutActivity extends AikumaActivity {
androidId.setText("Android ID: " + Aikuma.getAndroidID());
}
// Retrievs information about the user and displays it.
private void setupUsageInfo() {
TextView usageField = (TextView) findViewById(R.id.usageField);
usageField.setText("Recording time used: " + UsageUtils.timeUsed(16000, 16) +
"\nRecording time available: " + UsageUtils.timeAvailable(16000, 16) +
"\nOriginal recordings: " + UsageUtils.numOriginals() +
"\nCommentaries: " + UsageUtils.numCommentaries());
}
private void setupCloudInfo() {
int numOfUsers, numOfSpeakers, numOfItems = 0;
......
......@@ -148,7 +148,7 @@ public class CheckTranscription extends AikumaActivity {
* tsizepx matches for tablets but is too large for phones (applyDimension to 10 is better)
* find a way to fix it for phones AND for tablets
*/
int tsizepx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 25, getResources().getDisplayMetrics());
int tsizepx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 25, getResources().getDisplayMetrics());
if((getResources().getBoolean(R.bool.is_small_screen))) tsizepx*=0.5;
if(BuildConfig.DEBUG)Log.i(TAG,"Text size in px: "+tsizepx);
//transcription + checkbox
......
......@@ -38,8 +38,6 @@ public class CheckWordVariant extends AikumaActivity {
private String variantTextFile;
private int checkboxCount;
private String variantchecked;
private boolean wordvariant;
private boolean append;
private int nbReadLines;
private String date;
private SharedPreferences prefsUserSession;
......@@ -55,7 +53,8 @@ public class CheckWordVariant extends AikumaActivity {
date = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.FRANCE).format(new Date());
prefsUserSession = getSharedPreferences("userSession", MODE_PRIVATE);
//case: session already exists
if (prefsUserSession.getBoolean("active", false)) {
boolean append;
if (prefsUserSession.getBoolean("active", false)) {
/*
* TODO rajouter une condition en &&
* soustraire date.now à date session :
......@@ -89,7 +88,7 @@ public class CheckWordVariant extends AikumaActivity {
//new buffer to write in the output file
try {
outputFile = new BufferedWriter(new FileWriter(checkedFile,append));
outputFile = new BufferedWriter(new FileWriter(checkedFile, append));
if(BuildConfig.DEBUG)Log.i("onCreate", "outputFile initialisé");
} catch (IOException e2) {
e2.printStackTrace();
......@@ -132,14 +131,14 @@ public class CheckWordVariant extends AikumaActivity {
* tsizepx matches for tablets but is too large for phones (applyDimension to 10 is better)
* find a way to fix it for phones AND for tablets
*/
int tsizepx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 25, getResources().getDisplayMetrics());
int tsizepx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 25, getResources().getDisplayMetrics());
if((getResources().getBoolean(R.bool.is_small_screen))) tsizepx*=0.5;
if(BuildConfig.DEBUG)Log.i(TAG,"Text size in px: "+tsizepx);
for (String element : variantlist){
//variant + checkbox
variant = new CheckBox(this);
variant.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
variant.setPadding(padding_in_px, 0, 0, padding_in_px);
if((getResources().getBoolean(R.bool.is_small_screen)))
variant.setTextSize(tsizepx);
//variant.setTypeface(null, Typeface.ITALIC);
variant.setTypeface(Typeface.SERIF);
......@@ -282,8 +281,8 @@ public class CheckWordVariant extends AikumaActivity {
// TODO Auto-generated catch block
e.printStackTrace();
}
wordvariant = false;
if(BuildConfig.DEBUG)Log.i(TAG, "boolean value : "+wordvariant);
boolean wordvariant = false;
if(BuildConfig.DEBUG)Log.i(TAG, "boolean value : "+ wordvariant);
//si fichier non terminé alors sauver session
try {
......
......@@ -248,7 +248,7 @@ public class ElicitationFileSearch extends AikumaActivity
ImageView icon;
}
/** Verify if folder constrain one or more file with fileTypes extension
/** Verify if folder constain one or more file with fileTypes extension
* @param f Folder with file
* @param fileTypes Array with extension to verify
* @return True if contain file with fileTypes extension, false otherwise.
......
......@@ -24,6 +24,8 @@ import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.semantive.waveformandroid.waveform.MediaPlayerFactory;
import org.getalp.ligaikuma.lig_aikuma.Aikuma;
import org.getalp.ligaikuma.lig_aikuma.MainActivity;
import org.getalp.ligaikuma.lig_aikuma.audio.SimplePlayer;
......@@ -138,6 +140,8 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
Toast.makeText(this, R.string.please_fill_in_details_about_the_speaker, Toast.LENGTH_LONG).show();
}
loadSession();
MediaPlayerFactory._elicit_source = "";
MediaPlayerFactory._elicit_rspk = "";
_wait=false;
}
......@@ -419,7 +423,7 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
Date date = new Date();
Intent intent;
if (!respeak && !elicitation) { // MODE RECORD ?
if (!respeak && !elicitation) { // MODE RECORD
// pass metadata to RecordActivityLig and start it
Bundle metadataBundle = new Bundle();
metadataBundle.putParcelable(metaRecordLang, recordLang);
......@@ -435,7 +439,7 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
intent.putExtra(metaBundle, metadataBundle);
intent.putExtra(RespeakingSelection.RESPEAK, respeak);
startActivity(intent);
} else if (!respeak) { // MODE ELICITATION ?
} else if (!respeak) { // MODE ELICITATION
intent = new Intent(RecordingMetadataLig.this, RecordElicitation.class);
int choiceMode = getIntent().getIntExtra("selectedFileType", 0);
......@@ -454,7 +458,7 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
intent.putExtra(ElicitationMode.importFileName, getIntent().getStringExtra(ElicitationMode.importFileName));
if(BuildConfig.DEBUG)Log.i(TAG, "Selected file: " + getIntent().getStringExtra(ElicitationMode.importFileName));
startActivity(intent);
} else if (!elicitation){ // MODE RESPEAKING ?
} else if (!elicitation){ // MODE RESPEAKING
String gender = "";
switch(speakerGender) {
case RecordingMetadataLig.GENDER_MALE: gender = "Male"; break;
......@@ -479,8 +483,7 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
intent.putExtra(RecordActivityLig.intent_rewindAmount, 500);
} catch (IOException e) {
Toast.makeText(RecordingMetadataLig.this,
getString(R.string.failed_to_import_the_recording) +
e.getMessage(), Toast.LENGTH_LONG).show();
getString(R.string.failed_to_import_the_recording) + e.getMessage(), Toast.LENGTH_LONG).show();
if(BuildConfig.DEBUG)Log.e(TAG, "Failed to import the recording: " + e);
intent = new Intent(RecordingMetadataLig.this, RespeakingSelection.class);
}
......
......@@ -20,6 +20,8 @@ import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.semantive.waveformandroid.waveform.MediaPlayerFactory;
import org.getalp.ligaikuma.lig_aikuma.Aikuma;
import org.getalp.ligaikuma.lig_aikuma.ModeSelection;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.BuildConfig;
......@@ -524,6 +526,7 @@ public class RespeakingMetadataLig extends AikumaActivity implements OnClickList
}
public void onBackPressed(View v) {
MediaPlayerFactory._elicit_source="";
this.finish();
}
......
......@@ -19,6 +19,7 @@ import android.widget.TextView;
import android.widget.Toast;
import com.musicg.wave.Wave;
import com.semantive.waveformandroid.waveform.MediaPlayerFactory;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.ArrayUtils;
......@@ -77,15 +78,16 @@ public class RespeakingSelection extends AikumaActivity {
{
_nav_list = new ArrayList<>();
_adapteur = new RespeakingSelection.FileAdapter(this, _nav_list);
_current_folder_position = FileIO.getAppRootPath()+"/"+RecordingLig.RECORDINGS;
_is_init = true;
_current_folder_position = Environment.getExternalStorageDirectory().toString()+"/aikuma/recordings/";
}
_path_view = (TextView) findViewById(R.id.path_view_respeak);
translateMode = getIntent().getBooleanExtra(ModeSelection.TRANSLATE_MODE, false);
if(translateMode) ((TextView) findViewById(R.id.respeaking_title)).setText(R.string.translatemode);
((ListView) findViewById(R.id.search_file_list)).setAdapter(_adapteur);
loadFileList(_current_folder_position);
_path_view.setText(_current_folder_position);
loadFileList(_current_folder_position);
}
/**
......@@ -104,12 +106,13 @@ public class RespeakingSelection extends AikumaActivity {
Toast.makeText(RespeakingSelection.this, R.string.this_file_does_not_contain_any_audio_file, Toast.LENGTH_SHORT).show();
return;
}
_current_folder_position = folder;
Log.d(TAG, "Folder: "+folder);
_current_folder_position = folder;
_path_view.setText(_current_folder_position);
_nav_list.clear();
ArrayUtils.reverse(l);
Collections.addAll(_nav_list, l);
_adapteur.notifyDataSetChanged();
_path_view.setText(_current_folder_position);
}
/** Back on parent folder, not back if parent is Environment.getExternalStorageDirectory()
......@@ -130,10 +133,18 @@ public class RespeakingSelection extends AikumaActivity {
*/
public void openFile(String file)
{
File mPath = new File(file);
if(file.contains("_elicit_")&&new File(file.replace(".wav",METADATA_SUFFIX)).exists()) // is Aikuma elicitation file?
MediaPlayerFactory._elicit_source = "";
MediaPlayerFactory._elicit_rspk = "";
if(file.contains("_elicit_")&&(file.contains("_trsl")||file.contains("_rspk")))
{
Toast.makeText(this, R.string.impossible_to_import_a_respeak_or_translated_file_from_an_elicitation_file, Toast.LENGTH_LONG).show();
return;
}
File mPath = new File(file), aikumaFile = mPath.getParentFile().getParentFile().getParentFile();
if(file.contains("_elicit_")&&!(file.contains("_trsl")||file.contains("_rspk")) &&
aikumaFile != null && aikumaFile.getAbsolutePath().contains(FileIO.getAppRootPath().toString()))
openEliciteFile(mPath);
else if(new File(file.replace(".wav",METADATA_SUFFIX)).exists()) // Wav have an associate json file ?
else if(aikumaFile != null && aikumaFile.getAbsolutePath().contains(FileIO.getAppRootPath().toString()))
{
// if recording, send to RespeakingMetadataLig
String recordName;
......@@ -188,7 +199,6 @@ public class RespeakingSelection extends AikumaActivity {
if(BuildConfig.DEBUG)Log.d(TAG, "openEliciteFile called");
try {
//Retrieving information from the wave file
Log.d(TAG, "J1");
UUID uuid = UUID.randomUUID();
Wave wave = new Wave(new FileInputStream(mPath));
String format = wave.getWaveHeader().getFormat();
......@@ -199,7 +209,6 @@ public class RespeakingSelection extends AikumaActivity {
FileUtils.copyFile(mPath,new File(Recording.getNoSyncRecordingsPath(), uuid.toString() + ".wav"));
FileUtils.copyFile(mPath,new File(Recording.getNoSyncRecordingsPath(), uuid.toString() + "-preview.wav"));
if(BuildConfig.DEBUG)Log.i(TAG, "Copying original recording file to: " + Recording.getNoSyncRecordingsPath() + "/" + uuid.toString() + ".wav");
Log.d(TAG, "J2");
//Retrieving information from the json file
JSONObject jsonObj = FileIO.readJSONObject(new File(mPath.toString().replace(".wav", METADATA_SUFFIX)));
......@@ -207,39 +216,34 @@ public class RespeakingSelection extends AikumaActivity {
Language recordLang = code.isEmpty() ? new Language("","") : new Language(Aikuma.getLanguageCodeMap().get(code), code);
List<Language> languages = Language.decodeJSONArray((JSONArray) jsonObj.get("languages"));
code = (String) jsonObj.get(RecordingMetadataLig.metaMotherTong);
Language motherTong =/** TODO
* tsizepx matches for tablets but is too large for phones (applyDimension to 10 is better)
* find a way to fix it for phones AND for tablets
*/ code.isEmpty() ? new Language("", "") : new Language(Aikuma.getLanguageCodeMap().get(code), code);
String regionOrigin = (String) jsonObj.get(RecordingMetadataLig.metaOrigin);
String speakerName = (String) jsonObj.get(RecordingMetadataLig.metaSpkrName);
String speakerNote = (String) jsonObj.get(RecordingMetadataLig.metaSpkrNote);
Language motherTong = code.isEmpty() ? new Language("", "") : new Language(Aikuma.getLanguageCodeMap().get(code), code);
String regionOrigin = (String) jsonObj.get(RecordingMetadataLig.metaOrigin),
speakerName = (String) jsonObj.get(RecordingMetadataLig.metaSpkrName),
speakerNote = (String) jsonObj.get(RecordingMetadataLig.metaSpkrNote);
long age = (Long) jsonObj.get(RecordingMetadataLig.metaSpkrBirthYr);
int speakerBirthYear= (int) age;
String speakerGender = (String) jsonObj.get(RecordingMetadataLig.metaSpkrGender);
Log.d(TAG, "J3");
//Calling RespekingMetadata with the right parameters
String idDevice = Aikuma.getDeviceId(),
name = new SimpleDateFormat("yyMMdd-HHmmss").format(date) + "_" + recordLang.getCode() + "_" + idDevice;
Log.d(TAG, "D1");
name = new SimpleDateFormat("yyMMdd-HHmmss").format(new Date()) + "_" + recordLang.getCode() + "_" + idDevice;
RecordingLig recording = new RecordingLig(uuid, name, new Date(date),
AikumaSettings.getLatestVersion(),
AikumaSettings.getCurrentUserId(), recordLang, motherTong,
languages, new ArrayList<String>(), Aikuma.getDeviceName(),
AikumaSettings.getLatestVersion(), AikumaSettings.getCurrentUserId(),
recordLang, motherTong, languages, new ArrayList<String>(), Aikuma.getDeviceName(),
Aikuma.getAndroidID(), null, null, (long)sampleRate, durationMsec,
format, numChannels, bitsPerSample, MainActivity.locationDetector.getLatitude(),
MainActivity.locationDetector.getLongitude(),
regionOrigin, speakerName, speakerBirthYear, speakerGender, speakerNote);
Log.d(TAG, "D2");
recording.write();
Log.d(TAG, "D3");
MediaPlayerFactory._elicit_source = mPath.toString();
MediaPlayerFactory._elicit_rspk = name;
Intent intent = new Intent(RespeakingSelection.this, RespeakingMetadataLig.class);
intent.putExtra(RecordActivityLig.intent_recordname, name);
intent.putExtra("dirname", name);
intent.putExtra(RecordActivityLig.intent_rewindAmount, 500);
startActivity(intent);
Log.d(TAG, "J4");
} catch (IOException e) {
Toast.makeText(this,R.string.failed_to_import_the_recording_, Toast.LENGTH_LONG).show();
if(BuildConfig.DEBUG)Log.e(TAG, "Error !\n " + e);
......
......@@ -19,6 +19,7 @@ import android.widget.Toast;
import org.apache.commons.lang3.ArrayUtils;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.R;
import org.getalp.ligaikuma.lig_aikuma.util.FileIO;
import org.getalp.ligaikuma.lig_aikuma.util.ShareTool;
import java.io.File;
......@@ -54,7 +55,7 @@ public class ShareFileActivity extends AikumaActivity
if(!_is_init) {
_selectedFiles = new ArrayList<>();
_nav_list = new ArrayList<>();
_current_folder_position = Environment.getExternalStorageDirectory().toString() + "/aikuma/recordings/";
_current_folder_position = FileIO.getAppRootPath() + "/recordings/";
_adapteur = new FileAdapter(this, _nav_list);
_checkbox_list = new ArrayList<>();
_is_init=true;
......@@ -72,9 +73,10 @@ public class ShareFileActivity extends AikumaActivity
_selectedFiles.remove(_current_folder_position+s2);
_adapteur.notifyDataSetChanged();
}});
_path_view = (TextView) findViewById(R.id.path_view_share);
_checkbox_list.clear();
((ListView) findViewById(R.id.list_share)).setAdapter(_adapteur);
_path_view = (TextView) findViewById(R.id.path_view_share);
_path_view.setText(_current_folder_position);
loadFileList(_current_folder_position);
}
......
......@@ -147,10 +147,7 @@ public class ThumbRespeakActivityLig extends AikumaActivity {
recordLang = MetadataSession.getMetadataSession().getRecordLanguage();
}
//Extraction of the waveform file THEN activity display
String fullPath = FileIO.getOwnerPath()+"/recordings/"+(
(!sourceName.contains("_elicit"))?sourceName:sourceName.split("_elicit")[0]+"_elicit")+"/"+sourceName+".wav";
if(BuildConfig.DEBUG)Log.d(TAG, "File used for waveforme : " + fullPath);
String fullPath = FileIO.getOwnerPath()+"/"+RecordingLig.RECORDINGS+dirName+"/"+sourceName+".wav";
MediaPlayerFactory._currentReadFile = fullPath;
if(new File(fullPath).length()>=125829120) //120MB == 125829120B
Toast.makeText(this, R.string.warning_source_file_exceeds_120mb_potential_source_of_error, Toast.LENGTH_LONG).show();
......@@ -178,8 +175,7 @@ public class ThumbRespeakActivityLig extends AikumaActivity {
private void setUpThumbRespeaker() {
File metadataFile = new File(FileIO.getOwnerPath(),
RecordingLig.RECORDINGS + dirName + "/"
+ recordName + RecordingLig.METADATA_SUFFIX);
RecordingLig.RECORDINGS + dirName + "/" + recordName + RecordingLig.METADATA_SUFFIX);
try {
recording = RecordingLig.read(metadataFile);
sourceId = recording.getId();
......@@ -356,7 +352,6 @@ public class ThumbRespeakActivityLig extends AikumaActivity {
e.getMessage(), Toast.LENGTH_LONG).show();
if(BuildConfig.DEBUG)Log.e(TAG, "failed when saving files: " + e);
}
Intent intent = new Intent(this, RespeakingSelection.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
......
......@@ -72,7 +72,6 @@ public class ThumbRespeakSummaryLig extends AikumaActivity implements OnClickLis
FileUtils.copyFile(new File (respeaker.getRecorder().getWriter().getFullFileName()), new File(tempRspk));
} catch (IOException e) {
if(BuildConfig.DEBUG)Log.e(TAG, "Could not initiate (copy) the respeaking file");
}
int i=0;
......@@ -206,7 +205,6 @@ public class ThumbRespeakSummaryLig extends AikumaActivity implements OnClickLis
l_activity.addView(okButton);
}
@Override
public void onClick(View v) {
if(BuildConfig.DEBUG)Log.i(TAG, "id: " + v.getId());
......
......@@ -163,7 +163,7 @@ public class AikumaSettings {
// Latest version name.
private static final String DEFAULT_VERSION = "v01";
private static final String DEFAULT_VERSION = "/v03";
/**
......@@ -332,7 +332,6 @@ public class AikumaSettings {
* @return the scope of Google-Cloud
*/
public static String getScope() {
//TODO: Supprimer joiner ???
String joiner = "", scope = "oauth2:";
for(String s: GoogleDriveStorage.getScopes()) {
scope += joiner + s;
......
......@@ -29,8 +29,6 @@ import java.util.UUID;
*/
public class Client {
private static final String BOLD_DIR = "aikuma";
/**
* Set up the working directory for the client.
*
......
......@@ -55,12 +55,11 @@ public final class FileIO {
* The ISO 8601 date format used for parsing dates from JSON files.
*/
private static StandardDateFormat standardDateFormat = new StandardDateFormat();
/**
* The application's top level path in the external storage.
*/
static final String APP_ROOT_PATH = "aikuma/";
static final String APP_ROOT_PATH = "ligaikuma";
/**