Skip to content

armgit / ente

Public Imported from GitHub
0

💚 End-to-end encrypted cloud for everything.

Add option for offline local gallery change logs

laurenspriem99617eb924d6
diff --git a/mobile/apps/photos/lib/ui/home/landing_page_widget.dart b/mobile/apps/photos/lib/ui/home/landing_page_widget.dart
index a47bcd1630..f987f45f75 100644
--- a/mobile/apps/photos/lib/ui/home/landing_page_widget.dart
+++ b/mobile/apps/photos/lib/ui/home/landing_page_widget.dart
@@ -300,7 +300,6 @@ class _LandingPageWidgetState extends State<LandingPageWidget> {
}
Future<void> _navigateWithoutAccount() async {
- updateService.hideChangeLog().ignore();
await Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => const HomeWidget(startWithoutAccount: true),
diff --git a/mobile/apps/photos/lib/ui/notification/update/change_log_page.dart b/mobile/apps/photos/lib/ui/notification/update/change_log_page.dart
index c92151500d..79759b98c3 100644
--- a/mobile/apps/photos/lib/ui/notification/update/change_log_page.dart
+++ b/mobile/apps/photos/lib/ui/notification/update/change_log_page.dart
@@ -49,7 +49,7 @@ class _ChangeLogPageState extends State<ChangeLogPage> {
const SizedBox(
height: 24,
),
- Flexible(child: _getChangeLog(context)),
+ Flexible(child: _getChangeLog()),
const DividerWidget(
dividerType: DividerType.solid,
),
@@ -97,8 +97,14 @@ class _ChangeLogPageState extends State<ChangeLogPage> {
);
}
- Widget _getChangeLog(BuildContext ctx) {
- final strings = ChangeLogStrings.forLocale(Localizations.localeOf(context));
+ Widget _getChangeLog() {
+ final strings = ChangeLogStrings.maybeForLocale(
+ Localizations.localeOf(context),
+ isOffline: isOfflineMode,
+ );
+ if (strings == null) {
+ return const SizedBox.shrink();
+ }
final items = <ChangeLogEntry>[
ChangeLogEntry(
strings.title1,
diff --git a/mobile/apps/photos/lib/ui/notification/update/change_log_strings.dart b/mobile/apps/photos/lib/ui/notification/update/change_log_strings.dart
index 238886668b..89124ca9d0 100644
--- a/mobile/apps/photos/lib/ui/notification/update/change_log_strings.dart
+++ b/mobile/apps/photos/lib/ui/notification/update/change_log_strings.dart
@@ -21,14 +21,32 @@ class ChangeLogStrings {
required this.desc3,
});
- static ChangeLogStrings forLocale(Locale locale) {
+ bool get hasVisibleEntries =>
+ title1.trim().isNotEmpty ||
+ desc1.trim().isNotEmpty ||
+ desc1Item1.trim().isNotEmpty ||
+ desc1Item2.trim().isNotEmpty ||
+ title2.trim().isNotEmpty ||
+ desc2.trim().isNotEmpty ||
+ title3.trim().isNotEmpty ||
+ desc3.trim().isNotEmpty;
+
+ static ChangeLogStrings? maybeForLocale(
+ Locale locale, {
+ bool isOffline = false,
+ }) {
final key = locale.countryCode != null && locale.countryCode!.isNotEmpty
? '${locale.languageCode}_${locale.countryCode}'
: locale.languageCode;
+ final translations = isOffline ? _offlineTranslations : _translations;
+ final strings = translations[key] ??
+ translations[locale.languageCode] ??
+ translations['en'];
- return _translations[key] ??
- _translations[locale.languageCode] ??
- _translations['en']!;
+ if (strings == null || !strings.hasVisibleEntries) {
+ return null;
+ }
+ return strings;
}
static const Map<String, ChangeLogStrings> _translations = {
@@ -266,4 +284,17 @@ class ChangeLogStrings {
'我们让帮助与支持页面变得更易用,你可以在那里报告问题、提出疑问或提交功能请求。我们还新增了一个版块,带你前往常见问题页面,方便你快速找到答案。',
),
};
+
+ static const Map<String, ChangeLogStrings> _offlineTranslations = {
+ 'en': ChangeLogStrings(
+ title1: '',
+ desc1: '',
+ desc1Item1: '',
+ desc1Item2: '',
+ title2: '',
+ desc2: '',
+ title3: '',
+ desc3: '',
+ ),
+ };
}
diff --git a/mobile/apps/photos/lib/ui/tabs/home_widget.dart b/mobile/apps/photos/lib/ui/tabs/home_widget.dart
index 77ee174e63..879bfb4dbe 100644
--- a/mobile/apps/photos/lib/ui/tabs/home_widget.dart
+++ b/mobile/apps/photos/lib/ui/tabs/home_widget.dart
@@ -72,6 +72,7 @@ import "package:photos/ui/home/landing_page_widget.dart";
import "package:photos/ui/home/loading_photos_widget.dart";
import "package:photos/ui/home/start_backup_hook_widget.dart";
import "package:photos/ui/notification/update/change_log_page.dart";
+import "package:photos/ui/notification/update/change_log_strings.dart";
import "package:photos/ui/rituals/ritual_camera_page.dart";
import "package:photos/ui/rituals/ritual_page.dart";
import "package:photos/ui/rituals/ritual_privacy.dart";
@@ -124,6 +125,7 @@ class _HomeWidgetState extends State<HomeWidget> {
bool _showShowBackupHook = false;
bool _personSyncTriggered = false;
bool _collectionsSyncTriggered = false;
+ bool _isShowingChangeLog = false;
final isOnSearchTabNotifier = ValueNotifier<bool>(false);
final ValueNotifier<bool> _swipeToSelectInProgressNotifier =
ValueNotifier<bool>(false);
@@ -222,6 +224,9 @@ class _HomeWidgetState extends State<HomeWidget> {
Bus.instance.on<AppModeChangedEvent>().listen((event) async {
if (mounted) {
setState(() {});
+ _scheduleChangeLogCheck(
+ delay: const Duration(milliseconds: 250),
+ );
}
});
_firstImportEvent =
@@ -294,13 +299,8 @@ class _HomeWidgetState extends State<HomeWidget> {
// For sharing images coming from outside the app
_initMediaShareSubscription();
- WidgetsBinding.instance.addPostFrameCallback(
- (_) => Future.delayed(
- const Duration(seconds: 1),
- () => {
- if (mounted) {showChangeLog(context)},
- },
- ),
+ _scheduleChangeLogCheck(
+ delay: const Duration(seconds: 1),
);
if (Platform.isAndroid &&
@@ -343,6 +343,18 @@ class _HomeWidgetState extends State<HomeWidget> {
await MemoryHomeWidgetService.instance.checkPendingMemorySync();
}
+ void _scheduleChangeLogCheck({
+ required Duration delay,
+ }) {
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ Future.delayed(delay, () {
+ if (mounted) {
+ showChangeLog(context);
+ }
+ });
+ });
+ }
+
final Map<Uri, (bool, int)> _linkedPublicAlbums = {};
Future<void> _handlePublicAlbumLink(Uri uri, String via) async {
if (!mounted) {
@@ -1073,31 +1085,53 @@ class _HomeWidgetState extends State<HomeWidget> {
}
showChangeLog(BuildContext context) async {
- final bool show = await updateService.showChangeLog();
- if (!show || !Configuration.instance.isLoggedIn()) {
+ if (_isShowingChangeLog) {
return;
}
- final colorScheme = getEnteColorScheme(context);
- await showBarModalBottomSheet(
- topControl: const SizedBox.shrink(),
- shape: const RoundedRectangleBorder(
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(5),
- topRight: Radius.circular(5),
+ _isShowingChangeLog = true;
+ try {
+ final bool show = await updateService.showChangeLog();
+ if (!mounted || !show) {
+ return;
+ }
+ final bool canShow = isOfflineMode || Configuration.instance.isLoggedIn();
+ final hasContent = ChangeLogStrings.maybeForLocale(
+ Localizations.localeOf(context),
+ isOffline: isOfflineMode,
+ ) !=
+ null;
+ if (!canShow) {
+ return;
+ }
+ if (!hasContent) {
+ updateService.hideChangeLog().ignore();
+ return;
+ }
+ final colorScheme = getEnteColorScheme(context);
+ await showBarModalBottomSheet(
+ topControl: const SizedBox.shrink(),
+ shape: const RoundedRectangleBorder(
+ borderRadius: BorderRadius.only(
+ topLeft: Radius.circular(5),
+ topRight: Radius.circular(5),
+ ),
),
- ),
- backgroundColor: colorScheme.backgroundElevated,
- enableDrag: false,
- barrierColor: backdropFaintDark,
- context: context,
- builder: (BuildContext context) {
- return Padding(
- padding:
- EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
- child: const ChangeLogPage(),
- );
- },
- );
+ backgroundColor: colorScheme.backgroundElevated,
+ enableDrag: false,
+ barrierColor: backdropFaintDark,
+ context: context,
+ builder: (BuildContext context) {
+ return Padding(
+ padding: EdgeInsets.only(
+ bottom: MediaQuery.of(context).viewInsets.bottom,
+ ),
+ child: const ChangeLogPage(),
+ );
+ },
+ );
+ } finally {
+ _isShowingChangeLog = false;
+ }
// Do not show change dialog again
updateService.hideChangeLog().ignore();
}