diff options
author | Leon Scroggins <scroggo@google.com> | 2010-05-06 16:36:42 -0400 |
---|---|---|
committer | Leon Scroggins <scroggo@google.com> | 2010-05-06 18:09:26 -0400 |
commit | bff40383a6d685eb2f025a894e53d30d4bc239a1 (patch) | |
tree | 2d984f00189a8e63388c0fcdfe19fd8775683238 /src/com/android | |
parent | cda8600237ad458e9579b34541ef6fa3504e10b4 (diff) | |
download | packages_apps_Browser-bff40383a6d685eb2f025a894e53d30d4bc239a1.zip packages_apps_Browser-bff40383a6d685eb2f025a894e53d30d4bc239a1.tar.gz packages_apps_Browser-bff40383a6d685eb2f025a894e53d30d4bc239a1.tar.bz2 |
Improve the details shown about the matches.
Show "i of n" rather than just the number of matches. Also use a
separate string for 'zero' matches, since getQuantityString does
not work for quantity '0'.
Bug 2663680
Depends on changes to frameworks/base and external/webkit.
Change-Id: I4f2f096a4bc78e0c274993f42061cec85aeec745
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/browser/FindDialog.java | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/com/android/browser/FindDialog.java b/src/com/android/browser/FindDialog.java index 9646952..bcd5bb7 100644 --- a/src/com/android/browser/FindDialog.java +++ b/src/com/android/browser/FindDialog.java @@ -48,6 +48,7 @@ import android.widget.TextView; // (or the text needs to be changed) before WebView.findAll can be called. // Once it has been called, enter should move to the next match. private boolean mMatchesFound; + private int mNumberOfMatches; private View.OnClickListener mFindListener = new View.OnClickListener() { public void onClick(View v) { findNext(); @@ -68,6 +69,7 @@ import android.widget.TextView; throw new AssertionError("No WebView for FindDialog::onClick"); } mWebView.findNext(false); + updateMatchesString(); hideSoftInput(); } }; @@ -175,6 +177,7 @@ import android.widget.TextView; throw new AssertionError("No WebView for FindDialog::findNext"); } mWebView.findNext(true); + updateMatchesString(); hideSoftInput(); } @@ -182,12 +185,13 @@ import android.widget.TextView; // In case the matches view is showing from a previous search mMatchesView.setVisibility(View.INVISIBLE); mMatchesFound = false; + // This text is only here to ensure that mMatches has a height. + mMatches.setText("0"); mEditText.requestFocus(); Spannable span = (Spannable) mEditText.getText(); int length = span.length(); Selection.setSelection(span, 0, length); span.setSpan(this, 0, length, Spannable.SPAN_INCLUSIVE_INCLUSIVE); - setMatchesFound(0); disableButtons(); startAnimation(AnimationUtils.loadAnimation(mBrowserActivity, R.anim.find_dialog_enter)); @@ -207,14 +211,14 @@ import android.widget.TextView; int start, int before, int count) { - if (mWebView == null) { - throw new AssertionError( - "No WebView for FindDialog::onTextChanged"); - } findAll(); } private void findAll() { + if (mWebView == null) { + throw new AssertionError( + "No WebView for FindDialog::findAll"); + } CharSequence find = mEditText.getText(); if (0 == find.length()) { disableButtons(); @@ -228,7 +232,10 @@ import android.widget.TextView; if (found < 2) { disableButtons(); if (found == 0) { - setMatchesFound(0); + // Cannot use getQuantityString, which ignores the "zero" + // quantity. + mMatches.setText(mBrowserActivity.getResources().getString( + R.string.no_matches)); } } else { mPrevButton.setFocusable(true); @@ -240,8 +247,16 @@ import android.widget.TextView; } private void setMatchesFound(int found) { + mNumberOfMatches = found; + updateMatchesString(); + } + + private void updateMatchesString() { + // Note: updateMatchesString is only called by methods that have already + // checked mWebView for null. String template = mBrowserActivity.getResources(). - getQuantityString(R.plurals.matches_found, found, found); + getQuantityString(R.plurals.matches_found, mNumberOfMatches, + mWebView.findIndex() + 1, mNumberOfMatches); mMatches.setText(template); } |