From 5c2cc5e5e47e4f20115b3ff8dbe50074e2cf435e Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Wed, 5 Apr 2023 15:15:17 +0800 Subject: [PATCH] fix: Android `moveBg` during picking file --- ios/Runner.xcodeproj/project.pbxproj | 12 ++++++------ lib/core/utils/misc.dart | 5 +++++ lib/data/provider/app.dart | 7 +++++++ lib/data/res/build_data.dart | 6 +++--- lib/view/page/home.dart | 7 +++++-- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 72ba4418..ba9bd2d4 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -359,7 +359,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 254; + CURRENT_PROJECT_VERSION = 255; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -367,7 +367,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.254; + MARKETING_VERSION = 1.0.255; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -490,7 +490,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 254; + CURRENT_PROJECT_VERSION = 255; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -498,7 +498,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.254; + MARKETING_VERSION = 1.0.255; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -515,7 +515,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 254; + CURRENT_PROJECT_VERSION = 255; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -523,7 +523,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.254; + MARKETING_VERSION = 1.0.255; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/lib/core/utils/misc.dart b/lib/core/utils/misc.dart index a1a808b2..3d4fe6e5 100644 --- a/lib/core/utils/misc.dart +++ b/lib/core/utils/misc.dart @@ -6,6 +6,8 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:plain_notification_token/plain_notification_token.dart'; import 'package:share_plus/share_plus.dart'; +import 'package:toolbox/data/provider/app.dart'; +import 'package:toolbox/locator.dart'; import '../../view/widget/rebuild.dart'; import 'platform.dart'; @@ -32,7 +34,10 @@ void copy(String text) { } Future pickOneFile() async { + final app = locator(); + app.setMoveBg(false); final result = await FilePicker.platform.pickFiles(type: FileType.any); + app.setMoveBg(true); return result?.files.single.path; } diff --git a/lib/data/provider/app.dart b/lib/data/provider/app.dart index 7c9ac521..62feebc3 100644 --- a/lib/data/provider/app.dart +++ b/lib/data/provider/app.dart @@ -4,8 +4,15 @@ class AppProvider extends BusyProvider { int? _newestBuild; int? get newestBuild => _newestBuild; + bool _moveBg = true; + bool get moveBg => _moveBg; + void setNewestBuild(int build) { _newestBuild = build; notifyListeners(); } + + void setMoveBg(bool moveBg) { + _moveBg = moveBg; + } } diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index d50b82ae..6d27a629 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 = 254; + static const int build = 255; static const String engine = "Flutter 3.7.7 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 2ad6cd72c0 (4 weeks ago) • 2023-03-08 09:41:59 -0800\nEngine • revision 1837b5be5f\nTools • Dart 2.19.4 • DevTools 2.20.1\n"; - static const String buildAt = "2023-04-05 15:01:13.115057"; - static const int modifications = 3; + static const String buildAt = "2023-04-05 15:03:38.565037"; + static const int modifications = 2; } diff --git a/lib/view/page/home.dart b/lib/view/page/home.dart index e9fcbedc..788f3b14 100644 --- a/lib/view/page/home.dart +++ b/lib/view/page/home.dart @@ -2,6 +2,7 @@ import 'package:after_layout/after_layout.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:get_it/get_it.dart'; +import 'package:toolbox/data/provider/app.dart'; import 'package:toolbox/data/res/misc.dart'; import '../../core/analysis.dart'; @@ -87,9 +88,11 @@ class _MyHomePageState extends State } break; case AppLifecycleState.paused: + // Keep running in background on Android device if (isAndroid && _setting.bgRun.fetch()!) { - // Keep running in background on Android device - bgRunChannel.invokeMethod('sendToBackground'); + if (locator().moveBg) { + bgRunChannel.invokeMethod('sendToBackground'); + } } else { _serverProvider.setDisconnected(); _serverProvider.stopAutoRefresh();