How itszechs/drivestream works
1. What this repo is
- This is an Android streaming client for Google Drive video files.
- The app is Kotlin-based and organized around a classic MVVM-style split between UI, view models, repositories, and data sources.
2. Top-level module structure
- app/ is the main application module and contains the Drive client, UI, persistence, and networking.
- mpv/ is a separate player module that wraps native mpv playback through JNI, with prebuilt native libraries and a Java/Kotlin-facing bridge.
3. UI surface and navigation
- MainActivity appears to be the app shell that hosts the main navigation graph.
- Primary screens are HomeFragment, SignInFragment, FilesFragment, and SettingsFragment.
- Playback is split into dedicated activities: PlayerActivity for the ExoPlayer-based experience and MPVActivity for the mpv-based player.
4. Presentation layer boundaries
- Each screen has a corresponding ViewModel: HomeViewModel, SignInViewModel, FilesViewModel, MainViewModel, and PlayerViewModel.
- Fragments handle UI state and navigation; view models own the screen logic and call into repositories.
- BaseFragment and small extension utilities suggest shared UI behaviors and navigation helpers.
5. Drive data model and remote APIs
- The app’s core domain objects are DriveFile, DriveClient, and response/request models like FilesResponse, DriveResponse, TokenRequest, and TokenResponse.
- Network access is split across three Retrofit-style APIs:
- DriveApi for listing and downloading Drive content
- TokenApi for OAuth token exchange/refresh
- GithubApi for GitHub release metadata
6. Repository layer
- DriveRepository coordinates Drive file listing and file access.
- WatchListRepository manages local watchlist state.
- GithubRepository likely powers release/update checks.
- TokenAuthenticator sits at the boundary between authenticated requests and token renewal, so expired credentials can be refreshed without exposing that complexity to the UI.
7. Authentication and session flow
- The app uses Google OAuth with a required Drive scope, because it must both list files and fetch file content for streaming.
- SessionManager and the token-related models indicate persisted auth/session state.
- The sign-in flow is user-driven, then the resulting token is reused by the repositories and the player networking stack.
8. Local persistence
- Watchlist data is stored locally with Room via WatchListDatabase and WatchListDao.
- WatchList is the persisted entity/domain model for saved or favorited files.
- This local store is separate from Drive metadata, so user preferences survive independently of remote state.
9. Streaming pipeline
- The core flow is: user browses Drive files, selects a video, then the player requests the file stream directly from Google Drive.
- AuthenticatingDataSource in the player utilities is the key bridge that injects auth into media loading.
- Supporting classes like BufferConfig and CustomTrackNameProvider suggest player tuning and playback metadata customization.
10. Playback stack
- The main app references ExoPlayer and includes an FFmpeg extension AAR, so standard playback is likely the default path with broader codec support.
- The mpv/ module provides an alternate player implementation using native mpv, JNI bindings (MPVLib, MPVView), and native rendering/event code.
- This gives the architecture two playback backends: one Android-native and one embedded native media engine.
11. Dependency injection and app bootstrap
- ThisApp is the application class, and ApiModule, AppModule, and DatabaseModule indicate dependency injection wiring.
- These modules centralize creation of network clients, repositories, and the Room database so UI code stays thin.
12. External services and supporting concerns
- External dependencies that materially shape the architecture are Google Drive API for content access and GitHub API for release/update checks.
- There are also utility layers for settings, orientation, notification keys, and theme management, which support the app shell but do not define the core data flow.
Main entry points: MainActivity.kt MainActivity · FilesFragment.kt Files · SignInViewModel.kt SignInViewModel · FilesViewModel.kt FilesViewModel
Components 27
app module
Main Android application with UI, data, and DI.
- ThisApp · Application bootstrap and global setup.
app/src/main/java/zechs/drive/stream/ThisApp.kt - MainActivity · App shell hosting primary navigation.
app/src/main/java/zechs/drive/stream/ui/main/MainActivity.kt - Home · Landing screen for browsing and entry flows.
app/src/main/java/zechs/drive/stream/ui/home/HomeFragment.kt - Sign In · OAuth sign-in screen and session entry.
app/src/main/java/zechs/drive/stream/ui/signin/SignInFragment.kt - Files · Drive file browser and selection screen.
app/src/main/java/zechs/drive/stream/ui/files/FilesFragment.kt - Settings · App configuration and preference screen.
app/src/main/java/zechs/drive/stream/ui/settings/SettingsFragment.kt - Player · Primary ExoPlayer-based playback activity.
app/src/main/java/zechs/drive/stream/ui/player/PlayerActivity.kt - MPV Player · Alternate playback activity backed by mpv.
app/src/main/java/zechs/drive/stream/ui/player2/MPVActivity.kt - HomeViewModel · Home screen logic and state.
app/src/main/java/zechs/drive/stream/ui/home/HomeViewModel.kt - SignInViewModel · Sign-in flow state and token exchange orchestration.
app/src/main/java/zechs/drive/stream/ui/signin/SignInViewModel.kt - FilesViewModel · File listing, filtering, and user actions.
app/src/main/java/zechs/drive/stream/ui/files/FilesViewModel.kt - MainViewModel · App-level navigation and shell state.
app/src/main/java/zechs/drive/stream/ui/main/MainViewModel.kt - PlayerViewModel · Playback state and media preparation.
app/src/main/java/zechs/drive/stream/ui/player/PlayerViewModel.kt - DriveRepository · Coordinates Drive listing and file access.
app/src/main/java/zechs/drive/stream/data/repository/DriveRepository.kt - WatchListRepository · Persists and serves local watchlist state.
app/src/main/java/zechs/drive/stream/data/repository/WatchListRepository.kt - GithubRepository · Fetches release metadata and update info.
app/src/main/java/zechs/drive/stream/data/repository/GithubRepository.kt - TokenAuthenticator · Refreshes expired credentials for authenticated requests.
app/src/main/java/zechs/drive/stream/data/repository/TokenAuthenticator.kt - DriveApi · Retrofit API for Drive listing and streaming.
app/src/main/java/zechs/drive/stream/data/remote/DriveApi.kt - TokenApi · OAuth token exchange and refresh endpoints.
app/src/main/java/zechs/drive/stream/data/remote/TokenApi.kt - GithubApi · Release metadata lookup from GitHub.
app/src/main/java/zechs/drive/stream/data/remote/GithubApi.kt - WatchListDB · Room persistence for saved files.
app/src/main/java/zechs/drive/stream/data/local/WatchListDatabase.kt - WatchListDao · Database access for watchlist records.
app/src/main/java/zechs/drive/stream/data/local/WatchListDao.kt - SessionManager · Persists sign-in and token session state.
app/src/main/java/zechs/drive/stream/utils/SessionManager.kt - Auth DataSource · Injects authorization into player media loading.
app/src/main/java/zechs/drive/stream/ui/player/utils/AuthenticatingDataSource.kt - Player Utils · Buffering and track-name customization helpers.
app/src/main/java/zechs/drive/stream/ui/player/utils/BufferConfig.kt
Connections 26
- ThisApp → MainActivity: starts · Bootstraps the app shell.
- MainActivity → MainViewModel: binds · Main activity observes shell state.
- MainActivity → Home: hosts · Primary navigation destination.
- MainActivity → Sign In: hosts · Authentication entry screen.
- MainActivity → Files: hosts · File browsing destination.
- MainActivity → Settings: hosts · Settings destination.
- Home → HomeViewModel: uses · Home UI state and actions.
- Sign In → SignInViewModel: uses · Sign-in workflow logic.
- Files → FilesViewModel: uses · File list state and actions.
- Player → PlayerViewModel: uses · Playback screen logic.
- FilesViewModel → DriveRepository: reads · Requests Drive metadata and items.
- FilesViewModel → WatchListRepository: writes · Updates local saved items.
- SignInViewModel → TokenApi: exchanges · Obtains and refreshes OAuth tokens.
- SignInViewModel → SessionManager: persists · Stores authenticated session state.
- DriveRepository → DriveApi: calls · Fetches Drive data and streams.
- DriveRepository → TokenAuthenticator: uses · Ensures authenticated requests remain valid.
- TokenAuthenticator → TokenApi: refreshes · Renews access tokens when needed.
- GithubRepository → GithubApi: calls · Checks release metadata.
- WatchListRepository → WatchListDB: stores · Uses Room database for persistence.
- WatchListDB → WatchListDao: exposes · DAO access to watchlist entities.
- PlayerViewModel → Auth DataSource: streams via · Loads Drive media with auth headers.
- PlayerViewModel → Player Utils: configures · Applies buffering and track naming helpers.
- MPV Player → MPVView: hosts · Embeds native mpv rendering view.
- MPVView → MPVLib: bridges · Delegates playback control to JNI layer.
- Files → Player: opens · Launches standard playback.
- Files → MPV Player: opens · Launches alternate mpv playback.