Commit 52a8f9b1 authored by CallisteHanriat's avatar CallisteHanriat

adding auto filled texview into metadata activity for respeaking + adding some...

adding auto filled texview into metadata activity for respeaking + adding some comments above functions
parent 7592455b
......@@ -235,7 +235,7 @@ public class RespeakingMetadataLig extends AikumaActivity implements OnClickList
public void onOkButtonClick(View _view) {
// Log.i(TAG, "DEBUG - selected languages before validation: " + selectedLanguages.size());
// get spoken languages
recordLang = retrieveRecordLang();
recordLang = retrieveSelectedRecordLang();
motherTong = retrieveMotherTong();
languages = retrieveLanguages();
// get personal information
......@@ -247,8 +247,8 @@ public class RespeakingMetadataLig extends AikumaActivity implements OnClickList
speakerAge = Integer.parseInt(age);
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
if (speakerAge < RecordingMetadataLig.AGE_MAX || speakerAge > currentYear - RecordingMetadataLig.AGE_MIN) {
msgError = "Input birth year is implausible... interval [1880 -> " +
Integer.toString(currentYear-3) + "]";
msgError = "Input birth year is implausible... interval [" + Integer.toString(currentYear - RecordingMetadataLig.AGE_MAX) +
" -> " + Integer.toString(currentYear-RecordingMetadataLig.AGE_MIN) + "]";
new AlertDialog.Builder(this)
.setMessage(msgError)
.setPositiveButton("Ok", null)
......@@ -342,6 +342,11 @@ public class RespeakingMetadataLig extends AikumaActivity implements OnClickList
}
/**
* Find the good language object with a given language name
* @param lang the language name
* @return the language object associated
*/
private Language getLanguageFromName(String lang) {
Map<String,String> language_code_map = Aikuma.getLanguageCodeMap();
for (String lang_code : language_code_map.keySet()) {
......@@ -354,11 +359,24 @@ public class RespeakingMetadataLig extends AikumaActivity implements OnClickList
return null;
}
private Language retrieveRecordLang() {
/**
* retrieve the selected language object thanks to reading textview
* @return the good language object
*/
private Language retrieveSelectedRecordLang() {
String lang_name = ((TextView)findViewById(R.id.respeak_tv_selectedlangRespeaking)).getText().toString();
return getLanguageFromName(lang_name);
}
/**
* retreive the original language thanks to reading original textview
* @return the good language object
*/
private Language retriveOriginalRecordLang() {
String lang_name = ((TextView) findViewById(R.id.record_edit_recording_lang)).getText().toString();
return getLanguageFromName(lang_name);
}
private Language retrieveMotherTong() {
String lang_name = ((TextView)findViewById(R.id.respeak_tv_selectedmotherTongue)).getText().toString();
return getLanguageFromName(lang_name);
......@@ -413,10 +431,23 @@ public class RespeakingMetadataLig extends AikumaActivity implements OnClickList
// versionName = getIntent().getStringExtra(RecordActivityLig.intent_versionName);
}
/**
* function called to load a session into activity. It takes element previously entered by user and
* set graphical views to his values.
*/
private void loadSession() {
MetadataSession session = MetadataSession.getMetadataSession();
Language recordLanguage = retriveOriginalRecordLang();
if (!translateMode) {
((TextView) findViewById(R.id.respeak_tv_selectedlangRespeaking)).setText(recordLanguage.getName());
}
if (!session.isEmpty()) {
Language recordLanguage = session.getRecordLanguage();
if (translateMode) {
recordLanguage = session.getRecordLanguage();
((TextView) findViewById(R.id.respeak_tv_selectedlangRespeaking)).setText(recordLanguage.getName());
}
Language motherTongue = session.getMotherTongue();
ArrayList<Language> extraLanguages = session.getExtraLanguages();
String region = session.getRegionOrigin();
......@@ -437,7 +468,6 @@ public class RespeakingMetadataLig extends AikumaActivity implements OnClickList
onAddMoreLanguagesField(null);
}
}
((TextView) findViewById(R.id.respeak_tv_selectedlangRespeaking)).setText(recordLanguage.getName());
((TextView) findViewById(R.id.respeak_tv_selectedmotherTongue)).setText(motherTongue.getName());
for (int i=0; i<extraLanguages.size(); i++) {
((TextView) ((LinearLayout) (l_parent.getChildAt(i+2))).getChildAt(1)).setText(extraLanguages.get(i).getName());
......
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