Просмотр исходного кода

[mob][photos] Initial settings screen for face recognition

laurenspriem 1 год назад
Родитель
Сommit
e414128f18

+ 1 - 1
auth/assets/simple-icons

@@ -1 +1 @@
-Subproject commit 8a3731352af133a02223a6c7b1f37c4abb096af0
+Subproject commit 8e7701d6a40462733043f54b3849faf35af70a83

+ 4 - 0
mobile/lib/generated/intl/messages_cs.dart

@@ -46,6 +46,10 @@ class MessageLookup extends MessageLookupByLibrary {
                 "Edits to location will only be seen within Ente"),
         "enterPersonName":
             MessageLookupByLibrary.simpleMessage("Enter person name"),
+        "faceRecognition":
+            MessageLookupByLibrary.simpleMessage("Face recognition"),
+        "faceRecognitionIndexingDescription": MessageLookupByLibrary.simpleMessage(
+            "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."),
         "fileTypes": MessageLookupByLibrary.simpleMessage("File types"),
         "joinDiscord": MessageLookupByLibrary.simpleMessage("Join Discord"),
         "locations": MessageLookupByLibrary.simpleMessage("Locations"),

+ 4 - 0
mobile/lib/generated/intl/messages_de.dart

@@ -702,6 +702,10 @@ class MessageLookup extends MessageLookupByLibrary {
             MessageLookupByLibrary.simpleMessage("Protokolle exportieren"),
         "exportYourData":
             MessageLookupByLibrary.simpleMessage("Daten exportieren"),
+        "faceRecognition":
+            MessageLookupByLibrary.simpleMessage("Face recognition"),
+        "faceRecognitionIndexingDescription": MessageLookupByLibrary.simpleMessage(
+            "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."),
         "faces": MessageLookupByLibrary.simpleMessage("Gesichter"),
         "failedToApplyCode": MessageLookupByLibrary.simpleMessage(
             "Der Code konnte nicht aktiviert werden"),

+ 4 - 0
mobile/lib/generated/intl/messages_en.dart

@@ -700,6 +700,10 @@ class MessageLookup extends MessageLookupByLibrary {
         "exportLogs": MessageLookupByLibrary.simpleMessage("Export logs"),
         "exportYourData":
             MessageLookupByLibrary.simpleMessage("Export your data"),
+        "faceRecognition":
+            MessageLookupByLibrary.simpleMessage("Face recognition"),
+        "faceRecognitionIndexingDescription": MessageLookupByLibrary.simpleMessage(
+            "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."),
         "faces": MessageLookupByLibrary.simpleMessage("Faces"),
         "failedToApplyCode":
             MessageLookupByLibrary.simpleMessage("Failed to apply code"),

+ 4 - 0
mobile/lib/generated/intl/messages_es.dart

@@ -611,6 +611,10 @@ class MessageLookup extends MessageLookupByLibrary {
             MessageLookupByLibrary.simpleMessage("Exportar registros"),
         "exportYourData":
             MessageLookupByLibrary.simpleMessage("Exportar tus datos"),
+        "faceRecognition":
+            MessageLookupByLibrary.simpleMessage("Face recognition"),
+        "faceRecognitionIndexingDescription": MessageLookupByLibrary.simpleMessage(
+            "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."),
         "failedToApplyCode":
             MessageLookupByLibrary.simpleMessage("Error al aplicar el código"),
         "failedToCancel":

+ 4 - 0
mobile/lib/generated/intl/messages_fr.dart

@@ -690,6 +690,10 @@ class MessageLookup extends MessageLookupByLibrary {
         "exportLogs": MessageLookupByLibrary.simpleMessage("Exporter les logs"),
         "exportYourData":
             MessageLookupByLibrary.simpleMessage("Exportez vos données"),
+        "faceRecognition":
+            MessageLookupByLibrary.simpleMessage("Face recognition"),
+        "faceRecognitionIndexingDescription": MessageLookupByLibrary.simpleMessage(
+            "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."),
         "faces": MessageLookupByLibrary.simpleMessage("Visages"),
         "failedToApplyCode": MessageLookupByLibrary.simpleMessage(
             "Impossible d\'appliquer le code"),

+ 4 - 0
mobile/lib/generated/intl/messages_it.dart

@@ -667,6 +667,10 @@ class MessageLookup extends MessageLookupByLibrary {
             "Questo link è scaduto. Si prega di selezionare un nuovo orario di scadenza o disabilitare la scadenza del link."),
         "exportLogs": MessageLookupByLibrary.simpleMessage("Esporta log"),
         "exportYourData": MessageLookupByLibrary.simpleMessage("Esporta dati"),
+        "faceRecognition":
+            MessageLookupByLibrary.simpleMessage("Face recognition"),
+        "faceRecognitionIndexingDescription": MessageLookupByLibrary.simpleMessage(
+            "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."),
         "failedToApplyCode": MessageLookupByLibrary.simpleMessage(
             "Impossibile applicare il codice"),
         "failedToCancel":

+ 4 - 0
mobile/lib/generated/intl/messages_ko.dart

@@ -46,6 +46,10 @@ class MessageLookup extends MessageLookupByLibrary {
                 "Edits to location will only be seen within Ente"),
         "enterPersonName":
             MessageLookupByLibrary.simpleMessage("Enter person name"),
+        "faceRecognition":
+            MessageLookupByLibrary.simpleMessage("Face recognition"),
+        "faceRecognitionIndexingDescription": MessageLookupByLibrary.simpleMessage(
+            "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."),
         "fileTypes": MessageLookupByLibrary.simpleMessage("File types"),
         "joinDiscord": MessageLookupByLibrary.simpleMessage("Join Discord"),
         "locations": MessageLookupByLibrary.simpleMessage("Locations"),

+ 4 - 0
mobile/lib/generated/intl/messages_nl.dart

@@ -723,6 +723,10 @@ class MessageLookup extends MessageLookupByLibrary {
             MessageLookupByLibrary.simpleMessage("Logboek exporteren"),
         "exportYourData":
             MessageLookupByLibrary.simpleMessage("Exporteer je gegevens"),
+        "faceRecognition":
+            MessageLookupByLibrary.simpleMessage("Face recognition"),
+        "faceRecognitionIndexingDescription": MessageLookupByLibrary.simpleMessage(
+            "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."),
         "faces": MessageLookupByLibrary.simpleMessage("Gezichten"),
         "failedToApplyCode":
             MessageLookupByLibrary.simpleMessage("Code toepassen mislukt"),

+ 4 - 0
mobile/lib/generated/intl/messages_no.dart

@@ -63,6 +63,10 @@ class MessageLookup extends MessageLookupByLibrary {
             "Vennligst skriv inn en gyldig e-postadresse."),
         "enterYourEmailAddress": MessageLookupByLibrary.simpleMessage(
             "Skriv inn e-postadressen din"),
+        "faceRecognition":
+            MessageLookupByLibrary.simpleMessage("Face recognition"),
+        "faceRecognitionIndexingDescription": MessageLookupByLibrary.simpleMessage(
+            "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."),
         "feedback": MessageLookupByLibrary.simpleMessage("Tilbakemelding"),
         "fileTypes": MessageLookupByLibrary.simpleMessage("File types"),
         "invalidEmailAddress":

+ 4 - 0
mobile/lib/generated/intl/messages_pl.dart

@@ -111,6 +111,10 @@ class MessageLookup extends MessageLookupByLibrary {
             MessageLookupByLibrary.simpleMessage("Wprowadź hasło"),
         "enterYourRecoveryKey": MessageLookupByLibrary.simpleMessage(
             "Wprowadź swój klucz odzyskiwania"),
+        "faceRecognition":
+            MessageLookupByLibrary.simpleMessage("Face recognition"),
+        "faceRecognitionIndexingDescription": MessageLookupByLibrary.simpleMessage(
+            "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."),
         "feedback": MessageLookupByLibrary.simpleMessage("Informacja zwrotna"),
         "fileTypes": MessageLookupByLibrary.simpleMessage("File types"),
         "forgotPassword":

+ 4 - 0
mobile/lib/generated/intl/messages_pt.dart

@@ -713,6 +713,10 @@ class MessageLookup extends MessageLookupByLibrary {
         "exportLogs": MessageLookupByLibrary.simpleMessage("Exportar logs"),
         "exportYourData":
             MessageLookupByLibrary.simpleMessage("Exportar seus dados"),
+        "faceRecognition":
+            MessageLookupByLibrary.simpleMessage("Face recognition"),
+        "faceRecognitionIndexingDescription": MessageLookupByLibrary.simpleMessage(
+            "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."),
         "faces": MessageLookupByLibrary.simpleMessage("Rostos"),
         "failedToApplyCode":
             MessageLookupByLibrary.simpleMessage("Falha ao aplicar o código"),

+ 4 - 0
mobile/lib/generated/intl/messages_zh.dart

@@ -592,6 +592,10 @@ class MessageLookup extends MessageLookupByLibrary {
             MessageLookupByLibrary.simpleMessage("此链接已过期。请选择新的过期时间或禁用链接有效期。"),
         "exportLogs": MessageLookupByLibrary.simpleMessage("导出日志"),
         "exportYourData": MessageLookupByLibrary.simpleMessage("导出您的数据"),
+        "faceRecognition":
+            MessageLookupByLibrary.simpleMessage("Face recognition"),
+        "faceRecognitionIndexingDescription": MessageLookupByLibrary.simpleMessage(
+            "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."),
         "faces": MessageLookupByLibrary.simpleMessage("人脸"),
         "failedToApplyCode": MessageLookupByLibrary.simpleMessage("无法使用此代码"),
         "failedToCancel": MessageLookupByLibrary.simpleMessage("取消失败"),

+ 20 - 0
mobile/lib/generated/l10n.dart

@@ -8753,6 +8753,26 @@ class S {
       args: [],
     );
   }
+
+  /// `Face recognition`
+  String get faceRecognition {
+    return Intl.message(
+      'Face recognition',
+      name: 'faceRecognition',
+      desc: '',
+      args: [],
+    );
+  }
+
+  /// `Please note that this will result in a higher bandwidth and battery usage until all items are indexed.`
+  String get faceRecognitionIndexingDescription {
+    return Intl.message(
+      'Please note that this will result in a higher bandwidth and battery usage until all items are indexed.',
+      name: 'faceRecognitionIndexingDescription',
+      desc: '',
+      args: [],
+    );
+  }
 }
 
 class AppLocalizationDelegate extends LocalizationsDelegate<S> {

+ 3 - 1
mobile/lib/l10n/intl_cs.arb

@@ -20,5 +20,7 @@
   "createCollaborativeLink": "Create collaborative link",
   "search": "Search",
   "enterPersonName": "Enter person name",
-  "removePersonLabel": "Remove person label"
+  "removePersonLabel": "Remove person label",
+  "faceRecognition": "Face recognition",
+  "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."
 }

+ 3 - 1
mobile/lib/l10n/intl_de.arb

@@ -1208,5 +1208,7 @@
   "createCollaborativeLink": "Create collaborative link",
   "search": "Search",
   "enterPersonName": "Enter person name",
-  "removePersonLabel": "Remove person label"
+  "removePersonLabel": "Remove person label",
+  "faceRecognition": "Face recognition",
+  "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."
 }

+ 3 - 1
mobile/lib/l10n/intl_en.arb

@@ -1231,5 +1231,7 @@
   "castIPMismatchBody": "Please make sure you are on the same network as the TV.",
   "pairingComplete": "Pairing complete",
   "autoPair": "Auto pair",
-  "pairWithPin": "Pair with PIN"
+  "pairWithPin": "Pair with PIN",
+  "faceRecognition": "Face recognition",
+  "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."
 }

+ 3 - 1
mobile/lib/l10n/intl_es.arb

@@ -982,5 +982,7 @@
   "createCollaborativeLink": "Create collaborative link",
   "search": "Search",
   "enterPersonName": "Enter person name",
-  "removePersonLabel": "Remove person label"
+  "removePersonLabel": "Remove person label",
+  "faceRecognition": "Face recognition",
+  "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."
 }

+ 3 - 1
mobile/lib/l10n/intl_fr.arb

@@ -1163,5 +1163,7 @@
   "createCollaborativeLink": "Create collaborative link",
   "search": "Search",
   "enterPersonName": "Enter person name",
-  "removePersonLabel": "Remove person label"
+  "removePersonLabel": "Remove person label",
+  "faceRecognition": "Face recognition",
+  "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."
 }

+ 3 - 1
mobile/lib/l10n/intl_it.arb

@@ -1125,5 +1125,7 @@
   "createCollaborativeLink": "Create collaborative link",
   "search": "Search",
   "enterPersonName": "Enter person name",
-  "removePersonLabel": "Remove person label"
+  "removePersonLabel": "Remove person label",
+  "faceRecognition": "Face recognition",
+  "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."
 }

+ 3 - 1
mobile/lib/l10n/intl_ko.arb

@@ -20,5 +20,7 @@
   "createCollaborativeLink": "Create collaborative link",
   "search": "Search",
   "enterPersonName": "Enter person name",
-  "removePersonLabel": "Remove person label"
+  "removePersonLabel": "Remove person label",
+  "faceRecognition": "Face recognition",
+  "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."
 }

