Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Redesign] Downloads Storage Rewrite #568

Merged
merged 90 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 86 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
e938395
Added isar dependancy.
Komodo5197 Dec 16, 2023
a2bb6ff
Created initial Isar version of the download_helper.
Komodo5197 Dec 17, 2023
e5b0a68
Isar download storage now works. Can add, delete, and playback.
Komodo5197 Dec 18, 2023
2444d93
Most browsing tasks work now. Initial migration code.
Komodo5197 Dec 19, 2023
0d98815
Switched to background_downloader. Fully removed downloads_helper. …
Komodo5197 Dec 20, 2023
4d5ee16
Got numbers on downloads screen working. Got migration mostly functi…
Komodo5197 Dec 20, 2023
b015c33
Fix ios build.
Komodo5197 Dec 20, 2023
642fa0c
Merge branch 'main' of https://github.com/Komodo5197/finamp into main…
Komodo5197 Dec 20, 2023
0a2b55a
Addressed various TODOs.
Komodo5197 Dec 21, 2023
00a1b16
Fixed getting collectionInfo.
Komodo5197 Dec 21, 2023
1bfea88
Minor fixes.
Komodo5197 Dec 22, 2023
db142f5
Minor fixes.
Komodo5197 Dec 23, 2023
b934a86
Merge remote-tracking branch 'upstream/redesign' into main-downloads-…
Komodo5197 Dec 23, 2023
5e4960a
Merged into redesign. Needs more integration work.
Komodo5197 Dec 23, 2023
e8b4c7f
Improved metadata API. Added implementation of saving all songs for …
Komodo5197 Dec 24, 2023
b303dc0
Improved download/delete buttons and statusing. Got greyed-out songs…
Komodo5197 Dec 25, 2023
d7d6419
Switched to using info links instead of info types. This complicates…
Komodo5197 Dec 27, 2023
06e26cd
Changed download error screen into active downloads screen.
Komodo5197 Dec 28, 2023
7afa5c8
Upgraded dependancies. Got external download locations working, hope…
Komodo5197 Dec 30, 2023
97522b7
Fixed missing download completions. Added download library buttons. …
Komodo5197 Dec 31, 2023
2ba8813
Added secondary isar collection for download task data. Added backgr…
Komodo5197 Jan 1, 2024
0dd08a9
Added filtering by library to downloads display. Download BaseItemDt…
Komodo5197 Jan 2, 2024
c0fb4aa
Fixed migration breaking. Fixed artists library filtering.
Komodo5197 Jan 2, 2024
1a6c0f5
Various minor fixes. Added a bunch of comments.
Komodo5197 Jan 4, 2024
e08d2e5
Merge branch 'redesign' of https://github.com/jmshrv/finamp into main…
Komodo5197 Jan 4, 2024
f925264
Merged latest redesign changes.
Komodo5197 Jan 4, 2024
7d86016
Allowed offline deletes. Added download settings screen with configu…
Komodo5197 Jan 5, 2024
0770114
Added offline artist stuff. Created Isar queue for syncs to match the…
Komodo5197 Jan 6, 2024
12da8da
Improved downloads overview screen with syncing node count and song/i…
Komodo5197 Jan 6, 2024
495420f
Attempted to improve performance by reducing unneeded deserialization.
Komodo5197 Jan 7, 2024
9b98386
Various tweaks to hopefully improve performance and clean up some pos…
Komodo5197 Jan 8, 2024
e8ebb1e
Removed some throttling. Reduced database writes. Fixed a scenario …
Komodo5197 Jan 10, 2024
ed26b1b
Switched database writes to synchronous. Messed with throttling. De…
Komodo5197 Jan 11, 2024
036bce8
Moved some methods from isar_downloads to isar_downloads_backend. Im…
Komodo5197 Jan 12, 2024
b2290fc
Allowed falling back from blurhashes to imageIds - untested. Added s…
Komodo5197 Jan 13, 2024
5be8295
Improved item filesize display. Fixed sync error handling and retrie…
Komodo5197 Jan 14, 2024
6ca63b7
Threw some more finampCollection types in. Playlists and favorites a…
Komodo5197 Jan 15, 2024
549cd5f
Fixed light mode color issues. Fixed syncing while offline caching c…
Komodo5197 Jan 16, 2024
62ba887
Show requiring item in tooltip on incidental download button. Block …
Komodo5197 Jan 17, 2024
c758ae6
Added a way to localize names of finampCollections like favorites. A…
Komodo5197 Jan 18, 2024
833ed63
Moved getItems into worker isolate. Moved user store to Isar to assi…
Komodo5197 Jan 19, 2024
7f441a2
Tweaked throttling a bit. Added downloads repair indicator.
Komodo5197 Jan 20, 2024
9b295ff
Switched background_downloader to pull wifi github branch instead of …
Komodo5197 Jan 22, 2024
0ed1d5d
Merge branch 'redesign' into pr/Komodo5197/568
Chaphasilor Jan 23, 2024
3e1f118
Added mention of low-priority pause setting to background pause notice.
Komodo5197 Jan 24, 2024
3eec2ad
Removed max concurrent download limit on iOS.
Komodo5197 Jan 25, 2024
e9873ee
Added persistent logging to file.
Komodo5197 Jan 25, 2024
69ff2c6
Disabled logging to file.
Komodo5197 Jan 26, 2024
040ad03
Merge branch 'redesign' of https://github.com/jmshrv/finamp into main…
Komodo5197 Jan 26, 2024
3e2ae73
Merged latest redesign and cleaned up issues.
Komodo5197 Jan 26, 2024
ee6fe98
Improved offline sort order.
Komodo5197 Jan 26, 2024
a1179f1
Brand new throttling strategy. Fixed bug with music screen refresh. …
Komodo5197 Jan 26, 2024
2e2d7b2
Merge branch 'redesign' of https://github.com/jmshrv/finamp into main…
Komodo5197 Jan 27, 2024
9a34fe6
Correctly show playing downloaded songs.
Komodo5197 Jan 27, 2024
7702f2f
Re-enabled logging to file. Tweaked sync throttling.
Komodo5197 Jan 28, 2024
4ed4495
Cache current user data.
Komodo5197 Jan 28, 2024
1920a6f
Merge branch 'redesign' of https://github.com/jmshrv/finamp into main…
Komodo5197 Jan 28, 2024
6a28e66
Enabled offline functionality on new long press go to artist.
Komodo5197 Jan 28, 2024
bbce8d1
Handle paused downloads better. Delay startup for download queue ini…
Komodo5197 Feb 5, 2024
2055a2f
Avoid changing item path if not in notdownloaded state.
Komodo5197 Feb 6, 2024
71f3a14
Merge branch 'redesign' of https://github.com/jmshrv/finamp into main…
Komodo5197 Feb 6, 2024
458738d
Corrected errors with merge. Cleaned up authorization headers. Igno…
Komodo5197 Feb 7, 2024
84c21a5
Added transcoded downloads. This is mostly just a port of the code i…
Komodo5197 Feb 9, 2024
c2511f4
Merge branch 'redesign' of https://github.com/jmshrv/finamp into main…
Komodo5197 Feb 9, 2024
b579f50
Download settings are now properly updated by syncs so that items don…
Komodo5197 Feb 10, 2024
d3243aa
Merge branch 'redesign' of https://github.com/jmshrv/finamp into main…
Komodo5197 Feb 10, 2024
127e0c1
Merge fix.
Komodo5197 Feb 10, 2024
7443fe0
reduce padding of DownloadedItems list expansion tiles
Chaphasilor Feb 10, 2024
7d336f0
Fixed transcode settings propogation issues caused by use of a single…
Komodo5197 Feb 11, 2024
3fe5fff
Merge branch 'main-downloads-rework' of https://github.com/Komodo5197…
Komodo5197 Feb 11, 2024
d7e4de4
Downloads screen padding tweak.
Komodo5197 Feb 11, 2024
6931024
Merge branch 'redesign' of https://github.com/jmshrv/finamp into main…
Komodo5197 Feb 11, 2024
caea382
Merge cleanup.
Komodo5197 Feb 11, 2024
27465cf
Minor UI fixes.
Komodo5197 Feb 11, 2024
75f57ce
update active downloads button icon
Chaphasilor Feb 11, 2024
43e4e7b
Fixed possible issue where multiple download locations could result i…
Komodo5197 Feb 11, 2024
8472202
Merge branch 'redesign' of https://github.com/jmshrv/finamp into main…
Komodo5197 Feb 11, 2024
1def01d
Merge fixes.
Komodo5197 Feb 11, 2024
32ecb1b
Merge branch 'redesign' of https://github.com/jmshrv/finamp into main…
Komodo5197 Feb 14, 2024
7ca0f29
Updated background_downloader to stable.
Komodo5197 Feb 14, 2024
d0b539e
Merge branch 'redesign' of https://github.com/jmshrv/finamp into main…
Komodo5197 Feb 15, 2024
59d9ccd
Got extendbody working without cutting things off. Added shadow to i…
Komodo5197 Feb 15, 2024
659fafa
Removed rectangular playing bar setting.
Komodo5197 Feb 15, 2024
95fa529
Merge branch 'redesign' of https://github.com/jmshrv/finamp into main…
Komodo5197 Feb 16, 2024
116e699
Merge fixes. Upgraded gradle+dependancies after switch to flutter 3.19.
Komodo5197 Feb 16, 2024
255d2a7
code review fixes. Fixed some bugs with offline sorting.
Komodo5197 Feb 17, 2024
7c80734
Code review fixes. Copied playlist ordering code for albums.
Komodo5197 Feb 18, 2024
62b4df4
Code review fixes.
Komodo5197 Feb 18, 2024
eaa9d80
Code review fixes.
Komodo5197 Feb 20, 2024
b07aeca
Exclude Application Support from backups
jmshrv Feb 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
include: package:flutter_lints/flutter.yaml
include: package:flutter_lints/flutter.yaml
linter:
rules:
- unawaited_futures
- always_declare_return_types
- use_if_null_to_convert_nulls_to_bools
analyzer:
plugins:
- custom_lint
26 changes: 9 additions & 17 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -27,12 +28,8 @@ if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 33
compileSdkVersion 34

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -44,8 +41,8 @@ android {

defaultConfig {
applicationId "com.unicornsonlsd.finamp"
minSdkVersion 26
targetSdkVersion 33
minSdkVersion 21
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand All @@ -72,8 +69,3 @@ android {
flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
}
4 changes: 3 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
Expand Down Expand Up @@ -29,7 +30,8 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<service android:name="com.ryanheise.audioservice.AudioService" android:exported="true">
<service android:name="com.ryanheise.audioservice.AudioService" android:foregroundServiceType="mediaPlayback"
android:exported="true">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
Expand Down
13 changes: 0 additions & 13 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
buildscript {
ext.kotlin_version = '1.8.20'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
Expand Down
31 changes: 23 additions & 8 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}
settings.ext.flutterSdkPath = flutterSdkPath()

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.9.10" apply false
}

include ":app"
2 changes: 1 addition & 1 deletion ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>13.0</string>
</dict>
</plist>
12 changes: 10 additions & 2 deletions ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
platform :ios, '12.0'
platform :ios, '13.0'

# Fixing DKImagePickerController Bug
use_modular_headers!
Expand Down Expand Up @@ -43,7 +43,7 @@ post_install do |installer|
flutter_additional_ios_build_settings(target)

target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
end

target.build_configurations.each do |config|
Expand Down Expand Up @@ -93,5 +93,13 @@ post_install do |installer|
]

end

target.build_configurations.each do |config|
config.build_settings['OTHER_SWIFT_FLAGS'] ||= ['$(inherited)']
# Do not need ios photo permissions
#config.build_settings['OTHER_SWIFT_FLAGS'] << '-D BYPASS_PERMISSION_NOTIFICATIONS'
config.build_settings['OTHER_SWIFT_FLAGS'] << '-D BYPASS_PERMISSION_IOSADDTOPHOTOLIBRARY'
config.build_settings['OTHER_SWIFT_FLAGS'] << '-D BYPASS_PERMISSION_IOSCHANGEPHOTOLIBRARY'
end
end
end
9 changes: 0 additions & 9 deletions ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import UIKit
import Flutter
import flutter_downloader

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand All @@ -9,7 +8,6 @@ import flutter_downloader
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
FlutterDownloaderPlugin.setPluginRegistrantCallback(registerPlugins)

// Exclude the documents folder from iCloud backup since we keep songs there.
try! setExcludeFromiCloudBackup(isExcluded: true)
Expand All @@ -24,10 +22,3 @@ private func setExcludeFromiCloudBackup(isExcluded: Bool) throws {
values.isExcludedFromBackup = isExcluded
try fileOrDirectoryURL.setResourceValues(values)
}


private func registerPlugins(registry: FlutterPluginRegistry) {
if (!registry.hasPlugin("FlutterDownloaderPlugin")) {
FlutterDownloaderPlugin.register(with: registry.registrar(forPlugin: "FlutterDownloaderPlugin")!)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ class _CustomDownloadLocationFormState
child: Text(
field.errorText ??
AppLocalizations.of(context)!.unknownError,
style: Theme.of(context)
.textTheme
.bodySmall
?.copyWith(color: Theme.of(context).colorScheme.error),
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).colorScheme.error),
),
),
],
Expand All @@ -109,14 +107,14 @@ class _CustomDownloadLocationFormState
}

