2026-01-14 21:33:58 +07:00

328 lines
7.0 KiB
Markdown

# 📋 QUICK REFERENCE CARD - Aplikasi Absensi Akademik
## 🚀 Quick Start
### 1. Build & Run
```bash
cd /Users/maccomputer/AndroidStudioProjects/Starter-EAS-2025-2026
./gradlew clean build
./gradlew installDebug
```
### 2. First Login
- NPM: (register dulu)
- Password: (sesuai pilihan)
### 3. Test Absensi
- Allow location & camera permissions
- Ambil foto
- Kirim absensi (otomatis validate lokasi)
- Lihat riwayat
---
## 🔧 Key Configuration Points
### Campus Location
**File**: `MainActivity.kt` (line ~70)
```kotlin
campusLat: Double = -6.2030, // Ubah ini
campusLon: Double = 107.0045, // Ubah ini
radiusMeters: Float = 100f // Ubah ini (meter)
```
### Webhook URL
**File**: `MainActivity.kt` (line ~110)
```kotlin
val url = URL("https://n8n.lab.ubharajaya.ac.id/webhook/...")
```
### Database Version
**File**: `DatabaseHelper.kt` (line ~12)
```kotlin
private const val DATABASE_VERSION = 2
```
---
## 📱 Screen Navigation
```
LOGIN ←→ REGISTER
ABSENSI (ambil foto + lokasi)
├─ Kirim (validate lokasi → webhook)
└─ Lihat Riwayat → HISTORY (list)
```
---
## 📊 Database Schema
### Users Table
```sql
id | username | npm (UNIQUE) | password
```
### Attendance Table (NEW)
```sql
id | npm (FK) | timestamp | latitude | longitude | status
```
**Status Values**:
- `"success"` - dalam radius
- `"invalid_location"` - diluar radius
---
## 🔨 Main Functions
### Location Functions
```kotlin
calculateDistance(lat1, lon1, lat2, lon2): Float
Hitung jarak dalam meter
isWithinAbsensiRadius(studentLat, studentLon, ...): Boolean
Cek apakah dalam radius absensi
obfuscateCoordinates(lat, lon, offset): Pair<Double, Double>
Obfuscate koordinat untuk privacy
```
### Database Functions
```kotlin
db.addAttendanceRecord(npm, timestamp, lat, lon, status): Boolean
Simpan record absensi
db.getAttendanceHistory(npm): List<AttendanceRecord>
Ambil riwayat absensi
```
### Network Functions
```kotlin
kirimKeN8n(context, db, npm, nama, lat, lon, foto)
Send data ke webhook dengan validasi
```
---
## ⚡ Common Tasks
### Ubah Lokasi Campus
Edit `MainActivity.kt` line ~68:
```kotlin
fun isWithinAbsensiRadius(
studentLat: Double,
studentLon: Double,
campusLat: Double = -6.2030, // CHANGE THIS
campusLon: Double = 107.0045, // CHANGE THIS
radiusMeters: Float = 100f // CHANGE THIS
)
```
### Ubah Radius
```kotlin
radiusMeters: Float = 200f // Ganti 100 menjadi 200
```
### Ubah Webhook URL
Edit `MainActivity.kt` line ~110:
```kotlin
val url = URL("https://your-webhook-url-here")
```
### Clear Database
```bash
adb shell pm clear id.ac.ubharajaya.sistemakademik
```
### View Database
```bash
adb pull /data/data/id.ac.ubharajaya.sistemakademik/databases/Akademik.db
```
---
## 🧪 Testing Quick Checklist
- [ ] Register user baru
- [ ] Login dengan NPM/password
- [ ] Ambil foto (grant camera permission)
- [ ] Check lokasi (grant location permission)
- [ ] Kirim absensi
- [ ] Verifikasi di database:
- [ ] Attendance record tersimpan
- [ ] Status = "success" atau "invalid_location"
- [ ] Timestamp correct
- [ ] Lihat riwayat
- [ ] List muncul
- [ ] Status indicator (✓/✗) benar
- [ ] Tanggal format Indonesia
---
## 🐛 Debugging Tips
### View Logs
```bash
adb logcat id.ac.ubharajaya.sistemakademik:V *:S
```
### Check Database Content
```bash
adb shell
sqlite3 /data/data/id.ac.ubharajaya.sistemakademik/databases/Akademik.db
> SELECT * FROM users;
> SELECT * FROM attendance;
> .quit
```
### Test Permission
```bash
adb shell pm grant id.ac.ubharajaya.sistemakademik android.permission.ACCESS_FINE_LOCATION
adb shell pm grant id.ac.ubharajaya.sistemakademik android.permission.CAMERA
```
---
## 📦 Dependencies
```gradle
// Core
androidx.core:core-ktx
androidx.activity:activity-compose:1.9.0
// Compose
androidx.compose.ui
androidx.compose.material3
androidx.compose.material:material-icons-extended:1.6.0
// Location
com.google.android.gms:play-services-location:21.0.1
```
---
## 📂 Project Structure
```
app/
├── src/main/
│ ├── java/id/ac/ubharajaya/sistemakademik/
│ │ ├── MainActivity.kt (main app, all screens)
│ │ └── DatabaseHelper.kt (database operations)
│ ├── res/
│ │ ├── values/ (strings, colors, themes)
│ │ ├── layout/ (compose layouts)
│ │ └── drawable/ (icons, images)
│ └── AndroidManifest.xml (permissions, activities)
├── build.gradle.kts (dependencies, build config)
└── ...
```
---
## 🔐 Permissions Required
```xml
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.CAMERA"/>
```
---
## 📈 Useful Metrics
| Metric | Value |
|--------|-------|
| Min SDK | 28 |
| Target SDK | 36 |
| Compile SDK | 36 |
| Java Version | 11 |
| Default Radius | 100 meters |
| Photo Quality | 80% JPEG |
| DB Version | 2 |
---
## 🎯 Data Flow Summary
```
User Input
Validate (location, photo)
Save to Local DB
Send to Webhook (n8n)
Show Feedback
Update History UI
```
---
## 💡 Tips & Tricks
1. **Testing Location**:
- Use Android Emulator's extended controls to simulate location
- Or physically go ke lokasi yang valid
2. **Debugging Photo**:
- Photo tersimpan sebagai Bitmap in-memory
- Convert to Base64 untuk webhook
- Tidak di-save ke storage (enhancement needed)
3. **Database Testing**:
- Pull database dan buka di SQLite browser
- Check attendance records dan status values
- Verify foreign key relationships
4. **Network Testing**:
- Monitor network calls di Android Studio Profiler
- Check webhook responses di n8n dashboard
- Use packet sniffer (tcpdump) untuk HTTPS analysis
---
## 🚨 Common Issues & Solutions
| Issue | Solution |
|-------|----------|
| Location null | Grant permission, wait for GPS lock |
| Photo not captured | Check camera permission, device has camera |
| Webhook timeout | Check internet, verify URL |
| DB migration error | Clear app data, reinstall |
| Permission denied | Grant at runtime, check manifest |
---
## 📚 Documentation Files
| File | Content |
|------|---------|
| `DEVELOPMENT_GUIDE.md` | User guide, features, setup |
| `CHANGELOG.md` | Version history, detailed changes |
| `IMPLEMENTATION_NOTES.md` | Technical config, debugging |
| `IMPLEMENTATION_SUMMARY.md` | Project summary, metrics |
| `QUICK_REFERENCE.md` | This file - quick lookup |
---
## 🔗 Important URLs
- **Webhook Test**: https://n8n.lab.ubharajaya.ac.id/webhook-test/...
- **Webhook Prod**: https://n8n.lab.ubharajaya.ac.id/webhook/...
- **Ntfy Monitoring**: https://ntfy.ubharajaya.ac.id/EAS
- **Spreadsheet Tracking**: https://docs.google.com/spreadsheets/d/1jH15MfnNgpPGuGeid0hYfY7fFUHCEFbCmg8afTyyLZs/
---
**Last Updated**: 14 January 2026
**Version**: 1.1.0
**For**: Aplikasi Absensi Akademik Berbasis Koordinat dan Foto