android:layout_height="match_parent"
android:orientation="vertical" >
- <WebView
+ <com.hughes.android.dictionary.MyWebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="0dip"
<string name="BN">Bengali</string>
<string name="BS">Bosnisch</string>
<string name="BG">Bulgarisch</string>
+ <string name="MY">Burmesisch</string>
<string name="CA">Katalanisch</string>
<string name="HR">Kroatisch</string>
<string name="CS">Tschechisch</string>
- <string name="ZH">Chinesisch (Mandarin, Kantonesisch)</string>
+ <string name="yue">Kantonesisch</string>
+ <string name="ZH">Chinesisch (Mandarin)</string>
<string name="DA">Dänisch</string>
<string name="NL">Niederländisch</string>
<string name="EN">Englisch</string>
<string name="GD">Schottisch-Gälisch</string>
<string name="DE">Deutsch</string>
<string name="EL">Griechisch</string>
+ <string name="grc">Altgriechischmymymymymymymymy</string>
<string name="haw">Hawaiian</string>
<string name="HE">Hebräisch</string>
<string name="HI">Hindi</string>
<string name="BN">Bengali</string>
<string name="BS">Bosnian</string>
<string name="BG">Bulgarian</string>
+ <string name="MY">Burmese</string>
+ <string name="yue">Cantonese</string>
<string name="CA">Catalan</string>
<string name="HR">Croatian</string>
<string name="CS">Czech</string>
- <string name="ZH">Chinese (Mandarin, Cantonese)</string>
+ <string name="ZH">Chinese (Mandarin)</string>
<string name="DA">Danish</string>
<string name="NL">Dutch</string>
<string name="EN">English</string>
<string name="GD">Scottish Gaelic</string>
<string name="DE">German</string>
<string name="EL">Greek</string>
+ <string name="grc">Ancient Greek</string>
<string name="haw">Hawaiian</string>
<string name="HE">Hebrew</string>
<string name="HI">Hindi</string>
package com.hughes.android.dictionary;
-import com.hughes.android.dictionary.DictionaryInfo.IndexInfo;
-import com.hughes.android.dictionary.engine.Dictionary;
-import com.hughes.android.dictionary.engine.EntrySource;
-import com.hughes.android.dictionary.engine.HtmlEntry;
-import com.hughes.android.dictionary.engine.Index;
-import com.hughes.android.dictionary.engine.Index.IndexEntry;
-import com.hughes.android.dictionary.engine.PairEntry;
-import com.hughes.android.dictionary.engine.PairEntry.Pair;
-import com.hughes.android.dictionary.engine.RowBase;
-import com.hughes.android.dictionary.engine.TokenRow;
-import com.hughes.android.dictionary.engine.TransliteratorManager;
-import com.hughes.android.util.IntentLauncher;
-import com.hughes.android.util.NonLinkClickableSpan;
-
import android.app.Dialog;
import android.app.ListActivity;
import android.content.Context;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
+import android.widget.LinearLayout.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
+import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.TextView;
import android.widget.Toast;
+import com.hughes.android.dictionary.DictionaryInfo.IndexInfo;
+import com.hughes.android.dictionary.engine.Dictionary;
+import com.hughes.android.dictionary.engine.EntrySource;
+import com.hughes.android.dictionary.engine.HtmlEntry;
+import com.hughes.android.dictionary.engine.Index;
+import com.hughes.android.dictionary.engine.Index.IndexEntry;
+import com.hughes.android.dictionary.engine.PairEntry;
+import com.hughes.android.dictionary.engine.PairEntry.Pair;
+import com.hughes.android.dictionary.engine.RowBase;
+import com.hughes.android.dictionary.engine.TokenRow;
+import com.hughes.android.dictionary.engine.TransliteratorManager;
+import com.hughes.android.util.IntentLauncher;
+import com.hughes.android.util.NonLinkClickableSpan;
+
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
private TableLayout getView(TokenRow row, ViewGroup parent, final TableLayout result) {
final Context context = parent.getContext();
+
+ final TableRow tableRow = new TableRow(result.getContext());
+ tableRow.setBackgroundResource(row.hasMainEntry ? theme.tokenRowMainBg
+ : theme.tokenRowOtherBg);
+ tableRow.setPadding(mPaddingDefault, mPaddingDefault, mPaddingDefault, 0);
+ result.addView(tableRow);
+
+ final IndexEntry indexEntry = row.getIndexEntry();
+
final TextView textView = new TextView(context);
- textView.setText(row.getToken());
+ textView.setText(indexEntry.token);
// Doesn't work:
// textView.setTextColor(android.R.color.secondary_text_light);
textView.setTextAppearance(context, theme.tokenRowFg);
textView.setTypeface(typeface);
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 5 * fontSizeSp / 4);
-
- final TableRow tableRow = new TableRow(result.getContext());
+ TableRow.LayoutParams lp = new TableRow.LayoutParams(0);
+ lp.weight = 1.0f;
+ textView.setLayoutParams(lp);
tableRow.addView(textView);
- tableRow.setBackgroundResource(row.hasMainEntry ? theme.tokenRowMainBg
- : theme.tokenRowOtherBg);
- tableRow.setPadding(mPaddingDefault, mPaddingDefault, mPaddingDefault, 0);
- result.addView(tableRow);
+
+
+ if (!indexEntry.htmlEntries.isEmpty()) {
+ final ImageButton button = new ImageButton(context);
+ button.setImageResource(R.drawable.ic_menu_forward);
+ button.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ final String html = HtmlEntry.htmlBody(indexEntry.htmlEntries);
+ startActivity(HtmlDisplayActivity.getHtmlIntent(String.format(
+ "<html><head></head><body>%s</body></html>", html)));
+ }
+ });
+ tableRow.addView(button);
+ lp = new TableRow.LayoutParams(1);
+ lp.weight = 0.0f;
+ button.setLayoutParams(lp);
+ //result.setColumnStretchable(0, true);
+ //result.setColumnStretchable(1, false);
+ }
+
+
return result;
}
import android.app.Activity;\r
import android.content.Intent;\r
import android.os.Bundle;\r
+import android.view.ContextMenu;\r
+import android.view.ContextMenu.ContextMenuInfo;\r
+import android.view.MenuItem;\r
+import android.view.MenuItem.OnMenuItemClickListener;\r
import android.view.View;\r
import android.view.View.OnClickListener;\r
+import android.view.View.OnCreateContextMenuListener;\r
import android.webkit.WebView;\r
import android.widget.Button;\r
\r
--- /dev/null
+package com.hughes.android.dictionary;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.ContextMenu;
+import android.webkit.WebView;
+
+public class MyWebView extends WebView {
+
+ public MyWebView(Context context) {
+ super(context);
+ }
+
+ public MyWebView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+
+ @Override
+ public void onCreateContextMenu(ContextMenu menu) {
+ super.onCreateContextMenu(menu);
+ }
+
+}
public class HtmlEntry extends AbstractEntry implements RAFSerializable<HtmlEntry>, Comparable<HtmlEntry> {
+ // Both are HTML escaped already.
public final String title;
public String html;
}
+ public static String htmlBody(final List<HtmlEntry> htmlEntries) {
+ final StringBuilder result = new StringBuilder();
+ for (final HtmlEntry htmlEntry : htmlEntries) {
+ result.append(String.format("<h1>%s</h1>%s\n", htmlEntry.title, htmlEntry.html));
+ }
+ return result.toString();
+ }
+
}
isoCodeToResources.put("BN", new LanguageResources("Bengali", R.string.BN));\r
isoCodeToResources.put("BS", new LanguageResources("Bosnian", R.string.BS));\r
isoCodeToResources.put("BG", new LanguageResources("Bulgarian", R.string.BG));\r
+ isoCodeToResources.put("MY", new LanguageResources("Burmese", R.string.MY));\r
+ isoCodeToResources.put("yue", new LanguageResources("Cantonese", R.string.yue));\r
isoCodeToResources.put("CA", new LanguageResources("Catalan", R.string.CA));\r
isoCodeToResources.put("HR", new LanguageResources("Croatian", R.string.HR));\r
isoCodeToResources.put("CS", new LanguageResources("Czech", R.string.CS));\r
isoCodeToResources.put("FR", new LanguageResources("French", R.string.FR));\r
isoCodeToResources.put("DE", new LanguageResources("German", R.string.DE));\r
isoCodeToResources.put("EL", new LanguageResources("Greek", R.string.EL));\r
+ isoCodeToResources.put("grc", new LanguageResources("Ancient Greek", R.string.grc));\r
isoCodeToResources.put("haw", new LanguageResources("Hawaiian", R.string.haw));\r
isoCodeToResources.put("HE", new LanguageResources("Hebrew", R.string.HE));\r
isoCodeToResources.put("HI", new LanguageResources("Hindi", R.string.HI));\r
import java.util.List;
import java.util.regex.Pattern;
+import com.hughes.android.dictionary.engine.Index.IndexEntry;
import com.ibm.icu.text.Transliterator;
public class TokenRow extends RowBase {
}
public String getToken() {
- return index.sortedIndexEntries.get(referenceIndex).token;
+ return getIndexEntry().token;
+ }
+
+ public IndexEntry getIndexEntry() {
+ return index.sortedIndexEntries.get(referenceIndex);
}
@Override