Skip to content

Commit

Permalink
fix: Do not hardcode any predefined packages
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Sep 29, 2023
1 parent 15b8613 commit 2e8e3b0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 61 deletions.
4 changes: 0 additions & 4 deletions assets/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
11 changes: 0 additions & 11 deletions lib/services/github_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ class GithubAPI {
priority: CachePriority.high,
);

final Map<String, String> 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<void> initialize(String repoUrl) async {
try {
_dio = Dio(
Expand Down
43 changes: 8 additions & 35 deletions lib/ui/views/installer/installer_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -270,34 +270,6 @@ class InstallerViewModel extends BaseViewModel {
Future<void> 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: <Widget>[
CustomMaterialButton(
label: I18nText('okButton'),
onPressed: () => Navigator.of(context).pop(),
),
],
),
);
} else {
update(
1.0,
'Installing...',
Expand All @@ -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);
Expand Down
12 changes: 1 addition & 11 deletions lib/ui/widgets/appInfoView/app_info_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,7 @@ class AppInfoViewModel extends BaseViewModel {
}

String getAppliedPatchesString(List<String> appliedPatches) {
final List<String> 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) {
Expand Down

0 comments on commit 2e8e3b0

Please sign in to comment.