-
-
Notifications
You must be signed in to change notification settings - Fork 120
feat: Search (Fixes #4) #579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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.