@Override
protected void onResume() {
+ Log.d(LOG, "onResume");
super.onResume();
if (PreferenceActivity.prefsMightHaveChanged) {
PreferenceActivity.prefsMightHaveChanged = false;
if (initialSearchText != null) {
setSearchText(initialSearchText, true);
}
+ showKeyboard();
}
@Override
private void onClearSearchTextButton() {
setSearchText("", true);
+ showKeyboard();
+ }
+
+ private void showKeyboard() {
Log.d(LOG, "Trying to show soft keyboard.");
final InputMethodManager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
manager.showSoftInput(searchText, InputMethodManager.SHOW_IMPLICIT);
layoutParams.weight = 1.0f;
button.setLayoutParams(layoutParams);
result.addView(button);
+
+ if (i > 0) {
+ final TextView dash = new TextView(parent.getContext());
+ dash.setText("-");
+ result.addView(dash);
+ }
}
return result;
}
return result;
}
- private TableLayout getView(HtmlEntry.Row row, ViewGroup parent, final TableLayout result) {
- final Context context = parent.getContext();
-
- final HtmlEntry htmlEntry = row.getEntry();
-
- // final TableRow tableRow = new TableRow(context);
- final LinearLayout tableRow = new LinearLayout(context);
- result.addView(tableRow);
-
- // Text.
- final TextView textView = new TextView(context);
- textView.setText(htmlEntry.title);
- textView.setLayoutParams(new LinearLayout.LayoutParams(0,
- ViewGroup.LayoutParams.WRAP_CONTENT, 1.0f));
- tableRow.addView(textView);
-
- // Button.
- final Button button = new Button(context);
- button.setText("open");
- button.setLayoutParams(new LinearLayout.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0.0f));
- tableRow.addView(button);
-
- button.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- startActivity(HtmlDisplayActivity.getHtmlIntent(String.format(
- "<html><head></head><body>%s</body></html>", htmlEntry.html)));
- }
- });
-
- return result;
- }
-
- private TableLayout getView(TokenRow row, ViewGroup parent, final TableLayout result) {
+ private TableLayout getPossibleHtmlEntryView(final boolean isTokenRow, final String text, final boolean hasMainEntry, final List<HtmlEntry> htmlEntries, final String htmlTextToHighlight, ViewGroup parent, final TableLayout result) {
final Context context = parent.getContext();
final TableRow tableRow = new TableRow(result.getContext());
- tableRow.setBackgroundResource(row.hasMainEntry ? theme.tokenRowMainBg
+ tableRow.setBackgroundResource(hasMainEntry ? theme.tokenRowMainBg
: theme.tokenRowOtherBg);
- tableRow.setPadding(mPaddingDefault, mPaddingDefault, mPaddingDefault, 0);
+ if (isTokenRow) {
+ tableRow.setPadding(mPaddingDefault, mPaddingDefault, mPaddingDefault, 0);
+ } else {
+ tableRow.setPadding(mPaddingLarge, mPaddingDefault, mPaddingDefault, 0);
+ }
result.addView(tableRow);
-
- final IndexEntry indexEntry = row.getIndexEntry();
final TextView textView = new TextView(context);
- textView.setText(indexEntry.token);
+ textView.setText(text);
// 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);
TableRow.LayoutParams lp = new TableRow.LayoutParams(0);
+ if (isTokenRow) {
+ textView.setTextAppearance(context, theme.tokenRowFg);
+ textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 4 * fontSizeSp / 3);
+ } else {
+ textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSizeSp);
+ }
lp.weight = 1.0f;
+
textView.setLayoutParams(lp);
tableRow.addView(textView);
- if (!indexEntry.htmlEntries.isEmpty()) {
+ if (!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);
+ final String html = HtmlEntry.htmlBody(htmlEntries);
startActivity(HtmlDisplayActivity.getHtmlIntent(String.format(
- "<html><head></head><body>%s</body></html>", html)));
+ "<html><head></head><body>%s</body></html>", html), htmlTextToHighlight, false));
}
});
tableRow.addView(button);
//result.setColumnStretchable(0, true);
//result.setColumnStretchable(1, false);
}
-
-
return result;
}
+
+ private TableLayout getView(TokenRow row, ViewGroup parent, final TableLayout result) {
+ final IndexEntry indexEntry = row.getIndexEntry();
+ return getPossibleHtmlEntryView(true, indexEntry.token, row.hasMainEntry, indexEntry.htmlEntries, null, parent, result);
+ }
+
+ private TableLayout getView(HtmlEntry.Row row, ViewGroup parent, final TableLayout result) {
+ final HtmlEntry htmlEntry = row.getEntry();
+ final TokenRow tokenRow = row.getTokenRow(true);
+ return getPossibleHtmlEntryView(false, getString(R.string.seeAlso, htmlEntry.title), false, Collections.singletonList(htmlEntry), tokenRow.getToken(), parent, result);
+ }
+
}
+
+
static final Pattern CHAR_DASH = Pattern.compile("['\\p{L}\\p{M}\\p{N}]+");
}
void setFiltered(final SearchOperation searchOperation) {
- ((Button) findViewById(R.id.UpButton)).setEnabled(false);
- ((Button) findViewById(R.id.DownButton)).setEnabled(false);
+ ((ImageButton) findViewById(R.id.UpButton)).setEnabled(false);
+ ((ImageButton) findViewById(R.id.DownButton)).setEnabled(false);
rowsToShow = searchOperation.multiWordSearchResult;
setListAdapter(new IndexAdapter(index, rowsToShow, searchOperation.searchTokens));
}
void clearFiltered() {
- ((Button) findViewById(R.id.UpButton)).setEnabled(true);
- ((Button) findViewById(R.id.DownButton)).setEnabled(true);
+ ((ImageButton) findViewById(R.id.UpButton)).setEnabled(true);
+ ((ImageButton) findViewById(R.id.DownButton)).setEnabled(true);
setListAdapter(new IndexAdapter(index));
rowsToShow = null;
}