From 2e8e3b0d1ec4396796e264501ca6dbf1c615a878 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 29 Sep 2023 20:12:39 +0200 Subject: [PATCH] fix: Do not hardcode any predefined packages --- assets/i18n/en_US.json | 4 -- lib/services/github_api.dart | 11 ----- .../views/installer/installer_viewmodel.dart | 43 ++++--------------- .../appInfoView/app_info_viewmodel.dart | 12 +----- 4 files changed, 9 insertions(+), 61 deletions(-) diff --git a/assets/i18n/en_US.json b/assets/i18n/en_US.json index 571888cf..25945796 100644 --- a/assets/i18n/en_US.json +++ b/assets/i18n/en_US.json @@ -159,10 +159,6 @@ "exportApkButtonTooltip": "Export patched APK", "exportLogButtonTooltip": "Export log", - "installErrorDialogTitle": "Error", - "installErrorDialogText1": "Root install is not possible with the current patches selection.\nRepatch your app or choose non-root install.", - "installErrorDialogText2": "Non-root install is not possible with the current patches selection.\nRepatch your app or choose root install if you have your device rooted.", - "installErrorDialogText3": "Root install is not possible as the original APK was selected from storage.\nSelect an installed app or choose non-root install.", "noExit": "Installer is still running, cannot exit..." }, "settingsView": { diff --git a/lib/services/github_api.dart b/lib/services/github_api.dart index 5f393daf..442b3ee6 100644 --- a/lib/services/github_api.dart +++ b/lib/services/github_api.dart @@ -21,17 +21,6 @@ class GithubAPI { priority: CachePriority.high, ); - final Map repoAppPath = { - 'com.google.android.youtube': 'youtube', - 'com.google.android.apps.youtube.music': 'music', - 'com.twitter.android': 'twitter', - 'com.reddit.frontpage': 'reddit', - 'com.zhiliaoapp.musically': 'tiktok', - 'de.dwd.warnapp': 'warnwetter', - 'com.garzotto.pflotsh.ecmwf_a': 'ecmwf', - 'com.spotify.music': 'spotify', - }; - Future initialize(String repoUrl) async { try { _dio = Dio( diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index f523f2a0..2245cab7 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -270,34 +270,6 @@ class InstallerViewModel extends BaseViewModel { Future installResult(BuildContext context, bool installAsRoot) async { try { _app.isRooted = installAsRoot; - final bool hasMicroG = - _patches.any((p) => p.name.endsWith('MicroG support')); - final bool rootMicroG = installAsRoot && hasMicroG; - final bool rootFromStorage = installAsRoot && _app.isFromStorage; - final bool ytWithoutRootMicroG = - !installAsRoot && !hasMicroG && _app.packageName.contains('youtube'); - if (rootMicroG || rootFromStorage || ytWithoutRootMicroG) { - return showDialog( - context: context, - builder: (context) => AlertDialog( - title: I18nText('installerView.installErrorDialogTitle'), - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, - content: I18nText( - rootMicroG - ? 'installerView.installErrorDialogText1' - : rootFromStorage - ? 'installerView.installErrorDialogText3' - : 'installerView.installErrorDialogText2', - ), - actions: [ - CustomMaterialButton( - label: I18nText('okButton'), - onPressed: () => Navigator.of(context).pop(), - ), - ], - ), - ); - } else { update( 1.0, 'Installing...', @@ -311,16 +283,17 @@ class InstallerViewModel extends BaseViewModel { _app.isFromStorage = false; _app.patchDate = DateTime.now(); _app.appliedPatches = _patches.map((p) => p.name).toList(); - if (hasMicroG) { - _app.name += ' ReVanced'; - _app.packageName = _app.packageName.replaceFirst( - 'com.google.', - 'app.revanced.', - ); + + // In case a patch changed the app name or package name, + // update the app info. + final app = await DeviceApps.getAppFromStorage(_app.apkFilePath); + if (app != null) { + _app.name = app.appName; + _app.packageName = app.packageName; } + await _managerAPI.savePatchedApp(_app); } - } } on Exception catch (e) { if (kDebugMode) { print(e); diff --git a/lib/ui/widgets/appInfoView/app_info_viewmodel.dart b/lib/ui/widgets/appInfoView/app_info_viewmodel.dart index dd364c7d..69b3f68b 100644 --- a/lib/ui/widgets/appInfoView/app_info_viewmodel.dart +++ b/lib/ui/widgets/appInfoView/app_info_viewmodel.dart @@ -147,17 +147,7 @@ class AppInfoViewModel extends BaseViewModel { } String getAppliedPatchesString(List appliedPatches) { - final List names = appliedPatches - .map( - (p) => p - .replaceAll('-', ' ') - .split('-') - .join(' ') - .toTitleCase() - .replaceFirst('Microg', 'MicroG'), - ) - .toList(); - return '\u2022 ${names.join('\n\u2022 ')}'; + return '\u2022 ${appliedPatches.join('\n\u2022 ')}'; } void openApp(PatchedApplication app) {