How quantumbadger/redreader works
Project type and purpose
• This is a native Android client app (“RedReader”) for browsing Reddit.
• It’s a mobile‐only application that interfaces with Reddit’s REST API, provides local caching, image/video viewing, multiple accounts, and supports features like swipe actions and themes.
File structure
• Top‐level build files (build.gradle.kts, gradle/, fastlane/) indicate a Gradle‐based Android project with CI/CD and release metadata.
• src/main/java/org/quantumbadger/redreader contains the main app code, organized into feature packages (activities, fragments, adapters, cache, common, http, image, reddit, settings, views).
• libs/redreader-common and libs/redreader-datamodel are shared library modules encapsulating cross‐cutting utilities (time, collections) and data definitions.
• Resources (src/main/res/) include layouts, drawables, themes, localized strings.
• Tests under src/androidTest and src/test cover UI and unit tests.
• Receivers (receivers/), BootReceiver and schedulers indicate background jobs.
• HTTP implementations under http/ and http/okhttp/ show pluggable backends.
• Compose UI code under compose/ for Jetpack Compose integration.
README for additional insights
• Confirms features: caching, multiple accounts, image/video player, swipe actions, themes.
• Mentions open-source nature, build via Gradle, Android API 21+ support.
Main components
a. Presentation Layer
• Android Activities & Fragments
• Jetpack Compose components
• Custom Views (e.g., GIFView, ExoPlayerWrapperView)
b. Domain / Controller Layer
• ListingControllers (PostListingController, CommentListingController)
• Adapters & Managers (RedditListingManager, CacheManager, RedditAccountManager)
• FeatureFlagHandler, ChangelogManager
c. Data Layer
• HTTPBackend / OKHTTPBackend (network abstraction)
• JSON parsers (jsonwrap/, reddit/kthings/)
• Cache DB & ContentProvider (cache/CacheContentProvider, io/RawObjectDB)
• Download strategies (Cache download, prioritisation)
d. External Services
• Reddit REST API (RedditAPI, RedditOAuth)
• Image/video providers (ImgurAPI, GfycatAPI, DeviantArtAPI, RedditGalleryAPI)
e. Android Platform
• BroadcastReceivers & Alarms (BootReceiver, NewMessageChecker, RegularCachePruner)
• System services (Connectivity, Storage, SharedPreferences)
Relationships and interactions
• UI components initiate requests (e.g., user scrolls, swipes, taps).
• Controllers / Managers decide data source:
• If cached and within policy → CacheManager retrieves from local DB
• Otherwise → HTTPBackend issues network request via OKHTTP → remote API
• JSON responses parsed into datamodel objects → passed back to controllers → view updated.
• Background Receivers schedule periodic cache pruning and message checks.
• Shared libraries (redreader-common, redreader-datamodel) provide utility functions and type definitions.
Architectural patterns & design principles
• Layered architecture (Presentation → Domain → Data)
• Strategy pattern for download strategies
• Factory pattern for JSON/value object creation
• Observer/listener pattern (e.g., RedditAccountChangeListener, CacheRequestCallbacks)
• Separation of concerns: UI, networking, caching, parsing each in its own package
• Use of shared modules to avoid code duplication
Technologies, frameworks, libraries
• Android SDK (Activities, Fragments, Services, BroadcastReceivers)
• Gradle Kotlin DSL for build configuration
• Jetpack Compose (in compose/)
• OkHttp for HTTP networking
• ExoPlayer for video playback
• JSON handling via custom wrappers
• Local storage via SQLite/ContentProvider and custom RawObjectDB
Diagramming recommendations
• UI → Controllers → Data Layer → External Services
• Receivers → CacheManager
• Rectangles for code modules
Essential elements to capture
• All major packages: activities, fragments, http, cache, reddit, image
• Shared modules (redreader-common, redreader-datamodel)
• Network request flow and caching strategy
• Background scheduling via BroadcastReceivers
• UI update path from parsed data to view