Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.
feat: integrate user-defined currency and language preferences into smart action detection and translation workflows
Rishabh Bajpai921bc20faa59
diff --git a/app/src/main/java/com/gotcha/service/GotchaAccessibilityService.kt b/app/src/main/java/com/gotcha/service/GotchaAccessibilityService.ktindex f124151..e80416f 100644--- a/app/src/main/java/com/gotcha/service/GotchaAccessibilityService.kt+++ b/app/src/main/java/com/gotcha/service/GotchaAccessibilityService.kt@@ -398,7 +398,15 @@ class GotchaAccessibilityService : AccessibilityService() {}val fullText = fullTextBuilder.toString()- val entities = SmartActionDetector.detectAll(fullText, allowChat = false)+ val settings = runCatching { com.gotcha.data.SettingsRepository(applicationContext).load() }.getOrNull()+ val prefCurr = settings?.preferredCurrency ?: "USD"+ val prefLang = settings?.preferredLanguage ?: "English"+ val entities = SmartActionDetector.detectAll(+ fullText,+ allowChat = false,+ targetCurrency = prefCurr,+ targetLanguage = prefLang+ )val placeable = discardOversizedBounds(locateEntities(entities, nodeRanges))val selected = SmartActionDetector.selectForAnnotation(placeable.map { it.entity })// Matched by identity, not equality: selection hands back the very objectsdiff --git a/app/src/main/java/com/gotcha/service/GotchaNotificationListenerService.kt b/app/src/main/java/com/gotcha/service/GotchaNotificationListenerService.ktindex b2c300f..3fb2332 100644--- a/app/src/main/java/com/gotcha/service/GotchaNotificationListenerService.kt+++ b/app/src/main/java/com/gotcha/service/GotchaNotificationListenerService.kt@@ -69,7 +69,12 @@ class GotchaNotificationListenerService : NotificationListenerService() {val fullText = "$title $text".trim()if (fullText.isBlank()) return- val entities = SmartActionDetector.detectAll(fullText, allowChat = false)+ val entities = SmartActionDetector.detectAll(+ fullText,+ allowChat = false,+ targetCurrency = settings.preferredCurrency,+ targetLanguage = settings.preferredLanguage+ )if (entities.isEmpty()) return// Auto-copy OTP if enableddiff --git a/app/src/main/java/com/gotcha/service/ScreenCompanionController.kt b/app/src/main/java/com/gotcha/service/ScreenCompanionController.ktindex 83fa334..35a9e2a 100644--- a/app/src/main/java/com/gotcha/service/ScreenCompanionController.kt+++ b/app/src/main/java/com/gotcha/service/ScreenCompanionController.kt@@ -90,11 +90,12 @@ class ScreenCompanionController(if (settings != null && !settings.proactiveEnabled) returnif (triggerType == "Screenshot") {+ val prefLang = settings?.preferredLanguage ?: "English"onSmartActionPairReady("📸 Screenshot taken. Extract text?","Extract the text from this screenshot.","🌐 Translate Screenshot",- TRANSLATE_SCREENSHOT_PROMPT+ translateScreenshotPrompt(prefLang))return}@@ -144,8 +145,14 @@ class ScreenCompanionController(}val prefCurrency = effectiveSettings?.preferredCurrency ?: "USD"+ val prefLang = effectiveSettings?.preferredLanguage ?: "English"val textEntities = if (screenText.isNotEmpty()) {- SmartActionDetector.detectAll(screenText, allowChat = false, targetCurrency = prefCurrency)+ SmartActionDetector.detectAll(+ screenText,+ allowChat = false,+ targetCurrency = prefCurrency,+ targetLanguage = prefLang+ )} else {emptyList()}@@ -181,9 +188,8 @@ class ScreenCompanionController(const val ACTION_CLIPBOARD_CHANGED = "com.gotcha.action.CLIPBOARD_CHANGED"private const val DEBOUNCE_DELAY_MS = 600L- const val TRANSLATE_SCREENSHOT_PROMPT =- "Extract any text present on this screenshot, translate it to English " +- "(or the user's system language), and display both the original text " +- "and its translation side-by-side using a markdown table."+ fun translateScreenshotPrompt(targetLang: String = "English"): String =+ "Extract any text present on this screenshot, translate it to $targetLang, " ++ "and display both the original text and its translation side-by-side using a markdown table."}}diff --git a/app/src/main/java/com/gotcha/service/ScreenLensController.kt b/app/src/main/java/com/gotcha/service/ScreenLensController.ktindex 86113ef..bb2e862 100644--- a/app/src/main/java/com/gotcha/service/ScreenLensController.kt+++ b/app/src/main/java/com/gotcha/service/ScreenLensController.kt@@ -164,7 +164,12 @@ class ScreenLensController(withContext(Dispatchers.Main) { overlay?.freezeSelection(finalRect) }val regionText = service.dumpTextInRegion(finalRect)- val contextualActions = regionText?.let { SmartActionDetector.detectContextual(it) } ?: emptyList()+ val settings = runCatching { com.gotcha.data.SettingsRepository(appContext).load() }.getOrNull()+ val preferredLang = settings?.preferredLanguage ?: "English"+ val preferredCurr = settings?.preferredCurrency ?: "USD"+ val contextualActions = regionText?.let {+ SmartActionDetector.detectContextual(it, targetCurrency = preferredCurr, targetLanguage = preferredLang)+ } ?: emptyList()withContext(Dispatchers.Main) {overlay?.setCaptureMode(true)diff --git a/app/src/main/java/com/gotcha/service/SmartActionDetector.kt b/app/src/main/java/com/gotcha/service/SmartActionDetector.ktindex 6194d44..fc06e06 100644--- a/app/src/main/java/com/gotcha/service/SmartActionDetector.kt+++ b/app/src/main/java/com/gotcha/service/SmartActionDetector.kt@@ -369,8 +369,17 @@ object SmartActionDetector {* Contextual detection wrapper for Lens mode.* Returns primary actions for all distinct entities found in the text.*/- fun detectContextual(text: String): List<SmartAction> {- val entities = detectAll(text, allowChat = false)+ fun detectContextual(+ text: String,+ targetCurrency: String = "USD",+ targetLanguage: String = "English"+ ): List<SmartAction> {+ val entities = detectAll(+ text = text,+ allowChat = false,+ targetCurrency = targetCurrency,+ targetLanguage = targetLanguage+ )return entities.mapNotNull { it.primaryAction }}