Skip to content

wadrien-dev/compassly-android

Repository files navigation

Compassly

Overview

Compassly is a native Android compass application designed to demonstrate real-time device sensor integration, lifecycle-aware state management, and modern Jetpack Compose UI development. The app reads accelerometer and magnetic-field sensor data, converts the device heading into degrees and cardinal directions, and displays the result through a custom Compose compass interface.

Screenshots

Physical Device

Compassly running on a physical Android device

Android Emulator

Compassly running on Android Emulator

A physical Android device is recommended for full compass testing because sensor availability and accuracy can vary by emulator and hardware.

Project Purpose

This project was created to demonstrate native Android development skills, including sensor integration, Compose UI development, state management, lifecycle-aware logic, and unit testing.

Features

  • Real-time compass heading display
  • Degree reading with cardinal direction label
  • Direction formatter for North, Northeast, East, Southeast, South, Southwest, West, and Northwest
  • Sensor availability handling
  • Calibration message for low magnetic accuracy
  • Jetpack Compose UI with a custom compass dial
  • Lifecycle-aware sensor start and stop behavior
  • Unit tests for direction formatting logic

Tech Stack

  • Kotlin
  • Android SDK
  • Jetpack Compose
  • Material 3
  • SensorManager
  • StateFlow
  • Android ViewModel
  • JUnit

Architecture

Compassly separates sensor handling, UI state, and presentation logic into clear layers:

SensorManager
      ↓
CompassSensorManager
      ↓
CompassViewModel
      ↓
CompassScreen
      ↓
Jetpack Compose UI

Key Files

app/src/main/java/com/wadrien/compassly
├── MainActivity.kt
├── sensor
│   └── CompassSensorManager.kt
├── ui
│   ├── CompassScreen.kt
│   └── CompassViewModel.kt
└── util
    └── DirectionFormatter.kt

Testing

The project includes unit tests for the direction-formatting logic.

Example tested behavior:

0°   → N
45°  → NE
137° → SE
270° → W
359° → N

How to Run

  1. Clone the repository.
  2. Open the project in Android Studio.
  3. Allow Gradle to sync.
  4. Run the app on an Android emulator or physical Android device.

About

Native Android compass app built with Kotlin, Jetpack Compose, SensorManager, and lifecycle-aware state management.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages