From 3d5ce4b86360c8bb9db81224ed00253eac349011 Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Thu, 1 Feb 2024 11:57:18 +0800 Subject: [PATCH] new: clipboard backup (#263) --- .dart_tool/flutter_gen/gen_l10n/l10n.dart | 6 ++ .dart_tool/flutter_gen/gen_l10n/l10n_de.dart | 3 + .dart_tool/flutter_gen/gen_l10n/l10n_en.dart | 3 + .dart_tool/flutter_gen/gen_l10n/l10n_fr.dart | 3 + .dart_tool/flutter_gen/gen_l10n/l10n_id.dart | 3 + .dart_tool/flutter_gen/gen_l10n/l10n_zh.dart | 6 ++ ios/Runner.xcodeproj/project.pbxproj | 36 +++++----- lib/data/res/build_data.dart | 8 +-- lib/l10n/app_de.arb | 1 + lib/l10n/app_en.arb | 1 + lib/l10n/app_fr.arb | 1 + lib/l10n/app_id.arb | 1 + lib/l10n/app_zh.arb | 1 + lib/l10n/app_zh_tw.arb | 1 + lib/view/page/backup.dart | 69 ++++++++++++++++++++ macos/Runner.xcodeproj/project.pbxproj | 12 ++-- 16 files changed, 127 insertions(+), 28 deletions(-) diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n.dart b/.dart_tool/flutter_gen/gen_l10n/l10n.dart index a93a8119..b0da07da 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n.dart @@ -286,6 +286,12 @@ abstract class S { /// **'Clear'** String get clear; + /// No description provided for @clipboard. + /// + /// In en, this message translates to: + /// **'Clipboard'** + String get clipboard; + /// No description provided for @close. /// /// In en, this message translates to: diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart index 83ec34ca..12e7dc87 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart @@ -99,6 +99,9 @@ class SDe extends S { @override String get clear => 'Entfernen'; + @override + String get clipboard => 'Zwischenablage'; + @override String get close => 'Schließen'; diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart index 96758e4c..82335108 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart @@ -99,6 +99,9 @@ class SEn extends S { @override String get clear => 'Clear'; + @override + String get clipboard => 'Clipboard'; + @override String get close => 'Close'; diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_fr.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_fr.dart index 09beb03f..a8eb812a 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_fr.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_fr.dart @@ -99,6 +99,9 @@ class SFr extends S { @override String get clear => 'Effacer'; + @override + String get clipboard => 'presse-papiers'; + @override String get close => 'Fermer'; diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_id.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_id.dart index d08928cc..9a7c13e8 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_id.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_id.dart @@ -99,6 +99,9 @@ class SId extends S { @override String get clear => 'Jernih'; + @override + String get clipboard => 'papan klip'; + @override String get close => 'Menutup'; diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart index 3cb9465d..ab5c650c 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart @@ -99,6 +99,9 @@ class SZh extends S { @override String get clear => '清除'; + @override + String get clipboard => '剪切板'; + @override String get close => '关闭'; @@ -947,6 +950,9 @@ class SZhTw extends SZh { @override String get clear => '清除'; + @override + String get clipboard => '剪切板'; + @override String get close => '關閉'; diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 6c19210b..3049ead0 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -586,7 +586,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 732; + CURRENT_PROJECT_VERSION = 734; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -596,7 +596,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.732; + MARKETING_VERSION = 1.0.734; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -720,7 +720,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 732; + CURRENT_PROJECT_VERSION = 734; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -730,7 +730,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.732; + MARKETING_VERSION = 1.0.734; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -748,7 +748,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 732; + CURRENT_PROJECT_VERSION = 734; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -758,7 +758,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.732; + MARKETING_VERSION = 1.0.734; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -779,7 +779,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 732; + CURRENT_PROJECT_VERSION = 734; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -792,7 +792,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.732; + MARKETING_VERSION = 1.0.734; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; @@ -818,7 +818,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 732; + CURRENT_PROJECT_VERSION = 734; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -831,7 +831,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.732; + MARKETING_VERSION = 1.0.734; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -854,7 +854,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 732; + CURRENT_PROJECT_VERSION = 734; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -867,7 +867,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.732; + MARKETING_VERSION = 1.0.734; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -890,7 +890,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 732; + CURRENT_PROJECT_VERSION = 734; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -902,7 +902,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.732; + MARKETING_VERSION = 1.0.734; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; @@ -931,7 +931,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 732; + CURRENT_PROJECT_VERSION = 734; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -943,7 +943,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.732; + MARKETING_VERSION = 1.0.734; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; PRODUCT_NAME = ServerBox; @@ -969,7 +969,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 732; + CURRENT_PROJECT_VERSION = 734; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -981,7 +981,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.732; + MARKETING_VERSION = 1.0.734; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; PRODUCT_NAME = ServerBox; diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 751ebeed..c40ecc8e 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,9 +2,9 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 732; - static const String engine = "3.16.8"; - static const String buildAt = "2024-01-30 11:53:52"; - static const int modifications = 3; + static const int build = 734; + static const String engine = "3.16.9"; + static const String buildAt = "2024-02-01 11:26:59"; + static const int modifications = 5; static const int script = 36; } diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index 1bda9f78..9802931f 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -31,6 +31,7 @@ "chooseFontFile": "Schriftart auswählen", "choosePrivateKey": "Private key auswählen", "clear": "Entfernen", + "clipboard": "Zwischenablage", "close": "Schließen", "cmd": "Command", "collapseUI": "Zusammenbrechen", diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index c193873a..832511a3 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -31,6 +31,7 @@ "chooseFontFile": "Choose a font file", "choosePrivateKey": "Choose private key", "clear": "Clear", + "clipboard": "Clipboard", "close": "Close", "cmd": "Command", "collapseUI": "Collapse", diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index 18c22fcc..3458210c 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -31,6 +31,7 @@ "chooseFontFile": "Choisir un fichier de police", "choosePrivateKey": "Choisir la clé privée", "clear": "Effacer", + "clipboard": "presse-papiers", "close": "Fermer", "cmd": "Commande", "collapseUI": "обвал", diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb index 736bc358..fdc74901 100644 --- a/lib/l10n/app_id.arb +++ b/lib/l10n/app_id.arb @@ -31,6 +31,7 @@ "chooseFontFile": "Pilih file font", "choosePrivateKey": "Pilih Kunci Pribadi", "clear": "Jernih", + "clipboard": "papan klip", "close": "Menutup", "cmd": "Memerintah", "collapseUI": "Runtuh", diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 96a795aa..2c2f300c 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -31,6 +31,7 @@ "chooseFontFile": "选择字体文件", "choosePrivateKey": "选择私钥", "clear": "清除", + "clipboard": "剪切板", "close": "关闭", "cmd": "命令", "collapseUI": "折叠", diff --git a/lib/l10n/app_zh_tw.arb b/lib/l10n/app_zh_tw.arb index 0269c758..688a9124 100644 --- a/lib/l10n/app_zh_tw.arb +++ b/lib/l10n/app_zh_tw.arb @@ -31,6 +31,7 @@ "chooseFontFile": "選擇字體文件", "choosePrivateKey": "選擇私鑰", "clear": "清除", + "clipboard": "剪切板", "close": "關閉", "cmd": "命令", "collapseUI": "折疊", diff --git a/lib/view/page/backup.dart b/lib/view/page/backup.dart index 46c56e5e..64d9f956 100644 --- a/lib/view/page/backup.dart +++ b/lib/view/page/backup.dart @@ -47,6 +47,7 @@ class BackupPage extends StatelessWidget { if (isMacOS || isIOS) _buildIcloud(context), _buildWebdav(context), _buildFile(context), + _buildClipboard(context), ], ); } @@ -188,6 +189,31 @@ class BackupPage extends StatelessWidget { ); } + Widget _buildClipboard(BuildContext context) { + return CardX( + child: ExpandTile( + leading: const Icon(Icons.content_paste), + title: Text(l10n.clipboard), + children: [ + ListTile( + title: Text(l10n.backup), + trailing: const Icon(Icons.save), + onTap: () async { + final path = await Backup.backup(); + Shares.copy(await File(path).readAsString()); + context.showSnackBar(l10n.success); + }, + ), + ListTile( + trailing: const Icon(Icons.restore), + title: Text(l10n.restore), + onTap: () async => _onTapClipboardRestore(context), + ), + ], + ), + ); + } + Future _onTapFileRestore(BuildContext context) async { final path = await pickOneFile(); if (path == null) return; @@ -353,4 +379,47 @@ class BackupPage extends StatelessWidget { Webdav.changeClient(urlCtrl.text, userCtrl.text, pwdCtrl.text); } } + + void _onTapClipboardRestore(BuildContext context) async { + final text = await Shares.paste(); + if (text == null || text.isEmpty) { + context.showSnackBar(l10n.fieldMustNotEmpty); + return; + } + + try { + context.showLoadingDialog(); + final backup = + await Computer.shared.start(Backup.fromJsonString, text.trim()); + if (backupFormatVersion != backup.version) { + context.showSnackBar(l10n.backupVersionNotMatch); + return; + } + + await context.showRoundDialog( + title: Text(l10n.restore), + child: Text(l10n.askContinue( + '${l10n.restore} ${l10n.backup}(${backup.date})', + )), + actions: [ + TextButton( + onPressed: () => context.pop(), + child: Text(l10n.cancel), + ), + TextButton( + onPressed: () async { + await backup.restore(force: true); + context.pop(); + }, + child: Text(l10n.ok), + ), + ], + ); + } catch (e, trace) { + Loggers.app.warning('Import backup failed', e, trace); + context.showSnackBar(e.toString()); + } finally { + context.pop(); + } + } } diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 735af4b9..845425bf 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -439,7 +439,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 732; + CURRENT_PROJECT_VERSION = 734; DEVELOPMENT_TEAM = BA88US33G6; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Server Box"; @@ -449,7 +449,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 1.0.732; + MARKETING_VERSION = 1.0.734; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "Server Box"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -574,7 +574,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 732; + CURRENT_PROJECT_VERSION = 734; DEVELOPMENT_TEAM = BA88US33G6; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Server Box"; @@ -584,7 +584,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 1.0.732; + MARKETING_VERSION = 1.0.734; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "Server Box"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -604,7 +604,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "3rd Party Mac Developer Application"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 732; + CURRENT_PROJECT_VERSION = 734; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=macosx*]" = BA88US33G6; INFOPLIST_FILE = Runner/Info.plist; @@ -615,7 +615,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 1.0.732; + MARKETING_VERSION = 1.0.734; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "Server Box"; PROVISIONING_PROFILE_SPECIFIER = "";