diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n.dart b/.dart_tool/flutter_gen/gen_l10n/l10n.dart index 0d3f35c2..d8bb4bb5 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n.dart @@ -156,6 +156,12 @@ abstract class S { /// **'Auto'** String get auto; + /// No description provided for @autoUpdateHomeWidget. + /// + /// In en, this message translates to: + /// **'Auto update home widget'** + String get autoUpdateHomeWidget; + /// No description provided for @backup. /// /// In en, this message translates to: @@ -1320,6 +1326,12 @@ abstract class S { /// **'Please wait for the connection to be established.'** String get waitConnection; + /// No description provided for @whenOpenApp. + /// + /// In en, this message translates to: + /// **'When opening the app'** + String get whenOpenApp; + /// No description provided for @willTakEeffectImmediately. /// /// 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 e0c5e690..7f1a2a52 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart @@ -34,6 +34,9 @@ class SDe extends S { @override String get auto => 'System folgen'; + @override + String get autoUpdateHomeWidget => 'Home-Widget automatisch aktualisieren'; + @override String get backup => 'Backup'; @@ -660,6 +663,9 @@ class SDe extends S { @override String get waitConnection => 'Bitte warte, bis die Verbindung hergestellt wurde.'; + @override + String get whenOpenApp => 'Beim Öffnen der App'; + @override String get willTakEeffectImmediately => 'Wird sofort angewendet'; } diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart index 6d894f68..bdf3a65d 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart @@ -34,6 +34,9 @@ class SEn extends S { @override String get auto => 'Auto'; + @override + String get autoUpdateHomeWidget => 'Auto update home widget'; + @override String get backup => 'Backup'; @@ -660,6 +663,9 @@ class SEn extends S { @override String get waitConnection => 'Please wait for the connection to be established.'; + @override + String get whenOpenApp => 'When opening the app'; + @override String get willTakEeffectImmediately => 'Will take effect immediately'; } diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart index a8a0e271..31efeee3 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart @@ -34,6 +34,9 @@ class SZh extends S { @override String get auto => '自动'; + @override + String get autoUpdateHomeWidget => '自动更新桌面小部件'; + @override String get backup => '备份'; @@ -660,6 +663,9 @@ class SZh extends S { @override String get waitConnection => '请等待连接建立'; + @override + String get whenOpenApp => '当打开 App 时'; + @override String get willTakEeffectImmediately => '更改将会立即生效'; } @@ -698,6 +704,9 @@ class SZhTw extends SZh { @override String get auto => '自動'; + @override + String get autoUpdateHomeWidget => '自動更新桌面小部件'; + @override String get backup => '備份'; @@ -1324,6 +1333,9 @@ class SZhTw extends SZh { @override String get waitConnection => '請等待連接建立'; + @override + String get whenOpenApp => '當打開 App 時'; + @override String get willTakEeffectImmediately => '更改將會立即生效'; } diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 7ede42cc..f1d075c0 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -470,7 +470,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 380; + CURRENT_PROJECT_VERSION = 387; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -478,7 +478,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.380; + MARKETING_VERSION = 1.0.387; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -602,7 +602,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 380; + CURRENT_PROJECT_VERSION = 387; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -610,7 +610,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.380; + MARKETING_VERSION = 1.0.387; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -628,7 +628,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 380; + CURRENT_PROJECT_VERSION = 387; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -636,7 +636,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.380; + MARKETING_VERSION = 1.0.387; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -657,7 +657,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 380; + CURRENT_PROJECT_VERSION = 387; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -670,7 +670,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.380; + MARKETING_VERSION = 1.0.387; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; @@ -696,7 +696,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 380; + CURRENT_PROJECT_VERSION = 387; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -709,7 +709,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.380; + MARKETING_VERSION = 1.0.387; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -732,7 +732,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 380; + CURRENT_PROJECT_VERSION = 387; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -745,7 +745,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.380; + MARKETING_VERSION = 1.0.387; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index e5fafaff..54dd851b 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -9,9 +9,17 @@ import Flutter didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { GeneratedPluginRegistrant.register(with: self) - if #available(iOS 14.0, *) { + + let controller : FlutterViewController = window?.rootViewController as! FlutterViewController + let methodChannel = FlutterMethodChannel(name: "tech.lolli.toolbox/home_widget", binaryMessenger: controller.binaryMessenger) + methodChannel.setMethodCallHandler({ + (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in + if call.method == "update" { + if #available(iOS 14.0, *) { WidgetCenter.shared.reloadTimelines(ofKind: "StatusWidget") + } } + }) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } } diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 18e2c014..14a2775f 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,8 +2,8 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 380; + static const int build = 387; static const String engine = "3.10.6"; - static const String buildAt = "2023-07-20 18:08:32.806339"; - static const int modifications = 14; + static const String buildAt = "2023-07-21 18:06:24.239059"; + static const int modifications = 2; } diff --git a/lib/data/res/misc.dart b/lib/data/res/misc.dart index 2e6ec310..5eef7775 100644 --- a/lib/data/res/misc.dart +++ b/lib/data/res/misc.dart @@ -15,3 +15,4 @@ const maxDebugLogLines = 100; /// Method Channels const pkgName = 'tech.lolli.toolbox'; const bgRunChannel = MethodChannel('$pkgName/app_retain'); +const homeWidgetChannel = MethodChannel('$pkgName/home_widget'); diff --git a/lib/data/store/setting.dart b/lib/data/store/setting.dart index d2ce1c5a..e88b43db 100644 --- a/lib/data/store/setting.dart +++ b/lib/data/store/setting.dart @@ -95,4 +95,7 @@ class SettingStore extends PersistentStore { StoreProperty get netViewType => property('netViewType', defaultValue: NetViewType.speed); + + // Only valid on iOS + StoreProperty get autoUpdateHomeWidget => property('autoUpdateHomeWidget', defaultValue: isIOS); } diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index 97e0229f..2e0a3679 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -10,6 +10,7 @@ "alreadyLastDir": "Bereits im letzten Verzeichnis.", "attention": "Achtung", "auto": "System folgen", + "autoUpdateHomeWidget": "Home-Widget automatisch aktualisieren", "backup": "Backup", "backupAndRestore": "Backup und Wiederherstellung", "backupTip": "Das Backup wird nur einfach verschlüsselt.\nBitte bewahre die Datei sicher auf.", @@ -204,5 +205,6 @@ "versionUpdated": "v1.0.{build} ist bereits die neueste Version", "viewErr": "Fehler anzeigen", "waitConnection": "Bitte warte, bis die Verbindung hergestellt wurde.", + "whenOpenApp": "Beim Öffnen der App", "willTakEeffectImmediately": "Wird sofort angewendet" } \ No newline at end of file diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index fb5b71a8..931caa75 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -10,6 +10,7 @@ "alreadyLastDir": "Already in last directory.", "attention": "Attention", "auto": "Auto", + "autoUpdateHomeWidget": "Auto update home widget", "backup": "Backup", "backupAndRestore": "Backup and Restore", "backupTip": "The exported data is simply encrypted. \nPlease keep it safe.", @@ -204,5 +205,6 @@ "versionUpdated": "Current: v1.0.{build}, is up to date", "viewErr": "See error", "waitConnection": "Please wait for the connection to be established.", + "whenOpenApp": "When opening the app", "willTakEeffectImmediately": "Will take effect immediately" } \ No newline at end of file diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 74726e04..1995c2ca 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -10,6 +10,7 @@ "alreadyLastDir": "已经是最上层目录了", "attention": "注意", "auto": "自动", + "autoUpdateHomeWidget": "自动更新桌面小部件", "backup": "备份", "backupAndRestore": "备份和恢复", "backupTip": "导出的数据仅进行了简单加密,请妥善保管。", @@ -204,5 +205,6 @@ "versionUpdated": "当前:v1.0.{build}, 已是最新版本", "viewErr": "查看错误", "waitConnection": "请等待连接建立", + "whenOpenApp": "当打开 App 时", "willTakEeffectImmediately": "更改将会立即生效" } \ No newline at end of file diff --git a/lib/l10n/app_zh_tw.arb b/lib/l10n/app_zh_tw.arb index a9799ad2..9308d78f 100644 --- a/lib/l10n/app_zh_tw.arb +++ b/lib/l10n/app_zh_tw.arb @@ -10,6 +10,7 @@ "alreadyLastDir": "已經是最上層目錄了", "attention": "注意", "auto": "自動", + "autoUpdateHomeWidget": "自動更新桌面小部件", "backup": "備份", "backupAndRestore": "備份和還原", "backupTip": "導出的數據僅進行了簡單加密,請妥善保管。", @@ -204,5 +205,6 @@ "versionUpdated": "當前:v1.0.{build}, 已是最新版本", "viewErr": "查看錯誤", "waitConnection": "請等待連接建立", + "whenOpenApp": "當打開 App 時", "willTakEeffectImmediately": "更改將會立即生效" } \ No newline at end of file diff --git a/lib/view/page/home.dart b/lib/view/page/home.dart index afbccd2e..05cba87e 100644 --- a/lib/view/page/home.dart +++ b/lib/view/page/home.dart @@ -85,6 +85,7 @@ class _HomePageState extends State if (!_serverProvider.isAutoRefreshOn) { _serverProvider.startAutoRefresh(); } + updateHomeWidget(); break; case AppLifecycleState.paused: // Keep running in background on Android device @@ -306,6 +307,7 @@ class _HomePageState extends State @override Future afterFirstLayout(BuildContext context) async { doUpdate(context); + updateHomeWidget(); await GetIt.I.allReady(); await _serverProvider.loadLocalData(); await _serverProvider.refreshData(); @@ -313,4 +315,10 @@ class _HomePageState extends State Analysis.init(); } } + + void updateHomeWidget() { + if (_setting.autoUpdateHomeWidget.fetch()!) { + homeWidgetChannel.invokeMethod('update'); + } + } } diff --git a/lib/view/page/setting.dart b/lib/view/page/setting.dart index be7f1bf6..0ce1330b 100644 --- a/lib/view/page/setting.dart +++ b/lib/view/page/setting.dart @@ -145,6 +145,7 @@ class _SettingPageState extends State { ]; if (isIOS) { children.add(_buildPushToken()); + children.add(_buildAutoUpdateHomeWidget()); } if (isAndroid) { children.add(_buildBgRun()); @@ -928,4 +929,12 @@ class _SettingPageState extends State { }, ); } + + Widget _buildAutoUpdateHomeWidget() { + return ListTile( + title: Text(_s.autoUpdateHomeWidget), + subtitle: Text(_s.whenOpenApp, style: grey), + trailing: buildSwitch(context, _setting.autoUpdateHomeWidget), + ); + } } diff --git a/macos/Podfile.lock b/macos/Podfile.lock index ba2190c2..5b52c08f 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -7,6 +7,9 @@ PODS: - FlutterMacOS - share_plus (0.0.1): - FlutterMacOS + - shared_preferences_foundation (0.0.1): + - Flutter + - FlutterMacOS - url_launcher_macos (0.0.1): - FlutterMacOS @@ -15,6 +18,7 @@ DEPENDENCIES: - FlutterMacOS (from `Flutter/ephemeral`) - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) - share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`) + - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) EXTERNAL SOURCES: @@ -26,14 +30,17 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin share_plus: :path: Flutter/ephemeral/.symlinks/plugins/share_plus/macos + shared_preferences_foundation: + :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin url_launcher_macos: :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos SPEC CHECKSUMS: flutter_volume_controller: 25d09126b0d695560f11c80b1311d5063fed882f FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 - path_provider_foundation: c68054786f1b4f3343858c1e1d0caaded73f0be9 + path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8 share_plus: 76dd39142738f7a68dd57b05093b5e8193f220f7 + shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 url_launcher_macos: 5335912b679c073563f29d89d33d10d459f95451 PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 95e90227..cb2c2ba9 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -475,9 +475,9 @@ baseConfigurationReference = C1C758C41C4E208965A68933 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 380; + CURRENT_PROJECT_VERSION = 387; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.380; + MARKETING_VERSION = 1.0.387; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -490,9 +490,9 @@ baseConfigurationReference = 15AF97DF993E8968098D6EBE /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 380; + CURRENT_PROJECT_VERSION = 387; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.380; + MARKETING_VERSION = 1.0.387; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -505,9 +505,9 @@ baseConfigurationReference = 7CFA7DE7FABA75685DFB6948 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 380; + CURRENT_PROJECT_VERSION = 387; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.380; + MARKETING_VERSION = 1.0.387; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0;