Commit 39e5772b authored by CallisteHanriat's avatar CallisteHanriat

Adidng progressBar in transcription mode inside check mode + new progressBar...

Adidng progressBar in transcription mode inside check mode + new progressBar design (better quality)
parent 891a58fb
......@@ -115,6 +115,35 @@
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_phrase_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
/>
<TextView
android:id="@+id/check_total_phrase_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/check_seekbar_transcription"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxHeight="3dp"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
\ No newline at end of file
......@@ -12,7 +12,7 @@
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin" >
<!-- Back button
<!-- Back button
<GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -29,6 +29,7 @@
android:layout_marginTop="20dp" />
</GridLayout>
-->
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
......@@ -114,6 +115,35 @@
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_phrase_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
/>
<TextView
android:id="@+id/check_total_phrase_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/check_seekbar_transcription"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxHeight="3dp"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
\ No newline at end of file
package org.lp20.aikuma.ui;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
......@@ -7,6 +8,7 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -29,6 +31,7 @@ import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
......@@ -44,11 +47,12 @@ public class CheckTranscription extends AikumaActivity {
protected long sampleRate = 16000l;
private boolean append;
private int nbReadLines;
private int nb_total_lines;
private String date;
private SharedPreferences prefsUserSession;
private String externalStoragePath = Environment.getExternalStorageDirectory().getPath();
private String dataPath = externalStoragePath+"/Download/";
private String dataPath = externalStoragePath+"/aikuma/check_transcription_mode/";
private InterleavedSeekBar progressBar;
private ListenFragment fragment;
......@@ -59,6 +63,8 @@ public class CheckTranscription extends AikumaActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.check_transcription);
initProgressBars();
Log.d("dataPath", dataPath);
prefsUserSession = getSharedPreferences(getString(R.string.userSession), MODE_PRIVATE);
date = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.FRANCE).format(new Date());
//case: session already exists
......@@ -105,6 +111,7 @@ public class CheckTranscription extends AikumaActivity {
// test on the lines read:
// check that the file is not empty by ensuring that the phrase is not null (end of file reached)
// check that the sentence is correctly formatted (no empty line and ' : ' delimited found)
nb_total_lines = countNumberOfLines();
String line;
while ((line = reader.readLine()) != null && (line.isEmpty() || line.split(" : ").length <= 1)) { continue; }
if (line == null) { throw new IOException("Empty text file"); }
......@@ -119,6 +126,9 @@ public class CheckTranscription extends AikumaActivity {
//group2
String transcription = splittedline[1];
TextView tv = (TextView) findViewById(R.id.check_total_phrase_number);
tv.setText(" / " + nb_total_lines);
//retrieve layout to put element in
LinearLayout llparent = (LinearLayout) findViewById(R.id.ll_variant);
llparent.removeAllViews();
......@@ -163,6 +173,57 @@ public class CheckTranscription extends AikumaActivity {
}
}
/**
* called to set progressionBar behavior
* progressionBar is not modifiable by hand
*/
private void initProgressBars() {
progressBar = (InterleavedSeekBar) findViewById(R.id.check_seekbar_transcription);
progressBar.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 = progressBar.getProgress();
};
});
}
/**
* called by constructor to set the number of lines in the file
* @return the number of lines 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();
}
}
public void onNextClick(View _view) {
if (saveFile()) {
try {
......@@ -177,6 +238,11 @@ public class CheckTranscription extends AikumaActivity {
//group2
String transcription = splittedline[1];
TextView tv = (TextView) findViewById(R.id.check_phrase_number);
tv.setText("" + nbReadLines);
progressBar.setProgress((int) (((float)nbReadLines)/(float) nb_total_lines* 100));
LinearLayout llparent = (LinearLayout) findViewById(R.id.ll_variant);
llparent.removeAllViews();
......@@ -222,6 +288,8 @@ public class CheckTranscription extends AikumaActivity {
}
}
public void onValidate(View _view) {
if (saveFile()) {
try {
......
......@@ -178,6 +178,8 @@ public class CheckWordVariant extends AikumaActivity {
}
/**
* called to set progressionBar behavior
* progressionBar is not modifiable by hand
......@@ -257,32 +259,32 @@ 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.
* @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();
}
}
/**
* called by constructor to set the number of lines in the file
* @return the number of lines 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();
}
}
public void onValidate(View _view) {
if (saveFile()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment