$ show LinkSheet/LinkSheet
LinkSheet is an Android application that intercepts URL intents and presents a Material3 bottom sheet allowing users to choose which app or browser handles the link. In production, it replaces the removed Android 12+ chooser, supporting preferred app per domain, usage-based sorting, browser modes (always ask, none, whitelisted, single browser), and advanced URL processing including AMP to HTML conversion, redirect following, ClearURLs (tracker removal), FastForward (redirect bypass), LibRedirect (privacy-friendly frontends), and a custom rule engine (scenarios) for fine-grained link routing. The architecture is multi-modular: core app module, feature modules (analytics, backup, browser, device compat, downloader, engine, libredirect, profile, remote config, shizuku, wiki), integration libraries (amp2html, clearurl, embed-resolve, fastforward, mime-types), and shared libraries (api, compose, bottom-sheet, scaffold, http). Key entry points are `BottomSheetActivity`, `MainActivity`, and `LinkEngineService`. The system uses Koin dependency injection, Jetpack Compose for UI, Room for local caching, Ktor/OkHttp for networking, and Shizuku for privileged operations. It is actively maintained with nightly builds, extensive unit/instrumentation tests, and a large localization effort across 20+ languages.
The LLM identified 3 files worth highlighting for reuse:
A standalone Kotlin library for removing tracking parameters from URLs using JSON-defined rules. It loads a ruleset (currently embedded as `clearurls.json`) and applies transformations to strip known tracking parameters, redact URLs, and normalize queries. The library is self-contained (only depends on Kotlin stdlib) and can be extracted into a new project with minimal adaptation. It demonstrates non-obvious skill in implementing a performant, rule-based URL sanitizer with support for provider-specific rules, wildcards, and pattern matching.
A custom expression evaluation engine with its own bytecode-like opcodes (see `OpCodes.kt`) for evaluating rules on URL and intent contexts. It supports comparisons, string operations, regex matching, control flow (if/else), and access to engine run context (URL, app role, etc.). Expressions are serializable via protobuf, allowing persistence and potential exchange. The evaluator is designed as a tree of `Expression` nodes with a `BlockExpression` for sequences. Despite being part of the larger engine feature, the core evaluation logic is isolated and could be reused in any Kotlin project needing a lightweight, embeddable rule evaluator.
A set of interfaces and models that define a generic backup/export pattern for any repository. `ExportableRepository` declares `export()` and `import()` using typed export models. The `ExportModel` provides a `type` discriminator and a serializer. This pattern allows any data store to be easily included in the app's backup/restore flow. The design is clean, decoupled from the specific backup UI, and could be extracted as a reusable library for any Android app needing structured data export/import.