Commit b11287c3 authored by mistermad's avatar mistermad

- Deleting the session backup in elicitation mode if it in step one

- Changing the display of the distinction between file/folder translated and respected in the file exploreur.
- Fixed a bug corrupting files when using the undo button in elicitation mode.
- Fixed bug on dialog boxes at the end of the metadata entry
- Fixed various display bugs (RespeakingSelection, CheckTranscrition, CheckWordVariant, LanguageFilterList, RespeakingMetadataLig, RecordingMetadataLig...)
parent feababba
......@@ -7,7 +7,7 @@ import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
/**
* Instrumentation test, which will execute on an Android device.
......
......@@ -8,6 +8,7 @@
<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"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
......
......@@ -14,6 +14,7 @@ import android.net.NetworkInfo;
import android.os.Build;
import android.preference.PreferenceManager;
import android.provider.Settings.Secure;
import android.support.annotation.RequiresApi;
import org.getalp.ligaikuma.lig_aikuma.model.FileModel;
import org.getalp.ligaikuma.lig_aikuma.model.Language;
......@@ -28,9 +29,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import android.support.annotation.RequiresApi;
/**
* Offers a collection of static methods that require a context independently
* of an Activity.
......
......@@ -168,7 +168,7 @@ public class Mapper {
originalEndOfSegment = null;
return true;
}
/** Remap an existing map file with index file, used the create a no speak map file
/** Remap an existing map file with index file, used the create a temp no speak map file
*
* @param index index used for remap
*/
......
......@@ -4,11 +4,6 @@
*/
package org.getalp.ligaikuma.lig_aikuma.audio.record;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.io.File;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.util.Log;
......@@ -16,6 +11,11 @@ import android.util.Log;
import org.getalp.ligaikuma.lig_aikuma.audio.Sampler;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.BuildConfig;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
/**
* A writer that can handle PCM/WAV files.
......
......@@ -182,13 +182,9 @@ public class ThresholdSpeechAnalyzer extends Analyzer {
//
afterBuffer = Arrays.copyOf(afterBuffer, afterBuffer.length + buffer.length);
// Copy the buffer to avoid reference problems.
//
short[] copiedBuffer = Arrays.copyOf(buffer, buffer.length);
// Add the copied current buffer onto the end.
//
System.arraycopy(copiedBuffer, 0, afterBuffer, offset, buffer.length);
System.arraycopy(Arrays.copyOf(buffer, buffer.length), 0, afterBuffer, offset, buffer.length);
}
//TODO Duplicate method. See addToAfterBuffer.
......@@ -204,13 +200,9 @@ public class ThresholdSpeechAnalyzer extends Analyzer {
//
onsetBuffer = Arrays.copyOf(onsetBuffer, onsetBuffer.length + buffer.length);
// Copy the buffer to avoid reference problems.
//
short[] copiedBuffer = Arrays.copyOf(buffer, buffer.length);
// Add the copied current buffer onto the end.
//
System.arraycopy(copiedBuffer, 0, onsetBuffer, offset, buffer.length);
System.arraycopy(Arrays.copyOf(buffer, buffer.length), 0, onsetBuffer, offset, buffer.length);
}
/** Clear the before speech buffer. */
......
......@@ -181,13 +181,14 @@ 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
......@@ -203,12 +204,15 @@ public class RecordingLig extends Recording {
}
JSONObject encodedRecording = this.encode();
Log.d(TAG, "A3");
// Write the json metadata.
File metadataFile = new File(getIndividualRecordingPath(), this.name + METADATA_SUFFIX);
File metadataFile = new File(dir.toString(), this.name + METADATA_SUFFIX);
FileIO.writeJSONObject(metadataFile,encodedRecording);
Log.i(TAG, "Saved metadata file to " + metadataFile.getAbsolutePath());
Log.i(TAG, "Saved metadata file to " + metadataFile.getAbsolutePath());
Log.d(TAG, "A4");
}
/**
......@@ -276,7 +280,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");
}
......
......@@ -46,7 +46,6 @@ public class AddSpeakerActivity1 extends AikumaActivity {
textField.addTextChangedListener(new TextWatcher(){
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
if(s.toString().length() > 0) {
ImageButton okButton =
(ImageButton) findViewById(R.id.okButton1);
......@@ -74,7 +73,6 @@ public class AddSpeakerActivity1 extends AikumaActivity {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if((event.getAction() == KeyEvent.ACTION_DOWN &&
(event.getKeyCode() == KeyEvent.KEYCODE_ENTER))) {
onOkButtonPressed(null);
......
......@@ -12,11 +12,10 @@ import android.provider.MediaStore;
import android.view.View;
import android.widget.TextView;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.R;
import org.getalp.ligaikuma.lig_aikuma.model.Language;
import org.getalp.ligaikuma.lig_aikuma.util.ImageUtils;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.R;
import java.io.File;
import java.util.ArrayList;
import java.util.UUID;
......
......@@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.FragmentTransaction;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
......
package org.getalp.ligaikuma.lig_aikuma.ui;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import org.getalp.ligaikuma.lig_aikuma.ModeSelection;
import org.getalp.ligaikuma.lig_aikuma.audio.SimplePlayer;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.BuildConfig;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.R;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
......@@ -34,6 +17,23 @@ import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import org.getalp.ligaikuma.lig_aikuma.ModeSelection;
import org.getalp.ligaikuma.lig_aikuma.audio.SimplePlayer;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.BuildConfig;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.R;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class CheckTranscription extends AikumaActivity {
public static final String TAG = "CheckTranscription";
......@@ -149,6 +149,7 @@ public class CheckTranscription extends AikumaActivity {
* find a way to fix it for phones AND for tablets
*/
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
transcriptOK = new CheckBox(this);
......@@ -253,6 +254,7 @@ public class CheckTranscription extends AikumaActivity {
* find a way to fix it for phones AND for tablets
*/
int tsizepx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 25, getResources().getDisplayMetrics());
if((getResources().getBoolean(R.bool.is_small_screen))) tsizepx*=0.5;
//transcription + checkbox
transcriptOK = new CheckBox(this);
transcriptOK.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
......
package org.getalp.ligaikuma.lig_aikuma.ui;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Bundle;
......@@ -28,6 +16,18 @@ import android.widget.Toast;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.BuildConfig;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.R;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class CheckWordVariant extends AikumaActivity {
public static final String TAG = "CheckWordVariant";
......@@ -127,18 +127,19 @@ public class CheckWordVariant extends AikumaActivity {
String[] variantlist = wordlist[1].split(" ; ");
CheckBox variant;
checkboxCount=0;
final float scale = getResources().getDisplayMetrics().density;
int padding_in_px = (int) (10 * scale + 0.5f);
int padding_in_px = (int) (10 * getResources().getDisplayMetrics().density + 0.5f);
/** 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
*/
int tsizepx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 25, getResources().getDisplayMetrics());
if((getResources().getBoolean(R.bool.is_small_screen))) tsizepx*=0.5;
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);
......@@ -215,6 +216,7 @@ public class CheckWordVariant extends AikumaActivity {
* find a way to fix it for phones AND for tablets
*/
int tsizepx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 25, getResources().getDisplayMetrics());
if((getResources().getBoolean(R.bool.is_small_screen))) tsizepx*=0.5;
for (String element : variantlist){
//variant + checkbox
variant = new CheckBox(this);
......
......@@ -2,10 +2,10 @@ package org.getalp.ligaikuma.lig_aikuma.ui;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.os.Environment;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -32,7 +32,6 @@ import static org.getalp.ligaikuma.lig_aikuma.ui.ElicitationMode.importFileName;
public class ElicitationFileSearch extends AikumaActivity
{
public static final String TAG = "ElicitationFileSearch";
private static String _current_folder_position;
......@@ -55,6 +54,10 @@ public class ElicitationFileSearch extends AikumaActivity
_mode = getIntent().getIntExtra("mode",ElicitationMode.TEXT_MODE);
// Force portrait on phone
if(getResources().getBoolean(R.bool.is_small_screen))
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
if(!_is_init)
{
_nav_list = new ArrayList<>();
......@@ -90,7 +93,6 @@ public class ElicitationFileSearch extends AikumaActivity
* Loads the list of files in the specified directory into mFileList
*
* @param folder The directory to go
* for.
*/
private void loadFileList(String folder)
{
......@@ -116,6 +118,10 @@ public class ElicitationFileSearch extends AikumaActivity
_path_view.setText(folder);
}
/** Back on parent folder, not back if parent is Environment.getExternalStorageDirectory()
*
* @param v Item where the user clicked
*/
public void onBackFolderClick(View v)
{
if(_current_folder_position.equals(Environment.getExternalStorageDirectory().toString()+"/"))
......@@ -125,11 +131,15 @@ public class ElicitationFileSearch extends AikumaActivity
loadFileList(r);
}
/** Verify if it's valid file and go on next step
*
* @param filePath Open file, it's directory or .txt file
*/
public void selectFile(File filePath)
{
if(_mode == ElicitationMode.TEXT_MODE && !isValideElicitFile(filePath))
{
Toast.makeText(this, R.string.this_file_is_not_valid_for_an_elicitation, Toast.LENGTH_LONG).show();
Toast.makeText(this, R.string.this_file_is_not_valid_for_an_elicitation, Toast.LENGTH_SHORT).show();
return;
}
Intent intent = new Intent(this, RecordingMetadataLig.class);
......@@ -139,6 +149,10 @@ public class ElicitationFileSearch extends AikumaActivity
startActivity(intent);
}
/** Verify if text file is valid for text elicitation
* @param textFile Verified text file
* @return True if it's valid text file, false otherwise
*/
public boolean isValideElicitFile(File textFile)
{
try {
......@@ -174,7 +188,6 @@ public class ElicitationFileSearch extends AikumaActivity
sh.name.setText(name_f);
name_f = _current_folder_position+name_f;
Log.d(TAG, name_f);
File f = new File(name_f);
if(f.isDirectory())
{
......@@ -235,6 +248,11 @@ public class ElicitationFileSearch extends AikumaActivity
ImageView icon;
}
/** Verify if folder constrain 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.
*/
public static boolean containsFile(File f, String[] fileTypes)
{
String[] l = f.list();
......
......@@ -17,8 +17,6 @@ import org.getalp.ligaikuma.lig_aikuma.Aikuma;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.R;
import org.getalp.ligaikuma.lig_aikuma.model.Language;
import java.util.List;
/**
* @author Oliver Adams <oliver.adams@gmail.com>
* @author Florian Hanke <florian.hanke@gmail.com>
......
......@@ -139,9 +139,13 @@ public class ListenFragment extends Fragment implements OnClickListener {
@Override
public void onClick(View v) {
if(v != playPauseButton) return;
if(otherPlayer != null) otherPlayer.setEnabled(!isEnabled);
if(player.isPlaying()) pause();
else play();
if(player.isPlaying()) {
pause();
if(otherPlayer != null) otherPlayer.setEnabled(true);
return;
}
if(otherPlayer != null) otherPlayer.setEnabled(false);
play();
}
/**
......@@ -188,7 +192,7 @@ public class ListenFragment extends Fragment implements OnClickListener {
}
});
seekBarThread.start();
if(isEnabled)playPauseButton.setImageResource(R.drawable.pause_g);
playPauseButton.setImageResource(R.drawable.pause_g);
}
/**
......@@ -273,7 +277,6 @@ public class ListenFragment extends Fragment implements OnClickListener {
* @param isEnabled true: enable, false: disable
*/
private void setEnabled(boolean isEnabled) {
this.isEnabled = isEnabled;
playPauseButton.setEnabled(isEnabled);
playPauseButton.setImageResource((isEnabled)?R.drawable.play_g:R.drawable.play_grey);
}
......@@ -302,5 +305,4 @@ public class ListenFragment extends Fragment implements OnClickListener {
private Thread seekBarThread;
private View inflatedView;
private ListenFragment otherPlayer;
private boolean isEnabled;
}
......@@ -20,7 +20,6 @@ import org.getalp.ligaikuma.lig_aikuma.util.AikumaSettings;
import java.io.IOException;
;
/**
* Class that unifies some inter-activity navigation code.
......@@ -112,8 +111,7 @@ public class MenuBehaviour {
return true;
case R.id.cloud_sync_menu:
((MainActivity)activity).syncRefresh(true);
//intent = new Intent(activity, CloudSyncSettingsActivity.class);
//activity.startActivity(intent);
//activity.startActivity(new Intent(activity, CloudSyncSettingsActivity.class));
return true;
case R.id.cloud_sync_setting_menu:
activity.startActivity(new Intent(activity, CloudSettingsActivity.class));
......@@ -155,7 +153,7 @@ public class MenuBehaviour {
return true;
case R.id.record:
if(AikumaSettings.getCurrentUserId() == null)
Aikuma.showAlertDialog(activity, "You need to select an account to make a recording");
Aikuma.showAlertDialog(activity, "You need to select an account to make a recording");
else activity.startActivity(new Intent(activity, RecordActivity.class));
return true;
case R.id.help:
......
......@@ -221,8 +221,8 @@ public class RecordActivity extends AikumaActivity {
// Maybe make a recording metadata file that refers to the error so
// that the audio can be salvaged.
}
Double latitude = MainActivity.locationDetector.getLatitude();
Double longitude = MainActivity.locationDetector.getLongitude();
Double latitude = MainActivity.locationDetector.getLatitude(),
longitude = MainActivity.locationDetector.getLongitude();
Intent intent = new Intent(this, RecordingMetadataActivity1.class);
intent.putExtra("uuidString", soundUUID.toString());
......
......@@ -22,7 +22,6 @@ import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.R;
import org.getalp.ligaikuma.lig_aikuma.model.Language;
import org.getalp.ligaikuma.lig_aikuma.model.Recording;
import org.getalp.ligaikuma.lig_aikuma.model.RecordingLig;
import org.getalp.ligaikuma.lig_aikuma.model.SpeakerProfile;
import org.getalp.ligaikuma.lig_aikuma.util.AikumaSettings;
import org.getalp.ligaikuma.lig_aikuma.util.FileIO;
import org.getalp.ligaikuma.lig_aikuma.util.PDFBuilder;
......
......@@ -206,7 +206,8 @@ public class RecordElicitation extends AikumaActivity {
String phrase;
while((phrase = reader.readLine()) != null && (phrase.isEmpty() || phrase.split("##").length <= 1));
if(phrase == null) { throw new IOException("Empty text file"); }
if(phrase.matches("##$")) phrase+=" ";
String[] phrasePair = phrase.split("##");
((TextView) findViewById(R.id.tv_elicit_phrase)).setText(phrasePair[0]);
((TextView) findViewById(R.id.tv_orig_phrase)).setText(phrasePair[1]);
......@@ -406,12 +407,9 @@ public class RecordElicitation extends AikumaActivity {
while((phrase = reader.readLine()) != null && (phrase.isEmpty() || phrase.split("##").length <= 1));
if (phrase == null) { throw new IOException("End of text file reached."); }
String[] phrasePair = phrase.split("##");
TextView tvFrPhrase = (TextView) findViewById(R.id.tv_elicit_phrase);
tvFrPhrase.setText(phrasePair[0]);
tvFrPhrase = (TextView) findViewById(R.id.tv_orig_phrase);
tvFrPhrase.setText(phrasePair[1]);
TextView tv = (TextView) findViewById(R.id.phrase_x);
tv.setText("Phrase" + (entityId+1));
((TextView) findViewById(R.id.tv_elicit_phrase)).setText(phrasePair[0]);
((TextView) findViewById(R.id.tv_orig_phrase)).setText(phrasePair[1]);
((TextView) findViewById(R.id.phrase_x)).setText("Phrase" + (entityId+1));
break;
case ElicitationMode.IMAGE_MODE:
loadImage();
......@@ -759,70 +757,63 @@ public class RecordElicitation extends AikumaActivity {