Add E-ink Optimizations and AI-Assisted Reading#37
Open
kkbin505 wants to merge 2 commits into
Open
Conversation
Add two major feature areas on top of the MuPDF Android viewer base. ### E-ink Screen Optimizations - Add `setAnimationsEnabled(bool)` to ReaderView: when disabled, scroll duration drops from 400 ms to 1 ms and drag scrolling is suppressed, eliminating ghosting on e-ink panels. - Add `setEinkRefreshEnabled(bool)` to ReaderView: posts an invalidate() after each page settlement to trigger a full-screen refresh cycle. - Fling gestures now jump directly to the next/previous page instead of smooth-scrolling when animations are off. - Add a Settings button (wrench icon) to the top bar with a popup menu for toggling animations, e-ink refresh, and setting the OpenAI API key. All settings are persisted via SharedPreferences. ### AI-Assisted Reading - Add AiDocumentActivity (extends DocumentActivity) that overlays a Jetpack Compose UI onto the existing PDF reader without replacing it. - Add IonizationOverlay: a full-screen Canvas gesture layer that detects free-form draw gestures and fires a vibration + AI request on release. - Add OpenAiClient: streams chat completions from the OpenAI API over SSE using OkHttp. The system prompt produces two structured sections — an AI Explanation and an Atomic Note (core concept / key insight / connections). - Add AiPanel: a bottom sheet built in Compose that slides up and renders the streaming response token-by-token in real time. - Expose MuPDFCore.getPageText() to extract structured text from the current page via MuPDF's StructuredText API for use as AI context. - Add SecurePreferences: stores the OpenAI API key in EncryptedSharedPreferences (AES256-GCM) so the key is never stored in plain text. - Add ObsidianExporter: saves AI responses as Markdown files under Documents/ObsidianVault/Atoms/ with #atom #atomread tags for integration with Obsidian. - Add AtomReadActivity registered as an alternate PDF intent handler (application/pdf MIME), combining the PDF viewer with the AI overlay. - Add BondingView: prototype Compose component for visually linking atomic notes via drag-and-drop collision (not yet wired to main flow).
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.
This PR adds two major feature areas to the MuPDF Android viewer:
Changes
E-ink Screen Optimizations
ReaderView: addsetAnimationsEnabled(bool)— when disabled, scroll duration drops from 400 ms to 1 ms, drag scrolling is suppressed, and fling gestures jump directly to the next/previous page instead of smooth-scrolling.ReaderView: addsetEinkRefreshEnabled(bool)— postsinvalidate()after each page settlement to trigger a full-screen e-ink refresh cycle.DocumentActivity: add a Settings button (wrench icon) to the top bar with a popup menu for toggling animations, e-ink refresh, and entering the OpenAI API key. Settings persist viaSharedPreferences.AI-Assisted Reading
AiDocumentActivityDocumentActivity; hosts the Compose AI overlay without replacing the existing reader UIIonizationOverlayOpenAiClientAiPanelAiFloatingDialogAtomReadActivityMuPDFCore.getPageText()StructuredTextAPI for use as AI contextSecurePreferencesEncryptedSharedPreferences(AES256-GCM)ObsidianExporter.mdfiles underDocuments/ObsidianVault/Atoms/with#atom #atomreadtagsAtomReadActivityapplication/pdfMIME); registered in manifest so it appears in the system "Open with" sheetBondingView