An open API service indexing awesome lists of open source software.

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

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

| | | |
|---|---|---|
| Empty Main Screen
**Main Screen (empty)** | Camera Options
**Camera Options** | Taking Picture
**Taking a Picture** |
| Camera Selfie
**Selfie Mode** | Picture Preview
**Picture Preview** | Main with Picture
**Main with Captured Photo** |
| Camera Record
**Video Recording Screen** | Recording Selfie
**Recording in Selfie Mode** | Recording Preview
**Recorded Video Preview** |
| Main with Video
**Main with Saved Video** | Recorded Video View
**Playback Recorded Video** | |

## 🧑‍💻 Author

- [@samuel0122](https://www.github.com/samuel0122)