Skip to content

armgit / ente

Public Imported from GitHub
0

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

Use mode-aware ML consent in widgets and UI

Neeraj Guptab0ba30e1cba4
diff --git a/mobile/apps/photos/lib/services/memory_home_widget_service.dart b/mobile/apps/photos/lib/services/memory_home_widget_service.dart
index f71f380d02..43c876fbd6 100644
--- a/mobile/apps/photos/lib/services/memory_home_widget_service.dart
+++ b/mobile/apps/photos/lib/services/memory_home_widget_service.dart
@@ -196,7 +196,7 @@ class MemoryHomeWidgetService {
}
Future<List<SmartMemory>> _getMemoriesForWidget() async {
- final isMLEnabled = flagService.hasGrantedMLConsent;
+ final isMLEnabled = hasGrantedMLConsent;
bool? smartMemoryValue = getMLMemoriesSelected();
bool? lastYearValue = hasLastYearMemoriesSelected();
bool? onThisDayValue = getOnThisDayMemoriesSelected();
diff --git a/mobile/apps/photos/lib/services/people_home_widget_service.dart b/mobile/apps/photos/lib/services/people_home_widget_service.dart
index f054a06120..ae3cf3a600 100644
--- a/mobile/apps/photos/lib/services/people_home_widget_service.dart
+++ b/mobile/apps/photos/lib/services/people_home_widget_service.dart
@@ -231,7 +231,7 @@ class PeopleHomeWidgetService {
}
// Check ML consent
- if (!flagService.hasGrantedMLConsent) {
+ if (isOfflineMode || !hasGrantedMLConsent) {
return true;
}
diff --git a/mobile/apps/photos/lib/services/smart_albums_service.dart b/mobile/apps/photos/lib/services/smart_albums_service.dart
index 199925d390..483b5646e5 100644
--- a/mobile/apps/photos/lib/services/smart_albums_service.dart
+++ b/mobile/apps/photos/lib/services/smart_albums_service.dart
@@ -80,7 +80,7 @@ class SmartAlbumsService {
}
Future<void> syncSmartAlbums() async {
- final isMLEnabled = flagService.hasGrantedMLConsent;
+ final isMLEnabled = hasGrantedMLConsent;
if (!isMLEnabled) {
_logger.warning("ML is not enabled, skipping smart album sync");
return;
diff --git a/mobile/apps/photos/lib/ui/settings/debug/ml_debug_section_widget.dart b/mobile/apps/photos/lib/ui/settings/debug/ml_debug_section_widget.dart
index 87e38288b6..26db287665 100644
--- a/mobile/apps/photos/lib/ui/settings/debug/ml_debug_section_widget.dart
+++ b/mobile/apps/photos/lib/ui/settings/debug/ml_debug_section_widget.dart
@@ -625,12 +625,12 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
},
),
trailingWidget: ToggleSwitchWidget(
- value: () => flagService.hasGrantedMLConsent,
+ value: () => hasGrantedMLConsent,
onChanged: () async {
try {
- final oldMlConsent = flagService.hasGrantedMLConsent;
+ final oldMlConsent = hasGrantedMLConsent;
final mlConsent = !oldMlConsent;
- await flagService.setMLConsent(mlConsent);
+ await setMLConsent(mlConsent);
logger.info('ML consent turned ${mlConsent ? 'on' : 'off'}');
if (!mlConsent) {
MLService.instance.pauseIndexingAndClustering();
diff --git a/mobile/apps/photos/lib/ui/settings/debug/ml_debug_settings_page.dart b/mobile/apps/photos/lib/ui/settings/debug/ml_debug_settings_page.dart
index fbed59e1b4..19e8a25cb5 100644
--- a/mobile/apps/photos/lib/ui/settings/debug/ml_debug_settings_page.dart
+++ b/mobile/apps/photos/lib/ui/settings/debug/ml_debug_settings_page.dart
@@ -140,7 +140,7 @@ class _MLDebugSettingsPageState extends State<MLDebugSettingsPage> {
HugeIcons.strokeRoundedAiBrain01,
),
trailingWidget: ToggleSwitchWidget(
- value: () => flagService.hasGrantedMLConsent,
+ value: () => hasGrantedMLConsent,
onChanged: _onMLConsentChanged,
),
),
@@ -500,9 +500,9 @@ class _MLDebugSettingsPageState extends State<MLDebugSettingsPage> {
Future<void> _onMLConsentChanged() async {
try {
- final oldMlConsent = flagService.hasGrantedMLConsent;
+ final oldMlConsent = hasGrantedMLConsent;
final mlConsent = !oldMlConsent;
- await flagService.setMLConsent(mlConsent);
+ await setMLConsent(mlConsent);
logger.info('ML consent turned ${mlConsent ? 'on' : 'off'}');
if (!mlConsent) {
MLService.instance.pauseIndexingAndClustering();
diff --git a/mobile/apps/photos/lib/ui/settings/widget_settings_screen.dart b/mobile/apps/photos/lib/ui/settings/widget_settings_screen.dart
index 9d77fb0e58..0a6da3c624 100644
--- a/mobile/apps/photos/lib/ui/settings/widget_settings_screen.dart
+++ b/mobile/apps/photos/lib/ui/settings/widget_settings_screen.dart
@@ -14,7 +14,7 @@ class WidgetSettingsScreen extends StatelessWidget {
const WidgetSettingsScreen({super.key});
void onPeopleTapped(BuildContext context) {
- final bool isMLEnabled = !flagService.hasGrantedMLConsent;
+ final bool isMLEnabled = !hasGrantedMLConsent;
if (isMLEnabled) {
routeToPage(
context,
diff --git a/mobile/apps/photos/lib/ui/settings/widgets/memories_widget_settings.dart b/mobile/apps/photos/lib/ui/settings/widgets/memories_widget_settings.dart
index cb8c5dbf7a..f260cbdade 100644
--- a/mobile/apps/photos/lib/ui/settings/widgets/memories_widget_settings.dart
+++ b/mobile/apps/photos/lib/ui/settings/widgets/memories_widget_settings.dart
@@ -48,7 +48,7 @@ class _MemoriesWidgetSettingsState extends State<MemoriesWidgetSettings> {
Future<void> initVariables() async {
_changeMemoriesSettings = Debouncer(const Duration(milliseconds: 2500));
- isMLEnabled = flagService.hasGrantedMLConsent;
+ isMLEnabled = hasGrantedMLConsent;
isYearlyMemoriesEnabled =
MemoryHomeWidgetService.instance.hasLastYearMemoriesSelected();
isSmartMemoriesEnabled =
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
index 403e83c41e..b5e8f2aa23 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
@@ -572,7 +572,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
context.l10n.playOnTv,
icon: Icons.tv_outlined,
),
- if (flagService.hasGrantedMLConsent &&
+ if (hasGrantedMLConsent &&
(widget.collection?.canAutoAdd(userId) ?? false))
EntePopupMenuItemAsync(
(value) => (value?[widget.collection!.id]?.personIDs.isEmpty ?? true)