# โšก Quick Reference Guide ## ๐Ÿƒ Quick Start 1. **Buka project di Android Studio** 2. **Sinkronisasi Gradle** (automatic atau `./gradlew sync`) 3. **Run aplikasi** (Shift+F10 atau tombol Run) 4. **Izinkan permissions** saat diminta ## ๐Ÿ“‹ File yang Paling Penting | File | Fungsi | |------|--------| | `MainActivity.kt` | UI utama + logic absensi | | `AttendanceConfig.kt` | **Ubah koordinat/data di sini** | | `LocationValidator.kt` | Logic validasi lokasi | | `N8nService.kt` | Kirim data ke server | ## ๐ŸŽฏ Ubah Lokasi Referensi **File**: `app/src/main/java/id/ac/ubharajaya/sistemakademik/config/AttendanceConfig.kt` ```kotlin // Ubah koordinat kampus const val REFERENCE_LATITUDE = -7.0 // ๐Ÿ‘ˆ Ubah ini const val REFERENCE_LONGITUDE = 110.4 // ๐Ÿ‘ˆ Ubah ini // Ubah radius area (dalam meter) const val ALLOWED_RADIUS_METERS = 100.0 // ๐Ÿ‘ˆ Ubah ini // Ubah data mahasiswa const val STUDENT_NPM = "202310715082" // ๐Ÿ‘ˆ Ubah ini const val STUDENT_NAMA = "Fazri Abdurrahman" // ๐Ÿ‘ˆ Ubah ini ``` **Cara mendapat koordinat**: 1. Buka Google Maps 2. Klik lokasi โ†’ Koordinat muncul di atas 3. Format: -7.0035 (latitude), 110.4042 (longitude) ## ๐Ÿงช Test Webhook (Sebelum Production) **Edit**: `MainActivity.kt` baris ~265: ```kotlin isTest = true // ๐Ÿ‘ˆ Set ke true untuk test // Setelah test sukses, ubah ke: isTest = false // Untuk production ``` **Cek di**: https://n8n.lab.ubharajaya.ac.id/webhook-test/... ## ๐Ÿ› Debug Tips ### Check Logs ```bash # Di Android Studio View โ†’ Tool Windows โ†’ Logcat Cari: N8nService atau MainActivity ``` ### Test Lokasi Tertentu ```kotlin // Di MainActivity, buat hardcoded location untuk test: state = state.copy( location = LocationData( latitude = -7.0035, longitude = 110.4042 ) ) ``` ### Mock GPS (di Emulator) ``` Tools โ†’ Device Manager โ†’ Extended Controls โ†’ Location Masukkan latitude/longitude yang ingin ditest ``` ## ๐Ÿ“ฑ Build & Deploy ### Build APK (untuk test) ```bash ./gradlew assembleDebug # APK ada di: app/build/outputs/apk/debug/ ``` ### Build Release APK (untuk production) ```bash ./gradlew assembleRelease # APK ada di: app/build/outputs/apk/release/ ``` ## ๐Ÿ”ง Fix Umum ### "Permission denied" saat GPS โ†’ Buka Settings app โ†’ Izin Aplikasi โ†’ Location โ†’ Allow ### "GPS tidak berfungsi" โ†’ Nyalakan Location Services di device settings ### "Foto tidak muncul" โ†’ Izinkan Camera permission di settings ### "Server error 500" โ†’ Check N8n workflow di dashboard ### "Tidak bisa connect" โ†’ Cek internet connection & webhook URL ## ๐Ÿ“ Cara Kerja Validasi Lokasi 1. **Ambil GPS**: Latitude & Longitude dari device 2. **Hitung Jarak**: Formula Haversine ke referensi 3. **Compare**: Jarak vs ALLOWED_RADIUS_METERS 4. **Hasil**: Valid โœ“ atau Invalid โœ— ``` Contoh: - Referensi: -7.0, 110.4 - GPS: -7.0035, 110.4042 - Jarak: ~500m - Radius: 100m - Hasil: INVALID (500m > 100m) ``` ## ๐Ÿ“ก API Response Codes | Code | Arti | Action | |------|------|--------| | 200 | โœ“ Sukses | Toast "Diterima", reset form | | 400 | โœ— Data error | Tampilkan error message | | 500 | โœ— Server error | Retry atau hubungi admin | ## ๐ŸŽฎ UI Components Cheat Sheet ### LocationStatusCard - Tampilkan: Latitude, Longitude, Jarak, Status - Auto update saat GPS berubah ### PhotoPreviewCard - Preview: Foto dari camera - Tombol: Ambil Ulang (untuk ganti foto) ### ErrorAlertCard - Tampilkan: Error message - Dismissable: Tombol X ### SubmitButtonWithLoader - Loading: Spinner saat submit - Disabled: Jika data belum lengkap ## ๐Ÿ”‘ Key Variables ```kotlin // State management var state by remember { mutableStateOf(AttendanceState()) } // Fused location val fusedLocationClient = LocationServices.getFusedLocationProviderClient(context) // API service val n8nService = remember { N8nService(activity) } // Current location state.location?.latitude state.location?.longitude // Current photo state.foto // Bitmap // Validation state.validationResult.isValid state.validationResult.message ``` ## ๐Ÿš€ Deploy Steps 1. **Update AttendanceConfig.kt** (koordinat, NPM, nama) 2. **Test dengan WEBHOOK_TEST** (set isTest = true) 3. **Verify di N8n dashboard** 4. **Switch ke WEBHOOK_PRODUCTION** (set isTest = false) 5. **Build APK release**: `./gradlew assembleRelease` 6. **Distribute ke device/playstore** ## ๐Ÿ“Š Useful URLs | Purpose | URL | |---------|-----| | Test Webhook | https://n8n.lab.ubharajaya.ac.id/webhook-test/... | | Production Webhook | https://n8n.lab.ubharajaya.ac.id/webhook/... | | N8n Dashboard | https://n8n.lab.ubharajaya.ac.id | | Attendance Check | https://docs.google.com/spreadsheets/d/1jH15MfnNgpPGuGeid0... | | Ntfy Monitor | https://ntfy.ubharajaya.ac.id/EAS | --- **Perlu bantuan?** Check `DOKUMENTASI.md` untuk penjelasan lebih detail.