Skip to content

Commit

Permalink
Merge pull request #568 from Komodo5197/main-downloads-rework
Browse files Browse the repository at this point in the history
[Redesign] Downloads Storage Rewrite
  • Loading branch information
Chaphasilor authored Feb 20, 2024
2 parents c931dd9 + b07aeca commit e09bbde
Show file tree
Hide file tree
Showing 122 changed files with 14,781 additions and 6,606 deletions.
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
38 changes: 29 additions & 9 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ PODS:
- Flutter
- audio_session (0.0.1):
- Flutter
- background_downloader (0.0.1):
- Flutter
- CropViewController (2.6.1)
- device_info_plus (0.0.1):
- Flutter
Expand Down Expand Up @@ -59,18 +61,24 @@ PODS:
- DKImagePickerController/PhotoGallery
- Flutter
- Flutter (1.0.0)
- flutter_downloader (0.0.1):
- flutter_to_airplay (0.0.1):
- Flutter
- Mux-Stats-AVPlayer
- flutter_vibrate (0.0.1):
- Flutter
- isar_flutter_libs (1.0.0):
- Flutter
- just_audio (0.0.1):
- Flutter
- Mux-Stats-AVPlayer (3.5.1):
- Mux-Stats-Core (= 4.6.0)
- Mux-Stats-Core (4.6.0)
- package_info_plus (0.4.5):
- Flutter
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- permission_handler_apple (9.1.1):
- permission_handler_apple (9.3.0):
- Flutter
- SDWebImage (5.18.2):
- SDWebImage/Core (= 5.18.2)
Expand All @@ -85,12 +93,14 @@ PODS:
DEPENDENCIES:
- audio_service (from `.symlinks/plugins/audio_service/ios`)
- audio_session (from `.symlinks/plugins/audio_session/ios`)
- background_downloader (from `.symlinks/plugins/background_downloader/ios`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- DKImagePickerController (= 4.3.4)
- file_picker (from `.symlinks/plugins/file_picker/ios`)
- Flutter (from `Flutter`)
- flutter_downloader (from `.symlinks/plugins/flutter_downloader/ios`)
- flutter_to_airplay (from `.symlinks/plugins/flutter_to_airplay/ios`)
- flutter_vibrate (from `.symlinks/plugins/flutter_vibrate/ios`)
- isar_flutter_libs (from `.symlinks/plugins/isar_flutter_libs/ios`)
- just_audio (from `.symlinks/plugins/just_audio/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
Expand All @@ -104,6 +114,8 @@ SPEC REPOS:
- DKCamera
- DKImagePickerController
- DKPhotoGallery
- Mux-Stats-AVPlayer
- Mux-Stats-Core
- SDWebImage
- SwiftyGif

Expand All @@ -112,16 +124,20 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/audio_service/ios"
audio_session:
:path: ".symlinks/plugins/audio_session/ios"
background_downloader:
:path: ".symlinks/plugins/background_downloader/ios"
device_info_plus:
:path: ".symlinks/plugins/device_info_plus/ios"
file_picker:
:path: ".symlinks/plugins/file_picker/ios"
Flutter:
:path: Flutter
flutter_downloader:
:path: ".symlinks/plugins/flutter_downloader/ios"
flutter_to_airplay:
:path: ".symlinks/plugins/flutter_to_airplay/ios"
flutter_vibrate:
:path: ".symlinks/plugins/flutter_vibrate/ios"
isar_flutter_libs:
:path: ".symlinks/plugins/isar_flutter_libs/ios"
just_audio:
:path: ".symlinks/plugins/just_audio/ios"
package_info_plus:
Expand All @@ -138,24 +154,28 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
audio_service: f509d65da41b9521a61f1c404dd58651f265a567
audio_session: 4f3e461722055d21515cf3261b64c973c062f345
background_downloader: 9f788ffc5de45acf87d6380e91ca0841066c18cf
CropViewController: 58fb440f30dac788b129d2a1f24cffdcb102669c
device_info_plus: c6fb39579d0f423935b0c9ce7ee2f44b71b9fce6
DKCamera: a902b66921fca14b7a75266feb8c7568aa7caa71
DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
file_picker: ce3938a0df3cc1ef404671531facef740d03f920
file_picker: 15fd9539e4eb735dc54bae8c0534a7a9511a03de
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_downloader: b7301ae057deadd4b1650dc7c05375f10ff12c39
flutter_to_airplay: 3194fe6e4ca6ba1d9529c3c4194c32b9610d990f
flutter_vibrate: 9f4c2ab57008965f78969472367c329dd77eb801
isar_flutter_libs: b69f437aeab9c521821c3f376198c4371fa21073
just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa
Mux-Stats-AVPlayer: 1b1a877e5d8b57ca22e0717fa0a4eefef7529c40
Mux-Stats-Core: 53902e414f077b2239ea10d909a4cf072c0d4d5c
package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
permission_handler_apple: 036b856153a2b1f61f21030ff725f3e6fece2b78
SDWebImage: c0de394d7cf7f9838aed1fd6bb6037654a4572e4
share_plus: c3fef564749587fc939ef86ffb283ceac0baf9f5
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f

PODFILE CHECKSUM: 2129ec44a346995e229add1d94a10fae8b953738
PODFILE CHECKSUM: 047c0919aa274fcdf0ce568f883473a4587eda02

COCOAPODS: 1.13.0
2 changes: 1 addition & 1 deletion ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
47 changes: 24 additions & 23 deletions ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
import UIKit
import Flutter
import flutter_downloader

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
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)

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)

// Exclude the documents and support folders from iCloud backup since we keep songs there.
try! setExcludeFromiCloudBackup(
try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true),
isExcluded: true
)

try! setExcludeFromiCloudBackup(
try! FileManager.default.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true),
isExcluded: true
)

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}

private func setExcludeFromiCloudBackup(isExcluded: Bool) throws {
var fileOrDirectoryURL = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
private func setExcludeFromiCloudBackup(_ dir: URL, isExcluded: Bool) throws {
// Awkwardly make a mutable copy of the dir
var mutableDir = dir

var values = URLResourceValues()
values.isExcludedFromBackup = isExcluded
try fileOrDirectoryURL.setResourceValues(values)
}


private func registerPlugins(registry: FlutterPluginRegistry) {
if (!registry.hasPlugin("FlutterDownloaderPlugin")) {
FlutterDownloaderPlugin.register(with: registry.registrar(forPlugin: "FlutterDownloaderPlugin")!)
}
try mutableDir.setResourceValues(values)
}
Loading

0 comments on commit e09bbde

Please sign in to comment.