Developer Guide

EinkBro is built with Kotlin and modern Android development practices. This guide covers the architecture, build process, and key development areas for contributors.

Architecture Overview

┌─────────────────────────────────────────────────┐ │ app module │ │ │ │ ┌──────────┐ ┌───────────┐ ┌──────────────┐ │ │ │ Activity │ │ ViewModel │ │ Repository │ │ │ │ (Compose) │──│ (StateFlow│──│ (Room, API) │ │ │ └──────────┘ │ LiveData)│ └──────────────┘ │ │ └───────────┘ │ │ │ │ ┌──────────┐ ┌───────────┐ ┌──────────────┐ │ │ │ EBWebView│ │ Koin │ │ Services │ │ │ │ (Custom │ │ (DI) │ │ (Translation │ │ │ │ WebView) │ │ │ │ TTS, AI) │ │ │ └──────────┘ └───────────┘ └──────────────┘ │ ├─────────────────────────────────────────────────┤ │ ad-filter module │ │ JS scriptlets · FilterViewModel · filter logic │ ├─────────────────────────────────────────────────┤ │ adblock-client module │ │ Native C++ via CMake (JNI) │ └─────────────────────────────────────────────────┘

Core Patterns

Module Structure

ModulePurposeKey Technologies
appMain browser applicationKotlin, Compose, Room, Koin, WebView
ad-filterAd-blocking logic and JS scriptletsJavaScript, FilterViewModel
adblock-clientNative ad-blocking implementationC++, CMake, JNI

Key Components

ComponentDescription
EinkBroApplication.ktApplication class; initializes Koin DI container
BrowserActivity.ktMain activity (singleInstance launch mode); handles all browser UI
EBWebView.ktCustom WebView with E-Ink optimizations (scroll behavior, reader mode CSS injection, JS interfaces)
GptActionsActivity.ktUI for AI/ChatGPT interactions
OpenAiRepository.ktAPI communication layer for OpenAI, Gemini, and compatible servers
ChatGptQuery.ktRoom database entity for persisting GPT query results
ConfigManager.ktSharedPreferences wrapper with Kotlin property delegates for all settings
ToolbarAction.ktEnum defining all 43 toolbar actions with icons, labels, and states
MenuDialogFragment.ktCompose-based action menu with collapsible sections

Build Configuration

PropertyValue
Min SDK24 (Android 7.0)
Target SDK34 (Android 14)
JVM TargetJava 17
Kotlin2.0.0 with KSP
ABI Splitsarm64-v8a, armeabi-v7a, x86, x86_64

Build Commands

Development

# Build debug APK
./gradlew assembleDebug

# Build release APK
./gradlew assembleRelease

# Build releaseDebuggable variant
./gradlew assembleReleaseDebuggable

# Install debug on connected device
./gradlew installDebug

# Clean build
./gradlew clean

Testing

# Run unit tests
./gradlew test

# Run instrumented tests
./gradlew connectedAndroidTest

# Run lint checks
./gradlew lint

# Debug lint only
./gradlew lintDebug

Key Development Areas

WebView Customization

E-Ink specific WebView optimizations are implemented in EBWebView.kt:

AI Integration

ChatGPT/AI functionality spans several components:

EPUB Processing

Complete EPUB reading and writing using EPubLib:

Translation Services

Multi-provider translation with paragraph-level, full-page, and image translation. Providers include Google Translate, DeepL, and AI-based translation via OpenAI/Gemini.

Database & Schema

Room database schemas are stored in app/schemas/. When modifying entities, ensure migration paths are properly defined. Key entities include bookmarks, history records, GPT queries, and whitelists.

Internationalization

The project supports 25+ languages managed through Crowdin. Translation files follow standard Android format at res/values-*/strings.xml. Do not edit translation files directly — changes should go through Crowdin.

ProGuard

Release builds use ProGuard for code obfuscation and optimization:

Contributing

  1. Fork the repository on GitHub
  2. Create a feature branch from main
  3. Make your changes and test on an E-Ink device if possible
  4. Submit a Pull Request with a clear description of changes

The project uses Fastlane for deployment automation and supports F-Droid distribution.