mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-08 10:42:50 -06:00
better lexicon view
This commit is contained in:
BIN
src/ui/android/res/drawable-hdpi/open_arrow.png
Normal file
BIN
src/ui/android/res/drawable-hdpi/open_arrow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.9 KiB |
@@ -5,6 +5,17 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/lexical_header"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:background="#C0C0C0"
|
||||||
|
>
|
||||||
|
|
||||||
<org.grammaticalframework.ui.android.LanguageSelector
|
<org.grammaticalframework.ui.android.LanguageSelector
|
||||||
android:id="@+id/show_language"
|
android:id="@+id/show_language"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -14,11 +25,24 @@
|
|||||||
android:padding="0dp"
|
android:padding="0dp"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/lexical_desc"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/lexical_header"
|
||||||
|
android:paddingLeft="1dp"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
android:paddingBottom="2dp"
|
||||||
|
android:textSize="25sp"/>
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_below="@id/show_language"
|
android:layout_below="@id/lexical_desc"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
android:paddingLeft="1dp"
|
||||||
android:id="@android:id/list" >
|
android:id="@android:id/list" >
|
||||||
</ListView>
|
</ListView>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
21
src/ui/android/res/layout/lexical_item.xml
Normal file
21
src/ui/android/res/layout/lexical_item.xml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent" >
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/icon"
|
||||||
|
android:layout_width="30dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:contentDescription="@string/open_image"
|
||||||
|
android:src="@drawable/open_arrow"
|
||||||
|
android:paddingLeft="10dp"
|
||||||
|
android:paddingRight="5dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/lexical_desc"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_toRightOf="@+id/icon"
|
||||||
|
android:paddingLeft="10dp"
|
||||||
|
android:textSize="25sp"/>
|
||||||
|
</RelativeLayout>
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<string name="app_name">GF4Translator</string>
|
<string name="app_name">GF Translator</string>
|
||||||
|
|
||||||
<string name="microphone">Microphone</string>
|
<string name="microphone">Microphone</string>
|
||||||
<string name="switch_languages">Switch languages</string>
|
<string name="switch_languages">Switch languages</string>
|
||||||
|
<string name="open_image">Opening</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -76,7 +76,10 @@ public class ConversationView extends ScrollView {
|
|||||||
showWordButton.setOnClickListener(new OnClickListener() {
|
showWordButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
mListener.onWordSelected(lexicon2);
|
TextView textview = (TextView)
|
||||||
|
((View) v.getParent()).findViewById(R.id.text);
|
||||||
|
CharSequence text = textview.getText();
|
||||||
|
mListener.onWordSelected(text, lexicon2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -88,6 +91,6 @@ public class ConversationView extends ScrollView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface OnWordSelectedListener {
|
public interface OnWordSelectedListener {
|
||||||
public void onWordSelected(Object lexicon);
|
public void onWordSelected(CharSequence word, Object lexicon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,14 @@ package org.grammaticalframework.ui.android;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.grammaticalframework.pgf.*;
|
import org.grammaticalframework.pgf.*;
|
||||||
import org.grammaticalframework.ui.android.LanguageSelector.OnLanguageSelectedListener;
|
import org.grammaticalframework.ui.android.LanguageSelector.OnLanguageSelectedListener;
|
||||||
@@ -25,7 +30,6 @@ public class LexicalEntryActivity extends ListActivity {
|
|||||||
|
|
||||||
mShowLanguageView = (LanguageSelector) findViewById(R.id.show_language);
|
mShowLanguageView = (LanguageSelector) findViewById(R.id.show_language);
|
||||||
mShowLanguageView.setLanguages(mTranslator.getAvailableSourceLanguages());
|
mShowLanguageView.setLanguages(mTranslator.getAvailableSourceLanguages());
|
||||||
mShowLanguageView.setSelectedLanguage(mTranslator.getTargetLanguage());
|
|
||||||
mShowLanguageView.setOnLanguageSelectedListener(new OnLanguageSelectedListener() {
|
mShowLanguageView.setOnLanguageSelectedListener(new OnLanguageSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onLanguageSelected(Language language) {
|
public void onLanguageSelected(Language language) {
|
||||||
@@ -34,6 +38,9 @@ public class LexicalEntryActivity extends ListActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
TextView descrView = (TextView) findViewById(R.id.lexical_desc);
|
||||||
|
descrView.setText(getIntent().getExtras().getString("source"));
|
||||||
|
|
||||||
updateTranslations();
|
updateTranslations();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,17 +51,34 @@ public class LexicalEntryActivity extends ListActivity {
|
|||||||
|
|
||||||
List<String> data = new ArrayList<String>();
|
List<String> data = new ArrayList<String>();
|
||||||
for (MorphoAnalysis a : list) {
|
for (MorphoAnalysis a : list) {
|
||||||
// Expr e = Expr.readExpr(a.getLemma());
|
Expr e = Expr.readExpr(a.getLemma());
|
||||||
String phrase = "FOO" ; //mTranslator.linearize(e);
|
String phrase = mTranslator.linearize(e);
|
||||||
|
|
||||||
if (!data.contains(phrase)) {
|
if (!data.contains(phrase)) {
|
||||||
data.add(phrase);
|
data.add(phrase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayAdapter adapter = new ArrayAdapter(this,
|
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
|
||||||
android.R.layout.simple_list_item_1,
|
android.R.layout.simple_list_item_1,
|
||||||
data);
|
data) {
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
String item = getItem(position);
|
||||||
|
|
||||||
|
LayoutInflater inflater = (LayoutInflater) getContext()
|
||||||
|
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
|
||||||
|
if (convertView == null) {
|
||||||
|
convertView = inflater.inflate(R.layout.lexical_item, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
TextView descView =
|
||||||
|
(TextView) convertView.findViewById(R.id.lexical_desc);
|
||||||
|
descView.setText(item);
|
||||||
|
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
setListAdapter(adapter);
|
setListAdapter(adapter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,8 +68,9 @@ public class MainActivity extends Activity {
|
|||||||
|
|
||||||
mConversationView.setOnWordSelectedListener(new OnWordSelectedListener() {
|
mConversationView.setOnWordSelectedListener(new OnWordSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onWordSelected(Object lexicon) {
|
public void onWordSelected(CharSequence word, Object lexicon) {
|
||||||
Intent myIntent = new Intent(MainActivity.this, LexicalEntryActivity.class);
|
Intent myIntent = new Intent(MainActivity.this, LexicalEntryActivity.class);
|
||||||
|
myIntent.putExtra("source", word);
|
||||||
myIntent.putExtra("analyses", (Serializable) lexicon);
|
myIntent.putExtra("analyses", (Serializable) lexicon);
|
||||||
MainActivity.this.startActivity(myIntent);
|
MainActivity.this.startActivity(myIntent);
|
||||||
}
|
}
|
||||||
@@ -83,7 +84,6 @@ public class MainActivity extends Activity {
|
|||||||
mTranslator = ((GFTranslator) getApplicationContext()).getTranslator();
|
mTranslator = ((GFTranslator) getApplicationContext()).getTranslator();
|
||||||
|
|
||||||
mSourceLanguageView.setLanguages(mTranslator.getAvailableSourceLanguages());
|
mSourceLanguageView.setLanguages(mTranslator.getAvailableSourceLanguages());
|
||||||
mSourceLanguageView.setSelectedLanguage(mTranslator.getSourceLanguage());
|
|
||||||
mSourceLanguageView.setOnLanguageSelectedListener(new OnLanguageSelectedListener() {
|
mSourceLanguageView.setOnLanguageSelectedListener(new OnLanguageSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onLanguageSelected(Language language) {
|
public void onLanguageSelected(Language language) {
|
||||||
@@ -91,7 +91,6 @@ public class MainActivity extends Activity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
mTargetLanguageView.setLanguages(mTranslator.getAvailableTargetLanguages());
|
mTargetLanguageView.setLanguages(mTranslator.getAvailableTargetLanguages());
|
||||||
mTargetLanguageView.setSelectedLanguage(mTranslator.getTargetLanguage());
|
|
||||||
mTargetLanguageView.setOnLanguageSelectedListener(new OnLanguageSelectedListener() {
|
mTargetLanguageView.setOnLanguageSelectedListener(new OnLanguageSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onLanguageSelected(Language language) {
|
public void onLanguageSelected(Language language) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class Translator {
|
|||||||
private static final String TAG = "Translator";
|
private static final String TAG = "Translator";
|
||||||
|
|
||||||
// TODO: allow changing
|
// TODO: allow changing
|
||||||
private String mGrammar = "ParseEngChi.pgf";
|
private String mGrammar = "ParseEngAbs.pgf";
|
||||||
|
|
||||||
// TODO: build dynamically?
|
// TODO: build dynamically?
|
||||||
private Language[] mLanguages = {
|
private Language[] mLanguages = {
|
||||||
|
|||||||
Reference in New Issue
Block a user