Commit 7bca1f98 authored by CallisteHanriat's avatar CallisteHanriat

Modify the countLine function + delete one preview file in RecordingLig's write() function

Delete progressbar on thumbRespeakFragment + apply countLineNumber for all files which it needed
Adding Undo button on ThumbRespeakFragment

remove thread used to update every 0.001s for ThumbRespeakFragment

put textview update
parent b33e4a2d
......@@ -125,7 +125,7 @@
android:id="@+id/check_phrase_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:text="0"
/>
<TextView
......
......@@ -103,7 +103,7 @@
android:id="@+id/check_line_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:text="0"
/>
<TextView
......
......@@ -5,69 +5,64 @@
android:layout_height="fill_parent"
>
<LinearLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|fill_horizontal"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="0.5">
<TextView
android:id="@+id/respeak_current_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0s"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="0.5">
<TextView
android:id="@+id/respeak_current_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0s"
/>
<TextView
android:id="@+id/respeak_total_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/0s" />
<TextView
android:id="@+id/respeak_total_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/0s" />
</LinearLayout>
<view class="org.lp20.aikuma.ui.InterleavedSeekBar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:id="@+id/seek_progression"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxHeight="3dp"
/>
</LinearLayout>
<View
android:id="@+id/view1"
android:layout_width="0.2dp"
android:layout_height="40dp"
android:visibility="visible"
android:background="@android:color/darker_gray"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="0.5">
<View
android:id="@+id/view1"
android:layout_width="0.2dp"
android:layout_height="40dp"
android:visibility="visible"
android:background="@android:color/darker_gray"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="0.5">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/respeak_previous_segment" />
<FrameLayout
android:id="@+id/respeak_latest_segment_player"
android:layout_width="fill_parent"
android:layout_height="match_parent">
</FrameLayout>
</LinearLayout>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/respeak_previous_segment" />
<FrameLayout
android:id="@+id/respeak_latest_segment_player"
android:layout_width="fill_parent"
android:layout_height="match_parent">
</FrameLayout>
</LinearLayout>
</LinearLayout>
<!--
<Button
android:id="@+id/respeak_delete_segment"
......@@ -79,7 +74,6 @@
android:onClick="onClickDeleteSegment" />
-->
</LinearLayout>
<view class="org.lp20.aikuma.ui.InterleavedSeekBar"
style="@android:style/Widget.ProgressBar.Horizontal"
......@@ -88,14 +82,31 @@
android:layout_height="32dp"
android:maxHeight="3dp"
/>
<ImageButton
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:text="@string/undo"
android:layout_weight="0.5"
android:id="@+id/undoButton"
/>
<ImageButton
android:id="@+id/saveButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerInside"
android:layout_weight="0.5"
android:src="@drawable/ok_48"
android:onClick="onSaveRespeakingButton"
/>
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
......
......@@ -116,7 +116,7 @@
android:onClick="onValidate"
android:src="@drawable/ok_32" />
<LinearLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
......@@ -125,7 +125,7 @@
android:id="@+id/check_phrase_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:text="0"
/>
<TextView
......
......@@ -102,6 +102,33 @@
android:layout_weight="2"
android:onClick="onValidate"
android:src="@drawable/ok_32" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/check_line_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
/>
<TextView
android:id="@+id/check_total_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" / " />
<view class="org.lp20.aikuma.ui.InterleavedSeekBar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:id="@+id/seek_check_progression"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxHeight="3dp"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
\ No newline at end of file
......@@ -27,15 +27,7 @@
android:id="@+id/respeak_total_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/0s" />
<view class="org.lp20.aikuma.ui.InterleavedSeekBar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:id="@+id/seek_progression"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxHeight="3dp"
/>
android:text="/0s" />
</LinearLayout>
......@@ -90,14 +82,31 @@
android:layout_height="32dp"
android:maxHeight="3dp"
/>
<ImageButton
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:text="undo"
android:layout_weight="0.5"
android:id="@+id/undoButton"
/>
<ImageButton
android:id="@+id/saveButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerInside"
android:layout_weight="0.5"
android:src="@drawable/ok_48"
android:onClick="onSaveRespeakingButton"
/>
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
......
......@@ -22,6 +22,7 @@
</string>
<string name="add_iso_language">Add language from list </string>
<string name="add_custom_language">Add Custom Language </string>
<string name="undo">Undo</string>
<string name="take_photo">Take photo (necessary)</string>
<string name="thumb_respeaking">Thumb commentary</string>
<string name="phone_respeaking">Voice-activated commentary</string>
......
......@@ -180,17 +180,22 @@ public class RecordingLig extends Recording {
}
// if the recording is original
/*if (isOriginal()) {
if (isOriginal()) {
// Import the sample wave file into the new recording directory
importWav(recordingUUID + SAMPLE_SUFFIX, PRVW_WAV_EXT);
} else {
File wavFile = new File(getNoSyncRecordingsPath(), recordingUUID + SAMPLE_SUFFIX);
FileIO.delete(wavFile);
Log.d("file deleted", wavFile.getName());
}else {
// Try and import the mapping file
importMapping(recordingUUID, getId());
// Write the index file
super.index(sourceVerId, getVersionName() + "-" + getId());
}*/
}
JSONObject encodedRecording = this.encode();
......
......@@ -51,7 +51,7 @@ public class CheckTranscription extends AikumaActivity {
private String date;
private SharedPreferences prefsUserSession;
private String externalStoragePath = Environment.getExternalStorageDirectory().getPath();
private String dataPath = externalStoragePath+"/aikuma/check_transcription_mode/";
private String dataPath = externalStoragePath+"/Download/";
private InterleavedSeekBar progressBar;
private ListenFragment fragment;
......@@ -144,7 +144,6 @@ public class CheckTranscription extends AikumaActivity {
transcriptOK.setTypeface(Typeface.SERIF);
transcriptOK.setText(transcription);
llparent.addView(transcriptOK);
nbReadLines++;
Log.i(TAG, "current line: " + nbReadLines);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
......@@ -198,29 +197,20 @@ public class CheckTranscription extends AikumaActivity {
/**
* called by constructor to set the number of lines in the file
* @return the number of lines in a txt file.
* @return the number of lines in good format in a txt file.
* @throws IOException if the file cannot be read
*/
public int countNumberOfLines() throws IOException {
InputStream is;
is = new BufferedInputStream(new FileInputStream(this.transcripTextFile));
try {
byte[] c = new byte[8192];
int count = 0;
int readChars = 0;
boolean empty = true;
while ((readChars = is.read(c)) != -1) {
empty = false;
for (int i = 0; i < readChars-1; ++i) {
if (c[i] == ':') {
++count;
}
}
}
return (count == 0 && !empty) ? 1 : count;
} finally {
is.close();
}
int nbLine = 0;
boolean finFichier = false;
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(transcripTextFile)));
String phrase;
while ((phrase = bufferedReader.readLine()) != null) {
if (!phrase.isEmpty() && phrase.split(" : ").length > 1)
nbLine++;
}
return nbLine;
}
......@@ -230,6 +220,7 @@ public class CheckTranscription extends AikumaActivity {
String line;
while ((line = reader.readLine()) != null && (line.isEmpty() || line.split(" : ").length <= 1)) { continue; }
if (line == null) { throw new IOException("Empty text file"); }
nbReadLines++;
//split on line. group1=id, group2=transcription
String[] splittedline = line.split(" : ");
//group1
......@@ -258,7 +249,7 @@ public class CheckTranscription extends AikumaActivity {
transcriptOK.setTypeface(Typeface.SERIF);
transcriptOK.setText(transcription);
llparent.addView(transcriptOK);
nbReadLines++;
Log.i(TAG, "current line: " + nbReadLines);
} catch (IOException e) {
e.printStackTrace();
......
......@@ -134,9 +134,6 @@ public class CheckWordVariant extends AikumaActivity {
TextView tv_total = (TextView) findViewById(R.id.check_total_number);
tv_total.setText(" / " + totalNumberOfExpressions);
TextView tv = (TextView) findViewById(R.id.check_line_number);
tv.setText("" + nbReadLines);
LinearLayout llparent = (LinearLayout) findViewById(R.id.ll_variant);
llparent.removeAllViews();
......@@ -164,7 +161,6 @@ public class CheckWordVariant extends AikumaActivity {
* TODO 3 radiogroup avec des radio buttons plutôt qu'une... + associer un label (=variant)
*/
nbReadLines++;
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
Log.e(TAG,"text file could not be found: " + e1);
......@@ -209,6 +205,7 @@ public class CheckWordVariant extends AikumaActivity {
String line;
while ((line = reader.readLine()) != null && (line.isEmpty() || line.split(", ").length <= 1)) { continue; }
if (line == null) { throw new IOException("Empty text file"); }
nbReadLines++;
//split on line. group1=word, group2=variant(s)
String[] wordlist = line.split(", ");
TextView lexeme = (TextView) findViewById(R.id.tv_verif_lexeme);
......@@ -244,7 +241,7 @@ public class CheckWordVariant extends AikumaActivity {
/*
* TODO si rien n'est coché, désactiver le bouton next
*/
nbReadLines++;
} catch (IOException e) {
Log.e(TAG,"No more words to display or an error occurred: " + e);
try {
......@@ -261,29 +258,20 @@ public class CheckWordVariant extends AikumaActivity {
/**
* called by constructor to set the number of lines in the file
* @return the number of lines in a txt file.
* @return the number of lines in good format in a txt file.
* @throws IOException if the file cannot be read
*/
public int countNumberOfLines() throws IOException {
InputStream is;
is = new BufferedInputStream(new FileInputStream(this.variantTextFile));
try {
byte[] c = new byte[8192];
int count = 0;
int readChars = 0;
boolean empty = true;
while ((readChars = is.read(c)) != -1) {
empty = false;
for (int i = 0; i < readChars-1; ++i) {
if (c[i] == ',') {
++count;
}
}
}
return (count == 0 && !empty) ? 1 : count;
} finally {
is.close();
}
int nbLine = 0;
boolean finFichier = false;
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(variantTextFile)));
String phrase;
while ((phrase = bufferedReader.readLine()) != null) {
if (!phrase.isEmpty() && phrase.split(", ").length > 1)
nbLine++;
}
return nbLine;
}
public void onValidate(View _view) {
......
......@@ -359,29 +359,20 @@ public class RecordElicitation extends AikumaActivity {
/**
* called by constructor to set the number of lines in the file
* @return the number of lines in a txt file.
* @return the number of lines in good format in a txt file.
* @throws IOException if the file cannot be read
*/
public int countNumberOfLines() throws IOException {
InputStream is;
is = new BufferedInputStream(new FileInputStream(this.eliciTextFile));
try {
byte[] c = new byte[8192];
int count = 0;
int readChars = 0;
boolean empty = true;
while ((readChars = is.read(c)) != -1) {
empty = false;
for (int i = 0; i < readChars-1; ++i) {
if (c[i] == '#' && c[i+1] == '#') {
++count;
}
}
}
return (count == 0 && !empty) ? 1 : count;
} finally {
is.close();
}
int nbLine = 0;
boolean finFichier = false;
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(eliciTextFile)));
String phrase;
while ((phrase = bufferedReader.readLine()) != null) {
if (!phrase.isEmpty() && phrase.split("##").length > 1)
nbLine++;
}
return nbLine;
}
public void onBackPressed(View v) {
......
......@@ -59,7 +59,6 @@ public class ThumbRespeakFragment extends Fragment {
installButtonBehaviour(v);
textTimeProgression = (TextView) v.findViewById(R.id.respeak_current_time);
totalTime = (TextView) v.findViewById(R.id.respeak_total_time);
seekProgression = (InterleavedSeekBar) v.findViewById(R.id.seek_progression);
seekBar = (InterleavedSeekBar) v.findViewById(R.id.InterleavedSeekBar);
seekBar.setOnSeekBarChangeListener(
new SeekBar.OnSeekBarChangeListener() {
......@@ -75,23 +74,7 @@ public class ThumbRespeakFragment extends Fragment {
originalProgress = seekBar.getProgress();
};
});
seekProgression.setOnSeekBarChangeListener(
new SeekBar.OnSeekBarChangeListener() {
int originalProgress;
public void onProgressChanged(SeekBar seekBar,
int progress, boolean fromUser) {
if (fromUser) {
seekBar.setProgress(originalProgress);
}
}
public void onStopTrackingTouch(SeekBar _seekBar) {};
public void onStartTrackingTouch(SeekBar _seekBar) {
originalProgress = seekBar.getProgress();
};
});
seekProgression.invalidate();
seekBar.invalidate();
FragmentTransaction ft = getFragmentManager().beginTransaction();
......@@ -169,9 +152,6 @@ public class ThumbRespeakFragment extends Fragment {
isCommented = true;
}
}
startProgressionEvolutionBar();
startProgressionGlobalBar();
}
......@@ -179,7 +159,6 @@ public class ThumbRespeakFragment extends Fragment {
//playButton.setBackgroundColor(greyColor);
respeaker.pauseOriginal();
stopThread(seekBarThread);
stopThread(threadSeekProgression);
gestureTime = System.currentTimeMillis() - gestureTime;
gestureTimeUpToDown = System.currentTimeMillis();
Log.i("Thumb", ""+ gestureTime);
......@@ -277,52 +256,24 @@ public class ThumbRespeakFragment extends Fragment {
}
/**
* Permits to a SeekBar a precise evolution every 0.001 sec
* Permits to update the textview which displays current time of a browsed file.
* Permits to the main SeekBar a global evolution every 1 sec
*/
private void startProgressionEvolutionBar() {
//thread used to update the progression bar and the currentTime textview
threadSeekProgression = new Thread(new Runnable() {
private void startProgressionGlobalBar() {
seekBarThread = new Thread(new Runnable() {
public void run() {
int currentPosition;
while (true) {
currentPosition =
respeaker.getSimplePlayer().getCurrentMsec();
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
textTimeProgression.setText(respeaker.getSimplePlayer().getCurrentMsec()/1000 + "s");
}
});
seekProgression.setProgress(
(int)(((float)currentPosition/(float)
respeaker.getSimplePlayer().getDurationMsec())*100));
try {
Thread.sleep(10);
} catch (InterruptedException e) {
return;
}
}
}
});
threadSeekProgression.start();
}
/**
* Permits to the main SeekBar a global evolution every 1 sec
*/
private void startProgressionGlobalBar() {
seekBarThread = new Thread(new Runnable() {
public void run() {
int currentPosition;
while (true) {
currentPosition =
respeaker.getSimplePlayer().getCurrentMsec();
seekBar.setProgress(
(int)(((float)currentPosition/(float)
respeaker.getSimplePlayer().getDurationMsec())*100));
......@@ -407,17 +358,6 @@ public class ThumbRespeakFragment extends Fragment {
*/
private InterleavedSeekBar seekBar;
/**
* a precise progression bar updated every 0.001 sec
*/
private InterleavedSeekBar seekProgression;
/**
* thread used in startProgressionEvolutionBar to update a
* seekBar every 0.001 sec
*/
private Thread threadSeekProgression;
/**
* thread used in startProgressionGlobalBar to update a
* seekBar every 1 sec
......