https://github.com/samuel0122/android-camerax-mvvm
https://github.com/samuel0122/android-camerax-mvvm
android-app camerax camerax-api kotlin-android
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/samuel0122/android-camerax-mvvm
- Owner: samuel0122
- License: mit
- Created: 2024-11-01T14:11:37.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-09-13T09:10:26.000Z (10 months ago)
- Last Synced: 2025-09-13T12:08:15.705Z (10 months ago)
- Topics: android-app, camerax, camerax-api, kotlin-android
- Language: Kotlin
- Homepage:
- Size: 5.03 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Android CameraX MVVM
*Capture photos, record videos, and preview media with modern Android development practices.*
This project demonstrates how to implement **CameraX** in an Android application using the **MVVM** (Model-View-ViewModel) view pattern, combined with a **Clean Architecture** architectural pattern. The project includes features like capturing photos, recording videos, and previewing media with modern Android development practices.
## 📋 Features
- 📷 **Photo & Video Capture**: Take high-quality pictures and record videos using CameraX, with full support for exposure control, flash, and front/back camera switching.
- 👀 **Media Preview**: Preview captured photos and videos.
- 🧱 **Clean Architecture**: Clean separation in layers: Domain, Data and View.
- 🎯 **Jetpack Components**: Uses Navigation, DataStore, and more.
- 💉 **Dependency Injection**: Powered by Dagger Hilt for modular and testable code.
## 🛠️ Tech Stack
- **Kotlin**: 100% Kotlin-based code.
- **CameraX**: For camera functionality.
- **Jetpack**:
- Navigation Component
- DataStore for managing preferences
- ViewModel and LiveData for reactive UI updates
- **ExoPlayer**: For video playback.
- **Dagger Hilt**: Dependency Injection.
## 🚀 Getting Started
### Prerequisites
1. Android Studio (latest stable version recommended)
2. Android SDK 21+
### Setup
1. [ ] Clone the repository:
```bash
git clone https://github.com/samuel0122/Android-CameraX-MVVM.git
cd Android-CameraX-MVVM
```
2. [ ] Open the project in Android Studio.
3. [ ] Sync Gradle to download dependencies.
4. [ ] Run the app on a physical or virtual device.
## 📂 Project Structure
```
📂 app/
├── 📂 core/ # Utility classes and extensions
├── 📂 data/ # Data layer (e.g., repositories, DataStore management)
│ ├── 📂 mediaStorage # Handles loading and saving media on disk
│ ├── 📂 dataPreferences # Manages preferences using DataStore (e.g. last media URI)
│ ├── 🗒️ MediaRepository # Repository to access media files (photos & videos)
├── 📂 di/ # Dependency injection modules
├── 📂 domain/ # Domain layer (Use Cases, models and mappers)
├── 📂 ui/ # View layer (Fragments, Adapters, ViewModels)
│ ├── 📂 camera/ # Media capture (photo/video) fragments and its ViewModels
│ ├── 📂 common/ # Common components that are shared along the whole app
│ ├── 📂 mainPage/ # Main app view and its ViewModel
│ ├── 📂 preview/ # Media preview (photo/video) fragments and its ViewModels
├── 🗒️ CameraXMvvmApp # Application class for global inyection
├── 🗒️ MainActivity # Application entry point and navigation host
```
## 📸 Screenshots
| | | |
|---|---|---|
|
**Main Screen (empty)** |
**Camera Options** |
**Taking a Picture** |
|
**Selfie Mode** |
**Picture Preview** |
**Main with Captured Photo** |
|
**Video Recording Screen** |
**Recording in Selfie Mode** |
**Recorded Video Preview** |
|
**Main with Saved Video** |
**Playback Recorded Video** | |
## 🧑💻 Author
- [@samuel0122](https://www.github.com/samuel0122)