$ show uintdev/qrserv
QRServ is an Android application that turns a device into a local file-sharing server. Users select files (or use Direct Access Mode for single files without copying), and the app starts an embedded Ktor HTTP server on an unused port. The server URL is displayed as a QR code for other devices on the same network to scan and download files. Optionally, on Android 13+, QRServ can create a private Wi-Fi hotspot (with band selection on Android 16+) so that only devices joining the hotspot can access the files. The app runs a foreground service with a persistent notification, handles HTTP range requests for large files, and includes an idle timeout that automatically stops the server when no downloads occur for a configurable period. The architecture follows a standard Android MVVM pattern with Jetpack Compose UI, using StateFlow for reactive state management and a centralized ViewModel (QRServViewModel) that orchestrates server lifecycle, network callbacks, and hotspot control. The codebase demonstrates strong engineering practices including comprehensive unit tests, separation of concerns into repositories and controllers, and careful handling of Android-specific edge cases such as permission revocations, network changes, and file removal during sharing. The app is available on Google Play and IzzyOnDroid with multi-language support.
The LLM identified 5 files worth highlighting for reuse:
A Jetpack Compose Text composable that performs grapheme-aware middle ellipsis. Unlike simple character truncation, this component correctly handles Unicode graphemes (emoji, combining characters) by using a BreakIterator to identify grapheme cluster boundaries. It measures the text and replaces the middle portion with an ellipsis while preserving the beginning and end. This is a non-trivial, easily extractable utility for any Compose project needing readable filename or URL truncation.
A robust parser and data model for HTTP Range headers, supporting both single and multi-range requests (including 'bytes=0-', 'bytes=10-20', 'bytes=-100'). It correctly computes content length, validates ranges, and provides a data class for use in response headers. This is self-contained, well-tested, and can be reused in any HTTP server or client library that needs RFC 7233 compliant range parsing.
Manages a temporary file cache with atomic cleanup using a Kotlin Mutex. Provides methods to delete a cached file or the entire cache directory, ensuring that concurrent cleanup operations do not interfere. The cache path is a subdirectory of the app's cache directory, and the manager clears stale entries on import. This pattern is reusable in any Android app that needs a thread-safe temporary file store.
Generates cryptographically random, URL-safe tokens for sharing URLs. Uses SecureRandom and base64 encoding without padding to produce compact tokens. The token length is configurable. This is a small, self-contained utility that demonstrates secure token generation without external dependencies, suitable for any server or authentication context.
Comprehensive unit tests for the ByteRanges parser, covering valid single/multi-range headers, edge cases (zero-length, out-of-bounds, overlapping ranges), and malformed inputs. Uses Kotlin's parameterized tests for efficient coverage. This test file serves as an excellent template for testing parsers and demonstrates thorough edge-case enumeration in network protocol logic.