mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 01:01:56 +01:00
fix: Uninstall button should always be shown
This commit is contained in:
parent
733190e76c
commit
3d25655851
2 changed files with 54 additions and 52 deletions
|
@ -104,52 +104,50 @@ class AppInfoView extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
if (app.isRooted)
|
||||
VerticalDivider(
|
||||
color: Theme.of(context).canvasColor,
|
||||
indent: 12.0,
|
||||
endIndent: 12.0,
|
||||
width: 1.0,
|
||||
),
|
||||
if (app.isRooted)
|
||||
Expanded(
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
onTap: () => model.showUninstallDialog(
|
||||
context,
|
||||
app,
|
||||
false,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
Icons.delete_outline,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
I18nText(
|
||||
'appInfoView.uninstallButton',
|
||||
child: Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
VerticalDivider(
|
||||
color: Theme.of(context).canvasColor,
|
||||
indent: 12.0,
|
||||
endIndent: 12.0,
|
||||
width: 1.0,
|
||||
),
|
||||
Expanded(
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
onTap: () => model.showUninstallDialog(
|
||||
context,
|
||||
app,
|
||||
false,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
Icons.delete_outline,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
I18nText(
|
||||
'appInfoView.uninstallButton',
|
||||
child: Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
VerticalDivider(
|
||||
color: Theme.of(context).canvasColor,
|
||||
indent: 12.0,
|
||||
|
|
|
@ -20,20 +20,26 @@ class AppInfoViewModel extends BaseViewModel {
|
|||
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
|
||||
final RootAPI _rootAPI = RootAPI();
|
||||
|
||||
Future<void> uninstallApp(PatchedApplication app, bool onlyUnpatch) async {
|
||||
Future<void> uninstallApp(
|
||||
BuildContext context,
|
||||
PatchedApplication app,
|
||||
bool onlyUnpatch,
|
||||
) async {
|
||||
bool isUninstalled = true;
|
||||
if (app.isRooted) {
|
||||
bool hasRootPermissions = await _rootAPI.hasRootPermissions();
|
||||
if (hasRootPermissions) {
|
||||
_rootAPI.deleteApp(app.packageName, app.apkFilePath);
|
||||
_managerAPI.deletePatchedApp(app);
|
||||
await _rootAPI.deleteApp(app.packageName, app.apkFilePath);
|
||||
if (!onlyUnpatch) {
|
||||
DeviceApps.uninstallApp(app.packageName);
|
||||
await DeviceApps.uninstallApp(app.packageName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DeviceApps.uninstallApp(app.packageName).then(
|
||||
(value) => _managerAPI.deletePatchedApp(app),
|
||||
);
|
||||
isUninstalled = await DeviceApps.uninstallApp(app.packageName);
|
||||
}
|
||||
if (isUninstalled) {
|
||||
await _managerAPI.deletePatchedApp(app);
|
||||
locator<HomeViewModel>().initialize(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,8 +93,7 @@ class AppInfoViewModel extends BaseViewModel {
|
|||
CustomMaterialButton(
|
||||
label: I18nText('yesButton'),
|
||||
onPressed: () {
|
||||
uninstallApp(app, onlyUnpatch);
|
||||
locator<HomeViewModel>().initialize(context);
|
||||
uninstallApp(context, app, onlyUnpatch);
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
|
@ -97,8 +102,7 @@ class AppInfoViewModel extends BaseViewModel {
|
|||
),
|
||||
);
|
||||
} else {
|
||||
uninstallApp(app, onlyUnpatch);
|
||||
locator<HomeViewModel>().initialize(context);
|
||||
uninstallApp(context, app, onlyUnpatch);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue