A modern Android application that brings you a smile every day with random jokes. Built with the latest Android technologies following development best practices.
π― Random Jokes - Get fresh and funny jokes instantly
π Favorites System - Save your preferred jokes to view them later
πΎ Local Persistence - Your favorites are saved automatically
This project is built using cutting-edge Android technologies:
- Kotlin - 100% Kotlin, modern and concise language
- Jetpack Compose - Declarative toolkit for native UI
- Material 3 - Google's latest design system
- Retrofit - Type-safe HTTP client for Android
- StateFlow - Reactive state management
- ViewModel - UI state handling
- SharedPreferences - Lightweight local persistence
- JUnit - Unit testing framework
- Mockk - Mocking library for Kotlin
- Turbine - Testing for Flow
- Truth - Fluent assertions for tests
The project follows the MVVM (Model-View-ViewModel) pattern with Clean Architecture:
π app/src/main/java/dev/javfuentes/dailyjoke/
βββ π data/
β βββ π datasource/ # Data sources (API, Local)
β βββ π model/ # Data models and API
β βββ π repository/ # Repository pattern implementation
βββ π di/ # Manual dependency injection
βββ π network/ # Network configuration and APIs
βββ π ui/
β βββ π components/ # Reusable UI components
β βββ π navigation/ # Screen navigation
β βββ π screens/ # Main screens
β βββ π theme/ # Material 3 theme
βββ π utils/ # Utilities and constants
βββ π viewmodel/ # ViewModels and UI state
UI (Compose) β ViewModel β Repository β DataSource
β
StateFlow/UiState
- Single Activity Architecture - Single Activity with Composable navigation
- Reactive Programming - StateFlow for reactive state management
- Error Handling - Robust network and API error handling
- Offline Support - Favorites work without connection
- Edge-to-Edge Layout - Full support for modern screens
The application consumes the free JokeAPI:
- Endpoint:
https://v2.jokeapi.dev/joke/Programming - Format: JSON
- Types: Two-part jokes (setup + punchline)
- Filters: Safe mode enabled
- Language: English
- Android Studio Hedgehog | 2023.1.1 or higher
- JDK 11 or higher
- Android SDK API 26+
- Device/Emulator with Android 8.0+ (API 26)
-
Clone the repository
git clone https://github.com/yourusername/DailyJoke.git cd DailyJoke -
Open in Android Studio
- File β Open β Select the project folder
-
Sync the project
- Android Studio will automatically sync dependencies
-
Run the application
- Connect a device or start an emulator
- Click Run
βΆοΈ
# Clean project
./gradlew clean
# Build debug
./gradlew assembleDebug
# Run tests
./gradlew test
# Run instrumented tests
./gradlew connectedAndroidTest
# Lint check
./gradlew lint-
Main Screen
- View random jokes
- Tap "New Joke" to get a new joke
- Use the β€οΈ button to save favorites
-
Favorites Screen
- Access from "Favorites" button
- See all your saved jokes
- Remove favorites with "Remove" button
-
Navigation
- Simple navigation between screens
- Back button in favorites
The project includes comprehensive tests following TDD approach:
# Unit tests
./gradlew test
# UI tests (requires device)
./gradlew connectedAndroidTest
# Coverage report
./gradlew jacocoTestReport- β ViewModels (Business Logic)
- β Repository Pattern
- β Data Sources
- β UI Components (in development)
Automated CI/CD pipeline with GitHub Actions:
- β Build & Test - Automatic builds and unit tests on push/PR
- β Instrumented Tests - UI tests on Android emulator
- β Code Quality - Lint checks and static analysis
- π― Branches:
master,ci-testing
# Run CI checks locally
./gradlew clean build test lintMIT License
Copyright (c) 2023 Javier Fuentes
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
For more information about the author and his projects, visit http://javierfuentes.dev
Javier Fuentes
- GitHub: @javfuentes
- Email: contacto@javierfuentes.dev