Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Refresh ML consent screen and open Search

r4khul1d91e8b729b7
diff --git a/mobile/apps/photos/changes/ml-consent-screen.md b/mobile/apps/photos/changes/ml-consent-screen.md
new file mode 100644
index 0000000000..ffeb40536f
--- /dev/null
+++ b/mobile/apps/photos/changes/ml-consent-screen.md
@@ -0,0 +1 @@
+- Refreshed the machine learning consent screen. Enabling it now takes you to Search.
diff --git a/mobile/apps/photos/lib/events/tab_changed_event.dart b/mobile/apps/photos/lib/events/tab_changed_event.dart
index 4508c12785..c8764cbde1 100644
--- a/mobile/apps/photos/lib/events/tab_changed_event.dart
+++ b/mobile/apps/photos/lib/events/tab_changed_event.dart
@@ -13,6 +13,7 @@ enum TabChangedEventSource {
collectionsPage,
backButton,
appMode,
+ mlConsent,
}
class TabDoubleTapEvent extends Event {
diff --git a/mobile/apps/photos/lib/models/home_tab.dart b/mobile/apps/photos/lib/models/home_tab.dart
index ae5147b1b1..9fd5e77d19 100644
--- a/mobile/apps/photos/lib/models/home_tab.dart
+++ b/mobile/apps/photos/lib/models/home_tab.dart
@@ -1,7 +1,9 @@
+const int searchTabIndex = 3;
+
// Tab events keep stable IDs: Search remains 3 when Feed is hidden.
List<int> homeTabIndices({required bool showFeed}) => [
0,
1,
if (showFeed) 2,
- 3,
+ searchTabIndex,
];
diff --git a/mobile/apps/photos/lib/services/magic_cache_service.dart b/mobile/apps/photos/lib/services/magic_cache_service.dart
index e662c9b488..fa20011414 100644
--- a/mobile/apps/photos/lib/services/magic_cache_service.dart
+++ b/mobile/apps/photos/lib/services/magic_cache_service.dart
@@ -17,6 +17,7 @@ import "package:photos/events/tab_changed_event.dart";
import "package:photos/main.dart" show isIOSBackgroundRefresh;
import "package:photos/models/file/extensions/file_props.dart";
import "package:photos/models/file/file.dart";
+import "package:photos/models/home_tab.dart";
import "package:photos/models/ml/discover/prompt.dart";
import "package:photos/models/search/generic_search_result.dart";
import "package:photos/models/search/hierarchical/hierarchical_search_filter.dart";
@@ -231,7 +232,6 @@ GenericSearchResult? toGenericSearchResult(
class MagicCacheService {
static const _lastMagicCacheUpdateTime = "last_magic_cache_update_time";
static const _kPromptsAssetPath = "assets/discover.json";
- static const _kSearchTabIndex = 3;
static const _kBackgroundUpdateDebounce = Duration(minutes: 5);
// Avoid competing with other startup work.
@@ -256,7 +256,7 @@ class MagicCacheService {
});
Bus.instance.on<TabChangedEvent>().listen((event) {
if (event.source == TabChangedEventSource.pageView &&
- event.selectedIndex == _kSearchTabIndex) {
+ event.selectedIndex == searchTabIndex) {
_runPendingUpdateForSearch();
}
});
diff --git a/mobile/apps/photos/lib/ui/components/banners/ml_progress_banner.dart b/mobile/apps/photos/lib/ui/components/banners/ml_progress_banner.dart
index 969f822d36..4786361fc1 100644
--- a/mobile/apps/photos/lib/ui/components/banners/ml_progress_banner.dart
+++ b/mobile/apps/photos/lib/ui/components/banners/ml_progress_banner.dart
@@ -10,6 +10,7 @@ import "package:photos/core/event_bus.dart";
import "package:photos/events/local_photos_updated_event.dart";
import "package:photos/events/notification_event.dart";
import "package:photos/events/tab_changed_event.dart";
+import "package:photos/models/home_tab.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/machine_learning/ml_model_download_service.dart";
import "package:photos/theme/ente_theme.dart";
@@ -24,8 +25,6 @@ class MLProgressBanner extends StatefulWidget {
}
class _MLProgressBannerState extends State<MLProgressBanner> {
- static const int _searchTabIndex = 3;
-
IndexStatus? _indexStatus;
Timer? _timer;
bool _dismissed = false;
@@ -43,7 +42,7 @@ class _MLProgressBannerState extends State<MLProgressBanner> {
event,
) {
final wasOnSearchTab = _isOnSearchTab;
- _isOnSearchTab = event.selectedIndex == _searchTabIndex;
+ _isOnSearchTab = event.selectedIndex == searchTabIndex;
if (_isOnSearchTab && !wasOnSearchTab) {
_ensurePolling();
} else if (!_isOnSearchTab && wasOnSearchTab) {
diff --git a/mobile/apps/photos/lib/ui/home/home_bottom_nav_bar.dart b/mobile/apps/photos/lib/ui/home/home_bottom_nav_bar.dart
index 89433cad77..d012a71b37 100644
--- a/mobile/apps/photos/lib/ui/home/home_bottom_nav_bar.dart
+++ b/mobile/apps/photos/lib/ui/home/home_bottom_nav_bar.dart
@@ -37,7 +37,6 @@ class HomeBottomNavigationBar extends StatefulWidget {
}
class _HomeBottomNavigationBarState extends State<HomeBottomNavigationBar> {
- static const int _searchTabIndex = 3;
static const Duration _doubleTapWindow = Duration(milliseconds: 350);
late StreamSubscription<TabChangedEvent> _tabChangedEventSubscription;
int currentTabIndex = 0;
@@ -106,10 +105,10 @@ class _HomeBottomNavigationBarState extends State<HomeBottomNavigationBar> {
now.difference(_lastTapAt!) <= _doubleTapWindow;
_lastTapIndex = index;
_lastTapAt = now;
- if (index != _searchTabIndex || !isRepeatTap) {
+ if (index != searchTabIndex || !isRepeatTap) {
return;
}
- if (currentTabIndex != _searchTabIndex) {
+ if (currentTabIndex != searchTabIndex) {
Bus.instance.fire(TabDoubleTapEvent(index));
}
}
diff --git a/mobile/apps/photos/lib/ui/settings/ml/machine_learning_settings_page.dart b/mobile/apps/photos/lib/ui/settings/ml/machine_learning_settings_page.dart
index 77ef2d62a3..0fc755e923 100644
--- a/mobile/apps/photos/lib/ui/settings/ml/machine_learning_settings_page.dart
+++ b/mobile/apps/photos/lib/ui/settings/ml/machine_learning_settings_page.dart
@@ -10,6 +10,8 @@ import "package:photos/core/event_bus.dart";
import "package:photos/db/files_db.dart";
import "package:photos/db/ml/db.dart";
import "package:photos/events/notification_event.dart";
+import "package:photos/events/tab_changed_event.dart";
+import "package:photos/models/home_tab.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/machine_learning/ml_indexing_isolate.dart";
import "package:photos/services/machine_learning/ml_model_assets.dart";
@@ -24,6 +26,7 @@ import "package:photos/ui/settings/ml/ml_user_dev_screen.dart";
import "package:photos/utils/email_util.dart";
import "package:photos/utils/ml_util.dart";
import "package:photos/utils/network_util.dart";
+import "package:styled_text/styled_text.dart";
class MachineLearningSettingsPage extends StatefulWidget {
const MachineLearningSettingsPage({super.key});
@@ -143,41 +146,37 @@ class _MachineLearningSettingsPageState
}
Widget _buildDisabledMLScreen(BuildContext context) {
- return SettingsPageScaffold(
- title: context.strings.mlConsent,
- children: [
- const _MLConsentDescription(),
- const SizedBox(height: 20),
- Center(
- child: Image.asset(
- "assets/ducky_ml.png",
- height: 150,
- fit: BoxFit.contain,
+ return PopScope(
+ onPopInvokedWithResult: (_, _) => unawaited(_handleDisabledScreenExit()),
+ child: SettingsPageScaffold(
+ title: context.strings.machineLearning,
+ bottomNavigationBar: SafeArea(
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(16, 12, 16, 20),
+ child: ButtonComponent(
+ label: context.strings.mlConsent,
+ isDisabled: !_hasAcknowledgedMLConsent,
+ onTap: () async {
+ if (!_hasAcknowledgedMLConsent) return;
+ await toggleMlConsent(openSearchTab: true);
+ },
+ ),
),
),
- const SizedBox(height: 18),
- _buildDisabledConsentAckRow(context),
- const SizedBox(height: 20),
- ButtonComponent(
- label: context.strings.mlConsent,
- isDisabled: !_hasAcknowledgedMLConsent,
- onTap: () async {
- if (!_hasAcknowledgedMLConsent) return;
- await toggleMlConsent();
- },
- ),
- const SizedBox(height: 12),
- ButtonComponent(
- label: context.strings.cancel,
- variant: ButtonComponentVariant.secondary,
- onTap: () async {
- await _handleDisabledScreenExit();
- if (context.mounted) {
- Navigator.of(context).pop();
- }
- },
- ),
- ],
+ children: [
+ const _MLConsentDescription(),
+ const SizedBox(height: 20),
+ Center(
+ child: Image.asset(
+ "assets/ducky_ml.png",
+ height: 150,
+ fit: BoxFit.contain,
+ ),
+ ),
+ const SizedBox(height: 20),
+ _buildDisabledConsentAckRow(context),
+ ],
+ ),
);
}
@@ -214,7 +213,7 @@ class _MachineLearningSettingsPageState
Bus.instance.fire(NotificationEvent());
}
- Future<void> toggleMlConsent() async {
+ Future<void> toggleMlConsent({bool openSearchTab = false}) async {
final oldMlConsent = hasGrantedMLConsent;
final oldMlEnabled = oldMlConsent && localSettings.isMLLocalIndexingEnabled;
final mlConsent = !oldMlConsent;
@@ -236,6 +235,15 @@ class _MachineLearningSettingsPageState
await MLService.instance.init();
await SemanticSearchService.instance.init();
unawaited(MLService.instance.runAllML(force: true));
+ if (openSearchTab && mounted) {
+ Navigator.of(
+ context,
+ ).popUntil((route) => route.isFirst && !route.willHandlePopInternally);
+ Bus.instance.fire(
+ TabChangedEvent(searchTabIndex, TabChangedEventSource.mlConsent),
+ );
+ return;
+ }
}
if (mounted) {
setState(() {});
@@ -267,7 +275,7 @@ class _MachineLearningSettingsPageState
Expanded(
child: Text(
context.strings.mlConsentConfirmation,
- style: TextStyles.mini.copyWith(color: colors.textLight),
+ style: TextStyles.body.copyWith(color: colors.textLight),
),
),
],
@@ -346,28 +354,29 @@ class _MLConsentDescription extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final colors = context.componentColors;
+ final textStyle = TextStyles.body.copyWith(
+ color: context.componentColors.textLight,
+ );
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Text(
- context.strings.mlConsentDescription,
- textAlign: TextAlign.left,
- style: TextStyles.mini.copyWith(color: colors.textLight),
- ),
- const SizedBox(height: 6),
- GestureDetector(
- onTap: () async => _openMLPrivacyPolicy(context),
- child: Text(
- context.strings.mlConsentPrivacy,
- textAlign: TextAlign.left,
- style: TextStyles.mini.copyWith(
- color: colors.textLight,
- decoration: TextDecoration.underline,
- decorationColor: colors.textLight,
+ for (final paragraph in context.strings.mlConsentDescription.split(
+ "\n\n",
+ )) ...[Text(paragraph, style: textStyle), const SizedBox(height: 8)],
+ StyledText(
+ text: context.strings.mlConsentPrivacyDetails,
+ style: textStyle,
+ tags: {
+ 'policy': StyledTextActionTag(
+ (String? text, Map<String?, String?> attrs) =>
+ _openMLPrivacyPolicy(context),
+ style: textStyle.copyWith(
+ decoration: TextDecoration.underline,
+ decorationColor: textStyle.color,
+ ),
),
- ),
+ },
),
],
);
diff --git a/mobile/apps/photos/lib/ui/tabs/home_widget.dart b/mobile/apps/photos/lib/ui/tabs/home_widget.dart
index a3c551bffb..439e7025ac 100644
--- a/mobile/apps/photos/lib/ui/tabs/home_widget.dart
+++ b/mobile/apps/photos/lib/ui/tabs/home_widget.dart
@@ -199,7 +199,7 @@ class _HomeWidgetState extends State<HomeWidget> {
_selectedTabIndex = event.selectedIndex;
_selectedTabIndexNotifier.value = event.selectedIndex;
- if (event.selectedIndex == 3) {
+ if (event.selectedIndex == searchTabIndex) {
isOnSearchTabNotifier.value = true;
unawaited(SemanticSearchService.instance.prepareForInteractiveSearch());
} else {
@@ -891,7 +891,7 @@ class _HomeWidgetState extends State<HomeWidget> {
_isAlbumsSearchActiveNotifier.value = false;
}
}
- if (_selectedTabIndex == 3) {
+ if (_selectedTabIndex == searchTabIndex) {
if (_shouldSearchTabSearchConsumeBackNotifier.value) {
Bus.instance.fire(ClearAndUnfocusSearchBar());
return;
diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
index ba78865e75..67ab92bafc 100644
--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
@@ -2669,7 +2669,10 @@
"mlConsent": "Enable machine learning",
"mlConsentConfirmation": "I understand, and wish to enable machine learning",
"mlConsentDescription": "If you enable machine learning, Ente will extract information like face geometry from files, including those shared with you.\n\nThis will happen on your device, and any generated biometric information will be end-to-end encrypted.",
- "mlConsentPrivacy": "Please click here for more details about this feature in our privacy policy",
+ "mlConsentPrivacyDetails": "Please <policy>click here</policy> for more details about this feature in our privacy policy",
+ "@mlConsentPrivacyDetails": {
+ "description": "Machine learning consent screen sentence; only the text inside the policy tags is tappable and opens the privacy policy"
+ },
"mlCouldNotProcessItems": "{count, plural, one{Could not process {count} item} other{Could not process {count} items}}",
"@mlCouldNotProcessItems": {
"description": "Title shown when machine learning could not process one or more items",