Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Laurent Besacier
lig-aikuma
Commits
891a58fb
Commit
891a58fb
authored
Apr 22, 2016
by
CallisteHanriat
Browse files
adding a progress bar on the check mode + remove unnecessary lines
parent
3dde3ead
Changes
3
Hide whitespace changes
Inline
Side-by-side
Aikuma/res/layout-xlarge/check_word_variant.xml
View file @
891a58fb
...
...
@@ -93,6 +93,36 @@
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=
"1"
/>
<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
Aikuma/src/org/lp20/aikuma/ui/CheckWordVariant.java
View file @
891a58fb
package
org.lp20.aikuma.ui
;
import
java.io.BufferedInputStream
;
import
java.io.BufferedReader
;
import
java.io.BufferedWriter
;
import
java.io.File
;
...
...
@@ -8,6 +9,7 @@ import java.io.FileNotFoundException;
import
java.io.FileReader
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.OutputStreamWriter
;
import
java.text.DateFormat
;
...
...
@@ -40,6 +42,7 @@ import android.view.ViewGroup.LayoutParams;
import
android.widget.CheckBox
;
import
android.widget.ImageButton
;
import
android.widget.LinearLayout
;
import
android.widget.SeekBar
;
import
android.widget.TextView
;
import
android.widget.Toast
;
...
...
@@ -57,13 +60,15 @@ public class CheckWordVariant extends AikumaActivity {
private
int
nbReadLines
;
private
String
date
;
private
SharedPreferences
prefsUserSession
;
private
InterleavedSeekBar
progressBar
;
private
int
totalNumberOfExpressions
;
/** Called when the activity is first created. */
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
check_word_variant
);
initProgressBars
();
date
=
new
SimpleDateFormat
(
"yyyy-MM-dd-HH-mm-ss"
,
Locale
.
FRANCE
).
format
(
new
Date
());
prefsUserSession
=
getSharedPreferences
(
getString
(
R
.
string
.
userSession
),
MODE_PRIVATE
);
//case: session already exists
...
...
@@ -83,6 +88,7 @@ public class CheckWordVariant extends AikumaActivity {
//retrieve number of lines already handled in the last session
nbReadLines
=
prefsUserSession
.
getInt
(
getString
(
R
.
string
.
sessionProgress
),
0
);
append
=
true
;
// clear the current stored session
SharedPreferences
.
Editor
ed
=
prefsUserSession
.
edit
();
ed
.
clear
();
ed
.
commit
();
...
...
@@ -120,11 +126,18 @@ public class CheckWordVariant extends AikumaActivity {
for
(
int
countLine
=
0
;
countLine
<
nbReadLines
;
countLine
++)
{
line
=
reader
.
readLine
();
}
totalNumberOfExpressions
=
countNumberOfLines
();
//split on line. group1=word, group2=variant(s)
String
[]
wordlist
=
line
.
split
(
", "
);
TextView
lexeme
=
(
TextView
)
findViewById
(
R
.
id
.
tv_verif_lexeme
);
lexeme
.
setText
(
wordlist
[
0
]);
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,6 +177,28 @@ public class CheckWordVariant extends AikumaActivity {
}
}
/**
* called to set progressionBar behavior
* progressionBar is not modifiable by hand
*/
private
void
initProgressBars
()
{
progressBar
=
(
InterleavedSeekBar
)
findViewById
(
R
.
id
.
seek_check_progression
);
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
();
};
});
}
public
void
onNextClick
(
View
_view
)
{
if
(
saveFile
())
{
...
...
@@ -177,6 +212,11 @@ public class CheckWordVariant extends AikumaActivity {
TextView
lexeme
=
(
TextView
)
findViewById
(
R
.
id
.
tv_verif_lexeme
);
lexeme
.
setText
(
wordlist
[
0
]);
TextView
tv
=
(
TextView
)
findViewById
(
R
.
id
.
check_line_number
);
tv
.
setText
(
""
+
nbReadLines
);
progressBar
.
setProgress
((
int
)
(((
float
)
nbReadLines
)/(
float
)
totalNumberOfExpressions
*
100
));
LinearLayout
llparent
=
(
LinearLayout
)
findViewById
(
R
.
id
.
ll_variant
);
llparent
.
removeAllViews
();
...
...
@@ -217,6 +257,33 @@ 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
();
}
}
public
void
onValidate
(
View
_view
)
{
if
(
saveFile
())
{
try
{
...
...
Aikuma/src/org/lp20/aikuma/ui/RecordElicitation.java
View file @
891a58fb
...
...
@@ -156,9 +156,6 @@ public class RecordElicitation extends AikumaActivity {
TextView
tv2
=
(
TextView
)
findViewById
(
R
.
id
.
elicit_phrase_number
);
tv2
.
setText
(
phraseId
+
1
+
""
);
TextView
tv_total
=
(
TextView
)
findViewById
(
R
.
id
.
elicit_total_number
);
tv_total
.
setText
(
" / "
+
numberOfLines
);
progressBar
.
setProgress
((
int
)
(((
float
)
phraseId
+
1.0
)/(
float
)
numberOfLines
*
100
));
String
[]
phrasePair
=
phrase
.
split
(
"##"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment