chore: Merge branch dev to main (#2092)

This commit is contained in:
aAbed 2024-07-30 02:22:56 +05:45 committed by GitHub
commit 5bc7b135d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 55 deletions

View file

@ -38,8 +38,6 @@ class ManagerAPI {
bool releaseBuild = false;
bool suggestedAppVersionSelected = true;
bool isDynamicThemeAvailable = false;
bool isScopedStorageAvailable = false;
int sdkVersion = 0;
String storedPatchesFile = '/selected-patches.json';
String keystoreFile =
'/sdcard/Android/data/app.revanced.manager.flutter/files/revanced-manager.keystore';
@ -57,13 +55,8 @@ class ManagerAPI {
Future<void> initialize() async {
_prefs = await SharedPreferences.getInstance();
isRooted = await _rootAPI.isRooted();
if (sdkVersion == 0) {
sdkVersion = await getSdkVersion();
}
isDynamicThemeAvailable =
sdkVersion >= 31; // ANDROID_12_SDK_VERSION = 31
isScopedStorageAvailable =
sdkVersion >= 30; // ANDROID_11_SDK_VERSION = 30
(await getSdkVersion()) >= 31; // ANDROID_12_SDK_VERSION = 31
storedPatchesFile =
(await getApplicationDocumentsDirectory()).path + storedPatchesFile;
if (kReleaseMode) {

View file

@ -1,11 +1,8 @@
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:revanced_manager/app/app.locator.dart';
import 'package:flutter_file_dialog/flutter_file_dialog.dart';
import 'package:revanced_manager/gen/strings.g.dart';
import 'package:revanced_manager/models/patch.dart';
import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/ui/views/patch_options/patch_options_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
@ -401,7 +398,6 @@ class TextFieldForPatchOption extends StatefulWidget {
}
class _TextFieldForPatchOptionState extends State<TextFieldForPatchOption> {
final ManagerAPI _managerAPI = locator<ManagerAPI>();
final TextEditingController controller = TextEditingController();
String? selectedKey;
String? defaultValue;
@ -528,49 +524,29 @@ class _TextFieldForPatchOptionState extends State<TextFieldForPatchOption> {
];
},
onSelected: (String selection) async {
// manageExternalStorage permission is required for file/folder selection
// otherwise, the app will not complain, but the patches will error out
// the same way as if the user selected an empty file/folder.
// Android 11 and above requires the manageExternalStorage permission
final Map<String, dynamic> availableActions = {
t.patchOptionsView.selectFilePath: () async {
if (_managerAPI.isScopedStorageAvailable) {
final permission =
await Permission.manageExternalStorage.request();
if (!permission.isGranted) {
return;
}
switch (selection) {
case 'file':
final String? result = await FlutterFileDialog.pickFile();
if (result != null) {
controller.text = result;
widget.onChanged(controller.text);
}
final FilePickerResult? result =
await FilePicker.platform.pickFiles();
if (result == null) {
return;
break;
case 'folder':
final DirectoryLocation? result =
await FlutterFileDialog.pickDirectory();
if (result != null) {
controller.text = result.toString();
widget.onChanged(controller.text);
}
controller.text = result.files.single.path!;
widget.onChanged(controller.text);
},
t.patchOptionsView.selectFolder: () async {
if (_managerAPI.isScopedStorageAvailable) {
final permission =
await Permission.manageExternalStorage.request();
if (!permission.isGranted) {
return;
}
}
final String? result =
await FilePicker.platform.getDirectoryPath();
if (result == null) {
return;
}
controller.text = result;
widget.onChanged(controller.text);
},
t.remove: () {
break;
case 'remove':
widget.removeValue!();
},
};
if (availableActions.containsKey(selection)) {
await availableActions[selection]!();
break;
case 'null':
controller.text = '';
widget.onChanged(null);
break;
}
},
),

View file

@ -4,7 +4,7 @@ homepage: https://github.com/ReVanced/revanced-manager
publish_to: 'none'
version: 1.21.0+101800026
version: 1.21.1-dev.1+101800027
environment:
sdk: '>=3.0.0 <4.0.0'
@ -23,7 +23,6 @@ dependencies:
dynamic_color: ^1.7.0
dynamic_themes: ^1.1.0
expandable: ^5.0.1
file_picker: ^8.0.3
flutter:
sdk: flutter
flutter_background: