itkach / aard2-android

Aard2 for Android, a simple dictionary app
GNU General Public License v3.0
426 stars 98 forks source link

Implement a custom search box in the Webview #107

Closed qnga closed 4 years ago

qnga commented 4 years ago

Hello, I've faced the issue #106 too on my mobile and fixed it by implementing a custom search box (largely inspired by AOSP's one). Let me know if everything's ok.

itkach commented 4 years ago

@qnga Awesome, works well! one small thing I noticed is that when text to find is deleted with backspace, character by character, highlight for the last deleted character is not cleared; other than that looks good.

itkach commented 4 years ago

Looks like onTextChange needs to clear matches if new text is empty, like so:

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        if (s.length() == 0) {
            webview.clearMatches();
        }
        else {
            findAll();
        }
    }
qnga commented 4 years ago

Thanks for reporting this bug! I fixed it differently by removing a legacy separate case in findAll().

By the way, I was no able to test with API 15, when Webview.findAllAsync() is not available. I have a file access permission issue on startup.