Features
Dual viewing modes
Users can switch between two modes using a pill tab selector at the top of the screen:- Compass mode: Traditional compass with rotating dial and directional indicators
- AR mode: Live camera view with overlaid directional guidance
Compass mode
The compass mode displays a circular compass with the following elements: Visual indicators- Rotating compass dial with 360-degree markings
- Qibla direction arrow pointing toward Mecca
- Cardinal direction markers (N, E, S, W)
- Static north indicator at the top
- Center dot that changes to a mosque icon when facing Qibla
- Current location name and coordinates
- Qibla bearing in degrees and cardinal direction
- Distance to Mecca in kilometers
- Turn direction hint (“Turn left X°” or “Turn right X°”)
- Green glow effect appears around the compass
- Center indicator shows a mosque icon
- Banner displays “Facing Qibla” message
- Visual feedback changes to green color scheme
AR camera mode
The AR mode overlays directional information on the live camera feed: On-screen elements- Qibla direction marker that tracks the Kaaba location
- Edge arrows when Qibla is outside the camera view
- Compass strip at the bottom showing current heading
- Top HUD displaying current heading and Qibla bearing
- Bottom HUD showing distance to Mecca and compass accuracy
- Pulsing concentric rings appear at the center
- Large mosque icon with radial glow effect
- “Facing Qibla” badge in green gradient
- Screen border glow in green color
- Horizontal field of view: 60 degrees
- Qibla marker appears on screen when within visible range
- Diamond-shaped marker on compass strip
- Turn direction hints for navigation
How users interact
Initial setup
- Grant location permission to determine current position
- The app calculates Qibla direction using the Haversine formula
- Compass sensors start providing device orientation data
Switching modes
- Tap the “Compass” or “AR” tab at the top
- For AR mode, grant camera permission when prompted
- View transitions smoothly with crossfade animation
Finding Qibla
In compass mode:- Hold the device flat like a traditional compass
- Rotate slowly until the compass needle aligns with Qibla arrow
- Watch for turn direction hints (left/right with degrees)
- When aligned, see green confirmation indicators
- Hold the device upright and point the camera forward
- Follow the on-screen Qibla marker
- Turn toward the marker if it’s off-screen (follow edge arrows)
- Align the device until pulsing green indicator appears
Compass calibration
The app monitors compass accuracy with four levels:- High: Green indicator, reliable readings
- Medium: Yellow indicator, acceptable accuracy
- Low: Red indicator with calibrate button
- Unreliable: Red indicator with calibrate button
- Tap the “Calibrate” button in the accuracy section
- Follow the calibration dialog instructions:
- Hold device away from metal objects and magnets
- Move phone in a figure-8 pattern slowly
- Repeat the motion 2-3 times
- Wait for accuracy to improve
Calculations
Qibla bearing
The app calculates the Qibla bearing from the user’s location using:- Kaaba coordinates: 21.4225°N, 39.8262°E
- Bearing formula: Accounts for Earth’s curvature
- Output: 0-360 degrees from true north
Distance calculation
Distance to Mecca is calculated using the Haversine formula:- Accounts for Earth’s spherical shape
- Earth radius: 6,371 km
- Returns great-circle distance in kilometers
Alignment detection
The app considers the user facing Qibla when:- Compass heading is within ±5° of Qibla bearing
- Provides immediate visual feedback
- Updates continuously as device moves
Technical implementation
Relevant source files:QiblaModels.kt- Data models and calculationsQiblaScreen.kt- Compass mode UIArQiblaView.kt- AR camera overlayQiblaViewModel.kt- State management
CompassData- Azimuth, pitch, roll, and accuracyQiblaDirection- Bearing and distance to KaabaQiblaInfo- Complete location and direction data