* -> language in which the phrase is written to -> to which
* language shall be translated
*/
- if (intentAction != null && intentAction.equals("com.hughes.action.ACTION_SEARCH_DICT")) {
+ if ("com.hughes.action.ACTION_SEARCH_DICT".equals(intentAction)) {
String query = intent.getStringExtra(SearchManager.QUERY);
String from = intent.getStringExtra("from");
if (from != null)
final LinearLayout result = new LinearLayout(parent.getContext());
- for (int i = 0; dictionaryInfo.indexInfos != null && i < dictionaryInfo.indexInfos.size(); ++i) {
+ for (int i = 0; i < dictionaryInfo.indexInfos.size(); ++i) {
final IndexInfo indexInfo = dictionaryInfo.indexInfos.get(i);
final View button = IsoUtils.INSTANCE.createButton(parent.getContext(),
indexInfo, application.languageButtonPixels);
try {
wordList.getParentFile().mkdirs();
final PrintWriter out = new PrintWriter(new FileWriter(wordList, true));
- out.println(rawText.toString());
+ out.println(rawText);
out.close();
} catch (Exception e) {
Log.e(LOG, "Unable to append to " + wordList.getAbsolutePath(), e);
Log.d(LOG, "searchFinished: " + searchOperation + ", searchResult=" + searchResult);
currentSearchOperation = null;
- uiHandler.postDelayed(new Runnable() {
+ // Note: it's important to post to the ListView, otherwise
+ // the jumpToRow will randomly not work.
+ getListView().post(new Runnable() {
@Override
public void run() {
if (currentSearchOperation == null) {
Log.d(LOG, "More coming, waiting for currentSearchOperation.");
}
}
- }, 20);
+ });
}
- private final void jumpToRow(final int row) {
+ private void jumpToRow(final int row) {
Log.d(LOG, "jumpToRow: " + row + ", refocusSearchText=" + false);
// getListView().requestFocusFromTouch();
getListView().setSelectionFromTop(row, 0);
}
public String toString() {
- return String.format("SearchOperation(%s,%s)", searchText, interrupted.toString());
+ return String.format("SearchOperation(%s,%s)", searchText, interrupted);
}
@Override
private void showHtml(final List<HtmlEntry> htmlEntries, final String htmlTextToHighlight) {
String html = HtmlEntry.htmlBody(htmlEntries, index.shortName);
+ String style = "";
+ if (typeface == Typeface.SERIF) { style = "font-family: serif;"; }
+ else if (typeface == Typeface.SANS_SERIF) { style = "font-family: sans-serif;"; }
+ else if (typeface == Typeface.MONOSPACE) { style = "font-family: monospace;"; }
+ if (application.getSelectedTheme() == DictionaryApplication.Theme.DEFAULT)
+ style += "background-color: black; color: white;";
// Log.d(LOG, "html=" + html);
startActivityForResult(
HtmlDisplayActivity.getHtmlIntent(getApplicationContext(), String.format(
- "<html><head><meta name=\"viewport\" content=\"width=device-width\"></head><body>%s</body></html>", html),
+ "<html><head><meta name=\"viewport\" content=\"width=device-width\"></head><body style=\"%s\">%s</body></html>", style, html),
htmlTextToHighlight, false),
0);
}