feat: option to delete temporary directory.

This commit is contained in:
Aunali321 2022-10-17 00:41:20 +05:30
parent f5ebfc92fc
commit 3b8dc66da6
4 changed files with 33 additions and 1 deletions

View File

@ -139,7 +139,10 @@
"restartAppForChanges": "Restart the app to apply changes",
"deleteKeystoreLabel": "Delete keystore",
"deleteKeystoreHint": "Delete the keystore used to sign the app",
"deletedKeystore": "Keystore deleted"
"deletedKeystore": "Keystore deleted",
"deleteTempDirLabel": "Delete temp directory",
"deleteTempDirHint": "Delete the temporary directory used to store temporary files",
"deletedTempDir": "Temp directory deleted"
},
"appInfoView": {
"widgetTitle": "App Info",

View File

@ -98,6 +98,13 @@ class ManagerAPI {
await _prefs.setBool('crashlyticsEnabled', value);
}
Future<void> deleteTempFolder() async {
final Directory dir = Directory('/data/local/tmp/revanced-manager');
if (await dir.exists()) {
await dir.delete(recursive: true);
}
}
Future<void> deleteKeystore() async {
final File keystore = File(
'/sdcard/Android/data/app.revanced.manager.flutter/files/revanced-keystore.keystore');

View File

@ -152,6 +152,22 @@ class SettingsView extends StatelessWidget {
subtitle: I18nText('settingsView.deleteKeystoreHint'),
onTap: () => model.deleteKeystore,
),
ListTile(
contentPadding:
const EdgeInsets.symmetric(horizontal: 20.0),
title: I18nText(
'settingsView.deleteTempDirLabel',
child: const Text(
'',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
),
subtitle: I18nText('settingsView.deleteTempDirHint'),
onTap: () => model.deleteTempDir(),
),
],
),
_settingsDivider,

View File

@ -343,6 +343,12 @@ class SettingsViewModel extends BaseViewModel {
notifyListeners();
}
void deleteTempDir() {
_managerAPI.deleteTempFolder();
_toast.showBottom('settingsView.deletedTempDir');
notifyListeners();
}
Future<int> getSdkVersion() async {
AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo;
return info.version.sdkInt ?? -1;