π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Share About settings across mobile apps
Neeraj Gupta83e4f01dedfb
diff --git a/mobile/apps/auth/lib/services/update_service.dart b/mobile/apps/auth/lib/services/update_service.dartindex 4e65642d87..13ad3ac41d 100644--- a/mobile/apps/auth/lib/services/update_service.dart+++ b/mobile/apps/auth/lib/services/update_service.dart@@ -27,6 +27,7 @@ class UpdateService {}Future<bool> shouldUpdate() async {+ _latestVersion = null;if (!supportsInAppUpdates()) {return false;}diff --git a/mobile/apps/auth/lib/ui/settings/about_settings_page.dart b/mobile/apps/auth/lib/ui/settings/about_settings_page.dartindex 7221e98d55..81482d0f97 100644--- a/mobile/apps/auth/lib/ui/settings/about_settings_page.dart+++ b/mobile/apps/auth/lib/ui/settings/about_settings_page.dart@@ -1,13 +1,10 @@import 'package:ente_auth/services/update_service.dart';import 'package:ente_auth/ui/settings/app_update_dialog.dart';import 'package:ente_auth/ui/settings/components/auth_settings_page_scaffold.dart';-import 'package:ente_auth/utils/dialog_util.dart';-import 'package:ente_auth/utils/platform_util.dart';import 'package:ente_auth/utils/toast_util.dart';-import 'package:ente_components/ente_components.dart';import 'package:ente_strings/ente_strings.dart';+import 'package:ente_ui/components/settings/about_settings_section.dart';import 'package:flutter/material.dart';-import 'package:hugeicons/hugeicons.dart';class AboutSettingsPage extends StatelessWidget {const AboutSettingsPage({super.key});@@ -18,63 +15,31 @@ class AboutSettingsPage extends StatelessWidget {return AuthSettingsPageScaffold(title: l10n.about,children: [- SettingsItem(- title: l10n.weAreOpenSource,- icon: HugeIcons.strokeRoundedGithub,- showOnlyLoadingState: true,- onTap: () =>- PlatformUtil.openUrlInBrowser('https://github.com/ente/ente'),+ AboutSettingsSection(+ onCheckForUpdates: UpdateService.instance.supportsInAppUpdates()+ ? () => _checkForUpdates(context)+ : null,),- const SizedBox(height: Spacing.sm),- SettingsItem(- title: l10n.blog,- icon: HugeIcons.strokeRoundedPencilEdit01,- showOnlyLoadingState: true,- onTap: () => PlatformUtil.openUrlInBrowser('https://ente.com/blog'),- ),- const SizedBox(height: Spacing.sm),- SettingsItem(- title: l10n.privacy,- icon: HugeIcons.strokeRoundedShield01,- showOnlyLoadingState: true,- onTap: () =>- PlatformUtil.openUrlInBrowser('https://ente.com/privacy'),- ),- const SizedBox(height: Spacing.sm),- SettingsItem(- title: l10n.termsOfServicesTitle,- icon: HugeIcons.strokeRoundedFile01,- showOnlyLoadingState: true,- onTap: () => PlatformUtil.openUrlInBrowser('https://ente.com/terms'),- ),- if (UpdateService.instance.supportsInAppUpdates()) ...[- const SizedBox(height: Spacing.sm),- SettingsItem(- title: l10n.checkForUpdates,- icon: HugeIcons.strokeRoundedDownload04,- showOnlyLoadingState: true,- onTap: () => _checkForUpdates(context),- ),- ],],);}Future<void> _checkForUpdates(BuildContext context) async {- final dialog = createProgressDialog(context, context.strings.checking);- await dialog.show();final shouldUpdate = await UpdateService.instance.shouldUpdate();- await dialog.hide();+ final latestVersion = UpdateService.instance.getLatestVersionInfo();if (!context.mounted) return;- if (shouldUpdate) {- await showDialog<void>(- context: context,- builder: (_) =>- AppUpdateDialog(UpdateService.instance.getLatestVersionInfo()),- barrierColor: Colors.black.withValues(alpha: 0.85),- );+ if (latestVersion == null) {+ showShortToast(context, context.strings.unableToCheckForUpdatesRightNow);return;}- showShortToast(context, context.strings.youAreOnTheLatestVersion);+ if (!shouldUpdate) {+ showShortToast(context, context.strings.youAreOnTheLatestVersion);+ return;+ }+ await showDialog<void>(+ context: context,+ builder: (_) => AppUpdateDialog(latestVersion),+ barrierColor: Colors.black.withValues(alpha: 0.85),+ );}}diff --git a/mobile/apps/locker/lib/services/update_service.dart b/mobile/apps/locker/lib/services/update_service.dartindex 94a76a6e29..8ed5a20afd 100644--- a/mobile/apps/locker/lib/services/update_service.dart+++ b/mobile/apps/locker/lib/services/update_service.dart@@ -37,10 +37,10 @@ class UpdateService {}Future<bool> shouldUpdate() async {+ _latestVersion = null;if (!_isInitialized || !isIndependent()) {return false;}- _latestVersion = null;try {_latestVersion = await _getLatestVersionInfo();final currentVersionCode = int.tryParse(_packageInfo!.buildNumber) ?? 0;diff --git a/mobile/apps/locker/lib/ui/settings/pages/about_page.dart b/mobile/apps/locker/lib/ui/settings/pages/about_page.dartindex 095135b0ff..1d4664dacb 100644--- a/mobile/apps/locker/lib/ui/settings/pages/about_page.dart+++ b/mobile/apps/locker/lib/ui/settings/pages/about_page.dart@@ -1,12 +1,10 @@import "package:ente_components/ente_components.dart";import "package:ente_strings/ente_strings.dart";+import "package:ente_ui/components/settings/about_settings_section.dart";import "package:ente_ui/utils/toast_util.dart";-import "package:ente_utils/platform_util.dart";import "package:flutter/material.dart";-import "package:hugeicons/hugeicons.dart";import "package:locker/services/update_service.dart";import "package:locker/ui/settings/widgets/app_update_dialog.dart";-import "package:url_launcher/url_launcher.dart";class AboutPage extends StatelessWidget {const AboutPage({super.key});@@ -18,73 +16,15 @@ class AboutPage extends StatelessWidget {return SettingsPageScaffold(title: l10n.about,children: [- SettingsItem(- title: l10n.weAreOpenSource,- icon: HugeIcons.strokeRoundedGithub,- showOnlyLoadingState: true,- onTap: () => _onOpenSourceTapped(),+ AboutSettingsSection(+ onCheckForUpdates: UpdateService.instance.isIndependent()+ ? () => _onCheckForUpdatesTapped(context)+ : null,),- const SizedBox(height: 8),- SettingsItem(- title: l10n.blog,- icon: HugeIcons.strokeRoundedPencilEdit01,- showOnlyLoadingState: true,- onTap: () => _onBlogTapped(context),- ),- const SizedBox(height: 8),- SettingsItem(- title: l10n.privacy,- icon: HugeIcons.strokeRoundedShield01,- showOnlyLoadingState: true,- onTap: () => _onPrivacyTapped(context),- ),- const SizedBox(height: 8),- SettingsItem(- title: l10n.termsOfServicesTitle,- icon: HugeIcons.strokeRoundedFile01,- showOnlyLoadingState: true,- onTap: () => _onTermsTapped(context),- ),- if (UpdateService.instance.isIndependent()) ...[- const SizedBox(height: 8),- SettingsItem(- title: l10n.checkForUpdates,- icon: HugeIcons.strokeRoundedDownload04,- showOnlyLoadingState: true,- onTap: () => _onCheckForUpdatesTapped(context),- ),- ],],);}- Future<void> _onOpenSourceTapped() async {- await launchUrl(Uri.parse("https://github.com/ente/ente"));- }-- Future<void> _onBlogTapped(BuildContext context) async {- final l10n = context.strings;- await PlatformUtil.openWebView(context, l10n.blog, "https://ente.com/blog");- }-- Future<void> _onPrivacyTapped(BuildContext context) async {- final l10n = context.strings;- await PlatformUtil.openWebView(- context,- l10n.privacy,- "https://ente.com/privacy",- );- }-- Future<void> _onTermsTapped(BuildContext context) async {- final l10n = context.strings;- await PlatformUtil.openWebView(- context,- l10n.termsOfServicesTitle,- "https://ente.com/terms",- );- }-Future<void> _onCheckForUpdatesTapped(BuildContext context) async {final l10n = context.strings;final shouldUpdate = await UpdateService.instance.shouldUpdate();diff --git a/mobile/apps/photos/lib/services/update_service.dart b/mobile/apps/photos/lib/services/update_service.dartindex 496e7b98c1..612a8fcbb6 100644--- a/mobile/apps/photos/lib/services/update_service.dart+++ b/mobile/apps/photos/lib/services/update_service.dart@@ -67,6 +67,7 @@ class UpdateService {}Future<bool> shouldUpdate() async {+ _latestVersion = null;if (!isIndependent()) {return false;}diff --git a/mobile/apps/photos/lib/ui/settings/about/about_us_page.dart b/mobile/apps/photos/lib/ui/settings/about/about_us_page.dartindex d397c00bd9..6109476b7f 100644--- a/mobile/apps/photos/lib/ui/settings/about/about_us_page.dart+++ b/mobile/apps/photos/lib/ui/settings/about/about_us_page.dart@@ -1,13 +1,10 @@import "package:ente_components/ente_components.dart";import "package:ente_strings/ente_strings.dart";+import "package:ente_ui/components/settings/about_settings_section.dart";import "package:flutter/material.dart";-import "package:hugeicons/hugeicons.dart";import "package:photos/service_locator.dart";-import "package:photos/ui/common/web_page.dart";import "package:photos/ui/notification/toast.dart";import "package:photos/ui/settings/app_update_dialog.dart";-import "package:photos/utils/dialog_util.dart";-import "package:url_launcher/url_launcher.dart";class AboutUsPage extends StatelessWidget {const AboutUsPage({super.key});@@ -19,93 +16,32 @@ class AboutUsPage extends StatelessWidget {return SettingsPageScaffold(title: l10n.about,children: [- SettingsItem(- title: l10n.weAreOpenSource,- icon: HugeIcons.strokeRoundedGithub,- showOnlyLoadingState: true,- onTap: () async {- await launchUrl(Uri.parse("https://github.com/ente/ente"));- },+ AboutSettingsSection(+ onCheckForUpdates: updateService.isIndependent()+ ? () => _checkForUpdates(context)+ : null,),- const SizedBox(height: 8),- SettingsItem(- title: l10n.blog,- icon: HugeIcons.strokeRoundedPencilEdit01,- showOnlyLoadingState: true,- onTap: () async {- await Navigator.of(context).push(- MaterialPageRoute(- builder: (BuildContext context) {- return WebPage(l10n.blog, "https://ente.com/blog");- },- ),- );- },- ),- const SizedBox(height: 8),- SettingsItem(- title: l10n.privacy,- icon: HugeIcons.strokeRoundedShield01,- showOnlyLoadingState: true,- onTap: () async {- await Navigator.of(context).push(- MaterialPageRoute(- builder: (BuildContext context) {- return WebPage(l10n.privacy, "https://ente.com/privacy");- },- ),- );- },- ),- const SizedBox(height: 8),- SettingsItem(- title: l10n.termsOfServicesTitle,- icon: HugeIcons.strokeRoundedFile01,- showOnlyLoadingState: true,- onTap: () async {- await Navigator.of(context).push(- MaterialPageRoute(- builder: (BuildContext context) {- return WebPage(- l10n.termsOfServicesTitle,- "https://ente.com/terms",- );- },- ),- );- },- ),- if (updateService.isIndependent()) ...[- const SizedBox(height: 8),- SettingsItem(- title: l10n.checkForUpdates,- icon: HugeIcons.strokeRoundedDownload04,- showOnlyLoadingState: true,- onTap: () async => _checkForUpdates(context),- ),- ],],);}Future<void> _checkForUpdates(BuildContext context) async {- final dialog = createProgressDialog(context, context.strings.checking);- await dialog.show();final shouldUpdate = await updateService.shouldUpdate();- await dialog.hide();- if (shouldUpdate) {- if (!context.mounted) return;- await showDialog(- useRootNavigator: false,- context: context,- builder: (BuildContext context) {- return AppUpdateDialog(updateService.getLatestVersionInfo());- },- barrierColor: Colors.black.withValues(alpha: 0.85),- );- } else {- if (!context.mounted) return;+ final latestVersion = updateService.getLatestVersionInfo();+ if (!context.mounted) return;+ if (latestVersion == null) {+ showShortToast(context, context.strings.unableToCheckForUpdatesRightNow);+ return;+ }+ if (!shouldUpdate) {showShortToast(context, context.strings.youAreOnTheLatestVersion);+ return;}+ await showDialog(+ useRootNavigator: false,+ context: context,+ builder: (_) => AppUpdateDialog(latestVersion),+ barrierColor: Colors.black.withValues(alpha: 0.85),+ );}}diff --git a/mobile/packages/ui/lib/components/settings/about_settings_section.dart b/mobile/packages/ui/lib/components/settings/about_settings_section.dartnew file mode 100644index 0000000000..2f043f6e57--- /dev/null+++ b/mobile/packages/ui/lib/components/settings/about_settings_section.dart@@ -0,0 +1,73 @@+import 'dart:async';++import 'package:ente_components/ente_components.dart';+import 'package:ente_pure_utils/ente_pure_utils.dart';+import 'package:ente_strings/ente_strings.dart';+import 'package:flutter/material.dart';+import 'package:hugeicons/hugeicons.dart';+import 'package:url_launcher/url_launcher_string.dart';++class AboutSettingsSection extends StatelessWidget {+ const AboutSettingsSection({super.key, this.onCheckForUpdates});++ final FutureOr<void> Function()? onCheckForUpdates;++ @override+ Widget build(BuildContext context) {+ final strings = context.strings;+ final items = [+ SettingsItem(+ title: strings.weAreOpenSource,+ icon: HugeIcons.strokeRoundedGithub,+ showOnlyLoadingState: true,+ onTap: () => _openUrl('https://github.com/ente/ente'),+ ),+ SettingsItem(+ title: strings.blog,+ icon: HugeIcons.strokeRoundedPencilEdit01,+ showOnlyLoadingState: true,+ onTap: () => _openUrl('https://ente.com/blog'),+ ),+ SettingsItem(+ title: strings.privacy,+ icon: HugeIcons.strokeRoundedShield01,+ showOnlyLoadingState: true,+ onTap: () => _openUrl('https://ente.com/privacy'),+ ),+ SettingsItem(+ title: strings.termsOfServicesTitle,+ icon: HugeIcons.strokeRoundedFile01,+ showOnlyLoadingState: true,+ onTap: () => _openUrl('https://ente.com/terms'),+ ),+ if (onCheckForUpdates != null)+ SettingsItem(+ title: strings.checkForUpdates,+ icon: HugeIcons.strokeRoundedDownload04,+ showOnlyLoadingState: true,+ onTap: onCheckForUpdates,+ ),+ ];++ return Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ for (var index = 0; index < items.length; index++) ...[+ if (index > 0) const SizedBox(height: Spacing.sm),+ items[index],+ ],+ ],+ );+ }++ Future<void> _openUrl(String url) {+ return launchUrlString(+ url,+ mode: PlatformDetector.isMobile()+ ? LaunchMode.inAppBrowserView+ : LaunchMode.externalApplication,+ browserConfiguration: const BrowserConfiguration(showTitle: true),+ );+ }+}