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 {
compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'
compile 'javax.annotation:javax.annotation-api:1.2'
compile project(path: ':library')
}
......@@ -8,6 +8,8 @@ import android.media.AudioManager;
import android.media.MediaPlayer;
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.model.Recording;
......@@ -39,7 +41,7 @@ public class SimplePlayer extends Player implements Sampler
*/
public SimplePlayer(Recording recording, boolean playThroughSpeaker) throws IOException {
setRecording(recording);
mediaPlayer = new MediaPlayer();
mediaPlayer = MediaPlayerFactory.getNewMediaPlayer();
mediaPlayer.setAudioStreamType((playThroughSpeaker)?AudioManager.STREAM_MUSIC:AudioManager.STREAM_VOICE_CALL);
if(BuildConfig.DEBUG)Log.i("SimplePlayer", "Media Player - data source: " + recording.getFile().getCanonicalPath());
mediaPlayer.setDataSource(recording.getFile().getCanonicalPath());
......@@ -190,7 +192,7 @@ public class SimplePlayer extends Player implements Sampler
//Never use
//protected void setFinishedPlaying(boolean finished) {this.finishedPlaying = finished;}
protected Recording getRecording() {
public Recording getRecording() {
return recording;
}
......
......@@ -151,17 +151,15 @@ public class Microphone {
private static AudioRecord getListener(
int sampleRate, int audioFormat, int channelConfig) {
// Sample size.
int sampleSize = (audioFormat == AudioFormat.ENCODING_PCM_16BIT)? 16: 8;
// Channels.
int numberOfChannels = (channelConfig == AudioFormat.CHANNEL_IN_MONO)? 1: 2;
// Sample size and Channels.
int sampleSize = (audioFormat == AudioFormat.ENCODING_PCM_16BIT)? 16: 8,
numberOfChannels = (channelConfig == AudioFormat.CHANNEL_IN_MONO)? 1: 2,
// Calculate buffer size.
/** The period used for callbacks to onBufferFull. */
int framePeriod = sampleRate * 120 / 1000;
framePeriod = sampleRate * 120 / 1000,
/** 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,
sampleRate, AudioFormat.CHANNEL_IN_MONO,
......
......@@ -274,8 +274,7 @@ public class Recorder implements AudioHandler, MicrophoneListener, Sampler {
// Append all audio-values in srcBuffer to audioBuffer
private void storeBuffer(short[] srcBuffer) {
if(audioBuffer.length < audioBufLength + srcBuffer.length) {
int newBufLength = 2 * audioBuffer.length;
short[] newBuffer = new short[newBufLength];
short[] newBuffer = new short[(2 * audioBuffer.length)];
System.arraycopy(audioBuffer, 0, newBuffer, 0, audioBufLength);
audioBuffer = newBuffer;
}
......@@ -303,9 +302,7 @@ public class Recorder implements AudioHandler, MicrophoneListener, Sampler {
totalAudioLength += buffer.length;
if (this.type == 0 &&
Math.round((double) totalAudioLength / sampleRate) < Recording.SAMPLE_SEC) // 15sec sample
{
sampleFile.write(buffer);
}
}
......
......@@ -41,8 +41,7 @@ public class ThumbRespeaker {
public ThumbRespeaker(Recording original, UUID respeakingUUID,
int rewindAmount) throws Microphone.MicException, IOException {
if(BuildConfig.DEBUG)Log.d("Rte-ThumbRespeaker", "smp : " + original.getSampleRate());
recorder = new Recorder(1, new File(Recording.getNoSyncRecordingsPath(),
respeakingUUID + ".wav"), original.getSampleRate());
recorder = new Recorder(1, new File(Recording.getNoSyncRecordingsPath(), respeakingUUID + ".wav"), original.getSampleRate());
player = new SimplePlayer(original, true);
mapper = new Mapper(respeakingUUID);
setFinishedPlaying(false);
......@@ -60,10 +59,9 @@ public class ThumbRespeaker {
* @throws MicException If the microphone couldn't be used.
* @throws IOException If there is an I/O issue.
*/
public ThumbRespeaker(RecordingLig original, UUID respeakingUUID,
int rewindAmount) throws MicException, IOException {
recorder = new Recorder(1, new File(Recording.getNoSyncRecordingsPath(),
respeakingUUID + ".wav"), original.getSampleRate());
public ThumbRespeaker(RecordingLig original, UUID respeakingUUID, int rewindAmount)
throws MicException, IOException {
recorder = new Recorder(1, new File(Recording.getNoSyncRecordingsPath(), respeakingUUID + ".wav"), original.getSampleRate());
player = new SimplePlayer(original, true);
mapper = new Mapper(respeakingUUID);
setFinishedPlaying(false);
......
......@@ -1410,8 +1410,8 @@ public class Recording extends FileModel {
*/
/*
public static void enableSync(String id) throws IOException {
File wavFile = new File(getNoSyncRecordingsPath(), uuid + ".wav");
FileUtils.moveFileToDirectory(wavFile, getRecordingsPath(), false);
File WavFile = new File(getNoSyncRecordingsPath(), uuid + ".wav");
FileUtils.moveFileToDirectory(WavFile, getRecordingsPath(), false);
}
*/
......
......@@ -66,33 +66,31 @@ public class CheckTranscription extends AikumaActivity {
initProgressBars();
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());
//case: session already exists
boolean append;
if (prefsUserSession.getBoolean(getString(R.string.sessionActive), false)) {
if (prefsUserSession.getBoolean("active", false)) {
//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);
//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);
//retrieve number of lines already handled in the last session
//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);
append = true;
// clear the current stored session
SharedPreferences.Editor ed = prefsUserSession.edit();
ed.clear();
ed.commit();
prefsUserSession.edit().clear().apply();
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
} else {
transcripTextFile = getIntent().getStringExtra(CheckMode.importFileName);
if(BuildConfig.DEBUG)Log.i(TAG, "Is it a new session ? "+isNewSession);
if(BuildConfig.DEBUG)Log.i(TAG, "Selected file: " + transcripTextFile);
if(BuildConfig.DEBUG){Log.i(TAG, "Is it a new session ? "+isNewSession);
Log.i(TAG, "Selected file: " + transcripTextFile);}
append = false;
//output filename
transcriptChecked = transcripTextFile.replace(".txt", "_"+date+"_CHECKED.txt");
......@@ -307,13 +305,13 @@ public class CheckTranscription extends AikumaActivity {
*/
date = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.FRANCE).format(new Date());
SharedPreferences.Editor ed = prefsUserSession.edit();
ed.putBoolean(getString(R.string.sessionActive), true); //session activated
ed.putInt(getString(R.string.currentLine), nbReadLines); //nb lines
ed.putString(getString(R.string.sessionProgress), nbReadLines + " / " + nb_total_lines);
ed.putString(getString(R.string.sessionInputFile), transcripTextFile); //handled file
ed.putString(getString(R.string.sessionCheckExportFile), transcriptChecked); //resulting file
ed.putString(getString(R.string.sessionDate), date); //set date
ed.putString(getString(R.string.sessionMode),TAG); //set mode
ed.putBoolean("active", true); //session activated
ed.putInt("currentLine", nbReadLines); //nb lines
ed.putString("progress", nbReadLines + " / " + nb_total_lines);
ed.putString("inputFile", transcripTextFile); //handled file
ed.putString("checkExportFile", transcriptChecked); //resulting file
ed.putString("date", date); //set date
ed.putString("mode",TAG); //set mode
// ed.putBoolean(getString(R.string.checkTranscript), true); //set submode
//save infos
ed.commit();
......@@ -354,13 +352,12 @@ public class CheckTranscription extends AikumaActivity {
try {
if(BuildConfig.DEBUG)Log.i("saveFile", "Writing on file");
//if checked
if (transcriptOK.isChecked()) {
if(transcriptOK.isChecked())
outputFile.write(transcriptID.getText()+" : "+transcriptOK.getText()+"\n");
}
} catch (IOException e1) {e1.printStackTrace();}
return true;
}
private void interruptionCallback() {
if (nbReadLines == 0) {
......
......@@ -53,9 +53,9 @@ public class CheckWordVariant extends AikumaActivity {
setContentView(R.layout.check_word_variant);
initProgressBars();
date = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.FRANCE).format(new Date());
prefsUserSession = getSharedPreferences(getString(R.string.userSession), MODE_PRIVATE);
prefsUserSession = getSharedPreferences("userSession", MODE_PRIVATE);
//case: session already exists
if (prefsUserSession.getBoolean(getString(R.string.sessionActive), false)) {
if (prefsUserSession.getBoolean("active", false)) {
/*
* TODO rajouter une condition en &&
* soustraire date.now à date session :
......@@ -63,18 +63,17 @@ public class CheckWordVariant extends AikumaActivity {
* sinon continue;
*/
//retrieve selected file handled in the last session
variantTextFile = prefsUserSession.getString(getString(R.string.sessionInputFile),null);
variantTextFile = prefsUserSession.getString("inputFile", null);
if(BuildConfig.DEBUG)Log.i(TAG, "Selected import file: " + variantTextFile);
//retrieve result file handled in the last session
variantchecked = prefsUserSession.getString(getString(R.string.sessionCheckExportFile),null);
variantchecked = prefsUserSession.getString("checkExportFile",null);
if(BuildConfig.DEBUG)Log.i(TAG, "Selected export file: " + variantchecked);
//retrieve number of lines already handled in the last session
nbReadLines = prefsUserSession.getInt(getString(R.string.nbReadLines),0);
nbReadLines = prefsUserSession.getInt("nbReadLine",0);
append = true;
// clear the current stored session
SharedPreferences.Editor ed = prefsUserSession.edit();
ed.clear(); ed.commit();
prefsUserSession.edit().clear().apply();
//case: no session
} else {
variantTextFile = getIntent().getStringExtra(CheckMode.importFileName);
......@@ -304,16 +303,16 @@ public class CheckWordVariant extends AikumaActivity {
Toast.makeText(this, R.string.the_session_has_been_saved, Toast.LENGTH_SHORT).show();
date = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.FRANCE).format(new Date());
SharedPreferences.Editor ed = prefsUserSession.edit();
ed.putBoolean(getString(R.string.sessionActive), true); //session activated
ed.putInt(getString(R.string.nbReadLines), nbReadLines); //nb lines
ed.putString(getString(R.string.sessionProgress), nbReadLines + "/" + totalNumberOfExpressions);
ed.putString(getString(R.string.sessionInputFile), variantTextFile); //handled file
ed.putString(getString(R.string.sessionCheckExportFile), variantchecked); //resulting file
ed.putString(getString(R.string.sessionDate), date); //set date
ed.putString(getString(R.string.sessionMode),TAG); //set mode
ed.putBoolean("active", true); //session activated
ed.putInt("nbReadLine", nbReadLines); //nb lines
ed.putString("progress", nbReadLines + "/" + totalNumberOfExpressions);
ed.putString("inputFile", variantTextFile); //handled file
ed.putString("checkExportFile", variantchecked); //resulting file
ed.putString("date", date); //set date
ed.putString("mode",TAG); //set mode
// ed.putBoolean(getString(R.string.checkVariant), true); //set submode
//save infos
ed.commit();
ed.apply();
}
} catch (IOException e) {
e.printStackTrace();
......
......@@ -91,8 +91,8 @@ public class CloudSearchActivity extends AikumaListActivity {
isMediaPlayerPrepared = false;
setUpQuickMenu();
recordings = new ArrayList<Recording>();
itemIdsToDownload = new ArrayList<String>();
recordings = new ArrayList<>();
itemIdsToDownload = new ArrayList<>();
adapter = new RecordingArrayAdapter(this, recordings, quickMenu);
setListAdapter(adapter);
......@@ -176,7 +176,7 @@ public class CloudSearchActivity extends AikumaListActivity {
// Creates the quickMenu for the original recording
//(quickMenu: download)
private void setUpQuickMenu() {
quickMenu = new QuickActionMenu<Recording>(this);
quickMenu = new QuickActionMenu<>(this);
if(AikumaSettings.getCurrentUserToken() != null) {
QuickActionItem sampleDownloadAct = new QuickActionItem("Sample", R.drawable.download_32);
......@@ -224,7 +224,7 @@ public class CloudSearchActivity extends AikumaListActivity {
String sampleCloudId = new FileModel(recording.getVersionName(),
recording.getOwnerId(), recording.getPreviewId(), "preview", "wav").
getCloudIdentifier(0);
List<String> cloudId = new ArrayList<String>();
List<String> cloudId = new ArrayList<>();
cloudId.add(sampleCloudId);
new RequestShareFileTask(cloudId, googleEmailAccount, googleAuthToken).execute();
......@@ -290,10 +290,10 @@ public class CloudSearchActivity extends AikumaListActivity {
this.mAccessToken = accessToken;
this.mQuery = query;
constraints = new TreeMap<String, String>();
cloudIdsToDownload = new ArrayList<String>();
metadataToWrite = new HashMap<String, String>();
speakerIdsToDownload = new ArrayList<String>();
constraints = new TreeMap<>();
cloudIdsToDownload = new ArrayList<>();
metadataToWrite = new HashMap<>();
speakerIdsToDownload = new ArrayList<>();
}
@Override
......@@ -390,7 +390,7 @@ public class CloudSearchActivity extends AikumaListActivity {
// String metadataJSONStr = result.get("metadata");
// metadataToWrite.put(identifier, metadataJSONStr);
FileModel fm = FileModel.fromCloudId(identifier);
String metadataCloudId = fm.getCloudIdentifier(1);
String metadataCloudId = (fm != null)?fm.getCloudIdentifier(1):null;
cloudIdsToDownload.add(metadataCloudId);
}
......@@ -419,7 +419,7 @@ public class CloudSearchActivity extends AikumaListActivity {
File dir = new File(FileIO.getAppRootPath(), relPath);
dir.mkdirs();
if(BuildConfig.DEBUG)Log.i(TAG, dir.getAbsolutePath() + ", " + fileModel.getMetadataIdExt());
if(BuildConfig.DEBUG)Log.i(TAG, dir.getAbsolutePath() + ", " + ((fileModel != null)?fileModel.getMetadataIdExt():""));
FileIO.writeJSONObject(new File(dir, fileModel.getMetadataIdExt()), jsonObj);
} catch (ParseException | IOException e) {
if(BuildConfig.DEBUG)Log.e(TAG, e.getMessage());
......@@ -507,10 +507,8 @@ public class CloudSearchActivity extends AikumaListActivity {
if(BuildConfig.DEBUG)Log.i(TAG, "autodownload start");
Intent syncIntent = new Intent(CloudSearchActivity.this, GoogleCloudService.class);
syncIntent.putExtra(GoogleCloudService.ACTION_KEY, "autoDownload");
syncIntent.putExtra(GoogleCloudService.ACCOUNT_KEY,
AikumaSettings.getCurrentUserId());
syncIntent.putExtra(GoogleCloudService.TOKEN_KEY,
AikumaSettings.getCurrentUserToken());
syncIntent.putExtra(GoogleCloudService.ACCOUNT_KEY, AikumaSettings.getCurrentUserId());
syncIntent.putExtra(GoogleCloudService.TOKEN_KEY, AikumaSettings.getCurrentUserToken());
syncIntent.putStringArrayListExtra("downloadItems", mSharedFileCloudIds);
startService(syncIntent);
......@@ -543,8 +541,7 @@ public class CloudSearchActivity extends AikumaListActivity {
protected Boolean doInBackground(Void... params) {
DataStore gd;
try {
gd = new GoogleDriveStorage(mAccessToken,
AikumaSettings.ROOT_FOLDER_ID, AikumaSettings.CENTRAL_USER_ID);
gd = new GoogleDriveStorage(mAccessToken, AikumaSettings.ROOT_FOLDER_ID, AikumaSettings.CENTRAL_USER_ID);
} catch (DataStore.StorageException e) {
if(BuildConfig.DEBUG)Log.e(TAG, "Failed to initialize GoogleDriveStorage");
return false;
......@@ -578,15 +575,13 @@ public class CloudSearchActivity extends AikumaListActivity {
@Override
protected void onPostExecute(final Boolean result) {
if (result) {
Toast.makeText(CloudSearchActivity.this,
R.string.sample_is_downloaded,
Toast.LENGTH_LONG).show();
Toast.makeText(CloudSearchActivity.this, R.string.sample_is_downloaded, Toast.LENGTH_LONG).show();
/*
if(!isMediaPlayerReleased) {
setUpPlayer(mFile);
mediaPlayer.start();
}*/
} else {
//} else {
//Aikuma.showAlertDialog(getApplicationContext(), "Error in downloading a file");
}
......
......@@ -94,7 +94,7 @@ public class DebugInfo extends Activity {
mPref.edit()
.putString(AikumaSettings.SETTING_AUTH_TOKEN_KEY, toks[0])
.putString("id_token", toks[1])
.commit();
.apply();
displayTokens();
break;
default:
......@@ -158,11 +158,11 @@ public class DebugInfo extends Activity {
if (tokens == null)
if(BuildConfig.DEBUG)Log.i(TAG, "failed");
else {
final String[] toks = tokens;
final String[] toks = null;
mPref.edit()
.putString(AikumaSettings.SETTING_AUTH_TOKEN_KEY, tokens[0])
.putString("id_token", tokens[1])
.commit();
.apply();
new AsyncTask<Void,Void,Void>() {
@Override
......@@ -388,14 +388,13 @@ public class DebugInfo extends Activity {
StringBuffer hexString = new StringBuffer();
String prefix = "";
for (int i = 0; i < publicKey.length; i++) {
String appendString = Integer.toHexString(0xFF & publicKey[i]);
for(byte aPublicKey : publicKey) {
String appendString = Integer.toHexString(0xFF & aPublicKey);
if (appendString.length() == 1) hexString.append("0");
hexString.append(prefix);
hexString.append(appendString.toUpperCase());
prefix = ":";
}
return hexString.toString();
} catch (CertificateEncodingException e) {
e.printStackTrace();
......
......@@ -195,7 +195,7 @@ public class ElicitationMode extends AikumaActivity{
intent.putExtra(importFileName, mPath.getAbsolutePath());
if(BuildConfig.DEBUG)Log.i(TAG, "selected file: " + mPath.getAbsolutePath());
intent.putExtra(ELICITATION, true);
intent.putExtra(getString(R.string.selectedFileType), selectedFileType);
intent.putExtra("selectedFileType", selectedFileType);
startActivity(intent);
}
......
......@@ -26,7 +26,6 @@ import android.widget.VideoView;
import org.getalp.ligaikuma.lig_aikuma.Aikuma;
import org.getalp.ligaikuma.lig_aikuma.audio.InterleavedPlayer;
import org.getalp.ligaikuma.lig_aikuma.audio.Player;
import org.getalp.ligaikuma.lig_aikuma.audio.SimplePlayer;
import org.getalp.ligaikuma.lig_aikuma.audio.TranscriptPlayer;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.BuildConfig;
......
......@@ -108,7 +108,7 @@ public class ListenFragment extends Fragment implements OnClickListener {
isPlayed = false;
play ();
}
};
}
public void onStartTrackingTouch(SeekBar _seekBar) {};
});
seekBar.invalidate();
......
......@@ -8,7 +8,6 @@ import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.ThumbnailUtils;
import android.os.AsyncTask;
import android.os.Bundle;
......@@ -16,7 +15,6 @@ import android.provider.MediaStore;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.MediaController;
......@@ -102,7 +100,7 @@ public class RecordElicitation extends AikumaActivity {
recordUUID = UUID.randomUUID();
// retrieving metadata
prefsUserSession = getSharedPreferences(getString(R.string.userSession), MODE_PRIVATE);
prefsUserSession = getSharedPreferences("userSession", MODE_PRIVATE);
initSession();
switch (choiceMode) {
case ElicitationMode.TEXT_MODE:
......@@ -257,15 +255,16 @@ public class RecordElicitation extends AikumaActivity {
}
private void initBufferedWriter() throws FileNotFoundException {
bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(textFile, true)));
FileOutputStream fos;
fos = new FileOutputStream(textFile, true);
bufferedWriter = new BufferedWriter(new OutputStreamWriter(fos));
}
@SuppressWarnings("unchecked")
private void initSession() {
if (prefsUserSession.getBoolean(getString(R.string.sessionActive), false)) {
strFolderDate=prefsUserSession.getString(getString(R.string.sessionDate), "");
recordLang = new Language(prefsUserSession.getString(getString(R.string.language_name), ""),
prefsUserSession.getString(getString(R.string.languageCode), ""));
if (prefsUserSession.getBoolean("active", false)) {
strFolderDate=prefsUserSession.getString("date", "");
recordLang = new Language(prefsUserSession.getString("Language name", ""), prefsUserSession.getString("LanguageCode", ""));
try {
date = new SimpleDateFormat().parse(strFolderDate);
} catch (ParseException e) {
......@@ -273,17 +272,13 @@ public class RecordElicitation extends AikumaActivity {
e.printStackTrace();
}
SharedPreferences.Editor ed = prefsUserSession.edit();
ptrSelectedReference = prefsUserSession.getString(getString(R.string.sessionInputFile), "");
entityId = prefsUserSession.getInt(getString(R.string.currentLine), 0);
choiceMode = prefsUserSession.getInt(getString(R.string.selectedFileType), ElicitationMode.TEXT_MODE);
dirName = prefsUserSession.getString(getString(R.string.dirname), "");
recordingName = prefsUserSession.getString(getString(R.string.sessionOutputFile), "");
recordingName = prefsUserSession.getString(getString(R.string.sessionOutputFile), "");
ptrSelectedReference = prefsUserSession.getString("inputFile", "");
entityId = prefsUserSession.getInt("currentLine", 0);
choiceMode = prefsUserSession.getInt("selectedFileType", ElicitationMode.TEXT_MODE);
dirName = prefsUserSession.getString("dirname", "");
recordingName = prefsUserSession.getString("session_output_file", "");
if(BuildConfig.DEBUG)Log.d(TAG, "last saved recorded filename: " + recordingName);
ed.clear();
ed.commit();
prefsUserSession.edit().clear().apply();
try {
numberOfEntities = countNumberOfEntities();
......@@ -298,7 +293,7 @@ public class RecordElicitation extends AikumaActivity {
} else {
ptrSelectedReference = getIntent().getStringExtra(ElicitationMode.importFileName);
if(BuildConfig.DEBUG)Log.i(TAG, "Selected file: " + ptrSelectedReference);
choiceMode = getIntent().getIntExtra(getString(R.string.selectedFileType), 0);
choiceMode = getIntent().getIntExtra("selectedFileType", 0);
recordLang = MetadataSession.getMetadataSession().getRecordLanguage();
......@@ -326,6 +321,7 @@ 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();
......@@ -357,12 +353,13 @@ public class RecordElicitation extends AikumaActivity {
private void goToGoodPlaceInTextFile() {
if (choiceMode == ElicitationMode.TEXT_MODE){
String phrase;
for(int i = 0;i<entityId;) {
int i = 0;
while (i<entityId) {
try {
if(!((phrase = reader.readLine()) != null && (phrase.isEmpty() || phrase.split("##").length <= 1)) && phrase != null)
if(!((phrase = reader.readLine()) != null && (phrase.isEmpty() || phrase.split("##").length <= 1))&&phrase != null)
i++;
} catch (IOException e) {
e.printStackTrace();
e.printStackTrace();
}
}
}
......@@ -592,7 +589,7 @@ public class RecordElicitation extends AikumaActivity {
/**
* called when we want save a file.
* @return
* @return If record is saved
*/
private boolean saveRecording() {
if ((recorder != null && recorder.getFile().getPayloadSize() == 0) || recorder == null)
......@@ -654,7 +651,7 @@ public class RecordElicitation extends AikumaActivity {
}
} catch (IOException e) {
if(BuildConfig.DEBUG)Log.e(TAG, "error when saving the recording: " + e);
Toast.makeText(this, "An error occurred when saving the recording. Please try again.", Toast.LENGTH_LONG).show();
Toast.makeText(this, R.string.an_error_occurred_when_saving_the_recording_please_try_again, Toast.LENGTH_LONG).show();
return false;
}
return true;
......
......@@ -91,8 +91,6 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
private ArrayList<Language> selectedLanguages;
private String regionOrigin;
private String speakerName;
private String age;
private String msgError;
private String speakerNote;
private int speakerAge=0;
private int speakerGender=0;
......@@ -206,7 +204,7 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
/**
* Called when a user press the "Select from list" button
*
* @param _view
* @param _view No used
*/
public void onAddISOLanguageButton(View _view) {
Intent intent = new Intent(this, LanguageFilterListLIG.class);
......@@ -221,7 +219,7 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
* Called when a user press the "More Languages" button
* Update the view with a new field for inserting a new language
*
* @param _view
* @param _view No used
*/
@SuppressWarnings("ResourceType")
public void onClickMoreLanguages(View _view) {
......@@ -250,7 +248,7 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
TypedArray ta = obtainStyledAttributes(R.style.TextviewMetadata2, attrs);
String tsize = ta.getString(0); //fetching textSize from the style
if(BuildConfig.DEBUG)Log.i("Retrieved text:", tsize);
float textSize = Float.parseFloat(tsize.split("sp")[0]);
float textSize = Float.parseFloat(((tsize != null)?tsize.split("sp"):new String[0])[0]);
tv_otherLanguage.setTextSize(textSize); //set textSize
if(BuildConfig.DEBUG)Log.i("set textSize is:", Float.toString(textSize));
int tcolor = ta.getColor(1, Color.BLACK); //fetching color
......@@ -278,7 +276,7 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
//TextView tv_selectedSdLanguage = (TextView) findViewById(R.id.tv_selectedSecondLanguage);
TextView tv_selectedOtherLanguage = new TextView(l_parent.getContext());
RelativeLayout.LayoutParams tv_selected_params = (RelativeLayout.LayoutParams) new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
RelativeLayout.LayoutParams tv_selected_params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
tv_selected_params.addRule(RelativeLayout.RIGHT_OF, tv_otherLanguage.getId());
tv_selectedOtherLanguage.setLayoutParams(tv_selected_params);
//ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) tv_selectedSdLanguage.getLayoutParams();
......@@ -287,7 +285,7 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
//setTextSize of the TextView (tv_selectedOtherLanguage.setTextSize(20))
TypedArray ta_tvSelectedLang = obtainStyledAttributes(R.style.TextviewSelectedLanguage, attrs);
String textSizetvSelectedLang = ta_tvSelectedLang.getString(0);
float txtSzetv = Float.parseFloat(textSizetvSelectedLang.split("sp")[0]);
float txtSzetv = Float.parseFloat(((textSizetvSelectedLang != null)?textSizetvSelectedLang.split("sp"):new String[0])[0]);
tv_selectedOtherLanguage.setTextSize(txtSzetv); //set textSize of the TextView
ta_tvSelectedLang.recycle();
tv_selectedOtherLanguage.setId(rl_more.getId() + 10);
......@@ -301,7 +299,7 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
TypedArray ta_btnChooseLang = obtainStyledAttributes(R.style.ButtonChooseLanguage, attrs);
String btn_textsize = ta_btnChooseLang.getString(0);
if(BuildConfig.DEBUG)Log.i("Language TextSize:", btn_textsize);
btn_otherLanguage.setTextSize(Float.parseFloat(btn_textsize.split("sp")[0])); //set textSize of the button
btn_otherLanguage.setTextSize(Float.parseFloat(((btn_textsize != null)?btn_textsize.split("sp"):new String[0])[0])); //set textSize of the button
ta_btnChooseLang.recycle();
Button btn_selectLanguageFromList = (Button) findViewById(R.id.btn_chooseLanguage);
RelativeLayout.LayoutParams button_params = (RelativeLayout.LayoutParams)btn_selectLanguageFromList.getLayoutParams();
......@@ -320,7 +318,7 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
* Called when a user press the "Less Languages" button
* Update the view with a suppression of the last added language
*
* @param _view
* @param _view No used
*/
public void onClickLessLanguages(View _view) {
LinearLayout l_parent = (LinearLayout) findViewById(R.id.layout_languages); //Layout parent
......@@ -334,10 +332,10 @@ public class RecordingMetadataLig extends AikumaActivity implements OnClickListe
/**
* Called when a user press the Ok button
*
* @param _view
* @param _view No used
*/