|
|
|
@ -134,7 +134,7 @@ class ScreenCaptureService : Service() { |
|
|
|
|
|
|
|
private lateinit var screenCaptureManager: ScreenCaptureManager |
|
|
|
private var detectionOverlay: DetectionOverlay? = null |
|
|
|
private var overlayEnabled = true // Track overlay visibility state |
|
|
|
private var overlayEnabled = false // Track overlay visibility state |
|
|
|
private var lastDetections: List<MLDetection> = emptyList() // Cache last detections for toggle |
|
|
|
|
|
|
|
// MVC Components |
|
|
|
@ -558,6 +558,9 @@ class ScreenCaptureService : Service() { |
|
|
|
pokemonInfo = pokemonInfo, |
|
|
|
processingTimeMs = duration |
|
|
|
) |
|
|
|
|
|
|
|
// Stop spinning animation - detection complete |
|
|
|
enhancedFloatingFAB?.stopDetectionAnimation() |
|
|
|
} else { |
|
|
|
PGHLog.i(TAG, "❌ Could not extract complete Pokemon info") |
|
|
|
|
|
|
|
@ -566,6 +569,9 @@ class ScreenCaptureService : Service() { |
|
|
|
detections = extractorDetections, |
|
|
|
processingTimeMs = duration |
|
|
|
) |
|
|
|
|
|
|
|
// Stop spinning animation - detection complete (no results) |
|
|
|
enhancedFloatingFAB?.stopDetectionAnimation() |
|
|
|
} |
|
|
|
} finally { |
|
|
|
// Analysis cycle complete, allow next one |
|
|
|
@ -603,6 +609,9 @@ class ScreenCaptureService : Service() { |
|
|
|
errorMessage = "Processing error: ${e.message}", |
|
|
|
processingTimeMs = duration |
|
|
|
) |
|
|
|
|
|
|
|
// Stop spinning animation - detection failed |
|
|
|
enhancedFloatingFAB?.stopDetectionAnimation() |
|
|
|
} |
|
|
|
|
|
|
|
// Clear flag on error too |
|
|
|
@ -1185,6 +1194,9 @@ class ScreenCaptureService : Service() { |
|
|
|
private fun triggerManualDetection() { |
|
|
|
PGHLog.d(TAG, "🔍 Manual detection triggered via MVC!") |
|
|
|
|
|
|
|
// Start spinning animation to show detection is in progress |
|
|
|
enhancedFloatingFAB?.startDetectionAnimation() |
|
|
|
|
|
|
|
latestImage?.let { image -> |
|
|
|
try { |
|
|
|
// Convert image to Mat for processing |
|
|
|
@ -1210,11 +1222,16 @@ class ScreenCaptureService : Service() { |
|
|
|
|
|
|
|
// Extract Pokemon info using YOLO detections with OCR |
|
|
|
extractPokemonInfoFromYOLOAsync(mat, detections) |
|
|
|
} else { |
|
|
|
// No detections found - stop animation |
|
|
|
PGHLog.i(TAG, "No detections found") |
|
|
|
enhancedFloatingFAB?.stopDetectionAnimation() |
|
|
|
} |
|
|
|
|
|
|
|
mat.release() |
|
|
|
} else { |
|
|
|
PGHLog.e(TAG, "❌ Failed to convert image to Mat") |
|
|
|
enhancedFloatingFAB?.stopDetectionAnimation() |
|
|
|
} |
|
|
|
|
|
|
|
// Close the image after processing to free the buffer |
|
|
|
@ -1223,9 +1240,11 @@ class ScreenCaptureService : Service() { |
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
|
PGHLog.e(TAG, "❌ Error in manual detection", e) |
|
|
|
enhancedFloatingFAB?.stopDetectionAnimation() |
|
|
|
} |
|
|
|
} ?: run { |
|
|
|
PGHLog.w(TAG, "⚠️ No image available for detection") |
|
|
|
enhancedFloatingFAB?.stopDetectionAnimation() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|