Loading core/java/android/webkit/FindActionModeCallback.java +4 −7 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ class FindActionModeCallback implements ActionMode.Callback, TextWatcher, private int mNumberOfMatches; private int mActiveMatchIndex; private ActionMode mActionMode; private String mLastFind; FindActionModeCallback(Context context) { mCustomView = LayoutInflater.from(context).inflate( Loading Loading @@ -134,13 +133,12 @@ class FindActionModeCallback implements ActionMode.Callback, TextWatcher, mWebView.clearMatches(); mMatches.setVisibility(View.GONE); mMatchesFound = false; mLastFind = null; mWebView.findAll(null); } else { mMatchesFound = true; mMatches.setVisibility(View.INVISIBLE); mNumberOfMatches = 0; mLastFind = find.toString(); mWebView.findAllAsync(mLastFind); mWebView.findAllAsync(find.toString()); } } Loading @@ -150,9 +148,8 @@ class FindActionModeCallback implements ActionMode.Callback, TextWatcher, mInput.showSoftInput(mEditText, 0); } public void updateMatchCount(int matchIndex, int matchCount, String findText) { if (mLastFind != null && mLastFind.equals(findText)) { public void updateMatchCount(int matchIndex, int matchCount, boolean isNewFind) { if (!isNewFind) { mNumberOfMatches = matchCount; mActiveMatchIndex = matchIndex; updateMatchesString(); Loading core/java/android/webkit/FindListener.java 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.webkit; /** * @hide */ public interface FindListener { /** * Notify the host application that a find result is available. * * @param numberOfMatches How many matches have been found * @param activeMatchOrdinal The ordinal of the currently selected match * @param isDoneCounting Whether we have finished counting matches */ public void onFindResultReceived(int numberOfMatches, int activeMatchOrdinal, boolean isDoneCounting); } core/java/android/webkit/WebView.java +27 −2 Original line number Diff line number Diff line Loading @@ -1226,7 +1226,19 @@ public class WebView extends AbsoluteLayout } /* /** * Register the interface to be used when a find-on-page result has become * available. This will replace the current handler. * * @param listener An implementation of FindListener * @hide */ public void setFindListener(FindListener listener) { checkThread(); mProvider.setFindListener(listener); } /** * Highlight and scroll to the next occurance of String in findAll. * Wraps the page infinitely, and scrolls. Must be called after * calling findAll. Loading @@ -1238,8 +1250,9 @@ public class WebView extends AbsoluteLayout mProvider.findNext(forward); } /* /** * Find all instances of find on the page and highlight them. * * @param find String to find. * @return int The number of occurances of the String "find" * that were found. Loading @@ -1249,6 +1262,18 @@ public class WebView extends AbsoluteLayout return mProvider.findAll(find); } /** * Find all instances of find on the page and highlight them, * asynchronously. * * @param find String to find. * @hide */ public void findAllAsync(String find) { checkThread(); mProvider.findAllAsync(find); } /** * Start an ActionMode for finding text in this WebView. Only works if this * WebView is attached to the view system. Loading core/java/android/webkit/WebViewClassic.java +20 −4 Original line number Diff line number Diff line Loading @@ -1440,6 +1440,9 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc // Used to notify listeners of a new picture. private PictureListener mPictureListener; // Used to notify listeners about find-on-page results. private FindListener mFindListener; /** * Refer to {@link WebView#requestFocusNodeHref(Message)} for more information */ Loading Loading @@ -3694,6 +3697,17 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc return mCallbackProxy.getBackForwardList().clone(); } /** * Register the interface to be used when a find-on-page result has become * available. This will replace the current handler. * * @param listener An implementation of FindListener */ public void setFindListener(FindListener listener) { checkThread(); mFindListener = listener; } /** * See {@link WebView#findNext(boolean)} */ Loading Loading @@ -3723,6 +3737,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc checkThread(); if (0 == mNativeClass) return 0; // client isn't initialized mLastFind = find; if (find == null) return 0; mWebViewCore.removeMessages(EventHub.FIND_ALL); WebViewCore.FindAllRequest request = new WebViewCore.FindAllRequest(find); Loading Loading @@ -8478,10 +8493,11 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc } case UPDATE_MATCH_COUNT: { if (mFindCallback != null) { mFindCallback.updateMatchCount(msg.arg1, msg.arg2, (String) msg.obj); } boolean isNewFind = mLastFind == null || !mLastFind.equals(msg.obj); if (mFindCallback != null) mFindCallback.updateMatchCount(msg.arg1, msg.arg2, isNewFind); if (mFindListener != null) mFindListener.onFindResultReceived(msg.arg1, msg.arg2, true); break; } case CLEAR_CARET_HANDLE: Loading core/java/android/webkit/WebViewProvider.java +4 −0 Original line number Diff line number Diff line Loading @@ -191,10 +191,14 @@ public interface WebViewProvider { public WebBackForwardList copyBackForwardList(); public void setFindListener(FindListener listener); public void findNext(boolean forward); public int findAll(String find); public void findAllAsync(String find); public boolean showFindDialog(String text, boolean showIme); public void clearMatches(); Loading Loading
core/java/android/webkit/FindActionModeCallback.java +4 −7 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ class FindActionModeCallback implements ActionMode.Callback, TextWatcher, private int mNumberOfMatches; private int mActiveMatchIndex; private ActionMode mActionMode; private String mLastFind; FindActionModeCallback(Context context) { mCustomView = LayoutInflater.from(context).inflate( Loading Loading @@ -134,13 +133,12 @@ class FindActionModeCallback implements ActionMode.Callback, TextWatcher, mWebView.clearMatches(); mMatches.setVisibility(View.GONE); mMatchesFound = false; mLastFind = null; mWebView.findAll(null); } else { mMatchesFound = true; mMatches.setVisibility(View.INVISIBLE); mNumberOfMatches = 0; mLastFind = find.toString(); mWebView.findAllAsync(mLastFind); mWebView.findAllAsync(find.toString()); } } Loading @@ -150,9 +148,8 @@ class FindActionModeCallback implements ActionMode.Callback, TextWatcher, mInput.showSoftInput(mEditText, 0); } public void updateMatchCount(int matchIndex, int matchCount, String findText) { if (mLastFind != null && mLastFind.equals(findText)) { public void updateMatchCount(int matchIndex, int matchCount, boolean isNewFind) { if (!isNewFind) { mNumberOfMatches = matchCount; mActiveMatchIndex = matchIndex; updateMatchesString(); Loading
core/java/android/webkit/FindListener.java 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.webkit; /** * @hide */ public interface FindListener { /** * Notify the host application that a find result is available. * * @param numberOfMatches How many matches have been found * @param activeMatchOrdinal The ordinal of the currently selected match * @param isDoneCounting Whether we have finished counting matches */ public void onFindResultReceived(int numberOfMatches, int activeMatchOrdinal, boolean isDoneCounting); }
core/java/android/webkit/WebView.java +27 −2 Original line number Diff line number Diff line Loading @@ -1226,7 +1226,19 @@ public class WebView extends AbsoluteLayout } /* /** * Register the interface to be used when a find-on-page result has become * available. This will replace the current handler. * * @param listener An implementation of FindListener * @hide */ public void setFindListener(FindListener listener) { checkThread(); mProvider.setFindListener(listener); } /** * Highlight and scroll to the next occurance of String in findAll. * Wraps the page infinitely, and scrolls. Must be called after * calling findAll. Loading @@ -1238,8 +1250,9 @@ public class WebView extends AbsoluteLayout mProvider.findNext(forward); } /* /** * Find all instances of find on the page and highlight them. * * @param find String to find. * @return int The number of occurances of the String "find" * that were found. Loading @@ -1249,6 +1262,18 @@ public class WebView extends AbsoluteLayout return mProvider.findAll(find); } /** * Find all instances of find on the page and highlight them, * asynchronously. * * @param find String to find. * @hide */ public void findAllAsync(String find) { checkThread(); mProvider.findAllAsync(find); } /** * Start an ActionMode for finding text in this WebView. Only works if this * WebView is attached to the view system. Loading
core/java/android/webkit/WebViewClassic.java +20 −4 Original line number Diff line number Diff line Loading @@ -1440,6 +1440,9 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc // Used to notify listeners of a new picture. private PictureListener mPictureListener; // Used to notify listeners about find-on-page results. private FindListener mFindListener; /** * Refer to {@link WebView#requestFocusNodeHref(Message)} for more information */ Loading Loading @@ -3694,6 +3697,17 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc return mCallbackProxy.getBackForwardList().clone(); } /** * Register the interface to be used when a find-on-page result has become * available. This will replace the current handler. * * @param listener An implementation of FindListener */ public void setFindListener(FindListener listener) { checkThread(); mFindListener = listener; } /** * See {@link WebView#findNext(boolean)} */ Loading Loading @@ -3723,6 +3737,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc checkThread(); if (0 == mNativeClass) return 0; // client isn't initialized mLastFind = find; if (find == null) return 0; mWebViewCore.removeMessages(EventHub.FIND_ALL); WebViewCore.FindAllRequest request = new WebViewCore.FindAllRequest(find); Loading Loading @@ -8478,10 +8493,11 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc } case UPDATE_MATCH_COUNT: { if (mFindCallback != null) { mFindCallback.updateMatchCount(msg.arg1, msg.arg2, (String) msg.obj); } boolean isNewFind = mLastFind == null || !mLastFind.equals(msg.obj); if (mFindCallback != null) mFindCallback.updateMatchCount(msg.arg1, msg.arg2, isNewFind); if (mFindListener != null) mFindListener.onFindResultReceived(msg.arg1, msg.arg2, true); break; } case CLEAR_CARET_HANDLE: Loading
core/java/android/webkit/WebViewProvider.java +4 −0 Original line number Diff line number Diff line Loading @@ -191,10 +191,14 @@ public interface WebViewProvider { public WebBackForwardList copyBackForwardList(); public void setFindListener(FindListener listener); public void findNext(boolean forward); public int findAll(String find); public void findAllAsync(String find); public boolean showFindDialog(String text, boolean showIme); public void clearMatches(); Loading