Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Auto-activate text overlay when text is detected

Amrithesh Kakkoth Ente026d1aebcd1b
diff --git a/mobile/apps/photos/lib/ui/viewer/file/inline_text_detection.dart b/mobile/apps/photos/lib/ui/viewer/file/inline_text_detection.dart
index 2f4e42e86b..44e7811c58 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/inline_text_detection.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/inline_text_detection.dart
@@ -15,9 +15,9 @@ import "package:photos/utils/file_util.dart";
/// Inline text detection widget that mimics Apple's Live Text behavior:
///
/// 1. Quick `hasText()` check runs silently when the image loads.
-/// 2. If text is found, a transparent long-press detector covers the image.
-/// 3. Long press triggers haptic feedback and shows the text overlay inline,
-/// letting users select and copy text directly on the image.
+/// 2. If text is found, full detection runs automatically and the text
+/// overlay appears inline on top of the image.
+/// 3. Long press on detected text lets users select and copy text.
/// 4. A close button dismisses the overlay; swiping to another image resets.
class InlineTextDetection extends StatefulWidget {
final EnteFile file;
@@ -121,6 +121,7 @@ class _InlineTextDetectionState extends State<InlineTextDetection> {
_hasText = cached.hasText;
_localFilePath = cached.localPath;
_isChecking = false;
+ if (cached.hasText) _overlayActive = true;
});
return;
}
@@ -163,6 +164,7 @@ class _InlineTextDetectionState extends State<InlineTextDetection> {
_hasText = result.hasText;
_localFilePath = result.localPath;
_isChecking = false;
+ if (result.hasText) _overlayActive = true;
});
} catch (error, stackTrace) {
_logger.severe("Text detection pre-check failed", error, stackTrace);
@@ -176,14 +178,6 @@ class _InlineTextDetectionState extends State<InlineTextDetection> {
}
}
- void _onLongPress() {
- if (!_hasText || _localFilePath == null) return;
- HapticFeedback.mediumImpact();
- setState(() {
- _overlayActive = true;
- });
- }
-
void _dismissOverlay() {
HapticFeedback.selectionClick();
setState(() {
@@ -214,17 +208,6 @@ class _InlineTextDetectionState extends State<InlineTextDetection> {
);
}
- // Overlay inactive but text detected: invisible long-press detector
- if (_hasText && !_isChecking && _localFilePath != null) {
- return Positioned.fill(
- child: GestureDetector(
- behavior: HitTestBehavior.translucent,
- onLongPress: _onLongPress,
- child: const SizedBox.expand(),
- ),
- );
- }
-
return const SizedBox.shrink();
},
);