jenkins-bot has submitted this change and it was merged. Change subject: Show number of matches when finding in page ......................................................................
Show number of matches when finding in page (available only in API16+) Original feature request: https://ticket.wikimedia.org/otrs/index.pl?Action=AgentTicketZoom&TicketID=7662758 Co-authored-by: dbrant <[email protected]> Change-Id: If18fccc36ae0eac336f8c9988d681f77b5ef0f53 --- M wikipedia/res/layout/fragment_find_in_page.xml M wikipedia/src/main/java/org/wikipedia/page/FindInPageFragment.java 2 files changed, 32 insertions(+), 0 deletions(-) Approvals: Yuvipanda: Looks good to me, approved Dbrant: Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/wikipedia/res/layout/fragment_find_in_page.xml b/wikipedia/res/layout/fragment_find_in_page.xml index e9223eb..bdd6b65 100644 --- a/wikipedia/res/layout/fragment_find_in_page.xml +++ b/wikipedia/res/layout/fragment_find_in_page.xml @@ -33,6 +33,14 @@ android:background="@null" android:textCursorDrawable="@null" /> + <TextView + android:id="@+id/find_in_page_match" + android:visibility="gone" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:gravity="center" + style="?android:textAppearanceSmall" + /> <Button android:id="@+id/find_in_page_prev" android:layout_width="48dp" diff --git a/wikipedia/src/main/java/org/wikipedia/page/FindInPageFragment.java b/wikipedia/src/main/java/org/wikipedia/page/FindInPageFragment.java index b54393d..d28496e 100644 --- a/wikipedia/src/main/java/org/wikipedia/page/FindInPageFragment.java +++ b/wikipedia/src/main/java/org/wikipedia/page/FindInPageFragment.java @@ -10,7 +10,9 @@ import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; +import android.webkit.WebView.FindListener; import android.widget.EditText; +import android.widget.TextView; import org.wikipedia.R; import org.wikipedia.Utils; import org.wikipedia.ViewAnimations; @@ -24,6 +26,7 @@ private View findInPageNext; private View findInPagePrev; private View findInPageClose; + private TextView findInPageMatch; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { @@ -69,6 +72,8 @@ } }); + findInPageMatch = (TextView) getView().findViewById(R.id.find_in_page_match); + findInPageInput = (EditText) getView().findViewById(R.id.find_in_page_input); findInPageInput.addTextChangedListener(new TextWatcher() { @Override @@ -86,6 +91,7 @@ findInPage(s.toString()); } else { parentActivity.getCurPageFragment().getWebView().clearMatches(); + findInPageMatch.setVisibility(View.GONE); } } @@ -157,6 +163,24 @@ public void findInPage(String s) { // to make it stop complaining if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + parentActivity.getCurPageFragment().getWebView().setFindListener(new FindListener() { + @Override + public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches, boolean isDoneCounting) { + if (!isDoneCounting) { + return; + } + if (numberOfMatches > 0) { + findInPageMatch.setText( + Integer.toString(activeMatchOrdinal + 1) + + "/" + + Integer.toString(numberOfMatches) + ); + findInPageMatch.setVisibility(View.VISIBLE); + } else { + findInPageMatch.setVisibility(View.GONE); + } + } + }); parentActivity.getCurPageFragment().getWebView().findAllAsync(s); } else { parentActivity.getCurPageFragment().getWebView().findAll(s); -- To view, visit https://gerrit.wikimedia.org/r/147761 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If18fccc36ae0eac336f8c9988d681f77b5ef0f53 Gerrit-PatchSet: 8 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Alex Monk <[email protected]> Gerrit-Reviewer: BearND <[email protected]> Gerrit-Reviewer: Dbrant <[email protected]> Gerrit-Reviewer: Dr0ptp4kt <[email protected]> Gerrit-Reviewer: Yuvipanda <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
