From cdb492910c0a1968c69f10840eab2224e7417f40 Mon Sep 17 00:00:00 2001 From: Alberto Ponces Date: Wed, 14 Sep 2022 23:40:08 +0100 Subject: [PATCH] fix: Update package name if MicroG was applied --- lib/models/patched_application.dart | 2 +- lib/ui/views/installer/installer_viewmodel.dart | 7 +++++++ lib/ui/views/navigation/navigation_viewmodel.dart | 2 -- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/models/patched_application.dart b/lib/models/patched_application.dart index 35066087..aa89133e 100644 --- a/lib/models/patched_application.dart +++ b/lib/models/patched_application.dart @@ -7,7 +7,7 @@ part 'patched_application.g.dart'; @JsonSerializable() class PatchedApplication { String name; - final String packageName; + String packageName; String version; final String apkFilePath; @JsonKey( diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index 176502c2..89c59f77 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -142,6 +142,13 @@ class InstallerViewModel extends BaseViewModel { update(1.0, 'Installed!', 'Installed!'); _app.patchDate = DateTime.now(); _app.appliedPatches = _patches.map((p) => p.name).toList(); + bool hasMicroG = _patches.any((p) => p.name.endsWith('microg-support')); + if (hasMicroG) { + _app.packageName = _app.packageName.replaceFirst( + 'com.google.', + 'app.revanced.', + ); + } await _managerAPI.savePatchedApp(_app); } } diff --git a/lib/ui/views/navigation/navigation_viewmodel.dart b/lib/ui/views/navigation/navigation_viewmodel.dart index 5434b78a..1226bcfd 100644 --- a/lib/ui/views/navigation/navigation_viewmodel.dart +++ b/lib/ui/views/navigation/navigation_viewmodel.dart @@ -1,6 +1,4 @@ // ignore_for_file: use_build_context_synchronously -import 'package:app_installer/app_installer.dart'; -import 'package:device_apps/device_apps.dart'; import 'package:dynamic_themes/dynamic_themes.dart'; import 'package:flutter/material.dart'; import 'package:injectable/injectable.dart';