Skip to content

armgit / ente

Public Imported from GitHub
0

💚 End-to-end encrypted cloud for everything.

[mobile][photos] Enable memory lanes and simplify captions

aspizu55f3526586f2
diff --git a/mobile/apps/photos/lib/services/memory_lane/memory_lane_service.dart b/mobile/apps/photos/lib/services/memory_lane/memory_lane_service.dart
index 514fe0f466..f561d523fa 100644
--- a/mobile/apps/photos/lib/services/memory_lane/memory_lane_service.dart
+++ b/mobile/apps/photos/lib/services/memory_lane/memory_lane_service.dart
@@ -110,34 +110,30 @@ class MemoryLaneService {
}
persons.addAll(await PersonService.instance.getPersons());
}
- if (flagService.internalUser) {
- final assigned = <String>{};
- for (final person in persons) {
- for (final cluster in person.data.assigned) {
- assigned.add(cluster.id);
- }
- }
- try {
- _topNClusters = await _mlDataDB.getClustersForMemoryLane(assigned);
- } catch (e, s) {
- _logger.severe("getClustersForMemoryLane failed:", e, s);
- final cache = await _cacheService.getCache();
- _topNClusters = cache.timelines.entries
- .where(
- (entry) =>
- entry.value.isCluster &&
- !assigned.contains(entry.value.personId),
- )
- .map((entry) => entry.key)
- .toSet();
+ final assigned = <String>{};
+ for (final person in persons) {
+ for (final cluster in person.data.assigned) {
+ assigned.add(cluster.id);
}
}
- if (flagService.internalUser) {
- try {
- await _scheduleTimelinesForMemoriesStrip(persons);
- } catch (e, s) {
- _logger.severe("_scheduleTimelinesForMemoriesStrip failed:", e, s);
- }
+ try {
+ _topNClusters = await _mlDataDB.getClustersForMemoryLane(assigned);
+ } catch (e, s) {
+ _logger.severe("getClustersForMemoryLane failed:", e, s);
+ final cache = await _cacheService.getCache();
+ _topNClusters = cache.timelines.entries
+ .where(
+ (entry) =>
+ entry.value.isCluster &&
+ !assigned.contains(entry.value.personId),
+ )
+ .map((entry) => entry.key)
+ .toSet();
+ }
+ try {
+ await _scheduleTimelinesForMemoriesStrip(persons);
+ } catch (e, s) {
+ _logger.severe("_scheduleTimelinesForMemoriesStrip failed:", e, s);
}
if (!isLocalGalleryMode) {
for (final person in persons) {
@@ -148,22 +144,20 @@ class MemoryLaneService {
schedulePersonRecompute(person.remoteID, force: force);
}
}
- if (flagService.internalUser) {
- final cache = await _cacheService.getCache();
- final List<Future<void>> tasks = [];
- for (final timeline in cache.allTimelines) {
- if (timeline.isCluster && !_topNClusters.contains(timeline.personId)) {
- tasks.add(_cacheService.removeTimeline(timeline.personId));
- tasks.add(_cacheService.removeComputeLogEntry(timeline.personId));
- }
- }
- if (tasks.isNotEmpty) {
- unawaited(Future.wait(tasks).then((_) => _refreshReadyPersonIds()));
- }
- for (final cluster in _topNClusters) {
- schedulePersonRecompute(cluster, isCluster: true, force: force);
+ final cache = await _cacheService.getCache();
+ final List<Future<void>> tasks = [];
+ for (final timeline in cache.allTimelines) {
+ if (timeline.isCluster && !_topNClusters.contains(timeline.personId)) {
+ tasks.add(_cacheService.removeTimeline(timeline.personId));
+ tasks.add(_cacheService.removeComputeLogEntry(timeline.personId));
}
}
+ if (tasks.isNotEmpty) {
+ unawaited(Future.wait(tasks).then((_) => _refreshReadyPersonIds()));
+ }
+ for (final cluster in _topNClusters) {
+ schedulePersonRecompute(cluster, isCluster: true, force: force);
+ }
}
void schedulePersonRecompute(
diff --git a/mobile/apps/photos/lib/ui/home/memories/memories_strip.dart b/mobile/apps/photos/lib/ui/home/memories/memories_strip.dart
index 0572caa59d..da2cbc5abd 100644
--- a/mobile/apps/photos/lib/ui/home/memories/memories_strip.dart
+++ b/mobile/apps/photos/lib/ui/home/memories/memories_strip.dart
@@ -218,7 +218,6 @@ class _MemoriesStripWidgetState extends State<MemoriesStripWidget> {
final oldestMemoryLaneFace = _oldestMemoryLaneFace;
final newestMemoryLaneFace = _newestMemoryLaneFace;
final hasMemoryLane =
- flagService.internalUser &&
MemoryLaneService.instance.isFeatureEnabled &&
memoryLane != null &&
(memoryLane.isCluster || memoryLanePerson != null) &&
@@ -391,9 +390,6 @@ class _MemoriesStripWidgetState extends State<MemoriesStripWidget> {
}
Future<void> _fetchMemoryLane() async {
- if (!flagService.internalUser) {
- return;
- }
final timeline = await MemoryLaneService.instance
.getScheduledMemoriesStripTimeline();
if (timeline == null) {
diff --git a/mobile/apps/photos/lib/ui/viewer/people/cluster_page.dart b/mobile/apps/photos/lib/ui/viewer/people/cluster_page.dart
index 635349978d..3a8bc73e7b 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/cluster_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/cluster_page.dart
@@ -15,8 +15,7 @@ import "package:photos/models/file_load_result.dart";
import "package:photos/models/gallery_type.dart";
import "package:photos/models/ml/face/person.dart";
import "package:photos/models/selected_files.dart";
-import "package:photos/service_locator.dart"
- show flagService, isLocalGalleryMode;
+import "package:photos/service_locator.dart" show isLocalGalleryMode;
import "package:photos/services/machine_learning/face_ml/feedback/cluster_feedback.dart";
import "package:photos/services/machine_learning/ml_result.dart";
import "package:photos/services/memory_lane/memory_lane_service.dart";
@@ -120,15 +119,13 @@ class _ClusterPageState extends State<ClusterPage> {
if (mounted) setState(() {});
};
_timelineNotifier.addListener(_timelineListener);
- if (flagService.internalUser) {
- if (widget.personID == null) {
- unawaited(
- MemoryLaneService.instance.ensureTimelineReachability(
- widget.clusterID,
- isCluster: true,
- ),
- );
- }
+ if (widget.personID == null) {
+ unawaited(
+ MemoryLaneService.instance.ensureTimelineReachability(
+ widget.clusterID,
+ isCluster: true,
+ ),
+ );
}
kDebugMode
? ClusterFeedbackService.instance.debugLogClusterBlurValues(
@@ -177,7 +174,6 @@ class _ClusterPageState extends State<ClusterPage> {
}
Future<void> _openMemoryLanePage() async {
- if (!flagService.internalUser) return;
if (widget.personID == null &&
MemoryLaneService.instance.hasReadyTimelineSync(
widget.clusterID,
@@ -200,13 +196,13 @@ class _ClusterPageState extends State<ClusterPage> {
"${files.length} memories${widget.appendTitle}",
_selectedFiles,
widget.clusterID,
- memoryLaneReady: flagService.internalUser && widget.personID == null
+ memoryLaneReady: widget.personID == null
? MemoryLaneService.instance.hasReadyTimelineSync(
widget.clusterID,
isCluster: true,
)
: false,
- onMemoryLaneTap: flagService.internalUser ? _openMemoryLanePage : null,
+ onMemoryLaneTap: _openMemoryLanePage,
);
final gallery = Gallery(
appBar: appBar,
diff --git a/mobile/apps/photos/lib/ui/viewer/people/memory_lane_page_v2.dart b/mobile/apps/photos/lib/ui/viewer/people/memory_lane_page_v2.dart
index 85bfc2611d..992c4681ae 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/memory_lane_page_v2.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/memory_lane_page_v2.dart
@@ -25,7 +25,6 @@ import "package:photos/ui/home/memories/memory_music_session.dart";
import "package:photos/ui/home/memories/memory_progress_indicator.dart";
import "package:photos/ui/home/memories/memory_viewer_constants.dart";
import "package:photos/ui/viewer/gallery/jump_to_date_gallery.dart";
-import "package:photos/ui/viewer/people/memory_lane_page.dart";
import "package:photos/utils/dialog_util.dart";
import "package:photos/utils/face/face_thumbnail_cache.dart";
import "package:photos/utils/share_util.dart";
@@ -38,21 +37,10 @@ Future<void> openMemoryLanePage(
}) async {
if (!context.mounted || (!isCluster && person == null)) return;
- final Widget page;
- if (flagService.internalUser) {
- page = MemoryLanePageV2(
- personId: personId,
- isCluster: isCluster,
- person: person,
- );
- } else {
- page = MemoryLanePage(
- personId: personId,
- isCluster: isCluster,
- person: person,
- );
- }
- await routeToPage(context, page);
+ await routeToPage(
+ context,
+ MemoryLanePageV2(personId: personId, isCluster: isCluster, person: person),
+ );
}
class MemoryLanePageV2 extends StatefulWidget {
@@ -409,11 +397,6 @@ class _MemoryLanePageV2State extends State<MemoryLanePageV2> {
if (creationDate != null) {
final now = DateTime.now();
final today = DateTime.utc(now.year, now.month, now.day);
- final photoDate = DateTime.utc(
- creationDate.year,
- creationDate.month,
- creationDate.day,
- );
var months =
(now.year - creationDate.year) * 12 +
now.month -
@@ -427,7 +410,6 @@ class _MemoryLanePageV2State extends State<MemoryLanePageV2> {
),
);
if (today.isBefore(anniversary)) months--;
- final days = today.difference(photoDate).inDays;
if (months >= 12) {
captionValue = months ~/ 12;
caption = context.strings.memoryLaneCaptionYearsAgo(
@@ -435,29 +417,8 @@ class _MemoryLanePageV2State extends State<MemoryLanePageV2> {
count: captionValue,
number: captionPlaceholder,
);
- } else if (months >= 1) {
- captionValue = months;
- caption = context.strings.memoryLaneCaptionMonthsAgo(
- name: name ?? "",
- count: captionValue,
- number: captionPlaceholder,
- );
- } else if (days >= 7) {
- captionValue = days ~/ 7;
- caption = context.strings.memoryLaneCaptionWeeksAgo(
- name: name ?? "",
- count: captionValue,
- number: captionPlaceholder,
- );
- } else if (days >= 1) {
- captionValue = days;
- caption = context.strings.memoryLaneCaptionDaysAgo(
- name: name ?? "",
- count: captionValue,
- number: captionPlaceholder,
- );
} else {
- caption = context.strings.memoryLaneCaptionToday(name: name ?? "");
+ caption = context.strings.memoryLaneCaptionNow(name: name ?? "");
}
caption = caption.trim();
}
diff --git a/mobile/packages/strings/lib/l10n/arb/strings_de.arb b/mobile/packages/strings/lib/l10n/arb/strings_de.arb
index 7e96c07d66..1083a75531 100644
--- a/mobile/packages/strings/lib/l10n/arb/strings_de.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_de.arb
@@ -1482,57 +1482,9 @@
}
}
},
- "memoryLaneCaptionMonthsAgo": "{name} {count, plural, one{vor {number} Monat} other{vor {number} Monaten}}",
- "@memoryLaneCaptionMonthsAgo": {
- "description": "Memory Lane caption in elapsed months. Always keep the number, including for one.",
- "placeholders": {
- "name": {
- "type": "String"
- },
- "count": {
- "type": "int"
- },
- "number": {
- "type": "String",
- "description": "Placeholder rendered as a separate, larger number; retain in every plural form."
- }
- }
- },
- "memoryLaneCaptionWeeksAgo": "{name} {count, plural, one{vor {number} Woche} other{vor {number} Wochen}}",
- "@memoryLaneCaptionWeeksAgo": {
- "description": "Memory Lane caption in elapsed weeks. Always keep the number, including for one.",
- "placeholders": {
- "name": {
- "type": "String"
- },
- "count": {
- "type": "int"
- },
- "number": {
- "type": "String",
- "description": "Placeholder rendered as a separate, larger number; retain in every plural form."
- }
- }
- },
- "memoryLaneCaptionDaysAgo": "{name} {count, plural, one{vor {number} Tag} other{vor {number} Tagen}}",
- "@memoryLaneCaptionDaysAgo": {
- "description": "Memory Lane caption in elapsed days. Always keep the number, including for one.",
- "placeholders": {
- "name": {
- "type": "String"
- },
- "count": {
- "type": "int"
- },
- "number": {
- "type": "String",
- "description": "Placeholder rendered as a separate, larger number; retain in every plural form."
- }
- }
- },
- "memoryLaneCaptionToday": "{name} heute",
- "@memoryLaneCaptionToday": {
- "description": "Memory Lane caption for a photo taken today, without a number.",
+ "memoryLaneCaptionNow": "{name} jetzt",
+ "@memoryLaneCaptionNow": {
+ "description": "Memory Lane caption for a photo taken less than a year ago, without a number.",
"placeholders": {
"name": {
"type": "String"
diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
index ba78865e75..ee1a529ff0 100644
--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
@@ -1495,57 +1495,9 @@
}
}
},
- "memoryLaneCaptionMonthsAgo": "{name} {count, plural, one{{number} month ago} other{{number} months ago}}",
- "@memoryLaneCaptionMonthsAgo": {
- "description": "Memory Lane caption in elapsed months. Always keep the number, including for one.",
- "placeholders": {
- "name": {
- "type": "String"
- },
- "count": {
- "type": "int"
- },
- "number": {
- "type": "String",
- "description": "Placeholder rendered as a separate, larger number; retain in every plural form."
- }
- }
- },
- "memoryLaneCaptionWeeksAgo": "{name} {count, plural, one{{number} week ago} other{{number} weeks ago}}",
- "@memoryLaneCaptionWeeksAgo": {
- "description": "Memory Lane caption in elapsed weeks. Always keep the number, including for one.",
- "placeholders": {
- "name": {
- "type": "String"
- },
- "count": {
- "type": "int"
- },
- "number": {
- "type": "String",
- "description": "Placeholder rendered as a separate, larger number; retain in every plural form."
- }
- }
- },
- "memoryLaneCaptionDaysAgo": "{name} {count, plural, one{{number} day ago} other{{number} days ago}}",
- "@memoryLaneCaptionDaysAgo": {
- "description": "Memory Lane caption in elapsed days. Always keep the number, including for one.",
- "placeholders": {
- "name": {
- "type": "String"
- },
- "count": {
- "type": "int"
- },
- "number": {
- "type": "String",
- "description": "Placeholder rendered as a separate, larger number; retain in every plural form."
- }
- }
- },
- "memoryLaneCaptionToday": "{name} today",
- "@memoryLaneCaptionToday": {
- "description": "Memory Lane caption for a photo taken today, without a number.",
+ "memoryLaneCaptionNow": "{name} now",
+ "@memoryLaneCaptionNow": {
+ "description": "Memory Lane caption for a photo taken less than a year ago, without a number.",
"placeholders": {
"name": {
"type": "String"
diff --git a/mobile/packages/strings/lib/l10n/arb/strings_ru.arb b/mobile/packages/strings/lib/l10n/arb/strings_ru.arb
index bf66993222..5df52174ab 100644
--- a/mobile/packages/strings/lib/l10n/arb/strings_ru.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_ru.arb
@@ -1482,57 +1482,9 @@
}
}
},
- "memoryLaneCaptionMonthsAgo": "{name} {count, plural, one{{number} месяц назад} few{{number} месяца назад} many{{number} месяцев назад} other{{number} месяца назад}}",
- "@memoryLaneCaptionMonthsAgo": {
- "description": "Memory Lane caption in elapsed months. Always keep the number, including for one.",
- "placeholders": {
- "name": {
- "type": "String"
- },
- "count": {
- "type": "int"
- },
- "number": {
- "type": "String",
- "description": "Placeholder rendered as a separate, larger number; retain in every plural form."
- }
- }
- },
- "memoryLaneCaptionWeeksAgo": "{name} {count, plural, one{{number} неделю назад} few{{number} недели назад} many{{number} недель назад} other{{number} недели назад}}",
- "@memoryLaneCaptionWeeksAgo": {
- "description": "Memory Lane caption in elapsed weeks. Always keep the number, including for one.",
- "placeholders": {
- "name": {
- "type": "String"
- },
- "count": {
- "type": "int"
- },
- "number": {
- "type": "String",
- "description": "Placeholder rendered as a separate, larger number; retain in every plural form."
- }
- }
- },
- "memoryLaneCaptionDaysAgo": "{name} {count, plural, one{{number} день назад} few{{number} дня назад} many{{number} дней назад} other{{number} дня назад}}",
- "@memoryLaneCaptionDaysAgo": {
- "description": "Memory Lane caption in elapsed days. Always keep the number, including for one.",
- "placeholders": {
- "name": {
- "type": "String"
- },
- "count": {
- "type": "int"
- },
- "number": {
- "type": "String",
- "description": "Placeholder rendered as a separate, larger number; retain in every plural form."
- }
- }
- },
- "memoryLaneCaptionToday": "{name} сегодня",
- "@memoryLaneCaptionToday": {
- "description": "Memory Lane caption for a photo taken today, without a number.",
+ "memoryLaneCaptionNow": "{name} сейчас",
+ "@memoryLaneCaptionNow": {
+ "description": "Memory Lane caption for a photo taken less than a year ago, without a number.",
"placeholders": {
"name": {
"type": "String"
diff --git a/mobile/packages/strings/lib/l10n/arb/strings_sv.arb b/mobile/packages/strings/lib/l10n/arb/strings_sv.arb
index 18b14380f7..b9f75ddad1 100644
--- a/mobile/packages/strings/lib/l10n/arb/strings_sv.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_sv.arb
@@ -1478,57 +1478,9 @@
}
}
},
- "memoryLaneCaptionMonthsAgo": "{name} {count, plural, one{{number} månad sedan} other{{number} månader sedan}}",
- "@memoryLaneCaptionMonthsAgo": {
- "description": "Memory Lane caption in elapsed months. Always keep the number, including for one.",
- "placeholders": {
- "name": {
- "type": "String"
- },
- "count": {
- "type": "int"
- },
- "number": {
- "type": "String",
- "description": "Placeholder rendered as a separate, larger number; retain in every plural form."
- }
- }
- },
- "memoryLaneCaptionWeeksAgo": "{name} {count, plural, one{{number} vecka sedan} other{{number} veckor sedan}}",
- "@memoryLaneCaptionWeeksAgo": {
- "description": "Memory Lane caption in elapsed weeks. Always keep the number, including for one.",
- "placeholders": {
- "name": {
- "type": "String"
- },
- "count": {
- "type": "int"
- },
- "number": {
- "type": "String",
- "description": "Placeholder rendered as a separate, larger number; retain in every plural form."
- }
- }
- },
- "memoryLaneCaptionDaysAgo": "{name} {count, plural, one{{number} dag sedan} other{{number} dagar sedan}}",
- "@memoryLaneCaptionDaysAgo": {
- "description": "Memory Lane caption in elapsed days. Always keep the number, including for one.",
- "placeholders": {
- "name": {
- "type": "String"
- },
- "count": {
- "type": "int"
- },
- "number": {
- "type": "String",
- "description": "Placeholder rendered as a separate, larger number; retain in every plural form."
- }
- }
- },
- "memoryLaneCaptionToday": "{name} i dag",
- "@memoryLaneCaptionToday": {
- "description": "Memory Lane caption for a photo taken today, without a number.",
+ "memoryLaneCaptionNow": "{name} nu",
+ "@memoryLaneCaptionNow": {
+ "description": "Memory Lane caption for a photo taken less than a year ago, without a number.",
"placeholders": {
"name": {
"type": "String"
@@ -5094,4 +5046,4 @@
},
"notEnoughStorageTitle": "Otillräckligt lagringsutrymme",
"notEnoughStorageBody": "Du har inte tillräckligt med ledigt utrymme i Ente för att lägga till nya foton. Frigör utrymme eller uppgradera för att fortsätta lägga till."
-}
\ No newline at end of file
+}
diff --git a/mobile/packages/strings/lib/l10n/arb/strings_uk.arb b/mobile/packages/strings/lib/l10n/arb/strings_uk.arb
index 815c7e15ff..b9dae29129 100644
--- a/mobile/packages/strings/lib/l10n/arb/strings_uk.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_uk.arb
@@ -1028,9 +1028,9 @@
}
}
},
- "memoryLaneCaptionToday": "{name} сьогодні",
- "@memoryLaneCaptionToday": {
- "description": "Memory Lane caption for a photo taken today, without a number.",
+ "memoryLaneCaptionNow": "{name} зараз",
+ "@memoryLaneCaptionNow": {
+ "description": "Memory Lane caption for a photo taken less than a year ago, without a number.",
"placeholders": {
"name": {
"type": "String"
diff --git a/mobile/packages/strings/lib/l10n/arb/strings_vi.arb b/mobile/packages/strings/lib/l10n/arb/strings_vi.arb
index dee5a30b7f..54aba69a61 100644
--- a/mobile/packages/strings/lib/l10n/arb/strings_vi.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_vi.arb
@@ -1432,57 +1432,9 @@
}
}
},
- "memoryLaneCaptionMonthsAgo": "{name} {count, plural, other{{number} tháng trước}}",
- "@memoryLaneCaptionMonthsAgo": {
- "description": "Memory Lane caption in elapsed months. Always keep the number, including for one.",
- "placeholders": {
- "name": {
- "type": "String"
- },
- "count": {
- "type": "int"
- },
- "number": {
- "type": "String",
- "description": "Placeholder rendered as a separate, larger number; retain in every plural form."
- }
- }
- },
- "memoryLaneCaptionWeeksAgo": "{name} {count, plural, other{{number} tuần trước}}",
- "@memoryLaneCaptionWeeksAgo": {
- "description": "Memory Lane caption in elapsed weeks. Always keep the number, including for one.",
- "placeholders": {
- "name": {
- "type": "String"
- },
- "count": {
- "type": "int"
- },
- "number": {
- "type": "String",
- "description": "Placeholder rendered as a separate, larger number; retain in every plural form."
- }
- }
- },
- "memoryLaneCaptionDaysAgo": "{name} {count, plural, other{{number} ngày trước}}",
- "@memoryLaneCaptionDaysAgo": {
- "description": "Memory Lane caption in elapsed days. Always keep the number, including for one.",
- "placeholders": {
- "name": {
- "type": "String"
- },
- "count": {
- "type": "int"
- },
- "number": {
- "type": "String",
- "description": "Placeholder rendered as a separate, larger number; retain in every plural form."
- }
- }
- },
- "memoryLaneCaptionToday": "{name} hôm nay",
- "@memoryLaneCaptionToday": {
- "description": "Memory Lane caption for a photo taken today, without a number.",
+ "memoryLaneCaptionNow": "{name} bây giờ",
+ "@memoryLaneCaptionNow": {
+ "description": "Memory Lane caption for a photo taken less than a year ago, without a number.",
"placeholders": {
"name": {
"type": "String"