mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2026-01-27 13:01:02 +00:00
feat: root installation (wip)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/widgets/I18nText.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/ui/views/root_checker/root_checker_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/widgets/magisk_button.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
@@ -11,8 +12,9 @@ class RootCheckerView extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<RootCheckerViewModel>.reactive(
|
||||
disposeViewModel: false,
|
||||
onModelReady: (model) => model.initialize,
|
||||
viewModelBuilder: () => RootCheckerViewModel(),
|
||||
viewModelBuilder: () => locator<RootCheckerViewModel>(),
|
||||
builder: (context, model, child) => Scaffold(
|
||||
floatingActionButton: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
@@ -64,15 +66,20 @@ class RootCheckerView extends StatelessWidget {
|
||||
const SizedBox(height: 170),
|
||||
MagiskButton(
|
||||
onPressed: () {
|
||||
model.getMagiskPermissions();
|
||||
Future.delayed(const Duration(seconds: 5), () {
|
||||
model.checkRoot();
|
||||
});
|
||||
model
|
||||
.getMagiskPermissions()
|
||||
.then((value) => model.checkRoot());
|
||||
},
|
||||
),
|
||||
Text(
|
||||
"Magisk permission granted: ${model.isRooted.toString()}",
|
||||
style: GoogleFonts.poppins(),
|
||||
I18nText(
|
||||
'rootCheckerView.grantedPermission',
|
||||
translationParams: {
|
||||
'isRooted': model.isRooted.toString(),
|
||||
},
|
||||
child: Text(
|
||||
'',
|
||||
style: GoogleFonts.poppins(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/app/app.router.dart';
|
||||
import 'package:revanced_manager/ui/views/home/home_view.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:root/root.dart';
|
||||
@@ -18,21 +16,25 @@ class RootCheckerViewModel extends BaseViewModel {
|
||||
|
||||
Future<void> checkRoot() async {
|
||||
isRooted = await Root.isRooted();
|
||||
if (isRooted == true) {
|
||||
navigateToHome();
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> getMagiskPermissions() async {
|
||||
if (isRooted == true) {
|
||||
Fluttertoast.showToast(msg: 'Magisk permission already granted!');
|
||||
Future<bool> getMagiskPermissions() async {
|
||||
try {
|
||||
await Root.exec(cmd: 'cat /proc/version');
|
||||
} on Exception {
|
||||
return false;
|
||||
}
|
||||
await Root.exec(cmd: "adb shell su -c exit");
|
||||
notifyListeners();
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<void> navigateToHome() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
prefs.setBool('showHome', true);
|
||||
_navigationService.navigateTo(Routes.homeView);
|
||||
prefs.setBool('isRooted', isRooted!);
|
||||
_navigationService.navigateTo(Routes.navigation);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user