Skip to content

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.

fix(lens): ensure Copy text OCR chip button is always displayed for all selections with safe bitmap copy

Rishabh Bajpai682a76109334
diff --git a/app/src/main/java/com/gotcha/service/ScreenLensController.kt b/app/src/main/java/com/gotcha/service/ScreenLensController.kt
index 9906324..284e4bb 100644
--- a/app/src/main/java/com/gotcha/service/ScreenLensController.kt
+++ b/app/src/main/java/com/gotcha/service/ScreenLensController.kt
@@ -199,33 +199,37 @@ class ScreenLensController(
}
}
- val hasText = !cleanText.isNullOrBlank()
- if (hasText && cleanText != null) {
+ if (!cleanText.isNullOrBlank()) {
chipsLayout.addView(
chipButton("📝 Select text") {
showSelectableTextCard(cleanText)
}
)
- chipsLayout.addView(
- chipButton("📋 Copy text") {
- val crop = pendingCrop
- if (crop != null && !crop.isRecycled) {
- onOcrToClipboard(crop)
+ }
+
+ chipsLayout.addView(
+ chipButton("📋 Copy text") {
+ val crop = pendingCrop
+ if (crop != null && !crop.isRecycled) {
+ val cropCopy = runCatching { crop.copy(crop.config, false) }.getOrNull()
+ if (cropCopy != null) {
+ onOcrToClipboard(cropCopy)
}
- cancel()
}
- )
- chipsLayout.addView(
- chipButton("🌐 Translate") {
- val crop = pendingCrop
- if (crop != null && !crop.isRecycled) {
- val base64 = bitmapToBase64(crop)
- onImagePrompt(base64, ScreenCompanionController.TRANSLATE_SCREENSHOT_PROMPT)
- cancel()
- }
+ cancel()
+ }
+ )
+
+ chipsLayout.addView(
+ chipButton("🌐 Translate") {
+ val crop = pendingCrop
+ if (crop != null && !crop.isRecycled) {
+ val base64 = bitmapToBase64(crop)
+ onImagePrompt(base64, ScreenCompanionController.TRANSLATE_SCREENSHOT_PROMPT)
}
- )
- }
+ cancel()
+ }
+ )
chipsLayout.addView(
chipButton("💾 Save image") {