Skip to content

chanuthjayasekera/android-news-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The News App – Android News Reader Application

The News App is a modern Android news reader application built using Kotlin and the MVVM architectural pattern.
It allows users to browse top headlines, search for news articles, read full articles inside the app, and save favourite articles locally for later access.

The application integrates live news data from NewsAPI, supports local persistence using Room Database, and provides a clean multi-screen user experience using Navigation Components, RecyclerView, and ViewBinding.


Project Overview

The News App is designed to provide a simple and efficient mobile news experience.
Users can:

  • View top news headlines
  • Search for articles by keyword
  • Open and read full articles inside the app
  • Save articles to favourites
  • Remove articles from favourites
  • Browse news through a clean bottom-navigation-based interface

The application combines online API data fetching with offline local storage for saved news articles.


Core Features

Top Headlines

The app fetches and displays the latest top headlines from the NewsAPI service.

Features include:

  • Country-based headline loading
  • Paginated news loading
  • Infinite scrolling
  • Loading indicators
  • Error handling with retry support

Search News

Users can search for specific news topics or keywords.

Search features include:

  • Query-based news search
  • Paginated search results
  • Loading states
  • Search delay support for smoother requests
  • Error handling with retry support

Read Full Article

Users can open any news item and read the full content inside the application.

Features include:

  • In-app article viewing using WebView
  • JavaScript and DOM storage enabled for better page rendering
  • Safe handling of missing article data or invalid URLs

Save to Favourites

Users can save articles locally for future access.

Features include:

  • Save article to favourites
  • View all saved articles in a dedicated screen
  • Remove articles using swipe gestures
  • Undo delete with Snackbar
  • Offline access to favourite news articles

Technology Stack

Programming Language

  • Kotlin

Android Components

  • Fragments
  • RecyclerView
  • ViewBinding
  • Navigation Component
  • Safe Args
  • WebView
  • Snackbar
  • BottomNavigationView

Architecture

  • MVVM (Model-View-ViewModel)
  • Repository pattern

Networking

  • Retrofit
  • Gson Converter
  • OkHttp Logging Interceptor

Local Storage

  • Room Database
  • DAO
  • Type Converters

Image Loading

  • Glide

Concurrency

  • Kotlin Coroutines
  • LiveData
  • ViewModel

System Architecture

NewsAPI
   |
   v
Retrofit + Repository
   |
   v
ViewModel + LiveData
   |
   v
Fragments / RecyclerView UI
   |
   v
Room Database (Favourites)

The app follows an MVVM-based data flow where:

  • API layer fetches remote news data
  • Repository coordinates remote and local data access
  • ViewModel manages UI state
  • Fragments render the data
  • Room stores favourite articles locally

Project Structure

TheNewsApp
│
├── app
│   ├── src/main/java/com/example/thenewsapp
│   │   ├── adapters
│   │   │   └── NewsAdapter.kt
│   │   │
│   │   ├── api
│   │   │   ├── NewsAPI.kt
│   │   │   └── RetrofitInstance.kt
│   │   │
│   │   ├── db
│   │   │   ├── ArticleDAO.kt
│   │   │   ├── ArticleDatabase.kt
│   │   │   └── Converters.kt
│   │   │
│   │   ├── models
│   │   │   ├── Article.kt
│   │   │   ├── NewsResponse.kt
│   │   │   └── Source.kt
│   │   │
│   │   ├── repository
│   │   │   └── NewsRepository.kt
│   │   │
│   │   ├── ui
│   │   │   ├── NewsActivity.kt
│   │   │   ├── NewsViewModel.kt
│   │   │   ├── NewsViewModelProviderFactory.kt
│   │   │   └── fragments
│   │   │       ├── ArticleFragment.kt
│   │   │       ├── FavouritesFragment.kt
│   │   │       ├── HeadlinesFragment.kt
│   │   │       └── SearchFragment.kt
│   │   │
│   │   └── util
│   │       ├── Constants.kt
│   │       └── Resource.kt
│   │
│   ├── src/main/res
│   │   ├── layout
│   │   ├── navigation
│   │   ├── menu
│   │   ├── drawable
│   │   ├── values
│   │   └── xml
│   │
│   └── AndroidManifest.xml
│
├── gradle
├── build.gradle.kts
├── settings.gradle.kts
├── gradle.properties
├── gradlew
├── gradlew.bat
└── README.md

