Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements a comprehensive text search feature for the PDF viewer application and addresses a Toast deprecation warning by replacing the custom Toast view with a TextView overlay.
Key Changes:
- Added full-text search functionality with visual highlighting and navigation across PDF pages
- Replaced deprecated
Toast.setView()with a custom TextView overlay for page number display - Implemented bidirectional JavaScript-Android bridge communication for search operations
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| viewer/main.css | Added CSS classes for search highlight containers and selected/unselected highlight styling |
| viewer/js/search_controller.js | New search controller implementing asynchronous text indexing, substring matching, and DOM-based highlight rendering |
| viewer/js/index.js | Integrated search controller with PDF.js rendering pipeline and added message handler for Android bridge communication |
| viewer/css/text_layer.css | Code formatting improvements (spacing, line breaks) |
| app/src/main/res/values/strings.xml | Added search-related string resources (action_search, search_hint, no_matches, match_status) |
| app/src/main/res/menu/pdf_viewer.xml | Added search action menu item with SearchView configuration |
| app/src/main/res/layout/pdfviewer.xml | Added page_number_view TextView to replace deprecated Toast implementation |
| app/src/main/res/drawable/ic_search_24dp.xml | New search icon vector drawable |
| app/src/main/java/app/grapheneos/pdfviewer/PdfViewer.java | Implemented search UI logic, replaced Toast with TextView, added JSON-based WebView bridge methods, and integrated search navigation with existing prev/next buttons |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d8374d1 to
e1d86d3
Compare
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR implements native-feeling text search functionality within the PDF viewer and resolves a long-standing deprecation warning regarding Toasts.
Changes
Search Feature
SearchControllerclass in JavaScript that interfaces directly with the PDF.js text layer.requestAnimationFrame) to ensure the UI remains responsive even during large document scans.SearchView, providing a familiar Android UX.evaluateJavascriptto inject JSON command objects (find,findNext,closesearch) into a newonMessagehandler.@JavascriptInterfacecallbacks to report search progress and match counts to the native UI..search-highlight) that scale correctly with zoom.UI Improvements
Toast.setView()API with a custom, high-performanceTextViewoverlay.Maintenance
PdfViewer.java, removing legacy boilerplate and enforcing stricter type safety in bridge calls.Fixes
Toast.setView()deprecation warning.Disclaimer: This PR was implemented with the assistance of Gemini 3 Pro.