A modern, production-ready Android Qibla Compass built using MVI Architecture, StateFlow, Sensors API, Location Services, and Clean Architecture.
This project demonstrates how to build a scalable and lifecycle-safe Qibla direction feature similar to premium Islamic applications.
✅ MVI Architecture
✅ StateFlow + Channel Effects
✅ Compass + Qibla Direction
✅ Accurate Kaaba Bearing Calculation
✅ Smooth Compass Rotation
✅ Sensor Lifecycle Handling
✅ GPS + Permission Handling
✅ Cached Location Support
✅ Device Orientation Detection
✅ Horizontal/Vertical Device Handling
✅ Qibla Found Detection
✅ ±5° Tolerance Detection
✅ Haptic Feedback / Vibration
✅ Low Pass Sensor Filtering
✅ Magnetic Sensor + Accelerometer
✅ XML + ViewBinding
✅ Modern Islamic UI
✅ Dark Mode Friendly
✅ Landscape Support
✅ Production Ready Structure
- Real-time compass rotation
- Smooth needle animation
- Qibla arrow rotation
- Degree calculations
- Kaaba direction alignment
- Current location
- Cached fallback location
- GPS handling
- Permission handling
- Address integration
When user holds phone vertically:
- Compass hidden
- Direction data hidden
- Instruction shown:
Keep your phone flat for accurate Qibla direction
When phone becomes flat:
- Compass visible
- Qibla updates enabled
- Sensor calculations resumed
The app detects when the user is accurately facing Qibla.
Example:
Qibla Angle = 256°
Tolerance = ±5°
Valid Range:
251° → 261°
When inside tolerance:
✅ Vibrates once
✅ Shows “Qibla Found ✓”
✅ Highlights Qibla arrow
✅ Adds glow animation
When outside tolerance:
- Removes highlight
- Resets vibration state
Uses accurate bearing calculation toward Kaaba coordinates:
Latitude: 21.4225
Longitude: 39.8262
Calculates:
- azimuth
- bearing
- normalized direction
- qibla alignment
Contributions are welcome! Fork the repository, make changes, and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
Copyright OrbitalSonic
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.