Skip to content

Commit

Permalink
Merge pull request #126 from TheRedSpy15/development
Browse files Browse the repository at this point in the history
IOS tweaks
  • Loading branch information
TheRedSpy15 committed Mar 7, 2024
2 parents 4873b8f + ab7ab35 commit f1f9ac6
Show file tree
Hide file tree
Showing 39 changed files with 53 additions and 18 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-hdpi/launcher_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-mdpi/launcher_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xhdpi/launcher_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ SPEC CHECKSUMS:
SDWebImage: a3ba0b8faac7228c3c8eadd1a55c9c9fe5e16457
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812
url_launcher_ios: 6116280ddcfe98ab8820085d8d76ae7449447586
workmanager: 0afdcf5628bbde6924c21af7836fed07b42e30e6

PODFILE CHECKSUM: a57f30d18f102dd3ce366b1d62a55ecbef2158e5
Expand Down
14 changes: 14 additions & 0 deletions ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,27 @@ import workmanager

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
/// Registers all pubspec-referenced Flutter plugins in the given registry.
static func registerPlugins(with registry: FlutterPluginRegistry) {
GeneratedPluginRegistrant.register(with: registry)
}

override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
WorkmanagerPlugin.registerBGProcessingTask(withIdentifier: "download-task")
WorkmanagerPlugin.registerBGProcessingTask(withIdentifier: "upload-task")

WorkmanagerPlugin.setPluginRegistrantCallback { registry in
// The following code will be called upon WorkmanagerPlugin's registration.
// Note : all of the app's plugins may not be required in this context ;
// instead of using GeneratedPluginRegistrant.register(with: registry),
// you may want to register only specific plugins.
AppDelegate.registerPlugins(with: registry)
}

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,7 @@
</array>
<key>UISupportsDocumentBrowser</key>
<true/>
<key>NSPhotoLibraryUsageDescription</key>
<string>Allows access to your photos for uploading</string>
</dict>
</plist>
5 changes: 4 additions & 1 deletion ios/Runner/Runner.entitlements
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
<dict>
<key>aps-environment</key>
<string>development</string>
</dict>
</plist>
17 changes: 14 additions & 3 deletions lib/controllers/download_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ class DownloadController {
});
}

void addDownloadToOfflineQueue(String fileKey) {
static void addDownloadToOfflineQueue(String fileKey) {
SharedPreferences.getInstance().then((prefs) {
final offlineQueue = prefs.getStringList('offlineQueue') ?? [];
offlineQueue.add(jsonEncode({
'fileKey': fileKey,
'date': DateTime.now().millisecondsSinceEpoch,
}));
prefs.setStringList('offlineQueue', offlineQueue);
logger.i('Added download to offline queue: $fileKey ($offlineQueue)');
});
}

Expand Down Expand Up @@ -88,17 +89,27 @@ class DownloadController {
}

static Future<DownloadItem?> getOldestPlannedDownload() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
final offlineQueue = prefs.getStringList('offlineQueue') ?? [];
List<String> offlineQueue = [];
SharedPreferences prefs;
try {
prefs = await SharedPreferences.getInstance();
offlineQueue = prefs.getStringList('offlineQueue') ?? [];
} catch (error) {
logger.e('Error getting SharedPreferences: $error');
}

if (offlineQueue.isEmpty) {
logger.i('No planned downloads');
return null;
}
logger.i('Planned downloads: $offlineQueue');

final oldest = offlineQueue
.map((e) => jsonDecode(e))
.cast<Map<String, dynamic>>()
.toList()
..sort((a, b) => a['date'].compareTo(b['date']));
logger.i('Oldest planned download: ${oldest.first}');
return DownloadItem(oldest.first['fileKey'], oldest.first['date']);
}

Expand Down
9 changes: 7 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ void callbackDispatcher() {
logger.t("Native called background task: $task");

if (task == "download-task") {
return await DownloadController.startQueuedDownload(
inputData?['uid'], inputData?['token'], inputData?['exportDir']);
try {
return await DownloadController.startQueuedDownload(
inputData?['uid'], inputData?['token'], inputData?['exportDir']);
} catch (e) {
logger.e("Error starting download: $e");
return Future.value(false);
}
} else if (task == "upload-task") {
return await UploadController.processUploadQueue(
inputData?['uid'],
Expand Down
16 changes: 8 additions & 8 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ packages:
dependency: "direct main"
description:
name: file_picker
sha256: "4e42aacde3b993c5947467ab640882c56947d9d27342a5b6f2895b23956954a6"
sha256: caa6bc229eab3e32eb2f37b53a5f9d22a6981474afd210c512a7546c1e1a04f6
url: "https://pub.dev"
source: hosted
version: "6.1.1"
version: "6.2.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -258,10 +258,10 @@ packages:
dependency: "direct main"
description:
name: flutter_local_notifications
sha256: c18f1de98fe0bb9dd5ba91e1330d4febc8b6a7de6aae3ffe475ef423723e72f3
sha256: "55b9b229307a10974b26296ff29f2e132256ba4bd74266939118eaefa941cb00"
url: "https://pub.dev"
source: hosted
version: "16.3.2"
version: "16.3.3"
flutter_local_notifications_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -497,10 +497,10 @@ packages:
dependency: "direct main"
description:
name: logger
sha256: "6bbb9d6f7056729537a4309bda2e74e18e5d9f14302489cc1e93f33b3fe32cac"
sha256: b3ff55aeb08d9d8901b767650285872cb1bb8f508373b3e348d60268b0c7f770
url: "https://pub.dev"
source: hosted
version: "2.0.2+1"
version: "2.1.0"
logging:
dependency: transitive
description:
Expand Down Expand Up @@ -934,8 +934,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "73cc539cd2f1b992b468e6c44f5d0a7919d7ffda"
resolved-ref: "73cc539cd2f1b992b468e6c44f5d0a7919d7ffda"
ref: f3e717b0d875296e8bec619965dd73283a54c6e5
resolved-ref: f3e717b0d875296e8bec619965dd73283a54c6e5
url: "https://github.com/absar/flutter_workmanager.git"
source: git
version: "0.5.2"
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
# format: x.x.x+x0x0x
version: 1.3.6+10306
version: 1.3.7+10307

environment:
sdk: '>=3.1.2 <4.0.0'
Expand Down Expand Up @@ -54,7 +54,7 @@ dependencies:
workmanager:
git:
url: https://github.com/absar/flutter_workmanager.git
ref: 73cc539cd2f1b992b468e6c44f5d0a7919d7ffda
ref: f3e717b0d875296e8bec619965dd73283a54c6e5
local_auth: ^2.1.7
intl: ^0.18.1
flutter_localizations:
Expand All @@ -80,7 +80,7 @@ flutter_launcher_icons:
android: "launcher_icon"
adaptive_icon_background: "#000000"
adaptive_icon_foreground: "assets/icon/icon.png"
ios: false
ios: true
image_path: "assets/icon/icon.png"
min_sdk_android: 21 # android min sdk min:16, default 21

Expand Down

0 comments on commit f1f9ac6

Please sign in to comment.