Commit c78aa9e6 authored by Julien Lepiller's avatar Julien Lepiller
Browse files

Add meaning and sources to result screen.

parent be777cc2
......@@ -118,5 +118,102 @@ public class ResultActivity extends AppCompatActivity {
private void fillMeanings() {
LinearLayout layout = findViewById(R.id.result_content);
for(Result.Sense sense: result.getSenses()) {
LinearLayout senseLayout = new LinearLayout(this);
senseLayout.setOrientation(LinearLayout.VERTICAL);
for(int tag: sense.getTags()) {
// TODO
}
TextView senseView = new TextView(this);
StringBuilder sb = new StringBuilder();
boolean separator1 = false;
for (String s : sense.getGlosses()) {
if (separator1)
sb.append(getResources().getString(R.string.sense_separator));
else
separator1 = true;
sb.append(s);
}
senseView.setText(String.format(getString(R.string.result_sense), sense.getLanguage(),
sb.toString()));
senseLayout.addView(senseView);
if(sense.getReferences().size() > 0) {
LinearLayout referenceLayout = new LinearLayout(this);
referenceLayout.setOrientation(LinearLayout.HORIZONTAL);
TextView seeAlsoView = new TextView(this);
seeAlsoView.setText(R.string.result_see_also);
referenceLayout.addView(seeAlsoView);
FlexboxLayout referenceListLayout = new FlexboxLayout(this);
for(String r: sense.getReferences()) {
TextView referenceView = new TextView(this);
referenceView.setText(r);
referenceListLayout.addView(referenceView);
}
referenceLayout.addView(referenceListLayout);
senseLayout.addView(referenceLayout);
}
if(sense.getLimits().size() > 0) {
LinearLayout limitLayout = new LinearLayout(this);
limitLayout.setOrientation(LinearLayout.HORIZONTAL);
TextView onlyForView = new TextView(this);
onlyForView.setText(R.string.result_only_for);
limitLayout.addView(onlyForView);
FlexboxLayout limitListLayout = new FlexboxLayout(this);
for(String l: sense.getLimits()) {
TextView limitView = new TextView(this);
limitView.setText(l);
limitListLayout.addView(limitView);
}
limitLayout.addView(limitListLayout);
senseLayout.addView(limitLayout);
}
if(sense.getInfo().size() > 0) {
LinearLayout infoLayout = new LinearLayout(this);
infoLayout.setOrientation(LinearLayout.HORIZONTAL);
TextView noteView = new TextView(this);
noteView.setText(R.string.result_info);
infoLayout.addView(noteView);
LinearLayout infoListLayout = new LinearLayout(this);
infoListLayout.setOrientation(LinearLayout.VERTICAL);
for(String i: sense.getInfo()) {
TextView infoView = new TextView(this);
infoView.setText(i);
infoListLayout.addView(infoView);
}
infoLayout.addView(infoListLayout);
senseLayout.addView(infoLayout);
}
Log.d(TAG, "fillMeanings: sources: " + sense.getSources().size());
for(Result.Source source: sense.getSources()) {
LinearLayout sourceLayout = new LinearLayout(this);
sourceLayout.setOrientation(LinearLayout.HORIZONTAL);
TextView sourceView = new TextView(this);
sourceView.setText(
String.format(getString(source.isWasei()? R.string.result_source_wasei: R.string.result_source_loan),
source.getLanguage()));
sourceLayout.addView(sourceView);
Log.d(TAG, "fillMeanings: source content: " + source.getContent().size());
for(String w: source.getContent()) {
TextView wordView = new TextView(this);
wordView.setText(w);
sourceLayout.addView(wordView);
}
senseLayout.addView(sourceLayout);
}
layout.addView(senseLayout);
}
}
}
\ No newline at end of file
......@@ -58,6 +58,7 @@ public class Result implements Parcelable {
}
protected Source(Parcel in) {
Log.d(TAG, "Source: created from parcel");
content = in.createStringArrayList();
wasei = in.readInt() != 0;
type = in.readString();
......@@ -88,6 +89,22 @@ public class Result implements Parcelable {
dest.writeString(type);
dest.writeString(language);
}
public ArrayList<String> getContent() {
return content;
}
public boolean isWasei() {
return wasei;
}
public String getType() {
return type;
}
public String getLanguage() {
return language;
}
}
public static class Sense implements Parcelable {
......@@ -133,10 +150,34 @@ public class Result implements Parcelable {
}
};
public ArrayList<String> getReferences() {
return references;
}
public ArrayList<String> getLimits() {
return limits;
}
public ArrayList<String> getInfo() {
return info;
}
public ArrayList<String> getGlosses() {
return glosses;
}
public ArrayList<Integer> getTags() {
return tags;
}
public String getLanguage() {
return language;
}
public ArrayList<Source> getSources() {
return sources;
}
@Override
public int describeContents() {
return 0;
......
......@@ -39,6 +39,17 @@
<string name="alt_text_refresh">Update</string>
<string name="alt_text_remove">Remove</string>
<!-- Detailed result activity -->
<!-- TRANSLATORS: this is the meaning, preceded by the language. eg.: (en) fish -->
<string name="result_sense">(%1$s) %2$s</string>
<string name="result_see_also">See also:</string>
<string name="result_only_for">Only for:</string>
<string name="result_info">Note:</string>
<!-- %s is a language -->
<string name="result_source_wasei">Word created in Japan from %s:</string>
<!-- %s is a language -->
<string name="result_source_loan">Loan word from %s:</string>
<!-- Preferences -->
<string name="pref_rad_size">Radicals Size</string>
<string-array name="pref_rad_size_choice">
......
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