How krtonia/retromusicplayer works
1. What this repo is
Retro Music Player is a local Android music player. Its architecture is centered on browsing on-device media, maintaining a playback service, and rendering multiple UI surfaces around that shared player state. It does not stream music from a remote backend.
2. Module boundary
The repo has two main Gradle modules:
- app: the actual product app, with most features, UI, playback, persistence, and integrations.
- appthemehelper: a reusable theming/UI support library used by the app for consistent styling, tinted widgets, and preference components.
3. Application shell and entry points
The app starts from App.kt and the main activity stack (MainActivity, plus supporting activities like permission, error, lock screen, drive mode, tag editor, backup, etc.). The manifest is flavor-specific, with separate main, normal, and fdroid source sets that change packaging and integrations at build time.
4. UI structure
The UI is fragment-driven. MainActivity hosts navigation across major sections such as home, library, songs, albums, artists, playlists, genres, folders, search, settings, and about. A base layer of fragment/activity abstractions (AbsBaseActivity, AbsSlidingMusicPanelActivity, AbsPlayerFragment, etc.) keeps common behavior shared across the many screens and the now-playing variants.
5. Player screen variants
The app has a large “now playing” subsystem with many alternative layouts and fragments: normal, classic, blur, card, adaptive, color, fit, flat, full, gradient, material, md3, peek, plain, simple, tiny, and lock-screen controls. This is a major architectural axis: the same playback state is rendered through different view hierarchies and control fragments selected by user preference.
6. Playback core
Playback lives in the service package. MusicService is the central long-lived component, backed by classes such as PlaybackManager, RetroExoPlayer, CrossFadePlayer, AudioManagerPlayback, MediaSessionCallback, PlayingNotification, and related helpers. This layer owns queue state, media session integration, headset/media-button handling, notifications, seeking, and play-count updates.
7. Persistence and local library data
The app stores user/library data in Room (RetroDatabase, DAOs, entities, migrations). It persists playlists, songs, lyrics, history, play counts, and blacklist entries. The repository layer (SongRepository, AlbumRepository, ArtistRepository, PlaylistRepository, SearchRepository, etc.) sits above both Room and device media sources, providing the data used by fragments, adapters, and the player service.
8. Primary data flow
The typical flow is: Android media scan / MediaStore and local files feed repositories and scan helpers; repositories populate view models and UI fragments; user actions in fragments/adapters call helpers or repositories; playback commands are routed to MusicService; the service updates notification, queue, session, widgets, and persistent stores. This is the main boundary to draw in an architecture diagram.
9. Media artwork, palette, and image loading
The app has a custom image-loading layer under glide, with loaders for audio file covers, artist images, and playlist previews. This is coupled with palette/color utilities and blur/transform helpers to drive theming, album-art backgrounds, and now-playing visuals. Artwork is not just decoration; it feeds theme selection and player styling.
10. External services
The app uses Retrofit-based network clients for non-core enhancements: Last.fm, Deezer, and lyrics services. These are used for metadata enrichment and lyrics retrieval, not playback. There is also bug-reporting data modeling for GitHub submission. These external calls are peripheral and should be shown as optional add-ons to the local music experience.
11. Device and platform integrations
Several features integrate deeply with Android platform services: app widgets, home-screen shortcuts, Android Auto media browsing, cast/Chromecast, lock-screen controls, volume observation, storage access framework guidance, ringtone/share actions, and media-button receivers. These integrations hang off the playback service and repository layer rather than forming separate subsystems.
12. User customization and theming
Theme management is a first-class subsystem. The app supports multiple app themes, Material You / Monet styling, accent colors, and many preference-driven UI choices. The appthemehelper module supplies reusable themed widgets and preference components that keep UI consistency across the whole app.
13. Feature-specific write flows
Features like tag editing, playlist creation/import/export, backup/restore, and blacklist management form separate interaction paths but still converge on the same local storage and media-model layers. Tag editing writes back to files/metadata; playlist and backup flows write to app-owned storage and Room; blacklist affects scanning and library visibility.
14. Build flavors and distribution
The normal and fdroid source sets change behavior around proprietary integrations such as billing and cast support. This is important for architecture because some classes only exist in one flavor, so the product is effectively assembled from shared core code plus flavor-specific integration layers.
15. Diagram-friendly summary
A clear architecture diagram should show:
- Android UI layer: activity + fragment/navigation shell
- Playback/service layer: MusicService, player, media session, notification
- Data layer: repositories + Room + local files/MediaStore
- Media rendering layer: adapters, Glide loaders, theming/palette
- External enrichment layer: lyrics/Last.fm/Deezer/GitHub
- Platform integrations: widgets, shortcuts, Auto, cast, lock screen, backup/tag editing
Main entry points: MainActivity.kt MainActivity · MusicService.kt MusicService · Repository.kt Repositories · HomeFragment.kt Library screens
Components 22
App shell
Application entry points, activities, and navigation host in the main app module.
- App.kt · Application initialization and global wiring.
app/src/main/java/code/name/monkey/retromusic/App.kt - MainActivity · Primary activity hosting section navigation and the player panel.
app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.kt - Base activities · Shared activity abstractions for theming, service binding, and sliding player layout.
app/src/main/java/code/name/monkey/retromusic/activities/base/AbsBaseActivity.kt
UI surfaces
Fragments, adapters, dialogs, widgets, shortcuts, and player screen variants.
- Library screens · Home, library, songs, albums, artists, playlists, genres, folders, search, settings, about, and related detail screens.
app/src/main/java/code/name/monkey/retromusic/fragments/home/HomeFragment.kt - Now playing · Alternative now-playing layouts and playback-control fragments selected by preference.
app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerFragment.kt - Adapters · Recycler and list adapters for songs, albums, artists, playlists, search, home, backup, and queues.
app/src/main/java/code/name/monkey/retromusic/adapter/song/SongAdapter.kt - Dialogs · Playlist, sleep timer, playback speed, share, blacklist, deletion, and song detail flows.
app/src/main/java/code/name/monkey/retromusic/dialogs/CreatePlaylistDialog.kt - Widgets & shortcuts · Home-screen widgets and dynamic/app shortcuts that expose library and playback actions.
app/src/main/java/code/name/monkey/retromusic/appwidgets/base/BaseAppWidget.kt
Playback core
Long-lived playback service, player engine, media session, and notification handling.
- MusicService · Long-lived playback service coordinating queue, session, notification, and state updates.
app/src/main/java/code/name/monkey/retromusic/service/MusicService.kt - Player engine · ExoPlayer, crossfade, audio manager playback, and seek/fade helpers.
app/src/main/java/code/name/monkey/retromusic/service/RetroExoPlayer.kt - Session & notif · Media session callbacks and playback notification presentation.
app/src/main/java/code/name/monkey/retromusic/service/MediaSessionCallback.kt - Queue store · Persistent queue, play-count, and local service storage helpers.
app/src/main/java/code/name/monkey/retromusic/service/PersistentStorage.kt
Data layer
Repositories, Room persistence, local media scanning, and model layer for the on-device library.
- Media scan · Device media scanning, MediaStore observation, and local file sourcing.
app/src/main/java/code/name/monkey/retromusic/service/MediaStoreObserver.kt - Repositories · Song, album, artist, playlist, genre, search, and top-played repositories over local media and Room.
app/src/main/java/code/name/monkey/retromusic/repository/Repository.kt - Room DB · Room database, DAOs, entities, migrations, and app-owned library data such as playlists, history, lyrics, and blacklists.
app/src/main/java/code/name/monkey/retromusic/db/RetroDatabase.kt
Media rendering
Artwork loading, palette extraction, blur, and theme-driven visual rendering helpers.
- Artwork pipeline · Custom Glide loaders for audio covers, artist images, and playlist previews with palette and blur support.
app/src/main/java/code/name/monkey/retromusic/glide/RetroMusicGlideModule.kt - Theme colors · Palette, accent, blur, and wallpaper-driven color utilities used by artwork and player visuals.
app/src/main/java/code/name/monkey/retromusic/helper/WallpaperAccentManager.kt
Integrations
Platform integrations, external services, and flavor-specific features.
- External APIs · Retrofit clients for Last.fm, Deezer, lyrics services, and bug-report metadata submission.
app/src/main/java/code/name/monkey/retromusic/network/RetrofitClient.kt - Platform hooks · Android Auto, cast, media buttons, volume observation, SAF guidance, ringtone/share actions, and lock-screen controls.
app/src/main/java/code/name/monkey/retromusic/auto/AutoMusicProvider.kt - Flavor layers · Shared core augmented by normal/fdroid/debug source sets for billing, cast, and distribution-specific behavior.
app/src/normal/AndroidManifest.xml
Theme library
Reusable theming and preference support module shared by the app.
- appthemehelper · Reusable theming, tinting, and preference components shared across the app.
appthemehelper/src/main/java/code/name/monkey/appthemehelper/ThemeStore.kt - Theme widgets · Themed activities, preferences, switches, and view helpers used to keep UI consistent.
appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEPreference.kt
Connections 26
- App.kt → MainActivity: launches · Application startup hands off to the main activity stack.
- MainActivity → Base activities: inherits · Main screen uses shared activity abstractions for common behavior.
- MainActivity → Library screens: hosts · Activity navigates among the library and settings fragments.
- MainActivity → Now playing: renders · The activity/slider shell displays one of many now-playing layouts.
- MainActivity → Widgets & shortcuts: exposes · Main app state is surfaced through widgets and shortcuts.
- Library screens → Adapters: binds · Library and detail screens render lists through shared adapters.
- Library screens → Dialogs: opens · User actions on library screens invoke dialogs and secondary flows.
- Library screens → Repositories: reads · Fragments consume repository data for albums, artists, playlists, and search.
- Now playing → MusicService: controls · Now-playing UI is driven by the shared playback service state.
- Adapters → Repositories: loads · Adapters are populated from local library repositories and models.
- MusicService → Player engine: drives · Service owns the active player implementation and playback mechanics.
- MusicService → Session & notif: publishes · Service updates media session callbacks and playback notifications.
- MusicService → Queue store: persists · Service stores queue and play state in persistent service storage.
- MusicService → Room DB: updates · Playback actions update history, play counts, lyrics, and stored playlists.
- Repositories → Media scan: queries · Repositories combine MediaStore and local file sources.
- Repositories → Room DB: uses · Repositories read and write app-owned local data.
- Artwork pipeline → Theme colors: feeds · Loaded covers provide palette and blur inputs for theming.
- Now playing → Artwork pipeline: displays · Player screens depend on custom artwork loading and transformations.
- External APIs → Repositories: enriches · Metadata and lyrics services augment local library data.
- Platform hooks → MusicService: hooks into · Android integrations route control events into playback.
- Platform hooks → Repositories: queries · Some integrations need access to local library content.
- Flavor layers → Platform hooks: varies · Feature availability changes across normal and F-Droid builds.
- Flavor layers → appthemehelper: shares · All flavors reuse the theming support library.
- appthemehelper → Theme widgets: provides · Core theme state supports tinted preferences, widgets, and view helpers.
- appthemehelper → MainActivity: styles · App shell uses shared theming and activity helpers.
- appthemehelper → Now playing: styles · Player variants inherit consistent tinted UI behavior.