+ 3 - 1
mobile/lib/l10n/intl_nl.arb

@@ -1226,5 +1226,7 @@
   "stopCastingBody": "Wil je stoppen met casten?",
   "castIPMismatchTitle": "Album casten mislukt",
   "castIPMismatchBody": "Zorg ervoor dat je op hetzelfde netwerk zit als de tv.",
-  "pairingComplete": "Koppeling voltooid"
+  "pairingComplete": "Koppeling voltooid",
+  "faceRecognition": "Face recognition",
+  "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."
 }

+ 3 - 1
mobile/lib/l10n/intl_no.arb

@@ -34,5 +34,7 @@
   "createCollaborativeLink": "Create collaborative link",
   "search": "Search",
   "enterPersonName": "Enter person name",
-  "removePersonLabel": "Remove person label"
+  "removePersonLabel": "Remove person label",
+  "faceRecognition": "Face recognition",
+  "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."
 }

+ 3 - 1
mobile/lib/l10n/intl_pl.arb

@@ -121,5 +121,7 @@
   "createCollaborativeLink": "Create collaborative link",
   "search": "Search",
   "enterPersonName": "Enter person name",
-  "removePersonLabel": "Remove person label"
+  "removePersonLabel": "Remove person label",
+  "faceRecognition": "Face recognition",
+  "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."
 }

