Merge latest main into 2.0.0-beta.2

This commit is contained in:
Levi committed 2026-09-15 22:51:31 +08:00
commit 45d7b6f5bc
18 files changed
+2983 -3

No files matched your search

@@ -125,6 +125,7 @@ class ExtraConfig {
bool notifyWhenNewVersion;
bool desktopNotification;
bool backgroundLocationKeepAlive;
bool backgroundContinuedProcessing;
WindowStateConfig windowState;
Map<String, String> bookmarks;
List<String> createHistory;
@@ -146,6 +147,7 @@ class ExtraConfig {
this.notifyWhenNewVersion = true,
this.desktopNotification = true,
this.backgroundLocationKeepAlive = false,
this.backgroundContinuedProcessing = false,
WindowStateConfig? windowState,
this.bookmarks = const {},
this.createHistory = const [],
@@ -119,6 +119,10 @@ ExtraConfig _$ExtraConfigFromJson(Map<String, dynamic> json) =>
notifyWhenNewVersion: json['notifyWhenNewVersion'] as bool? ?? true,
desktopNotification: json['desktopNotification'] as bool? ?? true,
backgroundLocationKeepAlive: json['backgroundLocationKeepAlive'] as bool? ?? false,
backgroundContinuedProcessing:
json['backgroundContinuedProcessing']
as bool? ??
false,
windowState: json['windowState'] == null
? null
: WindowStateConfig.fromJson(json['windowState'] as Map<String, dynamic>?),
@@ -146,6 +150,8 @@ Map<String, dynamic> _$ExtraConfigToJson(ExtraConfig instance) => <String, dynam
'notifyWhenNewVersion': instance.notifyWhenNewVersion,
'desktopNotification': instance.desktopNotification,
'backgroundLocationKeepAlive': instance.backgroundLocationKeepAlive,
'backgroundContinuedProcessing':
instance.backgroundContinuedProcessing,
'windowState': instance.windowState.toJson(),
'bookmarks': instance.bookmarks,
'createHistory': instance.createHistory,
@@ -23,6 +23,7 @@ import '../../util/util.dart';
import '../rpc/webview_rpc_service.dart';
import 'android_foreground_service.dart';
import 'location_keep_alive.dart';
import 'continued_processing.dart';
const unixSocketPath = 'gopeed.sock';
@@ -105,8 +106,14 @@ class AppRuntimeController extends AsyncNotifier<AppRuntimeState> {
),
);
unawaited(LocationKeepAliveCoordinator.instance.reconcile(enabled: config.extra.backgroundLocationKeepAlive));
unawaited(
ContinuedProcessing.setEnabled(
config.extra.backgroundContinuedProcessing,
),
);
}
Future<AppRuntimeState> _init() async {
await AppInitializer.ensureStorageInitialized();
try {
@@ -180,6 +187,13 @@ class AppRuntimeController extends AsyncNotifier<AppRuntimeState> {
startupError: startupError,
);
if (Util.isIOS()) {
// Make sure the native Continued Processing manager has the
// persisted setting before app initialization completes. This
// avoids the first download racing ahead of setEnabled(true).
await ContinuedProcessing.setEnabled(
config.extra.backgroundContinuedProcessing,
);
LocationKeepAliveCoordinator.instance.start(
() =>
state.value?.downloaderConfig.extra.backgroundLocationKeepAlive ?? config.extra.backgroundLocationKeepAlive,
@@ -0,0 +1,39 @@
import 'dart:io';
import 'package:flutter/services.dart';
class ContinuedProcessing {
const ContinuedProcessing._();
static const _channel =
MethodChannel('gopeed/continued_processing');
static Future<bool> isSupported() async {
if (!Platform.isIOS) return false;
try {
return await _channel.invokeMethod<bool>(
'isSupported',
) ??
false;
} catch (_) {
return false;
}
}
static Future<bool> setEnabled(
bool enabled,
) async {
if (!Platform.isIOS) return false;
try {
return await _channel.invokeMethod<bool>(
'setEnabled',
{'enabled': enabled},
) ??
false;
} catch (_) {
return false;
}
}
}
@@ -13,6 +13,7 @@ import '../../../../app/application/app_appearance_controller.dart';
import '../../../../app/application/app_platform_controller.dart';
import '../../../../app/application/app_runtime_controller.dart';
import '../../../../app/application/location_keep_alive.dart';
import '../../../../app/application/continued_processing.dart';
import '../../../../core/common/start_config.dart';
import '../../../../core/network/gopeed/gopeed_transport.dart';
import '../../../../core/utils/breakpoints.dart';
@@ -377,6 +378,19 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
onChanged: (value) => unawaited(_setBackgroundLocationKeepAlive(value)),
),
),
if (Util.isIOS())
SettingsItem(
title: context.l10n.backgroundContinuedProcessing,
subtitle:
context.l10n.backgroundContinuedProcessingDescription,
child: shad.Switch(
value:
config.extra.backgroundContinuedProcessing,
onChanged: (value) => unawaited(
_setBackgroundContinuedProcessing(value),
),
),
),
],
),
),
@@ -1237,6 +1251,43 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
_mutateConfig((config) => config.extra.backgroundLocationKeepAlive = enabled);
await LocationKeepAliveCoordinator.instance.reconcile(enabled: enabled);
}
Future<void>
_setBackgroundContinuedProcessing(
bool enabled,
) async {
if (enabled &&
!await ContinuedProcessing.isSupported()) {
if (mounted) {
_toast(
context.l10n
.backgroundContinuedProcessingUnsupported,
);
}
return;
}
final applied =
await ContinuedProcessing.setEnabled(
enabled,
);
if (enabled && !applied) {
if (mounted) {
_toast(
context.l10n
.backgroundContinuedProcessingUnsupported,
);
}
return;
}
_mutateConfig(
(config) =>
config.extra
.backgroundContinuedProcessing =
enabled,
);
}
List<String> _lines(String text) {
return text.split('\n').map((line) => line.trim()).where((line) => line.isNotEmpty).toList();
+3
View File
@@ -248,6 +248,7 @@
"ed2kNodesDatHint": "nodes.dat path or URL, one per line",
"desktopNotification": "Desktop Notifications",
"backgroundLocationKeepAlive": "Background Downloads",
"backgroundContinuedProcessing": "Continued Processing (iOS 26+)",
"notificationTaskDone": "Task completed",
"notificationTaskError": "Task error",
"appTitle": "Gopeed Download Manager",
@@ -290,6 +291,8 @@
"browserExtensionDescription": "Send browser downloads directly to Gopeed after installation",
"desktopNotificationDescription": "Show a system notification when a task completes or fails",
"backgroundLocationKeepAliveDescription": "Use location access to keep downloads active in the background",
"backgroundContinuedProcessingDescription": "Use iOS continued processing and its system Live Activity to keep downloads running without location access",
"backgroundContinuedProcessingUnsupported": "Continued Processing requires iOS 26 or later",
"currentVersion": "Current version {version}",
"contributors": "Contributors",
"viewContributors": "View contributors",