From f927abcd151bae808aef9859e0481bbb6cc8d3c6 Mon Sep 17 00:00:00 2001 From: Dhruvan Bhalara <53393418+dhruvanbhalara@users.noreply.github.com> Date: Fri, 1 Dec 2023 20:13:03 +0530 Subject: [PATCH] refactor: pass `MIME` type while exporting the patched APK (#1541) --- lib/services/patcher_api.dart | 15 ++++++++------- lib/ui/views/settings/settings_viewmodel.dart | 14 +++++++------- pubspec.yaml | 4 ---- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/lib/services/patcher_api.dart b/lib/services/patcher_api.dart index 14cf2e26d7..65f5ecc095 100644 --- a/lib/services/patcher_api.dart +++ b/lib/services/patcher_api.dart @@ -1,10 +1,10 @@ import 'dart:io'; import 'package:collection/collection.dart'; -import 'package:cr_file_saver/file_saver.dart'; import 'package:device_apps/device_apps.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_file_dialog/flutter_file_dialog.dart'; import 'package:injectable/injectable.dart'; import 'package:install_plugin/install_plugin.dart'; import 'package:path_provider/path_provider.dart'; @@ -236,10 +236,11 @@ void exportPatchedFile(String appName, String version) { try { if (outFile != null) { final String newName = _getFileName(appName, version); - CRFileSaver.saveFileWithDialog( - SaveFileDialogParams( + FlutterFileDialog.saveFile( + params: SaveFileDialogParams( sourceFilePath: outFile!.path, - destinationFileName: newName, + fileName: newName, + mimeTypesFilter: ['application/vnd.android.package-archive'], ), ); } @@ -286,10 +287,10 @@ Future exportPatcherLog(String logs) async { final String fileName = 'revanced-manager_patcher_$dateTime.txt'; final File log = File('${logDir.path}/$fileName'); log.writeAsStringSync(logs); - CRFileSaver.saveFileWithDialog( - SaveFileDialogParams( + FlutterFileDialog.saveFile( + params:SaveFileDialogParams( sourceFilePath: log.path, - destinationFileName: fileName, + fileName: fileName, ), ); } diff --git a/lib/ui/views/settings/settings_viewmodel.dart b/lib/ui/views/settings/settings_viewmodel.dart index 6aa2a262fa..29368425d6 100644 --- a/lib/ui/views/settings/settings_viewmodel.dart +++ b/lib/ui/views/settings/settings_viewmodel.dart @@ -1,8 +1,8 @@ import 'dart:io'; -import 'package:cr_file_saver/file_saver.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_file_dialog/flutter_file_dialog.dart' hide SaveFileDialogParams; +import 'package:flutter_file_dialog/flutter_file_dialog.dart'; import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:logcat/logcat.dart'; import 'package:path_provider/path_provider.dart'; @@ -210,10 +210,10 @@ class SettingsViewModel extends BaseViewModel { if (outFile.existsSync()) { final String dateTime = DateTime.now().toString().replaceAll(' ', '_').split('.').first; - await CRFileSaver.saveFileWithDialog( - SaveFileDialogParams( + await FlutterFileDialog.saveFile( + params: SaveFileDialogParams( sourceFilePath: outFile.path, - destinationFileName: 'selected_patches_$dateTime.json', + fileName: 'selected_patches_$dateTime.json', ), ); _toast.showBottom('settingsView.exportedPatches'); @@ -261,10 +261,10 @@ class SettingsViewModel extends BaseViewModel { if (outFile.existsSync()) { final String dateTime = DateTime.now().toString().replaceAll(' ', '_').split('.').first; - await CRFileSaver.saveFileWithDialog( - SaveFileDialogParams( + await FlutterFileDialog.saveFile( + params: SaveFileDialogParams( sourceFilePath: outFile.path, - destinationFileName: 'keystore_$dateTime.keystore', + fileName: 'keystore_$dateTime.keystore', ), ); _toast.showBottom('settingsView.exportedKeystore'); diff --git a/pubspec.yaml b/pubspec.yaml index 0b70c3d3a7..b10e340091 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -79,10 +79,6 @@ dependencies: synchronized: ^3.1.0 connectivity_plus: ^5.0.1 flutter_file_dialog: ^3.0.2 - cr_file_saver: - git: - url: https://github.com/dhruvanbhalara/cr_file_saver - ref: d07417d2a0078a2715ac70a65edddbfe286d0282 wakelock_plus: ^1.1.3 share_plus: ^7.2.1