Skip to content
arj4ngPublic

About

Android work time tracker for recording when and where work sessions happened

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

20 Commits

Folders and files

Repository files navigation

Hourbit App Icon

Hourbit

Focus. Track. Review.

A modern Android work-session tracker built with Kotlin, Jetpack Compose, Room, Retrofit, and MVVM.


Kotlin Jetpack Compose Room Architecture Theme




πŸ“± Overview

Hourbit is an Android application for tracking focused work sessions and breaks.

A completed session can contain more than just a duration. Hourbit can optionally attach the location, city, temperature, and weather conditions that were present when the session ended.

The application was developed as an Android final project with a focus on clean architecture, persistent local data, API integration, reactive state management, error handling, and a polished Compose interface.


✦ Screenshots

Hourbit Home screen Hourbit History screen

✨ Features

⏱ Session tracking

  • Start and stop work sessions
  • Live HH:MM:SS timer
  • Separate break tracking
  • Resume work after a break
  • Work duration excludes break duration
  • Reset completed timer state

πŸ’Ύ Persistence

  • Completed sessions stored with Room
  • Active session state survives app restarts
  • Timestamp-based timer reconstruction
  • Persistent break state
  • Reactive history using Kotlin Flow

🌀 Session context

  • Optional device location
  • Latitude and longitude
  • Reverse-geocoded city name
  • Current temperature
  • WMO weather code
  • Human-readable weather condition

πŸ“… History

  • Seven-day activity calendar
  • Swipe horizontally into previous weeks
  • Sessions grouped by date
  • Work and break durations
  • Start and end times
  • Weather and city metadata

πŸ—‘ Session management

  • Swipe a history card to reveal Delete
  • Rubber-band swipe interaction
  • Explicit delete action
  • Confirmation dialog
  • Room updates reflected automatically

🎨 Interface

  • Jetpack Compose
  • Custom light theme
  • Custom dark theme
  • Dedicated work, break and destructive colors
  • Bottom navigation
  • Portrait-optimized layout

πŸ“± Home-screen widget

  • Interactive Android home-screen widget
  • Live work timer
  • Live break timer
  • Start, break and resume controls
  • Shared active-session state with the app
  • Quick access back into Hourbit

πŸ”„ Session continuity

  • Widget and app use the same persisted session state
  • Work time is reconstructed from timestamps
  • Break time remains separate from focused work
  • Session completion stays in the app workflow
  • Completed sessions remain the responsibility of Room

πŸ— Architecture

Hourbit follows an MVVM architecture with a Repository layer.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      Compose UI       β”‚
β”‚ HomeScreen / History  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚
            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      ViewModels       β”‚
β”‚ HomeVM / HistoryVM    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚
            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ WorkSessionRepository β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
         β”‚         β”‚
         β–Ό         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Room     β”‚  β”‚  Retrofit   β”‚
β”‚ Local data  β”‚  β”‚ Open-Meteo  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Home-screen Widget  β”‚
β”‚     RemoteViews       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚
            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   SessionStateStore   β”‚
β”‚   SharedPreferences   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The UI does not directly access Room or the weather API.

  1. The Compose UI displays state and sends user actions.
  2. The ViewModel manages application logic and UI state.
  3. The Repository provides access to local and remote data.
  4. Room stores completed work sessions.
  5. Retrofit communicates with Open-Meteo.

🧠 Timer design

Hourbit does not use an incrementing counter as the source of truth.

Instead, the timer is calculated from real timestamps.

Session start
     β”‚
     β”œβ”€β”€β”€β”€β”€β”€β”€β”€ Work ────────┐
     β”‚                      β”‚
     β”‚   Break start        β”‚
     β”‚       β”‚              β”‚
     β”‚       └── Break ──────
     β”‚                      β”‚
     β”‚   Resume work        β”‚
     β”‚                      β”‚
     └────────────── Session end

The effective work duration is:

Work time = Total session duration - Total break duration

This allows an active session to be reconstructed after the app is reopened instead of losing the timer state.

Active-session persistence

While a session is active, Hourbit stores:

  • session start timestamp
  • whether a break is active
  • break start timestamp
  • accumulated break duration
  • running state

This temporary state is stored with SharedPreferences through SessionStateStore.

Completed sessions are stored separately in Room.


πŸ“± Home-screen widget

Hourbit includes an interactive Android home-screen widget built with AppWidgetProvider and RemoteViews.

The widget uses the same persisted active-session state as the main application and provides quick access to the current session without requiring Hourbit to remain open.

Depending on the current state, the widget can display:

  • Ready β€” start a new work session
  • Focusing β€” show a live work timer and start a break
  • On break β€” freeze the work timer, show a live break timer and resume work

The widget reconstructs elapsed time from timestamps instead of maintaining a separate counter. This keeps its timer consistent with Hourbit's timer design.

Finishing a session returns the user to Hourbit, where the normal completion flow can retrieve optional location and weather information before storing the completed session in Room.


πŸ’Ύ Data model

Completed sessions are represented by WorkSession.

WorkSession
β”‚
β”œβ”€β”€ id
β”œβ”€β”€ startTime
β”œβ”€β”€ endTime
β”œβ”€β”€ breakDurationSeconds
β”‚
β”œβ”€β”€ latitude
β”œβ”€β”€ longitude
β”œβ”€β”€ cityName
β”‚
β”œβ”€β”€ temperature
└── weatherCode

Location and weather information are nullable because neither is required for the core timer functionality.


πŸ“ Location & city detection

Hourbit uses the Fused Location Provider from Google Play Services.

When a session ends:

Device
   β”‚
   β–Ό
Fused Location Provider
   β”‚
   β–Ό
Latitude + Longitude
   β”‚
   β–Ό
Android Geocoder
   β”‚
   β–Ό
Readable city name

Location permission is optional. If location cannot be retrieved, the session is still saved.


🌦 Weather API

Hourbit uses the free Open-Meteo API. No API key is required.

Requested values:

temperature_2m
weather_code

Endpoint:

https://api.open-meteo.com/v1/forecast

The saved WMO weather code is translated into a readable condition and corresponding UI icon.

Code Display
0 Clear
1–3 Cloudy
45–48 Fog
51–57 Drizzle
61–67 Rain
71–77 Snow
80–82 Showers
95–99 Thunderstorm

Weather is requested only when coordinates are available. If the request fails, the session is still saved.


πŸ“… History experience

The History screen is centered around a swipeable weekly calendar running from Monday to Sunday.

Current week β†’ swipe β†’ Previous week β†’ swipe β†’ Earlier weeks

The session list follows the visible calendar period automatically.

Each session can show:

πŸ“† Date ⏱ Work duration
πŸ• Start / end time β˜• Break duration
🌀 Weather πŸ“ City

↩ Swipe-to-delete

History entries use a custom swipe interaction instead of immediately deleting at a swipe threshold.

Normal card
      β”‚
      β”‚ swipe left
      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
β”‚ Session               β”‚ πŸ—‘ Delete
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ

The card settles with the delete action revealed. The user must explicitly tap Delete, after which a confirmation dialog appears.

This prevents accidental deletion while keeping the interaction fast.


⚠️ Error handling

Optional features do not block the core session flow.

Location unavailable
        ↓
Save session without location

Weather unavailable
        ↓
Save session without weather

Database and API operations are wrapped in error handling so failures can be surfaced to the UI instead of crashing the application.


πŸ” Permissions

Hourbit uses:

android.permission.ACCESS_FINE_LOCATION
android.permission.ACCESS_COARSE_LOCATION
android.permission.INTERNET

Location permission is optional.

Internet access is used for weather requests.


🧭 Navigation

Hourbit uses type-safe Navigation Compose routes.

HomeRoute
HistoryRoute

The bottom navigation switches directly between the two main sections without manually maintained route strings.


🧰 Tech stack

Area Technology
Language Kotlin
UI Jetpack Compose
Architecture MVVM + Repository
Database Room
Networking Retrofit
Weather API Open-Meteo
Location Google Play Services Location
Navigation Navigation Compose
State StateFlow / Flow
Concurrency Kotlin Coroutines
Active session state SharedPreferences
Home-screen widget AppWidgetProvider + RemoteViews
Build system Gradle Kotlin DSL

πŸ“‚ Project structure

com.arj4ng.hourbit
β”‚
β”œβ”€β”€ data
β”‚   β”œβ”€β”€ local
β”‚   β”‚   β”œβ”€β”€ HourbitDatabase
β”‚   β”‚   β”œβ”€β”€ WorkSession
β”‚   β”‚   β”œβ”€β”€ WorkSessionDao
β”‚   β”‚   └── SessionStateStore
β”‚   β”‚
β”‚   β”œβ”€β”€ location
β”‚   β”‚   └── LocationProvider
β”‚   β”‚
β”‚   β”œβ”€β”€ remote
β”‚   β”‚   β”œβ”€β”€ RetrofitClient
β”‚   β”‚   └── WeatherApi
β”‚   β”‚
β”‚   └── WorkSessionRepository
β”‚
β”œβ”€β”€ ui
β”‚   β”œβ”€β”€ home
β”‚   β”‚   β”œβ”€β”€ HomeScreen
β”‚   β”‚   β”œβ”€β”€ HomeViewModel
β”‚   β”‚   └── HomeViewModelFactory
β”‚   β”‚
β”‚   β”œβ”€β”€ history
β”‚   β”‚   β”œβ”€β”€ HistoryScreen
β”‚   β”‚   β”œβ”€β”€ HistoryViewModel
β”‚   β”‚   └── HistoryViewModelFactory
β”‚   β”‚
β”‚   β”œβ”€β”€ navigation
β”‚   └── theme
β”‚
β”œβ”€β”€ widget
β”‚   └── HourbitWidgetProvider
β”‚
└── MainActivity

🎨 Design system

Hourbit uses a custom color system for both light and dark mode.

Color role Meaning
πŸ”΅ Blue Active work, primary actions, selected states
🟠 Amber Breaks and paused work
πŸ”΄ Red Destructive actions
βšͺ Neutral Surfaces, metadata, secondary UI

The app follows the device light/dark appearance and is optimized for portrait use.


πŸš€ Build

Clone the repository and build the debug APK:

./gradlew assembleDebug

Or install directly on a connected device/emulator:

./gradlew installDebug

πŸ”­ Possible future improvements

  • Session titles or project/category assignment
  • Daily and weekly statistics
  • Charts for working time and breaks
  • Manual editing of completed sessions
  • Export to CSV
  • Search and filtering
  • Configurable work goals
  • Notifications or reminders
  • Cloud synchronization
  • Tablet layouts

πŸŽ“ Project context

Hourbit was created as an Android Abschlussprojekt.

The project demonstrates:

  • an original app concept
  • Jetpack Compose UI development
  • MVVM architecture
  • Repository pattern
  • Room persistence
  • Retrofit API integration
  • device location access
  • Kotlin Coroutines and Flow
  • type-safe navigation
  • error handling
  • persistent application state
  • interactive Android home-screen widget
  • AppWidgetProvider and RemoteViews
  • custom light and dark themes

Hourbit

One session at a time.

About

Android work time tracker for recording when and where work sessions happened

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages