Brion VIBBER has submitted this change and it was merged. Change subject: Make 'Go' button go to exact page title user typed ......................................................................
Make 'Go' button go to exact page title user typed Note that this crashes the app if there is no such page but that should be handled as part of bug 62639 Bug: 62774 Change-Id: Ic48bea20e1931eb861395605128d8c4fa894cde3 --- M wikipedia/res/layout/fragment_search.xml M wikipedia/src/main/java/org/wikipedia/search/SearchArticlesFragment.java 2 files changed, 27 insertions(+), 6 deletions(-) Approvals: Brion VIBBER: Verified; Looks good to me, approved diff --git a/wikipedia/res/layout/fragment_search.xml b/wikipedia/res/layout/fragment_search.xml index 419e6e7..013b4f4 100644 --- a/wikipedia/res/layout/fragment_search.xml +++ b/wikipedia/res/layout/fragment_search.xml @@ -56,7 +56,7 @@ android:padding="8dp" android:selectAllOnFocus="true" android:singleLine="true" - android:imeOptions="actionDone" + android:imeOptions="actionGo" android:textCursorDrawable="@null" /> <ProgressBar diff --git a/wikipedia/src/main/java/org/wikipedia/search/SearchArticlesFragment.java b/wikipedia/src/main/java/org/wikipedia/search/SearchArticlesFragment.java index 204f700..a5269bc 100644 --- a/wikipedia/src/main/java/org/wikipedia/search/SearchArticlesFragment.java +++ b/wikipedia/src/main/java/org/wikipedia/search/SearchArticlesFragment.java @@ -194,11 +194,7 @@ @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { PageTitle title = (PageTitle) searchResultsList.getAdapter().getItem(position); - HistoryEntry historyEntry = new HistoryEntry(title, HistoryEntry.SOURCE_SEARCH); - InputMethodManager keyboard = (InputMethodManager)app.getSystemService(Context.INPUT_METHOD_SERVICE); - keyboard.hideSoftInputFromWindow(searchTermText.getWindowToken(), 0); - app.getBus().post(new NewWikiPageNavigationEvent(title, historyEntry)); - hideSearchResults(); + navigateToTitle(title); } }); @@ -239,6 +235,23 @@ } }); + searchTermText.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView textView, int action, KeyEvent keyEvent) { + if (action == EditorInfo.IME_ACTION_GO) { + String searchTerm = searchTermText.getText().toString(); + if (searchTerm.length() > 0) { + PageTitle title = new PageTitle(searchTermText.getText().toString(), app.getPrimarySite()); + navigateToTitle(title); + } else { + hideSearchResults(); + } + return true; + } + return false; + } + }); + adapter = new SearchResultAdapter(inflater); searchResultsList.setAdapter(adapter); @@ -257,6 +270,14 @@ return parentLayout; } + private void navigateToTitle(PageTitle title) { + HistoryEntry historyEntry = new HistoryEntry(title, HistoryEntry.SOURCE_SEARCH); + InputMethodManager keyboard = (InputMethodManager)app.getSystemService(Context.INPUT_METHOD_SERVICE); + keyboard.hideSoftInputFromWindow(searchTermText.getWindowToken(), 0); + app.getBus().post(new NewWikiPageNavigationEvent(title, historyEntry)); + hideSearchResults(); + } + private void startSearch(String term) { if (Utils.compareStrings(term, lastSearchedText) && isSearchActive) { return; // Nothing has changed! -- To view, visit https://gerrit.wikimedia.org/r/121353 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic48bea20e1931eb861395605128d8c4fa894cde3 Gerrit-PatchSet: 3 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Yuvipanda <yuvipa...@gmail.com> Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org> Gerrit-Reviewer: Yuvipanda <yuvipa...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits