Commit 0052cb14 authored by mistermad's avatar mistermad

- Bugs fix on Elicitation mode

parent 00cc5c41
......@@ -2,12 +2,12 @@
xmlns:tools="http://schemas.android.com/tools"
package="org.getalp.ligaikuma.lig_aikuma.lig_aikuma"
android:versionCode="1"
android:versionName="1.0"
>
android:versionName="1.0">
<uses-sdk android:minSdkVersion="14"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
......
......@@ -106,12 +106,10 @@ public class Aikuma extends android.app.Application {
public static boolean isDeviceOnline() {
if(preferences == null) {
preferences = PreferenceManager.getDefaultSharedPreferences(appContext);
AikumaSettings.isOnlyWifi =
preferences.getBoolean(AikumaSettings.WIFI_MODE_KEY, true);
AikumaSettings.isOnlyWifi = preferences.getBoolean(AikumaSettings.WIFI_MODE_KEY, true);
}
ConnectivityManager connMgr = (ConnectivityManager)
appContext.getSystemService(Context.CONNECTIVITY_SERVICE);
ConnectivityManager connMgr = (ConnectivityManager) appContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = (AikumaSettings.isOnlyWifi)?
connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI):
connMgr.getActiveNetworkInfo();
......@@ -130,12 +128,10 @@ public class Aikuma extends android.app.Application {
public static boolean isArchived(String emailAccount, FileModel fm) {
String itemCloudId = fm.getCloudIdentifier(0);
Set<String> approvedSet;
Set<String> archivedSet;
Set<String> approvedSet, archivedSet;
int archiveProgress = -1;
SharedPreferences privatePreferences =
appContext.getSharedPreferences(emailAccount, MODE_PRIVATE);
SharedPreferences privatePreferences = appContext.getSharedPreferences(emailAccount, MODE_PRIVATE);
String fileType = fm.getFileType();
switch (fileType) {
case "source":
......@@ -148,19 +144,13 @@ public class Aikuma extends android.app.Application {
archivedSet = privatePreferences.getStringSet(AikumaSettings.ARCHIVED_SPEAKERS_KEY, new HashSet<String>());
break;
default:
approvedSet = privatePreferences.getStringSet(
AikumaSettings.APPROVED_OTHERS_KEY, new HashSet<String>());
archivedSet = privatePreferences.getStringSet(
AikumaSettings.ARCHIVED_OTHERS_KEY, new HashSet<String>());
approvedSet = privatePreferences.getStringSet(AikumaSettings.APPROVED_OTHERS_KEY, new HashSet<String>());
archivedSet = privatePreferences.getStringSet(AikumaSettings.ARCHIVED_OTHERS_KEY, new HashSet<String>());
break;
}
if(approvedSet.contains(itemCloudId)) {
String[] requestArchiveState =
privatePreferences.getString(itemCloudId, "").split("\\|");
archiveProgress =
Integer.parseInt(requestArchiveState[1]);
}
if(approvedSet.contains(itemCloudId))
archiveProgress = Integer.parseInt(privatePreferences.getString(itemCloudId, "").split("\\|")[1]);
return archivedSet.contains(itemCloudId) || (archiveProgress >= 0 && archiveProgress <= 3);
}
......@@ -171,9 +161,8 @@ public class Aikuma extends android.app.Application {
*/
public static ArrayList<String> getGoogleAccounts() {
ArrayList<String> accountList = new ArrayList<>();
Account[] accounts = AccountManager.get(appContext).getAccountsByType("com.google");
for(Account ac : accounts)
for(Account ac : AccountManager.get(appContext).getAccountsByType("com.google"))
accountList.add(ac.name);
return accountList;
......@@ -245,26 +234,4 @@ public class Aikuma extends android.app.Application {
* main thread.
*/
public static Thread loadLangCodesThread;
}
/*
public class Aikuma extends android.app.Application {
private static Context context;
public void onCreate() {
super.onCreate();
Aikuma.context = getApplicationContext();
}
public static Context getAppContext() {
return Aikuma.context;
}
public static String getAndroidID() {
return Secure.getString(
getAppContext().getContentResolver(), Secure.ANDROID_ID);
}
}
*/
}
\ No newline at end of file
......@@ -44,6 +44,8 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.semantive.waveformandroid.waveform.MediaPlayerFactory;
public class ModeSelection extends Activity implements OnClickListener{
private static final String TAG = "ModeSelection";
......@@ -163,7 +165,7 @@ public class ModeSelection extends Activity implements OnClickListener{
DialogFragment dialog = new UserSessionDiaglogFragment();
dialog.show(getFragmentManager(), "SessionDialogFragment");
}
@SuppressLint("ValidFragment")
public class UserSessionDiaglogFragment extends DialogFragment {
@Override
......@@ -210,7 +212,8 @@ public class ModeSelection extends Activity implements OnClickListener{
return builder.create();
}
public void retrieveSession() {
public void retrieveSession()
{
String mode = prefsUserSession.getString("mode", null);
if(BuildConfig.DEBUG)Log.d(TAG, "mode retrieval: "+mode);
if(((mode != null)?mode.compareToIgnoreCase(CheckTranscription.TAG):0) == 0)
......@@ -243,17 +246,22 @@ public class ModeSelection extends Activity implements OnClickListener{
String mode = prefsUserSession.getString("mode", "undefined");
String submode = prefsUserSession.getString("submode", "undefined");
String modeDialog = null, submodeDialog = null;
if (mode.compareToIgnoreCase(CheckWordVariant.TAG) == 0 || mode.compareTo(CheckTranscription.TAG) == 0) {
modeDialog = getString(R.string.check_mode);
if (mode.compareToIgnoreCase(CheckWordVariant.TAG) == 0 || mode.compareTo(CheckTranscription.TAG) == 0)
{
modeDialog ="Check mode";
submodeDialog = (mode.compareToIgnoreCase(CheckWordVariant.TAG) == 0) ? CheckWordVariant.TAG : CheckTranscription.TAG;
} else if (mode.compareToIgnoreCase(RecordElicitation.TAG) == 0) {
modeDialog = getString(R.string.elicitation);
}
else if (mode.compareToIgnoreCase(RecordElicitation.TAG) == 0)
{
modeDialog ="Elicitation";
if (submode.compareToIgnoreCase("text") == 0) submodeDialog = "text";
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(getString(R.string.respeak)) == 0) modeDialog = "Respeaking";
else if (submode.compareToIgnoreCase(getString(R.string.translation)) == 0) modeDialog = "Translation";
}
else if (mode.compareToIgnoreCase(ThumbRespeakActivityLig.TAG) == 0)
{
if (submode.compareToIgnoreCase("Respeaking") == 0) modeDialog = "Respeaking";
else if (submode.compareToIgnoreCase("translation") == 0) modeDialog = "Translation";
submodeDialog = "None";
}
((TextView) ll.findViewById(R.id.session_mode)).setText(modeDialog);
......@@ -273,7 +281,11 @@ public class ModeSelection extends Activity implements OnClickListener{
// display only filename
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);
//Usefull only for Translating and Respeaking ode
MediaPlayerFactory._currentReadFile = FileIO.getOwnerPath()+"/recordings/"+file+"/"+file+".wav";
Log.d(TAG,MediaPlayerFactory._currentReadFile);
}
}
......@@ -290,7 +302,7 @@ public class ModeSelection extends Activity implements OnClickListener{
if(BuildConfig.DEBUG)Log.d(TAG, "saved file: "+savedFile);
savedFile.delete();
if(BuildConfig.DEBUG)Log.i(TAG, "saved file erased: "+savedFile);
/*Elicitation Mode*/
} else if (savedMode.compareToIgnoreCase(RecordElicitation.TAG) == 0) {
if(BuildConfig.DEBUG)Log.d(TAG, "saved submode: "+savedSubmode);
......@@ -298,7 +310,7 @@ public class ModeSelection extends Activity implements OnClickListener{
String savedDate = prefsUserSession.getString("date", "");
Language savedRecordLang = new Language(prefsUserSession.getString("Language name", ""),
prefsUserSession.getString("LanguageCode", ""));
String name = savedDate + "_" +
String name = savedDate + "_" +
savedRecordLang.getCode() + "_" + idDevice;
//erase linker
File savedTextFile = new File(FileIO.getOwnerPath()+"/recordings/"+name + "/" + name + "_linker.txt");
......
......@@ -14,7 +14,6 @@ import org.getalp.ligaikuma.lig_aikuma.model.Segments;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.UUID;
......@@ -50,8 +49,8 @@ public class Mapper {
*/
public Mapper(UUID uuid) {
this.segments = new Segments();
this.mappingFile = new File(Recording.getNoSyncRecordingsPath(), uuid + ".map");
try {
this.mappingFile = new File(Recording.getNoSyncRecordingsPath(), uuid + ".map");
reader = new BufferedReader(new InputStreamReader(new FileInputStream(this.mappingFile)));
restoreFromMappingFile();
if(BuildConfig.DEBUG)Log.d("mapper generation", "yes");
......@@ -92,7 +91,7 @@ public class Mapper {
while ((line = reader.readLine()) != null && (line.isEmpty() || line.split(":").length <= 1));
if(BuildConfig.DEBUG)Log.d("line", line);
do {
String[] pair = line.split(":");
String[] pair = (line != null) ? line.split(":"):new String[0];
String[] strFirstSeg = pair[0].split(",");
String[] strSecondSeg = pair[1].split(",");
Segments.Segment original = new Segments.Segment(Long.parseLong(strFirstSeg[0]), Long.parseLong(strFirstSeg[1]));
......
......@@ -93,10 +93,7 @@ public class ListFolderAdapter extends ArrayAdapter {
case ElicitationMode.IMAGE_MODE:
while(i < files.length && (files[i].isFile() && (files[i].getAbsolutePath().contains(".jpg") || files[i].getAbsolutePath().contains(".jpeg") || files[i].getAbsolutePath().contains(".JPG") || files[i].getAbsolutePath().contains(".JPEG"))))
i++;
if(i == files.length && i>0)
holder.imageTypeOfFolder.setVisibility(ImageView.VISIBLE);
else
holder.imageTypeOfFolder.setVisibility(ImageView.INVISIBLE);
holder.imageTypeOfFolder.setVisibility((i == files.length && i>0)?ImageView.VISIBLE:ImageView.INVISIBLE);
break;
case ElicitationMode.VIDEO_MODE:
while(i < files.length && (files[i].isFile() && (files[i].getAbsolutePath().contains(".mp4") || files[i].getAbsolutePath().contains(".avi"))))
......
......@@ -8,7 +8,6 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
......@@ -17,10 +16,12 @@ import org.getalp.ligaikuma.lig_aikuma.Aikuma;
import org.getalp.ligaikuma.lig_aikuma.MainActivity;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.R;
import org.getalp.ligaikuma.lig_aikuma.model.Recording;
import org.getalp.ligaikuma.lig_aikuma.util.AikumaSettings;;
import org.getalp.ligaikuma.lig_aikuma.util.AikumaSettings;
import java.io.IOException;
;
/**
* Class that unifies some inter-activity navigation code.
*
......
......@@ -162,14 +162,9 @@ public class RecordActivityLig extends RecordActivity {
}
int duration = super.recorder.getCurrentMsec();
String deviceName = Aikuma.getDeviceName();
String androidID = Aikuma.getAndroidID();
String idDevice = Aikuma.getDeviceId();
ArrayList<String> speakerIds = new ArrayList<>();
Double latitude = MainActivity.locationDetector.getLatitude();
Double longitude = MainActivity.locationDetector.getLongitude();
String name = new SimpleDateFormat("yyMMdd-HHmmss").format(date) + "_" + recordLang.getCode()
+ "_" + idDevice;
+ "_" + Aikuma.getDeviceId();
if(BuildConfig.DEBUG)Log.d("new_name", name);
// + "_" + deviceName + "_" + selectedLanguages.get(0).getCode();
......@@ -185,10 +180,10 @@ public class RecordActivityLig extends RecordActivity {
RecordingLig recording = new RecordingLig(soundUUID, name, date,
AikumaSettings.getLatestVersion(),
AikumaSettings.getCurrentUserId(), recordLang, motherTong,
selectedLanguages, speakerIds, deviceName, androidID,
selectedLanguages, speakerIds, Aikuma.getDeviceName(), Aikuma.getAndroidID(),
null, null, super.sampleRate, duration,
super.recorder.getFormat(), super.recorder.getNumChannels(),
super.recorder.getBitsPerSample(), latitude, longitude,
super.recorder.getBitsPerSample(), MainActivity.locationDetector.getLatitude(), MainActivity.locationDetector.getLongitude(),
regionOrigin, speakerName, speakerAge, gender, speakerNote);
try {
......@@ -209,11 +204,9 @@ public class RecordActivityLig extends RecordActivity {
if (!respeak) {
intent = new Intent(this, ModeSelection.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Toast.makeText(RecordActivityLig.this, String.format("%s %s (%s)",
recording.getNameAndLang(),
new SimpleDateFormat("yyyy-MM-dd").format(recording.getDate()),
(duration / 1000) + ""),
Toast.LENGTH_LONG).show();
Toast.makeText(RecordActivityLig.this,
getString(R.string.file_saved)+ recording.getNameAndLang() +" | "+new SimpleDateFormat("yyyy-MM-dd").format(recording.getDate())+" ("+(duration / 1000)+")"
,Toast.LENGTH_LONG).show();
} else {
// TODO allow for the second mode of respeaking, phone near to ear?
intent = new Intent(this, RespeakingMetadataLig.class);
......
......@@ -255,9 +255,7 @@ public class RecordElicitation extends AikumaActivity {
}
private void initBufferedWriter() throws FileNotFoundException {
FileOutputStream fos;
fos = new FileOutputStream(textFile, true);
bufferedWriter = new BufferedWriter(new OutputStreamWriter(fos));
bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(textFile, true)));
}
@SuppressWarnings("unchecked")
......@@ -321,7 +319,6 @@ public class RecordElicitation extends AikumaActivity {
// String name = strFolderDate + "_" +
// recordLang.getCode() + "_" + idDevice;
dirName = strFolderDate + "_" + recordLang.getCode() + "_" + idDevice + mode;
Log.d("MAD", dirName);
textFile = new File(FileIO.getOwnerPath()+"/recordings/"+dirName + "/" + dirName + "_linker.txt");
images = new File(ptrSelectedReference).listFiles();
......@@ -430,13 +427,12 @@ public class RecordElicitation extends AikumaActivity {
new SeekBar.OnSeekBarChangeListener() {
int originalProgress;
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if(fromUser)
seekBar.setProgress(originalProgress);
if(fromUser) seekBar.setProgress(originalProgress);
}
public void onStopTrackingTouch(SeekBar _seekBar) {};
public void onStopTrackingTouch(SeekBar _seekBar) {}
public void onStartTrackingTouch(SeekBar _seekBar) {
originalProgress = progressBar.getProgress();
};
}
});
}
......@@ -457,16 +453,17 @@ public class RecordElicitation extends AikumaActivity {
* @param _view the next button
*/
public void onNextClick(View _view) {
_button_undo.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.undo2));
_button_undo.setEnabled(false);
ImageButton recordButton = (ImageButton) findViewById(R.id.btn_record_elicit);
recordButton.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.record));
recordButton.setEnabled(true);
saveOneRecord();
if(!saveRecording() && (entityId < numberOfEntities-1))
Toast.makeText(this, R.string.going_next, Toast.LENGTH_SHORT).show();
else
deleteAllTempFiles();
if(!saveRecording() && (entityId < numberOfEntities-1))
Toast.makeText(this, R.string.going_next, Toast.LENGTH_SHORT).show();
else
deleteAllTempFiles();
_button_undo.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.undo2));
_button_undo.setEnabled(false);
ImageButton recordButton = (ImageButton) findViewById(R.id.btn_record_elicit);
recordButton.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.record));
recordButton.setEnabled(true);
saveOneRecord();
}
......@@ -498,10 +495,9 @@ public class RecordElicitation extends AikumaActivity {
int i = entityId-1;
File metadataFile;
//do is used to get the last json file. Useful in case we have skip sentences
// Do is used to get the last json file. Useful in case we have skip sentences
do{
// metadataFile = new File(FileIO.getOwnerPath().getAbsolutePath() + "/"+ "recordings" + "/" +this.strFolderDate + "_"+recordLang.getCode()+"_"+Aikuma.getDeviceId(),
// this.strFolderDate + "_" + recordLang.getCode() + "_" + Aikuma.getDeviceId() + "_" + i + RecordingLig.METADATA_SUFFIX);
// metadataFile = new File(FileIO.getOwnerPath().getAbsolutePath() + "/"+ "recordings" + "/" +this.strFolderDate + "_"+recordLang.getCode()+"_"+Aikuma.getDeviceId(), this.strFolderDate + "_" + recordLang.getCode() + "_" + Aikuma.getDeviceId() + "_" + i + RecordingLig.METADATA_SUFFIX);
metadataFile = new File(FileIO.getOwnerPath().getAbsolutePath() + "/"+ RecordingLig.RECORDINGS + dirName +"/",
dirName + "_" + i + RecordingLig.METADATA_SUFFIX);
i--;
......@@ -536,18 +532,12 @@ public class RecordElicitation extends AikumaActivity {
Double latitude = MainActivity.locationDetector.getLatitude(),
longitude = MainActivity.locationDetector.getLongitude();
/* Not used
String suffix = (new File(ptrSelectedReference).getName().replace(".txt", "").length() >= 10)?
new File(ptrSelectedReference).getName().substring(0, 10):
new File(ptrSelectedReference).getName().replace(".txt", "");*/
// Not used
//String suffix = (new File(ptrSelectedReference).getName().replace(".txt", "").length() >= 10)? new File(ptrSelectedReference).getName().substring(0, 10): new File(ptrSelectedReference).getName().replace(".txt", "");
String idDevice = Aikuma.getDeviceId();
/* String recordingName = strFolderDate + "_" +
MetadataSession.getMetadataSession().getRecordLanguage().getCode()
+ "_" + idDevice;
+ "_elicit_" + new File(eliciTextFile).getName().substring(0,10);
+ "_" + eliciTextFile.substring(0, 10) + "_" + phraseId*/
recordingName = strFolderDate + "_" +
// String recordingName = strFolderDate + "_" + MetadataSession.getMetadataSession().getRecordLanguage().getCode() + "_" + idDevice; + "_elicit_" + new File(eliciTextFile).getName().substring(0,10);+ "_" + eliciTextFile.substring(0, 10) + "_" + phraseId
recordingName = strFolderDate + "_" +
MetadataSession.getMetadataSession().getRecordLanguage().getCode()
+ "_" + idDevice + mode + "_" + entityId;
if(BuildConfig.DEBUG)Log.i(TAG, "recording name: " + recordingName);
......
......@@ -84,9 +84,8 @@ public class RespeakingMetadataLig extends AikumaActivity implements OnClickList
JSONObject metaJSON;
try {
metaJSON = FileIO.readJSONObject(new File(FileIO.getOwnerPath(),
RecordingLig.RECORDINGS + OrigDirName
+ "/" + origRecName + RecordingLig.METADATA_SUFFIX));
recordSampleRate = 16000l;
RecordingLig.RECORDINGS + OrigDirName + "/" + origRecName + RecordingLig.METADATA_SUFFIX));
recordSampleRate = 16000L;
// JSONObject metaJSON = FileIO.readJSONObject(new File(recordPath.split(".")[0]+ RecordingLig.METADATA_SUFFIX));
// fill in the recording details about languages
......@@ -112,7 +111,7 @@ public class RespeakingMetadataLig extends AikumaActivity implements OnClickList
s.append(l.getName() + ";");
tv.setText(s.toString());
} else
tv.setText("None");
tv.setText(R.string.none);
// fill in the recording details about speaker
tv = (TextView) findViewById(R.id.record_edit_spkr_name);
tv.setText((String)metaJSON.get(RecordingMetadataLig.metaSpkrName));
......@@ -124,9 +123,7 @@ public class RespeakingMetadataLig extends AikumaActivity implements OnClickList
tv = (TextView) findViewById(R.id.record_edit_spkr_region_orig);
tv.setText((String)metaJSON.get(RecordingMetadataLig.metaOrigin));
} catch (IOException e) {
Toast.makeText(RespeakingMetadataLig.this,
R.string.error_failed_to_load_the_recording_please_try_again,
Toast.LENGTH_LONG).show();
Toast.makeText(RespeakingMetadataLig.this, R.string.error_failed_to_load_the_recording_please_try_again, Toast.LENGTH_LONG).show();
startActivity(new Intent(RespeakingMetadataLig.this, RespeakingSelection.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
RespeakingMetadataLig.this.finish();
......
......@@ -55,7 +55,7 @@ public class ThumbRespeakActivityLig extends AikumaActivity {
private String dirName;
private String recordName;
private int rewindAmount;
private Mapper mp;
private Mapper mapper;
private Language recordLang;
/**
......@@ -104,7 +104,8 @@ public class ThumbRespeakActivityLig extends AikumaActivity {
String recordLangName = prefsUserSession.getString("Language name", "");
recordLang = new Language(recordLangName, recordLangCode);
sampleRate = prefsUserSession.getLong("sampleRate", 0);
mp = new Mapper(respeakingUUID);
if(BuildConfig.DEBUG)Log.d(TAG, "(loeaded) respeakingUUID = "+respeakingUUID);
mapper = new Mapper(respeakingUUID);
totalAudioLength = prefsUserSession.getLong("totalAutioLength", 0);
// clear the current stored session
prefsUserSession.edit().clear().apply();
......@@ -125,7 +126,8 @@ public class ThumbRespeakActivityLig extends AikumaActivity {
rewindAmount = intent.getExtras().getInt(RecordActivityLig.intent_rewindAmount);
sampleRate = intent.getLongExtra(RecordActivityLig.intent_sampleRate, 16000);
respeakingUUID = UUID.randomUUID();
mp = new Mapper(respeakingUUID);
if(BuildConfig.DEBUG)Log.d(TAG, "(New) respeakingUUID = "+respeakingUUID);
mapper = new Mapper(respeakingUUID);
safeActivityTransition = true;
curSampl = 0;
payLoadSize = 0;
......@@ -134,7 +136,7 @@ public class ThumbRespeakActivityLig extends AikumaActivity {
sourceName = getIntent().getStringExtra(RecordActivityLig.intent_recordname);
dirName = getIntent().getStringExtra("dirname");
duration = 0;
totalAudioLength = 0l;
totalAudioLength = 0L;
recordLang = MetadataSession.getMetadataSession().getRecordLanguage();
}
......@@ -154,8 +156,7 @@ public class ThumbRespeakActivityLig extends AikumaActivity {
File metadataFile = new File(FileIO.getOwnerPath(),
RecordingLig.RECORDINGS + dirName + "/"
+ recordName + RecordingLig.METADATA_SUFFIX);
// File metadataFile = new File(recordName.split(".")[0]
// + "." + RecordingLig.METADATA_SUFFIX);
// File metadataFile = new File(recordName.split(".")[0] + "." + RecordingLig.METADATA_SUFFIX);
try {
recording = RecordingLig.read(metadataFile);
sourceId = recording.getId();
......@@ -163,7 +164,7 @@ public class ThumbRespeakActivityLig extends AikumaActivity {
try {
respeaker = new ThumbRespeaker(recording, respeakingUUID, rewindAmount);
respeaker.setMapper(mp);
respeaker.setMapper(mapper);
respeaker.setPreviousEndSample(duration);
respeaker.getSimplePlayer().seekToMsec(duration);
} catch (IOException e) {
......@@ -212,7 +213,7 @@ public class ThumbRespeakActivityLig extends AikumaActivity {
ed.putInt("payLoadaSize", fragment.getRespeaker().getRecorder().getFile().getPayloadSize());
ed.putLong("currentPCMSample", fragment.getRespeaker().getRecorder().getFile().getCurrentSample());
ed.commit();
ed.apply();
}
......@@ -255,27 +256,21 @@ public class ThumbRespeakActivityLig extends AikumaActivity {
Date date = new Date();
int duration = respeaker.getCurrentMsec();
String deviceName = Aikuma.getDeviceName(),
androidID = Aikuma.getAndroidID();
Double latitude = MainActivity.locationDetector.getLatitude(),
longitude = MainActivity.locationDetector.getLongitude();
String mode = translateMode ? "_trsl" : "_rspk";
String name = new SimpleDateFormat("yyMMdd-HHmmss").format(date) + "_" +
recordLang.getCode()
+ "_" + Aikuma.getDeviceId() + mode;
String deviceName = Aikuma.getDeviceName(), androidID = Aikuma.getAndroidID();
Double latitude = MainActivity.locationDetector.getLatitude(), longitude = MainActivity.locationDetector.getLongitude();
String tmode = translateMode ? "_trsl" : "_rspk";
String name = new SimpleDateFormat("yyMMdd-HHmmss").format(date) + "_" + recordLang.getCode() + "_" + Aikuma.getDeviceId() + tmode;
String groupId = Recording.getGroupIdFromId(sourceId);
String sourceVerId = recording.getVersionName() + "-" + recording.getId();
Recorder recorder = respeaker.getRecorder();
String speakerGender = "ERROR";
if(MetadataSession.getMetadataSession().getSpeakerGender() == 1)
speakerGender = "Male";
else if(MetadataSession.getMetadataSession().getSpeakerGender() == 2)
speakerGender = "Female";
else if(MetadataSession.getMetadataSession().getSpeakerGender() == 3)
speakerGender = "Unspecified";
String speakerGender;
switch (MetadataSession.getMetadataSession().getSpeakerGender())
{
case 1: speakerGender = "Male"; break;
case 2: speakerGender = "Female"; break;
case 3: speakerGender = "Unspecified"; break;
default:speakerGender = "ERROR";
}
recording = new RecordingLig(respeakingUUID, name, date,
AikumaSettings.getLatestVersion(),
......@@ -323,9 +318,7 @@ public class ThumbRespeakActivityLig extends AikumaActivity {
// the synced directory and write the metadata
recording.write();
Toast.makeText(ThumbRespeakActivityLig.this,
getString(R.string.respeaking_saved_into_the_file) + recording.getName(),
Toast.LENGTH_LONG)
.show();
getString(R.string.respeaking_saved_into_the_file) + recording.getName(),Toast.LENGTH_LONG).show();
} catch (IOException e) {
Toast.makeText(ThumbRespeakActivityLig.this,
getString(R.string.failed_to_write_the_respoken_recording_metadata) +
......@@ -378,16 +371,10 @@ public class ThumbRespeakActivityLig extends AikumaActivity {
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
File metadataFile = new File(FileIO.getNoSyncPath(),
ThumbRespeakActivityLig.this.respeakingUUID + RecordingLig.METADATA_SUFFIX);
File mapFile = new File(FileIO.getNoSyncPath(),
ThumbRespeakActivityLig.this.respeakingUUID + RecordingLig.MAP_EXT);
File wavFile = new File(FileIO.getNoSyncPath() + "/items/" + ThumbRespeakActivityLig.this.respeakingUUID
+ ".wav");
ThumbRespeakActivityLig.this.fragment.deleteLastTempFile();
mapFile.delete();
metadataFile.delete();
wavFile.delete();
new File(FileIO.getNoSyncPath(), ThumbRespeakActivityLig.this.respeakingUUID + RecordingLig.MAP_EXT).delete();
new File(FileIO.getNoSyncPath(), ThumbRespeakActivityLig.this.respeakingUUID + RecordingLig.METADATA_SUFFIX).delete();
new File(FileIO.getNoSyncPath() + "/items/" + ThumbRespeakActivityLig.this.respeakingUUID + ".wav").delete();
if (isNewSession)
ThumbRespeakActivityLig.this.finish();
else {
......
......@@ -115,7 +115,7 @@ public class ThumbRespeakFragment extends Fragment {
if(respeaker != null)
respeaker.release();
String filename = FileIO.getOwnerPath().getAbsolutePath() + "/recordings/" + "temp.rspk.wav";
String filename = FileIO.getOwnerPath().getAbsolutePath() + "/recordings/temp_rspk.wav";
if (listenFragment.getPlayer() != null)
listenFragment.getPlayer().release();
try {
......@@ -123,10 +123,10 @@ public class ThumbRespeakFragment extends Fragment {
FileIO.delete(new File(filename));
if(BuildConfig.DEBUG)Log.i(TAG, "Deleting " + filename);
count--;
filename = FileIO.getOwnerPath().getAbsolutePath() + "/recordings/" + "temp.rspk.wav";
filename = FileIO.getOwnerPath().getAbsolutePath() + "/recordings/temp_rspk.wav";
}
} catch (IOException e) {
if(BuildConfig.DEBUG)Log.e(TAG, "failed to delete " + filename + " - maybe the file didn't exist");
if(BuildConfig.DEBUG)Log.e(TAG, "failed to delete " + filename + " - maybe the file didn't exist (1)");
}
}
......@@ -211,14 +211,14 @@ public class ThumbRespeakFragment extends Fragment {
respeaker.recordRespeaking();
count++;
String filename = FileIO.getOwnerPath().getAbsolutePath() + "/recordings/" + "temp.rspk.wav";
String filename = FileIO.getOwnerPath().getAbsolutePath() + "/recordings/temp_rspk.wav";
if (listenFragment.getPlayer() != null)
listenFragment.getPlayer().release();
try {
FileIO.delete(new File(filename));
if(BuildConfig.DEBUG)Log.i(TAG, "Deleting " + filename);
} catch (IOException e) {
if(BuildConfig.DEBUG)Log.e(TAG, "failed to delete " + filename + " - maybe the file didn't exist");
if(BuildConfig.DEBUG)Log.e(TAG, "failed to delete " + filename + " - maybe the file didn't exist (2)");
}
}
if(event.getAction() == MotionEvent.ACTION_UP) {
......@@ -247,7 +247,7 @@ public class ThumbRespeakFragment extends Fragment {
// save the latest segment in a temporary file
int rate = respeaker.getRecorder().getMicrophone().getSampleRate();
String filename = FileIO.getOwnerPath().getAbsolutePath()+"/recordings/"+"temp.rspk.wav";
String filename = FileIO.getOwnerPath().getAbsolutePath() + "/recordings/temp_rspk.wav";
PCMWriter file = PCMWriter.getInstance(rate,
respeaker.getRecorder().getMicrophone().getChannelConfiguration(),
respeaker.getRecorder().getMicrophone().getAudioFormat());
......@@ -324,12 +324,12 @@ public class ThumbRespeakFragment extends Fragment {
* decrements the count attribute
*/
public void deleteLastTempFile() {
String filename = FileIO.getOwnerPath().getAbsolutePath() + "/recordings/" + "temp.rspk.wav";
String filename = FileIO.getOwnerPath().getAbsolutePath() + "/recordings/temp_rspk.wav";
try {
FileIO.delete(new File(filename));
if(BuildConfig.DEBUG)Log.i(TAG, "Deleting " + filename);
} catch (IOException e) {
if(BuildConfig.DEBUG)Log.e(TAG, "failed to delete " + filename + " - maybe the file didn't exist");
if(BuildConfig.DEBUG)Log.e(TAG, "failed to delete " + filename + " - maybe the file didn't exist (3)");
}
}
......
......@@ -141,19 +141,19 @@ public class ThumbRespeakSummaryLig extends AikumaActivity implements OnClickLis
l_seg_orig.setId((i+1)*1000);
l_segment.addView(l_seg_orig);
TextView tvSegment = new TextView(this);
tvSegment.setText("Segment " + i);
tvSegment.setText("");
l_seg_orig.addView(tvSegment);
ListenFragment playerOrigFragment = new ListenFragment();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.add(l_seg_orig.getId(), playerOrigFragment);
ft.commit();
LinearLayout l_seg_rspk = new LinearLayout(this);
l_seg_rspk.setLayoutParams(l_segment.getLayoutParams());
l_seg_rspk.setOrientation(LinearLayout.VERTICAL);
l_segment.addView(l_seg_rspk);
tvSegment = new TextView(this);
tvSegment.setText("Segment " + i);
tvSegment.setText("Segment " + (i+1