Main Screens

1. Headlines Screen

Displays trending top headlines using a RecyclerView.

2. Search Screen

Allows users to search for news articles by keyword.

3. Article Screen

Opens the selected article in a WebView.

4. Favourites Screen

Displays articles saved locally in the Room database.


Architecture Details

MVVM Pattern

The project follows the Model-View-ViewModel architecture.

Model

Represents the data layer:

  • Article
  • NewsResponse
  • Source

View

Represents the UI layer:

  • Fragments
  • RecyclerView layouts
  • Activity
  • WebView

ViewModel

Acts as the bridge between UI and data:

  • NewsViewModel

This improves maintainability, readability, and separation of concerns.


Local Database

Favourite articles are stored locally using Room.

Database-related components:

  • ArticleDAO.kt
  • ArticleDatabase.kt
  • Converters.kt

Stored operations include:

  • Insert / update article
  • Retrieve all favourite articles
  • Delete article

This allows offline access to saved news.


API Integration

The app uses NewsAPI to fetch live news content.

Implemented endpoints include:

  • top-headlines
  • everything

Networking is handled using:

  • Retrofit
  • Gson converter
  • OkHttp logging interceptor

Build & Run Instructions

Requirements

  • Android Studio
  • Android SDK
  • Kotlin support
  • Internet connection for live news fetching
  • A valid NewsAPI key

Setup Steps

  1. Clone the repository:
git clone https://github.com/yourusername/TheNewsApp.git
  1. Open the project in Android Studio

  2. Let Gradle sync complete

  3. Run the app on:

  • Android Emulator
  • Physical Android device

API Key Configuration

This project uses NewsAPI for fetching live news.

The API key is referenced in:

Constants.kt

Example:

const val API_KEY = "YOUR_NEWS_API_KEY"

For security, it is recommended not to commit real API keys to a public repository.
Replace the API key with your own key from NewsAPI before running the project.


Important Functional Highlights

Pagination

The app supports paginated loading of results for both headlines and search.

Error Handling

The project uses a Resource wrapper to handle:

  • Success
  • Error
  • Loading

This improves UI state management.

Favourite Article Management

Users can:

  • Save an article to favourites
  • Remove it with swipe
  • Restore it using Undo

Safe Navigation

The project uses Navigation Safe Args to safely pass selected article data between fragments.


UI Highlights

The UI includes:

  • Bottom navigation menu
  • Card-based news item design
  • Search field with custom styling
  • Progress bars for loading states
  • Error cards with retry support
  • Custom font integration

Dependencies Used

Main libraries used in this project include:

  • AndroidX Core
  • AppCompat
  • Material Design
  • ConstraintLayout
  • Lifecycle ViewModel
  • Room
  • Retrofit
  • Gson Converter
  • OkHttp Logging Interceptor
  • Navigation Components
  • Glide
  • Kotlin Coroutines

Future Improvements

Possible future enhancements include:

  • Category-based filtering
  • Dark mode improvements
  • Bookmark syncing with cloud
  • Offline caching of headlines
  • Better search suggestions
  • Share article feature
  • Push notifications for breaking news
  • API key management through local properties or BuildConfig

Project Status

The News App is a functional Android news reader application that demonstrates:

  • Kotlin Android development
  • MVVM architecture
  • REST API integration
  • Room database usage
  • Fragment navigation
  • RecyclerView implementation
  • WebView article reading
  • Local favourites persistence

It can be extended into a production-ready mobile news platform with additional personalization and caching features.


Author

Chanuth Jayasekera

About

Android news reader application built with Kotlin, MVVM architecture, Retrofit API integration, and Room database for favourite articles.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages