mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 01:01:56 +01:00
fix: Add Unpatch option on App Info view
This commit is contained in:
parent
e74fce8574
commit
ef3685c817
3 changed files with 80 additions and 25 deletions
|
@ -121,8 +121,11 @@
|
|||
"openButton": "Open",
|
||||
"uninstallButton": "Uninstall",
|
||||
"patchButton": "Patch",
|
||||
"unpatchButton": "Unpatch",
|
||||
"uninstallDialogTitle": "Uninstall",
|
||||
"uninstallDialogText": "Are you sure you want to uninstall this app?",
|
||||
"unpatchDialogTitle": "Unpatch",
|
||||
"unpatchDialogText": "Are you sure you want to unpatch this app?",
|
||||
"rootDialogTitle": "Error",
|
||||
"rootDialogText": "App was installed with root mode enabled but currently root mode is disabled.\nPlease enable root mode first.",
|
||||
"packageNameLabel": "Package Name",
|
||||
|
|
|
@ -64,7 +64,7 @@ class AppInfoView extends StatelessWidget {
|
|||
CustomCard(
|
||||
child: IntrinsicHeight(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
InkWell(
|
||||
onTap: () => model.openApp(app),
|
||||
|
@ -96,8 +96,11 @@ class AppInfoView extends StatelessWidget {
|
|||
color: Theme.of(context).canvasColor,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () =>
|
||||
model.showUninstallAlertDialog(context, app),
|
||||
onTap: () => model.showUninstallAlertDialog(
|
||||
context,
|
||||
app,
|
||||
false,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
|
@ -154,6 +157,45 @@ class AppInfoView extends StatelessWidget {
|
|||
],
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: app.isRooted,
|
||||
child: VerticalDivider(
|
||||
color: Theme.of(context).canvasColor,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: app.isRooted,
|
||||
child: InkWell(
|
||||
onTap: () => model.showUninstallAlertDialog(
|
||||
context,
|
||||
app,
|
||||
true,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
Icons.settings_backup_restore_outlined,
|
||||
color:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
I18nText(
|
||||
'appInfoView.unpatchButton',
|
||||
child: Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -19,12 +19,15 @@ class AppInfoViewModel extends BaseViewModel {
|
|||
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
|
||||
final RootAPI _rootAPI = RootAPI();
|
||||
|
||||
Future<void> uninstallApp(PatchedApplication app) async {
|
||||
Future<void> uninstallApp(PatchedApplication app, bool onlyUnpatch) async {
|
||||
if (app.isRooted) {
|
||||
bool hasRootPermissions = await _rootAPI.hasRootPermissions();
|
||||
if (hasRootPermissions) {
|
||||
_rootAPI.deleteApp(app.packageName, app.apkFilePath);
|
||||
_managerAPI.deletePatchedApp(app);
|
||||
if (!onlyUnpatch) {
|
||||
DeviceApps.uninstallApp(app.packageName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DeviceApps.uninstallApp(app.packageName);
|
||||
|
@ -43,32 +46,39 @@ class AppInfoViewModel extends BaseViewModel {
|
|||
Future<void> showUninstallAlertDialog(
|
||||
BuildContext context,
|
||||
PatchedApplication app,
|
||||
bool onlyUnpatch,
|
||||
) async {
|
||||
if (app.isRooted) {
|
||||
bool hasRootPermissions = await _rootAPI.hasRootPermissions();
|
||||
if (!hasRootPermissions) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: I18nText('appInfoView.rootDialogTitle'),
|
||||
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
||||
content: I18nText('appInfoView.rootDialogText'),
|
||||
actions: <Widget>[
|
||||
CustomMaterialButton(
|
||||
label: I18nText('okButton'),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
bool hasRootPermissions = await _rootAPI.hasRootPermissions();
|
||||
if (app.isRooted && !hasRootPermissions) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: I18nText('appInfoView.rootDialogTitle'),
|
||||
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
||||
content: I18nText('appInfoView.rootDialogText'),
|
||||
actions: <Widget>[
|
||||
CustomMaterialButton(
|
||||
label: I18nText('okButton'),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: I18nText('appInfoView.uninstallDialogTitle'),
|
||||
title: I18nText(
|
||||
onlyUnpatch
|
||||
? 'appInfoView.unpatchDialogTitle'
|
||||
: 'appInfoView.uninstallDialogTitle',
|
||||
),
|
||||
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
||||
content: I18nText('appInfoView.uninstallDialogText'),
|
||||
content: I18nText(
|
||||
onlyUnpatch
|
||||
? 'appInfoView.unpatchDialogText'
|
||||
: 'appInfoView.uninstallDialogText',
|
||||
),
|
||||
actions: <Widget>[
|
||||
CustomMaterialButton(
|
||||
isFilled: false,
|
||||
|
@ -78,7 +88,7 @@ class AppInfoViewModel extends BaseViewModel {
|
|||
CustomMaterialButton(
|
||||
label: I18nText('okButton'),
|
||||
onPressed: () {
|
||||
uninstallApp(app);
|
||||
uninstallApp(app, onlyUnpatch);
|
||||
locator<HomeViewModel>().initialize(context);
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
|
|
Loading…
Reference in a new issue