π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile][photos] Add text detection for iOS internal users
Neerajb7700424328d
diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart b/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dartindex 1cbb935ab4..65f09dfd64 100644--- a/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart+++ b/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart@@ -26,12 +26,14 @@ import "package:photos/theme/ente_theme.dart";import 'package:photos/ui/collections/collection_action_sheet.dart';import "package:photos/ui/common/popup_item.dart";import 'package:photos/ui/notification/toast.dart';+import "package:photos/ui/viewer/file/text_detection_page.dart";import "package:photos/ui/viewer/file_details/favorite_widget.dart";import "package:photos/ui/viewer/file_details/upload_icon_widget.dart";import 'package:photos/utils/dialog_util.dart';import "package:photos/utils/file_download_util.dart";import 'package:photos/utils/file_util.dart';import "package:photos/utils/magic_util.dart";+import "package:photos/utils/navigation_util.dart";class FileAppBar extends StatefulWidget {final EnteFile file;@@ -268,6 +270,18 @@ class FileAppBarState extends State<FileAppBar> {),);+ // Text detection for internal iOS users (images and live photos, but not videos)+ if (flagService.textDetection && widget.file.fileType != FileType.video) {+ items.add(+ EntePopupMenuItem(+ "Detect Text (i)",+ value: 10,+ icon: Icons.text_fields,+ iconColor: Theme.of(context).iconTheme.color,+ ),+ );+ }+if (widget.file.isVideo) {// Video streaming optionsif (_shouldShowCreateStreamOption()) {@@ -360,6 +374,8 @@ class FileAppBarState extends State<FileAppBar> {await _handleVideoStream('create');} else if (value == 9) {await _handleVideoStream('recreate');+ } else if (value == 10) {+ await _handleTextDetection();}},),@@ -529,4 +545,25 @@ class FileAppBarState extends State<FileAppBar> {await showGenericErrorDialog(context: context, error: e);}}++ Future<void> _handleTextDetection() async {+++ try {+ final File? localFile = await getFile(widget.file);+ if (localFile == null) {+ throw Exception("Failed to get file for text detection");+ }+ if (mounted) {+ await routeToPage(+ context,+ TextDetectionPage(imagePath: localFile.path),+ );+ }+ } catch (e) {++ _logger.severe("Failed to start text detection", e);+ await showGenericErrorDialog(context: context, error: e);+ }+ }}diff --git a/mobile/apps/photos/lib/ui/viewer/file/text_detection_page.dart b/mobile/apps/photos/lib/ui/viewer/file/text_detection_page.dartnew file mode 100644index 0000000000..8387069207--- /dev/null+++ b/mobile/apps/photos/lib/ui/viewer/file/text_detection_page.dart@@ -0,0 +1,54 @@+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import "package:logging/logging.dart";+import 'package:photos/ui/common/loading_widget.dart';+import 'package:photos/ui/notification/toast.dart';+import 'package:text_detector/text_detector.dart';++class TextDetectionPage extends StatefulWidget {+ final String imagePath;++ const TextDetectionPage({required this.imagePath, super.key});++ @override+ State<TextDetectionPage> createState() => _TextDetectionPageState();+}++class _TextDetectionPageState extends State<TextDetectionPage> {+ @override+ Widget build(BuildContext context) {+ Logger("TextDetectorWidget").info("started");+ return Scaffold(+ backgroundColor: Colors.black,+ body: SafeArea(+ child: Stack(+ children: [+ TextDetectorWidget(+ imagePath: widget.imagePath,+ autoDetect: true,+ backgroundColor: Colors.black,+ showUnselectedBoundaries: true,+ singleShotMode: true,+ loadingWidget: const Center(+ child: EnteLoadingWidget(color: Colors.white, size: 24),+ ),+ onTextCopied: (text) {+ HapticFeedback.lightImpact();+ showShortToast(context, "Text copied to clipboard");+ },+ ),+ // Back button on top left+ Positioned(+ top: 8,+ left: 8,+ child: IconButton(+ icon: const Icon(Icons.arrow_back, color: Colors.white),+ onPressed: () => Navigator.of(context).pop(),+ ),+ ),+ ],+ ),+ ),+ );+ }+}diff --git a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dartindex 4f95686c64..f1b5be3b32 100644--- a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart+++ b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart@@ -66,6 +66,8 @@ class FlagService {bool get albumGuestView => internalUser;+ bool get textDetection => internalUser && Platform.isIOS;+bool hasSyncedAccountFlags() {return _prefs.containsKey("remote_flags");}diff --git a/mobile/apps/photos/scripts/internal_changes.txt b/mobile/apps/photos/scripts/internal_changes.txtindex 6ef207fd5d..00426ae042 100644--- a/mobile/apps/photos/scripts/internal_changes.txt+++ b/mobile/apps/photos/scripts/internal_changes.txt@@ -1,3 +1,4 @@+- Neeraj: (i) Add text detection option for images (iOS internal users)- Neeraj: (i) Add collection-level guest view option in album overflow menu- Neeraj: Fix IDN domain display in public URLs [#7079](https://github.com/ente-io/ente/issues/7079)- Neeraj: (i) Add allow joining album option in manage links