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.
......
......@@ -4,8 +4,6 @@ package org.getalp.ligaikuma.lig_aikuma;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
......@@ -162,52 +160,33 @@ public class ModeSelection extends Activity implements OnClickListener{
startActivity(new Intent(this, ShareFileActivity.class));
}
// START DIALOG DECLARATION
@SuppressLint("InflateParams")
public void showSessionDialog() {
new UserSessionDiaglogFragment().show(getFragmentManager(), "SessionDialogFragment");
}
@SuppressLint("ValidFragment")
public class UserSessionDiaglogFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
View sessionView = getLayoutInflater().inflate(R.layout.session_dialog, null);
LinearLayout ll = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.session_dialog, null);
setDialogDetails((LinearLayout) sessionView);
setDialogDetails(ll);
builder.setView(ll)
new AlertDialog.Builder(this)
.setView(sessionView)
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@Override public void onClick(DialogInterface dialog, int which) {
if(BuildConfig.DEBUG)Log.i(TAG,"yes, retrieve the session");
retrieveSession();
}
})
}})
.setNegativeButton(R.string.no_but_keep_files, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@Override public void onClick(DialogInterface dialog, int which) {
if(BuildConfig.DEBUG)Log.i(TAG,"no don't retrieve the session but keep files");
prefsUserSession = getSharedPreferences("userSession", MODE_PRIVATE);
//clear sharedPrefs
ed.clear().commit();
}
})
}})
.setNeutralButton(R.string.no_and_erase_files, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@Override public void onClick(DialogInterface dialog, int which) {
if(BuildConfig.DEBUG)Log.i(TAG,"no don't retrieve the session and erase files");
//remove files
eraseFiles();
//clear sharedPrefs
// ed.putBoolean(getString(R.string.sessionActive), false);
ed.clear().commit();
}
});
return builder.create();
}})
.show();
}
public void retrieveSession()
......@@ -215,56 +194,41 @@ public class ModeSelection extends Activity implements OnClickListener{
String mode = prefsUserSession.getString("mode", null);
if(BuildConfig.DEBUG)Log.d(TAG, "mode retrieval: "+mode);
if(mode == null || mode.compareToIgnoreCase(CheckTranscription.TAG) == 0)
startActivity(new Intent(getActivity(), CheckTranscription.class));
startActivity(new Intent(ModeSelection.this, CheckTranscription.class));
else if (mode.compareToIgnoreCase(CheckWordVariant.TAG) == 0)
startActivity(new Intent(getActivity(), CheckWordVariant.class));
startActivity(new Intent(ModeSelection.this, CheckWordVariant.class));
else if (mode.compareToIgnoreCase(ThumbRespeakActivityLig.TAG) == 0)
startActivity(new Intent(getActivity(), ThumbRespeakActivityLig.class));
startActivity(new Intent(ModeSelection.this, ThumbRespeakActivityLig.class));
else if (mode.compareToIgnoreCase(RecordElicitation.TAG) == 0)
startActivity(new Intent(getActivity(), RecordElicitation.class));
startActivity(new Intent(ModeSelection.this, RecordElicitation.class));
else
Toast.makeText(getActivity(), "An error ocurred. The session could not be retrieved", Toast.LENGTH_LONG).show();
Toast.makeText(this, "An error ocurred. The session could not be retrieved", Toast.LENGTH_LONG).show();
}
public void setDialogDetails(LinearLayout ll) {
// retrieve prefs values and store display them on popup menu
/*
* *** convert internal mode/submode to display mode/submode following the rule: ***
* internal mode / internal submode ----------> display mode / display submode
* CheckWordVariant / null ----------> Check mode / CheckWordVariant
* CheckTranscription / null ----------> Check mode / CheckTranscription
* RecordElicitation / text ----------> Elicitation / text
* "" / image ----------> "" / image
* "" / video ----------> "" / video
* ThumbRespeakActivityLig / respeaking ----------> Respeaking / null
* "" / translation ----------> Translation / null
*/
String mode = prefsUserSession.getString("mode", "undefined");
String modeDialog = null, submodeDialog = null;
if (mode.compareToIgnoreCase(CheckWordVariant.TAG) == 0 || mode.compareTo(CheckTranscription.TAG) == 0)
{
modeDialog ="Check mode";
submodeDialog = (mode.compareToIgnoreCase(CheckWordVariant.TAG) == 0) ? CheckWordVariant.TAG : CheckTranscription.TAG;
;
((TextView) ll.findViewById(R.id.session_submode)).setText(
(mode.compareToIgnoreCase(CheckWordVariant.TAG) == 0) ? CheckWordVariant.TAG : CheckTranscription.TAG);
}
else if (mode.compareToIgnoreCase(RecordElicitation.TAG) == 0)
{
String submode = prefsUserSession.getString("submode", "undefined");
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";
String submode = prefsUserSession.getString("submode", "text");
((TextView) ll.findViewById(R.id.session_mode)).setText("Elicitation");
((TextView) ll.findViewById(R.id.session_submode)).setText(submode.toLowerCase());
}
else if (mode.compareToIgnoreCase(ThumbRespeakActivityLig.TAG) == 0)
{
String submode = prefsUserSession.getString("submode", "undefined");
if (submode.compareToIgnoreCase("Respeaking") == 0) modeDialog = "Respeaking";
else if (submode.compareToIgnoreCase("translation") == 0) modeDialog = "Translation";
submodeDialog = "None";
if(submode.compareToIgnoreCase("Respeaking") == 0)
((TextView) ll.findViewById(R.id.session_mode)).setText("Respeaking");
else if(submode.compareToIgnoreCase("translation") == 0)
((TextView) ll.findViewById(R.id.session_mode)).setText("Translation");
((TextView) ll.findViewById(R.id.session_submode)).setText("None");
}
((TextView) ll.findViewById(R.id.session_mode)).setText(modeDialog);
((TextView) ll.findViewById(R.id.session_submode)).setText(submodeDialog);
// display date in a more convenient way
try {
......@@ -286,7 +250,6 @@ public class ModeSelection extends Activity implements OnClickListener{
MediaPlayerFactory._currentReadFile = FileIO.getOwnerPath()+"/recordings/"+file+"/"+file+".wav";
if(BuildConfig.DEBUG)Log.d(TAG,MediaPlayerFactory._currentReadFile);
}
}
public void eraseFiles() {
String savedMode = prefsUserSession.getString("mode", null),
......@@ -352,6 +315,11 @@ public class ModeSelection extends Activity implements OnClickListener{
//}
Toast.makeText(this, R.string.session_and_files_erased, Toast.LENGTH_LONG).show();
// END OF DIALOG DECLARATION
}
}
......@@ -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.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