// This checks if the chosen directory is empty
if (selectedDirectory!
/*if (selectedDirectory!
.listSync()
.where((event) => !event.path
.replaceFirst(selectedDirectory!.path, "")
.contains("."))
.isNotEmpty) {
return AppLocalizations.of(context)!.directoryMustBeEmpty;
}
}*/
Komodo5197 marked this conversation as resolved.
Show resolved Hide resolved
return null;
},
onSaved: (_) {
Expand Down Expand Up @@ -149,4 +147,4 @@ class _CustomDownloadLocationFormState
),
);
}
}
}
15 changes: 13 additions & 2 deletions lib/components/AddToPlaylistScreen/add_to_playlist_list.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import 'dart:async';

import 'package:finamp/models/finamp_models.dart';
import 'package:finamp/services/downloads_service.dart';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';

import '../../models/jellyfin_models.dart';
import '../../services/jellyfin_api_helper.dart';
import '../MusicScreen/album_item.dart';
import '../error_snackbar.dart';
import '../global_snackbar.dart';

class AddToPlaylistList extends StatefulWidget {
const AddToPlaylistList({
Expand All @@ -28,7 +32,6 @@ class _AddToPlaylistListState extends State<AddToPlaylistList> {
addToPlaylistListFuture = jellyfinApiHelper.getItems(
includeItemTypes: "Playlist",
sortBy: "SortName",
isGenres: false,
);
}

Expand All @@ -52,6 +55,14 @@ class _AddToPlaylistListState extends State<AddToPlaylistList> {
playlistId: snapshot.data![index].id,
ids: [widget.itemToAddId],
);
final downloadsService =
GetIt.instance<DownloadsService>();
unawaited(downloadsService.resync(
DownloadStub.fromItem(
type: DownloadItemType.collection,
item: snapshot.data![index]),
null,
keepSlow: true));

if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:get_it/get_it.dart';

import '../../services/finamp_user_helper.dart';
import '../../services/jellyfin_api_helper.dart';
import '../error_snackbar.dart';
import '../global_snackbar.dart';

class NewPlaylistDialog extends StatefulWidget {
const NewPlaylistDialog({
Expand Down
Loading
Loading