feat: migrate downloads to background_downloader

close #454
This commit is contained in:
edde746
2026-02-14 18:02:49 +01:00
parent 2278af8d83
commit d986f0d2ea
10 changed files with 1762 additions and 880 deletions
+4
View File
@@ -17,6 +17,10 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
<!-- Background download notifications and foreground service -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
<!-- Explicitly remove media permissions that media_kit may add -->
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" tools:node="remove" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" tools:node="remove" />
+6
View File
@@ -1,4 +1,6 @@
PODS:
- background_downloader (0.0.1):
- Flutter
- connectivity_plus (0.0.1):
- Flutter
- device_info_plus (0.0.1):
@@ -105,6 +107,7 @@ PODS:
- Flutter
DEPENDENCIES:
- background_downloader (from `.symlinks/plugins/background_downloader/ios`)
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- file_picker (from `.symlinks/plugins/file_picker/ios`)
@@ -138,6 +141,8 @@ SPEC REPOS:
- sqlite3
EXTERNAL SOURCES:
background_downloader:
:path: ".symlinks/plugins/background_downloader/ios"
connectivity_plus:
:path: ".symlinks/plugins/connectivity_plus/ios"
device_info_plus:
@@ -172,6 +177,7 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/workmanager_apple/ios"
SPEC CHECKSUMS:
background_downloader: 50e91d979067b82081aba359d7d916b3ba5fadad
connectivity_plus: cb623214f4e1f6ef8fe7403d580fdad517d2f7dd
device_info_plus: 21fcca2080fbcd348be798aa36c3e5ed849eefbe
file_picker: 8fc6fe5e42585a217d44d22f79ec046cb8d81140
+5
View File
@@ -49,6 +49,11 @@
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>processing</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
+5 -2
View File
@@ -16,7 +16,7 @@ class AppDatabase extends _$AppDatabase {
AppDatabase() : super(_openConnection());
@override
int get schemaVersion => 7; // Added OfflineWatchProgress table
int get schemaVersion => 8; // Added bgTaskId column to DownloadedMedia
@override
MigrationStrategy get migration {
@@ -25,11 +25,14 @@ class AppDatabase extends _$AppDatabase {
await m.createAll();
},
onUpgrade: (Migrator m, int from, int to) async {
// Additive migration for schema version 7
if (from < 7) {
appLogger.i('Adding OfflineWatchProgress table (v7 migration)');
await m.createTable(offlineWatchProgress);
}
if (from < 8) {
appLogger.i('Adding bgTaskId column to DownloadedMedia (v8 migration)');
await m.addColumn(downloadedMedia, downloadedMedia.bgTaskId);
}
},
);
}
File diff suppressed because it is too large Load Diff
+1
View File
@@ -47,6 +47,7 @@ class DownloadedMedia extends Table {
IntColumn get downloadedAt => integer().nullable()();
TextColumn get errorMessage => text().nullable()();
IntColumn get retryCount => integer().withDefault(const Constant(0))();
TextColumn get bgTaskId => text().nullable()();
}
/// Queue for offline watch progress and manual watch actions.
File diff suppressed because it is too large Load Diff
+13 -2
View File
@@ -654,8 +654,8 @@ class _DownloadTreeItemState extends State<_DownloadTreeItem> {
),
],
// Progress bar
if (widget.node.status == DownloadStatus.downloading || widget.node.status == DownloadStatus.queued) ...[
// Progress bar for active downloads
if (widget.node.status == DownloadStatus.downloading) ...[
const SizedBox(height: 8),
LinearProgressIndicator(
value: widget.node.progress,
@@ -671,6 +671,17 @@ class _DownloadTreeItemState extends State<_DownloadTreeItem> {
),
],
],
// Queued label
if (widget.node.status == DownloadStatus.queued) ...[
const SizedBox(height: 4),
Text(
t.downloads.downloadQueued,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurface.withValues(alpha: 0.5),
),
),
],
],
),
),
+8
View File
@@ -65,6 +65,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.13.0"
background_downloader:
dependency: "direct main"
description:
name: background_downloader
sha256: "2ea5322fe836c0aaf96aefd29ef1936771c71927f687cf18168dcc119666a45f"
url: "https://pub.dev"
source: hosted
version: "9.5.2"
boolean_selector:
dependency: transitive
description:
+1
View File
@@ -53,6 +53,7 @@ dependencies:
flutter_svg: ^2.2.3
mobile_scanner: ^6.0.2
android_intent_plus: ^5.0.2
background_downloader: ^9.5.2
dev_dependencies:
flutter_test: