Skip to content

armgit / ente

Public Imported from GitHub
0

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

Update UX for ml settings

Neeraj Gupta6ba4892294cf
diff --git a/mobile/lib/generated/intl/messages_en.dart b/mobile/lib/generated/intl/messages_en.dart
index 50b03455a2..96e46d6c32 100644
--- a/mobile/lib/generated/intl/messages_en.dart
+++ b/mobile/lib/generated/intl/messages_en.dart
@@ -656,11 +656,13 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Email your logs"),
"empty": MessageLookupByLibrary.simpleMessage("Empty"),
"emptyTrash": MessageLookupByLibrary.simpleMessage("Empty trash?"),
+ "enable": MessageLookupByLibrary.simpleMessage("Enable"),
"enableMLIndexingDesc": MessageLookupByLibrary.simpleMessage(
"Ente supports on-device machine learning for face recognition, magic search and other advanced search features"),
"enableMaps": MessageLookupByLibrary.simpleMessage("Enable Maps"),
"enableMapsDesc": MessageLookupByLibrary.simpleMessage(
"This will show your photos on a world map.\n\nThis map is hosted by Open Street Map, and the exact locations of your photos are never shared.\n\nYou can disable this feature anytime from Settings."),
+ "enabled": MessageLookupByLibrary.simpleMessage("Enabled"),
"encryptingBackup":
MessageLookupByLibrary.simpleMessage("Encrypting backup..."),
"encryption": MessageLookupByLibrary.simpleMessage("Encryption"),
@@ -975,7 +977,6 @@ class MessageLookup extends MessageLookupByLibrary {
"Please click here for more details about this feature in our privacy policy"),
"mlConsentTitle":
MessageLookupByLibrary.simpleMessage("Enable machine learning?"),
- "mlIndexing": MessageLookupByLibrary.simpleMessage("Enable Indexing"),
"mlIndexingDescription": MessageLookupByLibrary.simpleMessage(
"Please note that machine learning will result in a higher bandwidth and battery usage until all items are indexed."),
"mobileWebDesktop":
diff --git a/mobile/lib/generated/l10n.dart b/mobile/lib/generated/l10n.dart
index 47d3775d0c..f0b468cfe4 100644
--- a/mobile/lib/generated/l10n.dart
+++ b/mobile/lib/generated/l10n.dart
@@ -9025,11 +9025,21 @@ class S {
);
}
- /// `Enable Indexing`
- String get mlIndexing {
+ /// `Enable`
+ String get enable {
return Intl.message(
- 'Enable Indexing',
- name: 'mlIndexing',
+ 'Enable',
+ name: 'enable',
+ desc: '',
+ args: [],
+ );
+ }
+
+ /// `Enabled`
+ String get enabled {
+ return Intl.message(
+ 'Enabled',
+ name: 'enabled',
desc: '',
args: [],
);
diff --git a/mobile/lib/l10n/intl_en.arb b/mobile/lib/l10n/intl_en.arb
index 73797ed27e..ac4a24a330 100644
--- a/mobile/lib/l10n/intl_en.arb
+++ b/mobile/lib/l10n/intl_en.arb
@@ -1269,7 +1269,8 @@
}
}
},
- "mlIndexing": "Enable Indexing",
+ "enable": "Enable",
+ "enabled": "Enabled",
"moreDetails" : "More details",
"enableMLIndexingDesc": "Ente supports on-device machine learning for face recognition, magic search and other advanced search features",
"magicSearchHint": "Magic search allows to search photos by their contents, e.g. 'flower', 'red car', 'identity documents'",
diff --git a/mobile/lib/ui/settings/machine_learning_settings_page.dart b/mobile/lib/ui/settings/machine_learning_settings_page.dart
index 140fc4dfa5..9f2acf5961 100644
--- a/mobile/lib/ui/settings/machine_learning_settings_page.dart
+++ b/mobile/lib/ui/settings/machine_learning_settings_page.dart
@@ -128,6 +128,14 @@ class _MachineLearningSettingsPageState
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
children: [
+ ButtonWidget(
+ buttonType: ButtonType.primary,
+ labelText: context.l10n.enable,
+ onTap: () async {
+ await toggleIndexingState();
+ },
+ ),
+ const SizedBox(height: 12),
ButtonWidget(
buttonType: ButtonType.secondary,
labelText: context.l10n.moreDetails,
@@ -164,52 +172,57 @@ class _MachineLearningSettingsPageState
);
}
+ Future<void> toggleIndexingState() async {
+ final hasGivenConsent = UserRemoteFlagService.instance
+ .getCachedBoolValue(UserRemoteFlagService.mlEnabled);
+ if (!localSettings.isFaceIndexingEnabled && !hasGivenConsent) {
+ final result = await Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) {
+ return const EnableMachineLearningConsent();
+ },
+ ),
+ );
+ if (result == null || result == false) {
+ return;
+ }
+ }
+ final isEnabled = await localSettings.toggleFaceIndexing();
+ if (isEnabled) {
+ await MLService.instance.init(firstTime: true);
+ await SemanticSearchService.instance.init();
+ unawaited(MLService.instance.runAllML(force: true));
+ } else {
+ await UserRemoteFlagService.instance
+ .setBoolValue(UserRemoteFlagService.mlEnabled, false);
+ }
+ if (mounted) {
+ setState(() {});
+ }
+ }
+
Widget _getMlSettings(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
final hasEnabled = localSettings.isFaceIndexingEnabled;
return Column(
children: [
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: S.of(context).mlIndexing,
- ),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: ToggleSwitchWidget(
- value: () => localSettings.isFaceIndexingEnabled,
- onChanged: () async {
- final hasGivenConsent = UserRemoteFlagService.instance
- .getCachedBoolValue(UserRemoteFlagService.mlEnabled);
- if (!localSettings.isFaceIndexingEnabled && !hasGivenConsent) {
- final result = await Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) {
- return const EnableMachineLearningConsent();
- },
- ),
- );
- if (result == null || result == false) {
- return;
- }
- }
- final isEnabled = await localSettings.toggleFaceIndexing();
- if (isEnabled) {
- await MLService.instance.init(firstTime: true);
- await SemanticSearchService.instance.init();
- unawaited(MLService.instance.runAllML(force: true));
- } else {
- await UserRemoteFlagService.instance
- .setBoolValue(UserRemoteFlagService.mlEnabled, false);
- }
- if (mounted) {
- setState(() {});
- }
- },
+ if (hasEnabled)
+ MenuItemWidget(
+ captionedTextWidget: CaptionedTextWidget(
+ title: S.of(context).enabled,
+ ),
+ menuItemColor: colorScheme.fillFaint,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => localSettings.isFaceIndexingEnabled,
+ onChanged: () async {
+ await toggleIndexingState();
+ },
+ ),
+ singleBorderRadius: 8,
+ alignCaptionedTextToLeft: true,
+ isGestureDetectorDisabled: true,
),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- isGestureDetectorDisabled: true,
- ),
const SizedBox(
height: 12,
),