+ 3 - 1
mobile/lib/l10n/intl_pt.arb

@@ -1226,5 +1226,7 @@
   "stopCastingBody": "Você quer parar a transmissão?",
   "castIPMismatchTitle": "Falha ao transmitir álbum",
   "castIPMismatchBody": "Certifique-se de estar na mesma rede que a TV.",
-  "pairingComplete": "Pareamento concluído"
+  "pairingComplete": "Pareamento concluído",
+  "faceRecognition": "Face recognition",
+  "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."
 }

+ 3 - 1
mobile/lib/l10n/intl_zh.arb

@@ -1226,5 +1226,7 @@
   "stopCastingBody": "您想停止投放吗?",
   "castIPMismatchTitle": "投放相册失败",
   "castIPMismatchBody": "请确保您的设备与电视处于同一网络。",
-  "pairingComplete": "配对完成"
+  "pairingComplete": "配对完成",
+  "faceRecognition": "Face recognition",
+  "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."
 }

+ 48 - 3
mobile/lib/ui/settings/machine_learning_settings_page.dart

@@ -6,6 +6,7 @@ import "package:photos/core/event_bus.dart";
 import 'package:photos/events/embedding_updated_event.dart';
 import "package:photos/generated/l10n.dart";
 import "package:photos/service_locator.dart";
+import "package:photos/services/machine_learning/face_ml/face_ml_service.dart";
 import 'package:photos/services/machine_learning/semantic_search/frameworks/ml_framework.dart';
 import 'package:photos/services/machine_learning/semantic_search/semantic_search_service.dart';
 import "package:photos/theme/ente_theme.dart";
@@ -89,6 +90,8 @@ class _MachineLearningSettingsPageState
                       mainAxisSize: MainAxisSize.min,
                       children: [
                         _getMagicSearchSettings(context),
+                        const SizedBox(height: 12),
+                        _getFacesSearchSettings(context),
                       ],
                     ),
                   ),
@@ -147,7 +150,7 @@ class _MachineLearningSettingsPageState
                 children: [
                   _state == InitializationState.initialized
                       ? const MagicSearchIndexStatsWidget()
-                      : ModelLoadingState(_state),
+                      : MagicSearchModelLoadingState(_state),
                   const SizedBox(
                     height: 12,
                   ),
@@ -174,12 +177,54 @@ class _MachineLearningSettingsPageState
       ],
     );
   }
+
+  Widget _getFacesSearchSettings(BuildContext context) {
+    final colorScheme = getEnteColorScheme(context);
+    final hasEnabled = LocalSettings.instance.isFaceIndexingEnabled;
+    return Column(
+      children: [
+        MenuItemWidget(
+          captionedTextWidget: CaptionedTextWidget(
+            title: S.of(context).faceRecognition,
+          ),
+          menuItemColor: colorScheme.fillFaint,
+          trailingWidget: ToggleSwitchWidget(
+            value: () => LocalSettings.instance.isFaceIndexingEnabled,
+            onChanged: () async {
+              final isEnabled =
+                  await LocalSettings.instance.toggleFaceIndexing();
+              if (isEnabled) {
+                unawaited(FaceMlService.instance.ensureInitialized());
+              } else {
+                FaceMlService.instance.pauseIndexing();
+              }
+              if (mounted) {
+                setState(() {});
+              }
+            },
+          ),
+          singleBorderRadius: 8,
+          alignCaptionedTextToLeft: true,
+          isGestureDetectorDisabled: true,
+        ),
+        const SizedBox(
+          height: 4,
+        ),
+        MenuSectionDescriptionWidget(
+          content: S.of(context).faceRecognitionIndexingDescription,
+        ),
+        const SizedBox(
+          height: 12,
+        ),
+      ],
+    );
+  }
 }
 
-class ModelLoadingState extends StatelessWidget {
+class MagicSearchModelLoadingState extends StatelessWidget {
   final InitializationState state;
 
-  const ModelLoadingState(
+  const MagicSearchModelLoadingState(
     this.state, {
     Key? key,
   }) : super(key: key);