Multi-Provider AI Unification & UX Overhaul - #39
Open
kkbin505 wants to merge 7 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).
…ocument viewing ,DeepSeek V3/R1 和 GPT 4.1/5.4 Mini 支持
## Body
- **Multi-Key Secure Storage**: Refactored `SecurePreferences` to support 5 independent API key slots (OpenAI, DeepSeek, Qwen, Anthropic, Gemini) with smart auto-routing based on model/URL.
- **Enhanced AI Settings**: Redesigned the settings dialog with a secure multi-input layout and 12 "Quick Presets" for instant configuration of top-tier models (GPT-4o, Claude 3.5, Gemini 2.0, DeepSeek R1, etc.).
- **Unified AiClient**:
- Native support for Anthropic Messages API (Claude).
- Robust streaming parser for OpenAI-compatible providers.
- Improved stability with 60s timeouts and null-chunk filtering (fixed "nullnullnull" output).
- **UX Polishing**:
- Automatic exit from AI mode upon closing the assistant panel to restore page-turning.
- Context-aware error messages identifying which specific API key is missing.
- Removed redundant reasoning/thinking blocks for a cleaner user experience.
## Footer
Co-authored-by: Antigravity <antigravity@google.com>
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 unifies the AI integration architecture, enabling seamless switching between major AI providers without credential re-entry. It also polishes the AI Assistant's interactive flow for a more "frictionless" reading experience.
Key Changes
1. Smart Credential Management
2. Redesigned AI Settings Dialog
3. Core Engine Upgrades (
AiClient)4. Interaction Flow (心流优化)
Testing Performed