From 36b88c602c3493c3a6e41846ea6a7e3da810c0b5 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Wed, 10 Jan 2024 17:42:33 +0700 Subject: [PATCH] feat: update privacy policy and add version code (#4343) --- .../presentation/setting/about/about.dart | 1 - .../setting/about/about_setting_group.dart | 22 +++++++++++-------- .../setting/about/privacy_policy_page.dart | 22 ------------------- .../keyboard_height_observer.dart | 2 +- .../appflowy_flutter/lib/startup/startup.dart | 2 +- .../lib/startup/tasks/device_info_task.dart | 14 ++++++++++-- .../lib/startup/tasks/generate_router.dart | 11 ---------- frontend/resources/translations/en.json | 4 +++- 8 files changed, 30 insertions(+), 48 deletions(-) delete mode 100644 frontend/appflowy_flutter/lib/mobile/presentation/setting/about/privacy_policy_page.dart diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/setting/about/about.dart b/frontend/appflowy_flutter/lib/mobile/presentation/setting/about/about.dart index fee2e3497b..ef58850dad 100644 --- a/frontend/appflowy_flutter/lib/mobile/presentation/setting/about/about.dart +++ b/frontend/appflowy_flutter/lib/mobile/presentation/setting/about/about.dart @@ -1,3 +1,2 @@ export 'about_setting_group.dart'; -export 'privacy_policy_page.dart'; export 'user_agreement_page.dart'; diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/setting/about/about_setting_group.dart b/frontend/appflowy_flutter/lib/mobile/presentation/setting/about/about_setting_group.dart index 62173370d0..99e9fbf33b 100644 --- a/frontend/appflowy_flutter/lib/mobile/presentation/setting/about/about_setting_group.dart +++ b/frontend/appflowy_flutter/lib/mobile/presentation/setting/about/about_setting_group.dart @@ -1,10 +1,11 @@ import 'package:appflowy/generated/locale_keys.g.dart'; +import 'package:appflowy/startup/tasks/device_info_task.dart'; +import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:easy_localization/easy_localization.dart'; +import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; import '../widgets/widgets.dart'; -import 'about.dart'; class AboutSettingGroup extends StatelessWidget { const AboutSettingGroup({ @@ -21,18 +22,21 @@ class AboutSettingGroup extends StatelessWidget { trailing: const Icon( Icons.chevron_right, ), - onTap: () { - context.push(PrivacyPolicyPage.routeName); - }, + onTap: () => safeLaunchUrl('https://appflowy.io/privacy/mobile'), ), MobileSettingItem( - name: LocaleKeys.settings_mobile_userAgreement.tr(), + name: LocaleKeys.settings_mobile_termsAndConditions.tr(), trailing: const Icon( Icons.chevron_right, ), - onTap: () { - context.push(UserAgreementPage.routeName); - }, + onTap: () => safeLaunchUrl('https://appflowy.io/terms'), + ), + MobileSettingItem( + name: LocaleKeys.settings_mobile_version.tr(), + trailing: FlowyText( + '${DeviceOrApplicationInfoTask.applicationVersion} (${DeviceOrApplicationInfoTask.buildNumber})', + color: Theme.of(context).colorScheme.onSurface, + ), ), ], showDivider: false, diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/setting/about/privacy_policy_page.dart b/frontend/appflowy_flutter/lib/mobile/presentation/setting/about/privacy_policy_page.dart deleted file mode 100644 index fb57b1d6a2..0000000000 --- a/frontend/appflowy_flutter/lib/mobile/presentation/setting/about/privacy_policy_page.dart +++ /dev/null @@ -1,22 +0,0 @@ -import 'package:appflowy/generated/locale_keys.g.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:flutter/material.dart'; - -class PrivacyPolicyPage extends StatelessWidget { - const PrivacyPolicyPage({super.key}); - - static const routeName = '/PrivacyPolicyPage'; - - @override - Widget build(BuildContext context) { - // TODO(yijing): implement page - return Scaffold( - appBar: AppBar( - title: Text(LocaleKeys.settings_mobile_privacyPolicy.tr()), - ), - body: const Center( - child: Text('🪜 Under construction'), - ), - ); - } -} diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mobile_toolbar_v3/keyboard_height_observer.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mobile_toolbar_v3/keyboard_height_observer.dart index b4d36cbd23..a1a58184fc 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mobile_toolbar_v3/keyboard_height_observer.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mobile_toolbar_v3/keyboard_height_observer.dart @@ -34,7 +34,7 @@ class KeyboardHeightObserver { void notify(double height) { // the keyboard height will notify twice with the same value on Android 14 - if (DeviceInfoTask.androidSDKVersion == 34) { + if (DeviceOrApplicationInfoTask.androidSDKVersion == 34) { if (height == 0 && currentKeyboardHeight == 0) { return; } diff --git a/frontend/appflowy_flutter/lib/startup/startup.dart b/frontend/appflowy_flutter/lib/startup/startup.dart index d2e21ce525..d1e9c56190 100644 --- a/frontend/appflowy_flutter/lib/startup/startup.dart +++ b/frontend/appflowy_flutter/lib/startup/startup.dart @@ -109,7 +109,7 @@ class FlowyRunner { // there's a flag named _enable in memory_leak_detector.dart. If it's false, the task will be ignored. MemoryLeakDetectorTask(), const DebugTask(), - const DeviceInfoTask(), + const DeviceOrApplicationInfoTask(), // localization const InitLocalizationTask(), // init the app window diff --git a/frontend/appflowy_flutter/lib/startup/tasks/device_info_task.dart b/frontend/appflowy_flutter/lib/startup/tasks/device_info_task.dart index 6dd5af5032..61225b8f58 100644 --- a/frontend/appflowy_flutter/lib/startup/tasks/device_info_task.dart +++ b/frontend/appflowy_flutter/lib/startup/tasks/device_info_task.dart @@ -1,21 +1,31 @@ import 'dart:io'; import 'package:device_info_plus/device_info_plus.dart'; +import 'package:package_info_plus/package_info_plus.dart'; import '../startup.dart'; -class DeviceInfoTask extends LaunchTask { - const DeviceInfoTask(); +class DeviceOrApplicationInfoTask extends LaunchTask { + const DeviceOrApplicationInfoTask(); static int androidSDKVersion = -1; + static String applicationVersion = ''; + static String buildNumber = ''; @override Future initialize(LaunchContext context) async { final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin(); + final PackageInfo packageInfo = await PackageInfo.fromPlatform(); + if (Platform.isAndroid) { final androidInfo = await deviceInfoPlugin.androidInfo; androidSDKVersion = androidInfo.version.sdkInt; } + + if (Platform.isAndroid || Platform.isIOS) { + applicationVersion = packageInfo.version; + buildNumber = packageInfo.buildNumber; + } } @override diff --git a/frontend/appflowy_flutter/lib/startup/tasks/generate_router.dart b/frontend/appflowy_flutter/lib/startup/tasks/generate_router.dart index 0505e4cda9..4f98cb5226 100644 --- a/frontend/appflowy_flutter/lib/startup/tasks/generate_router.dart +++ b/frontend/appflowy_flutter/lib/startup/tasks/generate_router.dart @@ -47,7 +47,6 @@ GoRouter generateRouter(Widget child) { if (PlatformExtension.isMobile) ...[ // settings _mobileHomeSettingPageRoute(), - _mobileSettingPrivacyPolicyPageRoute(), _mobileSettingUserAgreementPageRoute(), _mobileCloudSettingAppFlowyCloudPageRoute(), @@ -196,16 +195,6 @@ GoRoute _mobileHomeSettingPageRoute() { ); } -GoRoute _mobileSettingPrivacyPolicyPageRoute() { - return GoRoute( - parentNavigatorKey: AppGlobals.rootNavKey, - path: PrivacyPolicyPage.routeName, - pageBuilder: (context, state) { - return const MaterialPage(child: PrivacyPolicyPage()); - }, - ); -} - GoRoute _mobileCloudSettingAppFlowyCloudPageRoute() { return GoRoute( parentNavigatorKey: AppGlobals.rootNavKey, diff --git a/frontend/resources/translations/en.json b/frontend/resources/translations/en.json index 613c0ad4d3..55473e881f 100644 --- a/frontend/resources/translations/en.json +++ b/frontend/resources/translations/en.json @@ -447,10 +447,12 @@ "joinDiscord": "Join us in Discord", "privacyPolicy": "Privacy Policy", "userAgreement": "User Agreement", + "termsAndConditions": "Terms and Conditions", "userprofileError": "Failed to load user profile", "userprofileErrorDescription": "Please try to log out and log back in to check if the issue still persists.", "selectLayout": "Select layout", - "selectStartingDay": "Select starting day" + "selectStartingDay": "Select starting day", + "version": "Version" } }, "grid": {