Skip to content

armgit / ente

Public Imported from GitHub
0

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

Add setting to enable Magic Search

vishnukvmd30139f1b9718
diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart
index 5362df384d..9348ae18c9 100644
--- a/lib/generated/intl/messages_en.dart
+++ b/lib/generated/intl/messages_en.dart
@@ -807,6 +807,11 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage(
"Long-press on an item to view in full-screen"),
"lostDevice": MessageLookupByLibrary.simpleMessage("Lost device?"),
+ "machineLearning":
+ MessageLookupByLibrary.simpleMessage("Machine learning"),
+ "magicSearch": MessageLookupByLibrary.simpleMessage("Magic search"),
+ "magicSearchDescription": MessageLookupByLibrary.simpleMessage(
+ "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."),
"manage": MessageLookupByLibrary.simpleMessage("Manage"),
"manageDeviceStorage":
MessageLookupByLibrary.simpleMessage("Manage device storage"),
diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart
index 3ce3051b71..c732cc098e 100644
--- a/lib/generated/l10n.dart
+++ b/lib/generated/l10n.dart
@@ -2857,6 +2857,36 @@ class S {
);
}
+ /// `Machine learning`
+ String get machineLearning {
+ return Intl.message(
+ 'Machine learning',
+ name: 'machineLearning',
+ desc: '',
+ args: [],
+ );
+ }
+
+ /// `Magic search`
+ String get magicSearch {
+ return Intl.message(
+ 'Magic search',
+ name: 'magicSearch',
+ desc: '',
+ args: [],
+ );
+ }
+
+ /// `Please note that this will result in a higher bandwidth and battery usage until all items are indexed.`
+ String get magicSearchDescription {
+ return Intl.message(
+ 'Please note that this will result in a higher bandwidth and battery usage until all items are indexed.',
+ name: 'magicSearchDescription',
+ desc: '',
+ args: [],
+ );
+ }
+
/// `Select folders for backup`
String get selectFoldersForBackup {
return Intl.message(
diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb
index 7fa90f291e..bfabb401cc 100644
--- a/lib/l10n/intl_en.arb
+++ b/lib/l10n/intl_en.arb
@@ -406,6 +406,9 @@
},
"photoGridSize": "Photo grid size",
"manageDeviceStorage": "Manage device storage",
+ "machineLearning": "Machine learning",
+ "magicSearch": "Magic search",
+ "magicSearchDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed.",
"selectFoldersForBackup": "Select folders for backup",
"selectedFoldersWillBeEncryptedAndBackedUp": "Selected folders will be encrypted and backed up",
"unselectAll": "Unselect all",
diff --git a/lib/ui/settings/advanced_settings_screen.dart b/lib/ui/settings/advanced_settings_screen.dart
index e22611f390..e2f2e77c2a 100644
--- a/lib/ui/settings/advanced_settings_screen.dart
+++ b/lib/ui/settings/advanced_settings_screen.dart
@@ -10,6 +10,7 @@ import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';
import 'package:photos/ui/components/title_bar_title_widget.dart';
import 'package:photos/ui/components/title_bar_widget.dart';
import "package:photos/ui/components/toggle_switch_widget.dart";
+import "package:photos/ui/settings/machine_learning_settings_page.dart";
import 'package:photos/ui/tools/debug/app_storage_viewer.dart';
import 'package:photos/ui/viewer/gallery/photo_grid_size_picker_page.dart';
import 'package:photos/utils/local_settings.dart';
@@ -65,6 +66,27 @@ class _AdvancedSettingsScreenState extends State<AdvancedSettingsScreen> {
children: [
Column(
children: [
+ MenuItemWidget(
+ captionedTextWidget: CaptionedTextWidget(
+ title: S.of(context).machineLearning,
+ ),
+ menuItemColor: colorScheme.fillFaint,
+ trailingWidget: Icon(
+ Icons.chevron_right_outlined,
+ color: colorScheme.strokeBase,
+ ),
+ singleBorderRadius: 8,
+ alignCaptionedTextToLeft: true,
+ onTap: () async {
+ routeToPage(
+ context,
+ const MachineLearningSettingsPage(),
+ );
+ },
+ ),
+ const SizedBox(
+ height: 24,
+ ),
GestureDetector(
onTap: () {
routeToPage(
diff --git a/lib/ui/settings/machine_learning_settings_page.dart b/lib/ui/settings/machine_learning_settings_page.dart
new file mode 100644
index 0000000000..ac1f31096a
--- /dev/null
+++ b/lib/ui/settings/machine_learning_settings_page.dart
@@ -0,0 +1,92 @@
+import "package:flutter/material.dart";
+import "package:photos/generated/l10n.dart";
+import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/components/buttons/icon_button_widget.dart";
+import "package:photos/ui/components/captioned_text_widget.dart";
+import "package:photos/ui/components/menu_item_widget/menu_item_widget.dart";
+import "package:photos/ui/components/menu_section_description_widget.dart";
+import "package:photos/ui/components/title_bar_title_widget.dart";
+import "package:photos/ui/components/title_bar_widget.dart";
+import "package:photos/ui/components/toggle_switch_widget.dart";
+import "package:photos/utils/local_settings.dart";
+
+class MachineLearningSettingsPage extends StatelessWidget {
+ const MachineLearningSettingsPage({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ return Scaffold(
+ body: CustomScrollView(
+ primary: false,
+ slivers: <Widget>[
+ TitleBarWidget(
+ flexibleSpaceTitle: TitleBarTitleWidget(
+ title: S.of(context).machineLearning,
+ ),
+ actionIcons: [
+ IconButtonWidget(
+ icon: Icons.close_outlined,
+ iconButtonType: IconButtonType.secondary,
+ onTap: () {
+ Navigator.pop(context);
+ Navigator.pop(context);
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ SliverList(
+ delegate: SliverChildBuilderDelegate(
+ (delegateBuildContext, index) {
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(vertical: 20),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Column(
+ children: [
+ Column(
+ children: [
+ MenuItemWidget(
+ captionedTextWidget: CaptionedTextWidget(
+ title: S.of(context).magicSearch,
+ ),
+ menuItemColor: colorScheme.fillFaint,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => LocalSettings.instance
+ .hasEnabledMagicSearch(),
+ onChanged: () {
+ return LocalSettings.instance
+ .setShouldEnableMagicSearch(
+ !LocalSettings.instance
+ .hasEnabledMagicSearch(),
+ );
+ },
+ ),
+ singleBorderRadius: 8,
+ alignCaptionedTextToLeft: true,
+ isGestureDetectorDisabled: true,
+ ),
+ MenuSectionDescriptionWidget(
+ content: S.of(context).magicSearchDescription,
+ ),
+ ],
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ );
+ },
+ childCount: 1,
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/lib/utils/local_settings.dart b/lib/utils/local_settings.dart
index 501601d979..864598c565 100644
--- a/lib/utils/local_settings.dart
+++ b/lib/utils/local_settings.dart
@@ -13,6 +13,7 @@ class LocalSettings {
static final LocalSettings instance = LocalSettings._privateConstructor();
static const kCollectionSortPref = "collection_sort_pref";
static const kPhotoGridSize = "photo_grid_size";
+ static const kEnableMagicSearch = "enable_magic_search";
late SharedPreferences _prefs;
@@ -39,4 +40,15 @@ class LocalSettings {
Future<void> setPhotoGridSize(int value) async {
await _prefs.setInt(kPhotoGridSize, value);
}
+
+ bool hasEnabledMagicSearch() {
+ if (_prefs.containsKey(kEnableMagicSearch)) {
+ return _prefs.getBool(kEnableMagicSearch)!;
+ }
+ return false;
+ }
+
+ Future<void> setShouldEnableMagicSearch(bool value) async {
+ await _prefs.setBool(kEnableMagicSearch, value);
+ }
}