mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 09:07:47 +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",
|
"openButton": "Open",
|
||||||
"uninstallButton": "Uninstall",
|
"uninstallButton": "Uninstall",
|
||||||
"patchButton": "Patch",
|
"patchButton": "Patch",
|
||||||
|
"unpatchButton": "Unpatch",
|
||||||
"uninstallDialogTitle": "Uninstall",
|
"uninstallDialogTitle": "Uninstall",
|
||||||
"uninstallDialogText": "Are you sure you want to uninstall this app?",
|
"uninstallDialogText": "Are you sure you want to uninstall this app?",
|
||||||
|
"unpatchDialogTitle": "Unpatch",
|
||||||
|
"unpatchDialogText": "Are you sure you want to unpatch this app?",
|
||||||
"rootDialogTitle": "Error",
|
"rootDialogTitle": "Error",
|
||||||
"rootDialogText": "App was installed with root mode enabled but currently root mode is disabled.\nPlease enable root mode first.",
|
"rootDialogText": "App was installed with root mode enabled but currently root mode is disabled.\nPlease enable root mode first.",
|
||||||
"packageNameLabel": "Package Name",
|
"packageNameLabel": "Package Name",
|
||||||
|
|
|
@ -64,7 +64,7 @@ class AppInfoView extends StatelessWidget {
|
||||||
CustomCard(
|
CustomCard(
|
||||||
child: IntrinsicHeight(
|
child: IntrinsicHeight(
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () => model.openApp(app),
|
onTap: () => model.openApp(app),
|
||||||
|
@ -96,8 +96,11 @@ class AppInfoView extends StatelessWidget {
|
||||||
color: Theme.of(context).canvasColor,
|
color: Theme.of(context).canvasColor,
|
||||||
),
|
),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () =>
|
onTap: () => model.showUninstallAlertDialog(
|
||||||
model.showUninstallAlertDialog(context, app),
|
context,
|
||||||
|
app,
|
||||||
|
false,
|
||||||
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: <Widget>[
|
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 PatcherAPI _patcherAPI = locator<PatcherAPI>();
|
||||||
final RootAPI _rootAPI = RootAPI();
|
final RootAPI _rootAPI = RootAPI();
|
||||||
|
|
||||||
Future<void> uninstallApp(PatchedApplication app) async {
|
Future<void> uninstallApp(PatchedApplication app, bool onlyUnpatch) async {
|
||||||
if (app.isRooted) {
|
if (app.isRooted) {
|
||||||
bool hasRootPermissions = await _rootAPI.hasRootPermissions();
|
bool hasRootPermissions = await _rootAPI.hasRootPermissions();
|
||||||
if (hasRootPermissions) {
|
if (hasRootPermissions) {
|
||||||
_rootAPI.deleteApp(app.packageName, app.apkFilePath);
|
_rootAPI.deleteApp(app.packageName, app.apkFilePath);
|
||||||
_managerAPI.deletePatchedApp(app);
|
_managerAPI.deletePatchedApp(app);
|
||||||
|
if (!onlyUnpatch) {
|
||||||
|
DeviceApps.uninstallApp(app.packageName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DeviceApps.uninstallApp(app.packageName);
|
DeviceApps.uninstallApp(app.packageName);
|
||||||
|
@ -43,10 +46,10 @@ class AppInfoViewModel extends BaseViewModel {
|
||||||
Future<void> showUninstallAlertDialog(
|
Future<void> showUninstallAlertDialog(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
PatchedApplication app,
|
PatchedApplication app,
|
||||||
|
bool onlyUnpatch,
|
||||||
) async {
|
) async {
|
||||||
if (app.isRooted) {
|
|
||||||
bool hasRootPermissions = await _rootAPI.hasRootPermissions();
|
bool hasRootPermissions = await _rootAPI.hasRootPermissions();
|
||||||
if (!hasRootPermissions) {
|
if (app.isRooted && !hasRootPermissions) {
|
||||||
return showDialog(
|
return showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => AlertDialog(
|
builder: (context) => AlertDialog(
|
||||||
|
@ -61,14 +64,21 @@ class AppInfoViewModel extends BaseViewModel {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return showDialog(
|
return showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => AlertDialog(
|
builder: (context) => AlertDialog(
|
||||||
title: I18nText('appInfoView.uninstallDialogTitle'),
|
title: I18nText(
|
||||||
|
onlyUnpatch
|
||||||
|
? 'appInfoView.unpatchDialogTitle'
|
||||||
|
: 'appInfoView.uninstallDialogTitle',
|
||||||
|
),
|
||||||
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
||||||
content: I18nText('appInfoView.uninstallDialogText'),
|
content: I18nText(
|
||||||
|
onlyUnpatch
|
||||||
|
? 'appInfoView.unpatchDialogText'
|
||||||
|
: 'appInfoView.uninstallDialogText',
|
||||||
|
),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
CustomMaterialButton(
|
CustomMaterialButton(
|
||||||
isFilled: false,
|
isFilled: false,
|
||||||
|
@ -78,7 +88,7 @@ class AppInfoViewModel extends BaseViewModel {
|
||||||
CustomMaterialButton(
|
CustomMaterialButton(
|
||||||
label: I18nText('okButton'),
|
label: I18nText('okButton'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
uninstallApp(app);
|
uninstallApp(app, onlyUnpatch);
|
||||||
locator<HomeViewModel>().initialize(context);
|
locator<HomeViewModel>().initialize(context);
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
Loading…
Reference in a new issue