Skip to content

pmjsankar/Android-TV-News-App

Repository files navigation

NewsFlow - Android TV App

Kotlin Jetpack Compose Android TV License: MIT

A modern Android TV application built with Jetpack Compose, following MVVM architecture and using Retrofit for network operations. The app displays news articles from the GNews API.

Screenshots

Architecture Overview

This app follows the MVVM (Model-View-ViewModel) architecture pattern with the following layers:

1. Data Layer

  • Models: Data classes representing the domain entities (e.g., News)
  • API Service: Retrofit interface for GNews API operations
  • Local Database: Room database for offline news storage
  • Repository: Single source of truth that combines local and remote data

2. Domain Layer

  • Repository Interface: Defines the contract for data operations
  • Use Cases: Business logic operations (can be added as needed)

3. Presentation Layer

  • ViewModels: Manage UI state and business logic
  • Composables: Jetpack Compose UI components optimized for TV
  • Screens: Complete screen implementations

Key Features

  • MVVM Architecture: Clean separation of concerns
  • GNews API Integration: Real-time news from GNews API
  • Room Database: Local news persistence
  • Koin Dependency Injection: Clean dependency management
  • Jetpack Compose for TV: Modern UI framework optimized for Android TV
  • Coroutines & Flow: Asynchronous programming with reactive streams
  • Coil: Efficient image loading

Project Structure

app/src/main/java/com/pmj/jaytv/
├── data/
│   ├── api/
│   │   └── NewsApiService.kt          # GNews API interface
│   ├── local/
│   │   ├── AppDatabase.kt             # Room database
│   │   └── NewsDao.kt                 # Data access object
│   ├── model/
│   │   └── News.kt                    # News data model
│   └── repository/
│       └── NewsRepository.kt          # Repository implementation
├── di/
│   └── AppModule.kt                   # Koin module
├── ui/
│   ├── components/
│   │   └── NewsCard.kt                # Reusable UI components
│   ├── screen/
│   │   └── HomeScreen.kt              # Main screen implementation
│   ├── theme/
│   │   └── Theme.kt                   # App theming
│   └── viewmodel/
│       └── NewsViewModel.kt           # ViewModel for news management
├── NewsFlowApplication.kt             # Application class with Koin
└── MainActivity.kt                    # Main activity

Dependencies

Core Dependencies

  • Jetpack Compose for TV: UI framework
  • Koin: Dependency injection
  • Retrofit: Network communication with GNews API
  • Room: Local database
  • Coroutines: Asynchronous programming
  • Coil: Image loading

Setup Instructions

1. Prerequisites

  • Android Studio Hedgehog or later
  • Android SDK 23+ (target: 35)
  • Kotlin 1.9.22+

2. Build Configuration

The app uses the new Gradle Version Catalogs (libs.versions.toml) for dependency management.

3. Running the App

  1. Clone the repository
  2. Open in Android Studio
  3. Sync Gradle files
  4. Run on Android TV emulator or device

API Configuration

To use the GNews API:

  1. The base URL is already configured in NetworkModule.kt:
baseUrl("https://gnews.io/api/v4/")
  1. Add your GNews API key in local.properties:
GNEWS_API_KEY = "your_api_key"

Database Schema

The app uses Room database with the following entity:

News Entity

  • id: Primary key (String)
  • title: News article title
  • description: News article description
  • content: News article content
  • url: Article URL
  • image: Article image URL
  • publishedAt: Publication date
  • sourceName: News source name
  • sourceUrl: News source URL
  • isFavorite: Favorite status
  • timestamp: Creation timestamp

UI Components

NewsCard

  • TV-optimized card component for news articles
  • Focus handling for remote navigation
  • Image, title, description, and source display
  • Favorite toggle functionality
  • Publication date formatting

HomeScreen

  • Main screen with news grid
  • Search functionality for news articles
  • Top headlines section
  • Favorite news section
  • Loading and error states

Navigation

The app currently uses a single-activity architecture with Compose navigation. When a news article is clicked, it opens in the device's default browser.

Performance Considerations

  • Lazy Loading: News articles are loaded in chunks
  • Image Caching: Coil handles efficient image loading
  • Database Optimization: Room with Flow for reactive updates
  • Memory Management: Proper lifecycle management in ViewModels

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A Jetpack Compose-based Android TV news app powered by GNews API.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages