mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 01:01:56 +01:00
fix: Readd permission_handler
with a proper fix
This commit is contained in:
parent
c5ad337daa
commit
9c5b0b9c14
3 changed files with 13 additions and 11 deletions
|
@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_background/flutter_background.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
//import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/models/patch.dart';
|
||||
import 'package:revanced_manager/models/patched_application.dart';
|
||||
|
@ -30,7 +30,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||
bool hasErrors = false;
|
||||
|
||||
Future<void> initialize(BuildContext context) async {
|
||||
if (true /*await Permission.ignoreBatteryOptimizations.isGranted*/) {
|
||||
if (await Permission.ignoreBatteryOptimizations.isGranted) {
|
||||
try {
|
||||
await FlutterBackground.initialize(
|
||||
androidConfig: FlutterBackgroundAndroidConfig(
|
||||
|
@ -122,7 +122,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||
hasErrors = true;
|
||||
update(-1.0, 'Aborting...', 'No app or patches selected! Aborting');
|
||||
}
|
||||
if (true /*await Permission.ignoreBatteryOptimizations.isGranted*/) {
|
||||
if (await Permission.ignoreBatteryOptimizations.isGranted) {
|
||||
try {
|
||||
await FlutterBackground.disableBackgroundExecution();
|
||||
} on Exception {
|
||||
|
|
|
@ -3,7 +3,7 @@ import 'package:dynamic_themes/dynamic_themes.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
//import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:revanced_manager/services/root_api.dart';
|
||||
import 'package:revanced_manager/ui/views/home/home_view.dart';
|
||||
import 'package:revanced_manager/ui/views/patcher/patcher_view.dart';
|
||||
|
@ -15,6 +15,14 @@ import 'package:stacked/stacked.dart';
|
|||
class NavigationViewModel extends IndexTrackingViewModel {
|
||||
void initialize(BuildContext context) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
if (prefs.getBool('permissionsRequested') == null) {
|
||||
await prefs.setBool('permissionsRequested', true);
|
||||
RootAPI().hasRootPermissions().then(
|
||||
(value) => Permission.requestInstallPackages.request().then(
|
||||
(value) => Permission.ignoreBatteryOptimizations.request(),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (prefs.getBool('useDarkTheme') == null) {
|
||||
bool isDark =
|
||||
MediaQuery.of(context).platformBrightness != Brightness.light;
|
||||
|
@ -31,12 +39,6 @@ class NavigationViewModel extends IndexTrackingViewModel {
|
|||
: Brightness.light,
|
||||
),
|
||||
);
|
||||
//if (prefs.getBool('permissionsRequested') == null) {
|
||||
//await prefs.setBool('permissionsRequested', true);
|
||||
RootAPI().hasRootPermissions();
|
||||
//Permission.requestInstallPackages.request();
|
||||
//Permission.ignoreBatteryOptimizations.request();
|
||||
//}
|
||||
}
|
||||
|
||||
Widget getViewForIndex(int index) {
|
||||
|
|
|
@ -52,7 +52,7 @@ dependencies:
|
|||
ref: feature/nullSafe
|
||||
package_info_plus: ^1.4.3+1
|
||||
path_provider: ^2.0.11
|
||||
#permission_handler: ^10.0.0
|
||||
permission_handler: ^10.0.0
|
||||
pull_to_refresh: ^2.0.0
|
||||
root: ^2.0.2
|
||||
share_extend: ^2.0.0
|
||||
|
|
Loading…
Reference in a new issue