[PR #1] [MERGED] Implement HackerNews client with offline caching, background sync, and smart notifications #1

Closed
opened 2026-04-08 13:49:47 +00:00 by thisisjaymehta · 0 comments

📋 Pull Request Information

Original PR: https://github.com/thisisjaymehta/HackerNewsClient/pull/1
Author: @Copilot
Created: 1/8/2026
Status: Merged
Merged: 1/9/2026
Merged by: @thisisjaymehta

Base: mainHead: copilot/implement-hacker-news-client


📝 Commits (10+)

  • 59fa013 Initial plan
  • 7622084 Implement complete HackerNews client with caching, background sync, and notifications
  • 7486733 Refactor: Extract notification logic to shared utility, fix ViewModel flow handling
  • 530a83f Fix: Add Material Icons Extended dependency for missing icons
  • 71b670c Fix multiple bugs: story ordering, Chrome Custom Tabs, loading indicators, swipe navigation, clickable links, settings page with theme and notification options, pagination
  • c21a299 Address code review: improve code quality with named constants and better patterns
  • 84cf653 Fix combine() function to use Array parameter for 6+ flows
  • 79cf6ae Fix comments loading indicator - show loader until network request completes
  • 68c9e72 Fix duplicate loading indicators - show only one in comments section
  • cccee24 Add share button to story detail page

📊 Changes

34 files changed (+3042 additions, -65 deletions)

View changed files

📝 app/build.gradle.kts (+57 -3)
📝 app/src/main/AndroidManifest.xml (+16 -0)
app/src/main/java/com/neuralquark/hackernewsclient/HackerNewsApplication.kt (+27 -0)
📝 app/src/main/java/com/neuralquark/hackernewsclient/MainActivity.kt (+63 -26)
app/src/main/java/com/neuralquark/hackernewsclient/data/api/HackerNewsApi.kt (+36 -0)
app/src/main/java/com/neuralquark/hackernewsclient/data/db/CommentDao.kt (+33 -0)
app/src/main/java/com/neuralquark/hackernewsclient/data/db/Converters.kt (+31 -0)
app/src/main/java/com/neuralquark/hackernewsclient/data/db/HackerNewsDatabase.kt (+29 -0)
app/src/main/java/com/neuralquark/hackernewsclient/data/db/StoryDao.kt (+49 -0)
app/src/main/java/com/neuralquark/hackernewsclient/data/model/Comment.kt (+33 -0)
app/src/main/java/com/neuralquark/hackernewsclient/data/model/HNItemResponse.kt (+56 -0)
app/src/main/java/com/neuralquark/hackernewsclient/data/model/Story.kt (+33 -0)
app/src/main/java/com/neuralquark/hackernewsclient/data/preferences/UserPreferences.kt (+81 -0)
app/src/main/java/com/neuralquark/hackernewsclient/data/repository/HackerNewsRepository.kt (+224 -0)
app/src/main/java/com/neuralquark/hackernewsclient/di/AppModule.kt (+85 -0)
app/src/main/java/com/neuralquark/hackernewsclient/ui/navigation/Navigation.kt (+76 -0)
app/src/main/java/com/neuralquark/hackernewsclient/ui/screens/detail/StoryDetailScreen.kt (+464 -0)
app/src/main/java/com/neuralquark/hackernewsclient/ui/screens/detail/StoryDetailViewModel.kt (+103 -0)
app/src/main/java/com/neuralquark/hackernewsclient/ui/screens/list/NewsListScreen.kt (+376 -0)
app/src/main/java/com/neuralquark/hackernewsclient/ui/screens/list/NewsListViewModel.kt (+171 -0)

...and 14 more files

📄 Description

  • Add dependencies: Retrofit, Room, WorkManager, Navigation, Hilt, DataStore, Browser (Chrome Custom Tabs)
  • Create data layer:
    • HackerNews API interface (Retrofit)
    • Story/Comment data models
    • Room database for caching
    • Repository pattern implementation
  • Create UI layer:
    • News list screen with tabs (Top, New, Best, Ask, Show, Job)
    • Story detail screen with comments
    • Visit URL button functionality (now opens in Chrome Custom Tab)
    • "View New News" floating button
    • Share button on story detail page
    • Tap on current tab to scroll to top
  • Background sync:
    • WorkManager for background sync (every 15 minutes)
    • Periodic sync even when app is closed
  • Notifications:
    • High vote story detection (500+ points)
    • Configurable notification hours (default: 10am-6pm)
    • Time range slider in settings with validation
    • Scheduled notifications outside time window
    • Settings toggle to enable/disable notifications
  • Bug fixes (from user feedback):
    • Fixed story ordering - preserves API order using orderIndex field
    • Open Article button uses Chrome Custom Tabs
    • Added proper loading indicators for comments
    • Added horizontal swipe navigation between category tabs
    • Made links in comments clickable
    • Added Settings page with notification toggle
    • Added theme options (System, Light, Dark, Material You)
    • Added pagination - loads more stories at end of list
  • Code review improvements:
    • Fixed combine() for 6+ flows with documented expected order
    • Added 16KB page size compatibility for Android 15+ devices
    • Added named constants for MAX_COMMENTS_PER_LEVEL and MAX_COMMENT_DEPTH
    • Replaced synchronized with Mutex for coroutine-safe thread synchronization
    • Used intPreferencesKey instead of stringPreferencesKey for notification hours
    • Fixed duplicate navigation logic for deep links
    • Updated compileSdk and targetSdk to 35 for Android 15+ features
    • Made HTTP logging level configurable based on BuildConfig.DEBUG
    • Added comment about fallbackToDestructiveMigration for production consideration
    • Added exception logging in workers for better debugging
    • Added validation for notification hours in settings
    • Fixed notification hours to be inclusive of end hour
    • Added debug logging for URL parsing failures
    • Extracted MAX_COMMENT_UI_DEPTH constant
    • Updated AGP version to 8.5.2
Original prompt

An hacker news client made with kotlin and best practices and latest apis and design implementation like latest material design. It should show top, new etc categories. When clicked it should open detail view with comments. With a button to visit url of story. It should cache latest news so it can show the list at app launch and then refresh in background and appends new news at top of list but does not scroll to top. Instead will show a view new news button which can be clicked to scroll to top. Also fetch new news in background even when app is in not open or even in recent apps. And if a news story with very high votes comes then send notification. But only send notification during morning 9 to evening 8. Or else schedule it.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/thisisjaymehta/HackerNewsClient/pull/1 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 1/8/2026 **Status:** ✅ Merged **Merged:** 1/9/2026 **Merged by:** [@thisisjaymehta](https://github.com/thisisjaymehta) **Base:** `main` ← **Head:** `copilot/implement-hacker-news-client` --- ### 📝 Commits (10+) - [`59fa013`](https://github.com/thisisjaymehta/HackerNewsClient/commit/59fa0131d1ba4da30d94a9a2c1a2cb645c06bd2b) Initial plan - [`7622084`](https://github.com/thisisjaymehta/HackerNewsClient/commit/762208444de46cf52e99dd43189193d553e80112) Implement complete HackerNews client with caching, background sync, and notifications - [`7486733`](https://github.com/thisisjaymehta/HackerNewsClient/commit/74867331092dd3d0893cc2f21513076005cbb624) Refactor: Extract notification logic to shared utility, fix ViewModel flow handling - [`530a83f`](https://github.com/thisisjaymehta/HackerNewsClient/commit/530a83f554265c5820eac8023fc458d546fa0290) Fix: Add Material Icons Extended dependency for missing icons - [`71b670c`](https://github.com/thisisjaymehta/HackerNewsClient/commit/71b670c391c33c4360e6a86901b039d67154e396) Fix multiple bugs: story ordering, Chrome Custom Tabs, loading indicators, swipe navigation, clickable links, settings page with theme and notification options, pagination - [`c21a299`](https://github.com/thisisjaymehta/HackerNewsClient/commit/c21a299206e981a9bceeeb3447650838b9476b1e) Address code review: improve code quality with named constants and better patterns - [`84cf653`](https://github.com/thisisjaymehta/HackerNewsClient/commit/84cf653fbc596bc329b1aa902bfe87eba3f8a3bb) Fix combine() function to use Array parameter for 6+ flows - [`79cf6ae`](https://github.com/thisisjaymehta/HackerNewsClient/commit/79cf6ae042fbee919685bc6f38c16ed2fce1e11d) Fix comments loading indicator - show loader until network request completes - [`68c9e72`](https://github.com/thisisjaymehta/HackerNewsClient/commit/68c9e728a45d7995f55ea7e705893e13ab47563a) Fix duplicate loading indicators - show only one in comments section - [`cccee24`](https://github.com/thisisjaymehta/HackerNewsClient/commit/cccee24bd9897d0a4283ec987bbf43bb21f7af6c) Add share button to story detail page ### 📊 Changes **34 files changed** (+3042 additions, -65 deletions) <details> <summary>View changed files</summary> 📝 `app/build.gradle.kts` (+57 -3) 📝 `app/src/main/AndroidManifest.xml` (+16 -0) ➕ `app/src/main/java/com/neuralquark/hackernewsclient/HackerNewsApplication.kt` (+27 -0) 📝 `app/src/main/java/com/neuralquark/hackernewsclient/MainActivity.kt` (+63 -26) ➕ `app/src/main/java/com/neuralquark/hackernewsclient/data/api/HackerNewsApi.kt` (+36 -0) ➕ `app/src/main/java/com/neuralquark/hackernewsclient/data/db/CommentDao.kt` (+33 -0) ➕ `app/src/main/java/com/neuralquark/hackernewsclient/data/db/Converters.kt` (+31 -0) ➕ `app/src/main/java/com/neuralquark/hackernewsclient/data/db/HackerNewsDatabase.kt` (+29 -0) ➕ `app/src/main/java/com/neuralquark/hackernewsclient/data/db/StoryDao.kt` (+49 -0) ➕ `app/src/main/java/com/neuralquark/hackernewsclient/data/model/Comment.kt` (+33 -0) ➕ `app/src/main/java/com/neuralquark/hackernewsclient/data/model/HNItemResponse.kt` (+56 -0) ➕ `app/src/main/java/com/neuralquark/hackernewsclient/data/model/Story.kt` (+33 -0) ➕ `app/src/main/java/com/neuralquark/hackernewsclient/data/preferences/UserPreferences.kt` (+81 -0) ➕ `app/src/main/java/com/neuralquark/hackernewsclient/data/repository/HackerNewsRepository.kt` (+224 -0) ➕ `app/src/main/java/com/neuralquark/hackernewsclient/di/AppModule.kt` (+85 -0) ➕ `app/src/main/java/com/neuralquark/hackernewsclient/ui/navigation/Navigation.kt` (+76 -0) ➕ `app/src/main/java/com/neuralquark/hackernewsclient/ui/screens/detail/StoryDetailScreen.kt` (+464 -0) ➕ `app/src/main/java/com/neuralquark/hackernewsclient/ui/screens/detail/StoryDetailViewModel.kt` (+103 -0) ➕ `app/src/main/java/com/neuralquark/hackernewsclient/ui/screens/list/NewsListScreen.kt` (+376 -0) ➕ `app/src/main/java/com/neuralquark/hackernewsclient/ui/screens/list/NewsListViewModel.kt` (+171 -0) _...and 14 more files_ </details> ### 📄 Description - [x] **Add dependencies**: Retrofit, Room, WorkManager, Navigation, Hilt, DataStore, Browser (Chrome Custom Tabs) - [x] **Create data layer**: - [x] HackerNews API interface (Retrofit) - [x] Story/Comment data models - [x] Room database for caching - [x] Repository pattern implementation - [x] **Create UI layer**: - [x] News list screen with tabs (Top, New, Best, Ask, Show, Job) - [x] Story detail screen with comments - [x] Visit URL button functionality (now opens in Chrome Custom Tab) - [x] "View New News" floating button - [x] Share button on story detail page - [x] Tap on current tab to scroll to top - [x] **Background sync**: - [x] WorkManager for background sync (every 15 minutes) - [x] Periodic sync even when app is closed - [x] **Notifications**: - [x] High vote story detection (500+ points) - [x] Configurable notification hours (default: 10am-6pm) - [x] Time range slider in settings with validation - [x] Scheduled notifications outside time window - [x] Settings toggle to enable/disable notifications - [x] **Bug fixes** (from user feedback): - [x] Fixed story ordering - preserves API order using orderIndex field - [x] Open Article button uses Chrome Custom Tabs - [x] Added proper loading indicators for comments - [x] Added horizontal swipe navigation between category tabs - [x] Made links in comments clickable - [x] Added Settings page with notification toggle - [x] Added theme options (System, Light, Dark, Material You) - [x] Added pagination - loads more stories at end of list - [x] **Code review improvements**: - [x] Fixed combine() for 6+ flows with documented expected order - [x] Added 16KB page size compatibility for Android 15+ devices - [x] Added named constants for MAX_COMMENTS_PER_LEVEL and MAX_COMMENT_DEPTH - [x] Replaced synchronized with Mutex for coroutine-safe thread synchronization - [x] Used intPreferencesKey instead of stringPreferencesKey for notification hours - [x] Fixed duplicate navigation logic for deep links - [x] Updated compileSdk and targetSdk to 35 for Android 15+ features - [x] Made HTTP logging level configurable based on BuildConfig.DEBUG - [x] Added comment about fallbackToDestructiveMigration for production consideration - [x] Added exception logging in workers for better debugging - [x] Added validation for notification hours in settings - [x] Fixed notification hours to be inclusive of end hour - [x] Added debug logging for URL parsing failures - [x] Extracted MAX_COMMENT_UI_DEPTH constant - [x] Updated AGP version to 8.5.2 <!-- START COPILOT CODING AGENT SUFFIX --> <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > An hacker news client made with kotlin and best practices and latest apis and design implementation like latest material design. It should show top, new etc categories. When clicked it should open detail view with comments. With a button to visit url of story. It should cache latest news so it can show the list at app launch and then refresh in background and appends new news at top of list but does not scroll to top. Instead will show a view new news button which can be clicked to scroll to top. Also fetch new news in background even when app is in not open or even in recent apps. And if a news story with very high votes comes then send notification. But only send notification during morning 9 to evening 8. Or else schedule it. </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
thisisjaymehta 2026-04-08 13:49:47 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
thisisjaymehta/HackerNewsClient#1
No description provided.