Skip to content

armgit / ente

Public Imported from GitHub
0

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

Second entry point in app bar

laurenspriem5e4005d2ec6f
diff --git a/mobile/apps/photos/lib/ui/viewer/people/faces_timeline_page.dart b/mobile/apps/photos/lib/ui/viewer/people/faces_timeline_page.dart
index 0f830d8839..a62796f0f6 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/faces_timeline_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/faces_timeline_page.dart
@@ -14,6 +14,7 @@ import "package:photos/l10n/l10n.dart";
import "package:photos/models/faces_timeline/faces_timeline_models.dart";
import "package:photos/models/ml/face/face.dart";
import "package:photos/models/ml/face/person.dart";
+import "package:photos/service_locator.dart";
import "package:photos/services/faces_timeline/faces_timeline_service.dart";
import "package:photos/theme/colors.dart";
import "package:photos/theme/effects.dart";
@@ -70,6 +71,7 @@ class _FacesTimelinePageState extends State<FacesTimelinePage>
bool _hasStartedPlayback = false;
bool _allFramesLoaded = false;
bool _timelineUnavailable = false;
+ bool _hasMarkedTimelineSeen = false;
int _expectedFrameCount = 0;
int _currentIndex = 0;
@@ -106,6 +108,8 @@ class _FacesTimelinePageState extends State<FacesTimelinePage>
}
Future<void> _loadFrames() async {
+ _hasMarkedTimelineSeen =
+ localSettings.hasSeenFacesTimeline(widget.person.remoteID);
_playTimer?.cancel();
if (mounted) {
setState(() {
@@ -180,6 +184,7 @@ class _FacesTimelinePageState extends State<FacesTimelinePage>
setState(() {
_allFramesLoaded = true;
});
+ _maybeMarkTimelineSeen();
} catch (error, stackTrace) {
_logger.severe(
"Faces timeline failed to load",
@@ -206,6 +211,19 @@ class _FacesTimelinePageState extends State<FacesTimelinePage>
return math.max(1, math.min(_initialFrameTarget, _expectedFrameCount));
}
+ void _maybeMarkTimelineSeen() {
+ if (_hasMarkedTimelineSeen || !_allFramesLoaded || _frames.isEmpty) {
+ return;
+ }
+ if (_currentIndex != _frames.length - 1) {
+ return;
+ }
+ _hasMarkedTimelineSeen = true;
+ unawaited(
+ localSettings.markFacesTimelineSeen(widget.person.remoteID),
+ );
+ }
+
void _handleFrameLoaded(_TimelineFrame frame, int loadedCount) {
final bool isFirstFrame = _frames.isEmpty;
final int digitCount = _captionDigitCount(frame.captionValue);
@@ -799,6 +817,7 @@ class _FacesTimelinePageState extends State<FacesTimelinePage>
_currentCaptionType = frame.captionType;
_isScrubbing = true;
});
+ _maybeMarkTimelineSeen();
}
: null,
onChangeEnd: frameCount > 1
@@ -811,6 +830,7 @@ class _FacesTimelinePageState extends State<FacesTimelinePage>
_stackProgress = _sliderValue;
_isScrubbing = false;
});
+ _maybeMarkTimelineSeen();
}
: null,
),
@@ -882,6 +902,7 @@ class _FacesTimelinePageState extends State<FacesTimelinePage>
_currentCaptionType = frame.captionType;
_sliderValue = clampedIndex.toDouble();
});
+ _maybeMarkTimelineSeen();
}
}
diff --git a/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart b/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart
index f0bf281e3d..5117087eed 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart
@@ -34,6 +34,8 @@ class PeopleAppBar extends StatefulWidget {
final String? title;
final SelectedFiles selectedFiles;
final PersonEntity person;
+ final bool facesTimelineReady;
+ final Future<void> Function()? onFacesTimelineTap;
bool get isIgnored => person.data.isIgnored;
@@ -42,6 +44,8 @@ class PeopleAppBar extends StatefulWidget {
this.title,
this.selectedFiles,
this.person, {
+ this.facesTimelineReady = false,
+ this.onFacesTimelineTap,
super.key,
});
@@ -56,6 +60,7 @@ enum PeoplePopupAction {
reviewSuggestions,
unignore,
reassignMe,
+ memoryLane,
}
class _AppBarWidgetState extends State<PeopleAppBar> {
@@ -214,6 +219,27 @@ class _AppBarWidgetState extends State<PeopleAppBar> {
}
final List<PopupMenuItem<PeoplePopupAction>> items = [];
+ final bool showTimelineAction =
+ widget.facesTimelineReady && widget.onFacesTimelineTap != null;
+ if (showTimelineAction) {
+ items.add(
+ PopupMenuItem(
+ value: PeoplePopupAction.memoryLane,
+ child: Row(
+ children: [
+ const Icon(Icons.auto_awesome_outlined),
+ const Padding(
+ padding: EdgeInsets.all(8),
+ ),
+ Text(
+ context.l10n.facesTimelineAppBarTitle,
+ style: textTheme.bodyBold,
+ ),
+ ],
+ ),
+ ),
+ );
+ }
if (!widget.isIgnored) {
items.addAll(
@@ -332,6 +358,11 @@ class _AppBarWidgetState extends State<PeopleAppBar> {
),
),
);
+ } else if (value == PeoplePopupAction.memoryLane) {
+ final callback = widget.onFacesTimelineTap;
+ if (callback != null) {
+ unawaited(callback());
+ }
} else if (value == PeoplePopupAction.rename) {
await _editPerson(context);
} else if (value == PeoplePopupAction.setCover) {
diff --git a/mobile/apps/photos/lib/ui/viewer/people/people_page.dart b/mobile/apps/photos/lib/ui/viewer/people/people_page.dart
index 5a970ce113..43f1963c58 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/people_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/people_page.dart
@@ -33,6 +33,7 @@ import "package:photos/ui/viewer/people/link_email_screen.dart";
import "package:photos/ui/viewer/people/people_app_bar.dart";
import "package:photos/ui/viewer/people/person_gallery_suggestion.dart";
import "package:photos/utils/navigation_util.dart";
+import "package:photos/service_locator.dart";
class PeoplePage extends StatefulWidget {
final String tagPrefix;
@@ -150,16 +151,24 @@ class _PeoplePageState extends State<PeoplePage> {
super.dispose();
}
- void _openFacesTimelinePage() {
+ Future<void> _openFacesTimelinePage() async {
_timelineLogger.info("banner_tap person=${_person.remoteID}");
- unawaited(routeToPage(context, FacesTimelinePage(person: _person)));
+ await routeToPage(context, FacesTimelinePage(person: _person));
+ if (!mounted) {
+ return;
+ }
+ setState(() {});
}
@override
Widget build(BuildContext context) {
_logger.info("Building for ${_person.data.name}");
- final bool showFacesTimelineBanner =
+ final bool facesTimelineReady =
FacesTimelineService.instance.hasReadyTimelineSync(_person.remoteID);
+ final bool hasSeenFacesTimeline =
+ localSettings.hasSeenFacesTimeline(_person.remoteID);
+ final bool showFacesTimelineBanner =
+ facesTimelineReady && !hasSeenFacesTimeline;
return GalleryBoundariesProvider(
child: GalleryFilesState(
@@ -177,6 +186,9 @@ class _PeoplePageState extends State<PeoplePage> {
: _person.data.name,
_selectedFiles,
_person,
+ facesTimelineReady: facesTimelineReady,
+ onFacesTimelineTap:
+ facesTimelineReady ? _openFacesTimelinePage : null,
),
),
body: FutureBuilder<List<EnteFile>>(
@@ -211,7 +223,10 @@ class _PeoplePageState extends State<PeoplePage> {
personEntity: _person,
showTimelineBanner:
showFacesTimelineBanner,
- onTimelineTap: _openFacesTimelinePage,
+ onTimelineTap: () =>
+ unawaited(
+ _openFacesTimelinePage(),
+ ),
);
},
)
@@ -222,7 +237,9 @@ class _PeoplePageState extends State<PeoplePage> {
loadPersonFiles: loadPersonFiles,
personEntity: _person,
showTimelineBanner: showFacesTimelineBanner,
- onTimelineTap: _openFacesTimelinePage,
+ onTimelineTap: () => unawaited(
+ _openFacesTimelinePage(),
+ ),
),
FileSelectionOverlayBar(
PeoplePage.overlayType,
diff --git a/mobile/apps/photos/lib/utils/local_settings.dart b/mobile/apps/photos/lib/utils/local_settings.dart
index 208621a008..a63fabe6a9 100644
--- a/mobile/apps/photos/lib/utils/local_settings.dart
+++ b/mobile/apps/photos/lib/utils/local_settings.dart
@@ -45,6 +45,7 @@ class LocalSettings {
static const kCollectionSortDirection = "collection_sort_direction";
static const kShowLocalIDOverThumbnails = "show_local_id_over_thumbnails";
static const kEnableDatabaseLogging = "enable_db_logging";
+ static const _facesTimelineSeenKey = "faces_timeline_seen_person_ids";
final SharedPreferences _prefs;
@@ -180,6 +181,24 @@ class LocalSettings {
await _prefs.setBool(_kHasSeenMLEnablingBanner, true);
}
+ bool hasSeenFacesTimeline(String personId) {
+ final seenIds = _prefs.getStringList(_facesTimelineSeenKey);
+ if (seenIds == null || seenIds.isEmpty) {
+ return false;
+ }
+ return seenIds.contains(personId);
+ }
+
+ Future<void> markFacesTimelineSeen(String personId) async {
+ final List<String> seenIds =
+ List<String>.from(_prefs.getStringList(_facesTimelineSeenKey) ?? []);
+ if (seenIds.contains(personId)) {
+ return;
+ }
+ seenIds.add(personId);
+ await _prefs.setStringList(_facesTimelineSeenKey, seenIds);
+ }
+
//#region todo:(NG) remove this section, only needed for internal testing to see
// if the OS stops the app during indexing
bool get remoteFetchEnabled => _prefs.getBool("remoteFetchEnabled") ?? true;