diff --git a/android/app/build.gradle b/android/app/build.gradle index ade5350c..4749530e 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -52,6 +52,8 @@ android { buildTypes { release { + shrinkResources false + minifyEnabled false signingConfig signingConfigs.debug } } diff --git a/android/app/src/main/jniLibs/arm64-v8a/aapt.so b/android/app/src/main/jniLibs/arm64-v8a/libaapt.so similarity index 100% rename from android/app/src/main/jniLibs/arm64-v8a/aapt.so rename to android/app/src/main/jniLibs/arm64-v8a/libaapt.so diff --git a/android/app/src/main/jniLibs/x86/aapt2.so b/android/app/src/main/jniLibs/x86/libaapt2.so similarity index 100% rename from android/app/src/main/jniLibs/x86/aapt2.so rename to android/app/src/main/jniLibs/x86/libaapt2.so diff --git a/android/app/src/main/kotlin/app/revanced/manager/MainActivity.kt b/android/app/src/main/kotlin/app/revanced/manager/MainActivity.kt index d8714fcf..334c5954 100644 --- a/android/app/src/main/kotlin/app/revanced/manager/MainActivity.kt +++ b/android/app/src/main/kotlin/app/revanced/manager/MainActivity.kt @@ -121,7 +121,7 @@ class MainActivity : FlutterActivity() { path, DexClassLoader( path, - context.cacheDir.path, + applicationContext.cacheDir.path, null, javaClass.classLoader ) @@ -180,7 +180,7 @@ class MainActivity : FlutterActivity() { fun createPatcher(inputFilePath: String, cacheDirPath: String): Boolean { val inputFile = File(inputFilePath) - val aaptPath = Aapt.binary(context).absolutePath + val aaptPath = Aapt.binary(applicationContext).absolutePath patcher = Patcher(PatcherOptions(inputFile, cacheDirPath, true, aaptPath, cacheDirPath)) return true } diff --git a/lib/app/app.locator.dart b/lib/app/app.locator.dart index 6a44d2ab..8a5d9aab 100644 --- a/lib/app/app.locator.dart +++ b/lib/app/app.locator.dart @@ -4,11 +4,11 @@ // StackedLocatorGenerator // ************************************************************************** -// ignore_for_file: public_member_api_docs, depend_on_referenced_packages, implementation_imports +// ignore_for_file: public_member_api_docs, depend_on_referenced_packages import 'package:stacked_core/stacked_core.dart'; -import 'package:stacked_services/src/navigation/navigation_service.dart'; -import 'package:stacked_themes/src/theme_service.dart'; +import 'package:stacked_services/stacked_services.dart'; +import 'package:stacked_themes/stacked_themes.dart'; import '../services/patcher_api.dart'; import '../ui/views/app_selector/app_selector_viewmodel.dart'; diff --git a/lib/app/app.router.dart b/lib/app/app.router.dart index 3a618c20..1d074b86 100644 --- a/lib/app/app.router.dart +++ b/lib/app/app.router.dart @@ -4,165 +4,176 @@ // StackedRouterGenerator // ************************************************************************** -// ignore_for_file: no_leading_underscores_for_library_prefixes, implementation_imports -import 'package:flutter/material.dart'; -import 'package:flutter/src/foundation/key.dart' as _i7; -import 'package:stacked/stacked.dart' as _i1; -import 'package:stacked_services/stacked_services.dart' as _i8; +// ignore_for_file: public_member_api_docs, unused_import, non_constant_identifier_names -import '../ui/views/app_selector/app_selector_view.dart' as _i2; -import '../ui/views/contributors/contributors_view.dart' as _i6; -import '../ui/views/installer/installer_view.dart' as _i4; -import '../ui/views/patches_selector/patches_selector_view.dart' as _i3; -import '../ui/views/settings/settings_view.dart' as _i5; +import 'package:flutter/material.dart'; +import 'package:stacked/stacked.dart'; +import 'package:stacked_services/stacked_services.dart'; + +import '../ui/views/app_selector/app_selector_view.dart'; +import '../ui/views/contributors/contributors_view.dart'; +import '../ui/views/installer/installer_view.dart'; +import '../ui/views/patches_selector/patches_selector_view.dart'; +import '../ui/views/settings/settings_view.dart'; class Routes { - static const appSelectorView = '/app-selector-view'; - - static const patchesSelectorView = '/patches-selector-view'; - - static const installerView = '/installer-view'; - - static const settingsView = '/settings-view'; - - static const contributorsView = '/contributors-view'; - + static const String appSelectorView = '/app-selector-view'; + static const String patchesSelectorView = '/patches-selector-view'; + static const String installerView = '/installer-view'; + static const String settingsView = '/settings-view'; + static const String contributorsView = '/contributors-view'; static const all = { appSelectorView, patchesSelectorView, installerView, settingsView, - contributorsView + contributorsView, }; } -class StackedRouter extends _i1.RouterBase { - final _routes = <_i1.RouteDef>[ - _i1.RouteDef(Routes.appSelectorView, page: _i2.AppSelectorView), - _i1.RouteDef(Routes.patchesSelectorView, page: _i3.PatchesSelectorView), - _i1.RouteDef(Routes.installerView, page: _i4.InstallerView), - _i1.RouteDef(Routes.settingsView, page: _i5.SettingsView), - _i1.RouteDef(Routes.contributorsView, page: _i6.ContributorsView) +class StackedRouter extends RouterBase { + @override + List get routes => _routes; + final _routes = [ + RouteDef(Routes.appSelectorView, page: AppSelectorView), + RouteDef(Routes.patchesSelectorView, page: PatchesSelectorView), + RouteDef(Routes.installerView, page: InstallerView), + RouteDef(Routes.settingsView, page: SettingsView), + RouteDef(Routes.contributorsView, page: ContributorsView), ]; - - final _pagesMap = { - _i2.AppSelectorView: (data) { + @override + Map get pagesMap => _pagesMap; + final _pagesMap = { + AppSelectorView: (data) { return MaterialPageRoute( - builder: (context) => const _i2.AppSelectorView(), + builder: (context) => const AppSelectorView(), settings: data, ); }, - _i3.PatchesSelectorView: (data) { + PatchesSelectorView: (data) { return MaterialPageRoute( - builder: (context) => const _i3.PatchesSelectorView(), + builder: (context) => const PatchesSelectorView(), settings: data, ); }, - _i4.InstallerView: (data) { - final args = data.getArgs( - orElse: () => const InstallerViewArguments(), + InstallerView: (data) { + var args = data.getArgs( + orElse: () => InstallerViewArguments(), ); return MaterialPageRoute( - builder: (context) => _i4.InstallerView(key: args.key), + builder: (context) => InstallerView(key: args.key), settings: data, ); }, - _i5.SettingsView: (data) { + SettingsView: (data) { return MaterialPageRoute( - builder: (context) => const _i5.SettingsView(), + builder: (context) => const SettingsView(), settings: data, ); }, - _i6.ContributorsView: (data) { + ContributorsView: (data) { return MaterialPageRoute( - builder: (context) => const _i6.ContributorsView(), + builder: (context) => const ContributorsView(), settings: data, ); - } + }, }; - - @override - List<_i1.RouteDef> get routes => _routes; - @override - Map get pagesMap => _pagesMap; } +/// ************************************************************************ +/// Arguments holder classes +/// ************************************************************************* + +/// InstallerView arguments holder class class InstallerViewArguments { - const InstallerViewArguments({this.key}); - - final _i7.Key? key; + final Key? key; + InstallerViewArguments({this.key}); } -extension NavigatorStateExtension on _i8.NavigationService { - Future navigateToAppSelectorView( - [int? routerId, - bool preventDuplicates = true, - Map? parameters, - Widget Function( - BuildContext, Animation, Animation, Widget)? - transition]) async { - navigateTo(Routes.appSelectorView, - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition); +/// ************************************************************************ +/// Extension for strongly typed navigation +/// ************************************************************************* + +extension NavigatorStateExtension on NavigationService { + Future navigateToAppSelectorView({ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + }) async { + return navigateTo( + Routes.appSelectorView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition, + ); } - Future navigateToPatchesSelectorView( - [int? routerId, - bool preventDuplicates = true, - Map? parameters, - Widget Function( - BuildContext, Animation, Animation, Widget)? - transition]) async { - navigateTo(Routes.patchesSelectorView, - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition); + Future navigateToPatchesSelectorView({ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + }) async { + return navigateTo( + Routes.patchesSelectorView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition, + ); } - Future navigateToInstallerView( - {_i7.Key? key, - int? routerId, - bool preventDuplicates = true, - Map? parameters, - Widget Function( - BuildContext, Animation, Animation, Widget)? - transition}) async { - navigateTo(Routes.installerView, - arguments: InstallerViewArguments(key: key), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition); + Future navigateToInstallerView({ + Key? key, + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + }) async { + return navigateTo( + Routes.installerView, + arguments: InstallerViewArguments(key: key), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition, + ); } - Future navigateToSettingsView( - [int? routerId, - bool preventDuplicates = true, - Map? parameters, - Widget Function( - BuildContext, Animation, Animation, Widget)? - transition]) async { - navigateTo(Routes.settingsView, - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition); + Future navigateToSettingsView({ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + }) async { + return navigateTo( + Routes.settingsView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition, + ); } - Future navigateToContributorsView( - [int? routerId, - bool preventDuplicates = true, - Map? parameters, - Widget Function( - BuildContext, Animation, Animation, Widget)? - transition]) async { - navigateTo(Routes.contributorsView, - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition); + Future navigateToContributorsView({ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + }) async { + return navigateTo( + Routes.contributorsView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition, + ); } } diff --git a/lib/services/patcher_api.dart b/lib/services/patcher_api.dart index b722e183..96925e7a 100644 --- a/lib/services/patcher_api.dart +++ b/lib/services/patcher_api.dart @@ -44,16 +44,16 @@ class PatcherAPI { String? dexFileUrl = await githubAPI.latestRelease('revanced', 'revanced-patches'); if (dexFileUrl != null && dexFileUrl.isNotEmpty) { - _patchBundleFile = - await DefaultCacheManager().getSingleFile(dexFileUrl); try { + _patchBundleFile = + await DefaultCacheManager().getSingleFile(dexFileUrl); return await platform.invokeMethod( 'loadPatches', { 'pathBundlesPaths': [_patchBundleFile!.absolute.path], }, ); - } on PlatformException { + } on Exception { _patchBundleFile = null; return false; } @@ -81,7 +81,7 @@ class PatcherAPI { } } } - } on PlatformException { + } on Exception { _filteredPackages.clear(); return List.empty(); } @@ -122,7 +122,7 @@ class PatcherAPI { } } } - } on PlatformException { + } on Exception { _filteredPatches[selectedApp.packageName]!.clear(); return List.empty(); } @@ -171,7 +171,7 @@ class PatcherAPI { 'inputFilePath': _inputFile!.path, }, ); - } on PlatformException { + } on Exception { return false; } } @@ -188,7 +188,7 @@ class PatcherAPI { 'cacheDirPath': _cacheDir!.path, }, ); - } on PlatformException { + } on Exception { return false; } } @@ -203,7 +203,7 @@ class PatcherAPI { 'integrationsPath': _integrations!.path, }, ); - } on PlatformException { + } on Exception { return false; } } @@ -216,7 +216,7 @@ class PatcherAPI { 'selectedPatches': selectedPatches.map((e) => e.name).toList(), }, ); - } on PlatformException { + } on Exception { return false; } } @@ -231,7 +231,7 @@ class PatcherAPI { 'patchedFilePath': _patchedFile!.path, }, ); - } on PlatformException { + } on Exception { return false; } } @@ -248,7 +248,7 @@ class PatcherAPI { 'outFilePath': _outFile!.path, }, ); - } on PlatformException { + } on Exception { return false; } } @@ -277,9 +277,11 @@ class PatcherAPI { } } - bool sharePatchedFile(String packageName) { + bool sharePatchedFile(String appName, String version) { if (_outFile != null) { - String sharePath = '${_outFile!.parent.path}/$packageName.revanced.apk'; + String path = _outFile!.parent.path; + String prefix = appName.toLowerCase().replaceAll(' ', '-'); + String sharePath = '$path/$prefix-revanced_v$version.apk'; File share = _outFile!.copySync(sharePath); ShareExtend.share(share.path, "file"); return true; diff --git a/lib/ui/views/app_selector/app_selector_viewmodel.dart b/lib/ui/views/app_selector/app_selector_viewmodel.dart index fdd1c4f7..93a4eada 100644 --- a/lib/ui/views/app_selector/app_selector_viewmodel.dart +++ b/lib/ui/views/app_selector/app_selector_viewmodel.dart @@ -9,6 +9,7 @@ import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/models/application_info.dart'; import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; +import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart'; import 'package:stacked/stacked.dart'; class AppSelectorViewModel extends BaseViewModel { @@ -34,6 +35,7 @@ class AppSelectorViewModel extends BaseViewModel { apkFilePath: application.apkFilePath, ); locator().selectedApp = app; + locator().selectedPatches.clear(); locator().dimPatchCard = false; locator().notifyListeners(); } @@ -55,6 +57,7 @@ class AppSelectorViewModel extends BaseViewModel { apkFilePath: result.files.single.path!, ); locator().selectedApp = app; + locator().selectedPatches.clear(); locator().dimPatchCard = false; locator().notifyListeners(); } diff --git a/lib/ui/views/home/home_view.dart b/lib/ui/views/home/home_view.dart index dfe5db15..551f0c48 100644 --- a/lib/ui/views/home/home_view.dart +++ b/lib/ui/views/home/home_view.dart @@ -23,15 +23,6 @@ class HomeView extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Align( - alignment: Alignment.topRight, - child: IconButton( - onPressed: () => {}, - icon: const Icon( - Icons.more_vert, - ), - ), - ), const SizedBox(height: 60), I18nText( 'homeView.widgetTitle', diff --git a/lib/ui/views/installer/installer_view.dart b/lib/ui/views/installer/installer_view.dart index 5543b386..a90c7058 100644 --- a/lib/ui/views/installer/installer_view.dart +++ b/lib/ui/views/installer/installer_view.dart @@ -75,7 +75,10 @@ class InstallerView extends StatelessWidget { child: SelectableText( model.logs, style: const TextStyle( - fontFamily: 'monospace', fontSize: 15), + fontFamily: 'monospace', + fontSize: 15, + height: 1.5, + ), ), ), const Spacer(), @@ -133,6 +136,7 @@ class InstallerView extends StatelessWidget { ), onWillPop: () async { if (!model.isPatching) { + model.cleanWorkplace(); Navigator.of(context).pop(); } return false; diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index 32728f06..34507825 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -3,6 +3,7 @@ import 'package:revanced_manager/models/application_info.dart'; import 'package:revanced_manager/models/patch.dart'; import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/ui/views/app_selector/app_selector_viewmodel.dart'; +import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart'; import 'package:stacked/stacked.dart'; @@ -43,7 +44,7 @@ class InstallerViewModel extends BaseViewModel { List selectedPatches = locator().selectedPatches; if (selectedPatches.isNotEmpty) { - addLog('Initializing patcher...'); + addLog('Initializing installer...'); bool? isSuccess = await locator().initPatcher(); if (isSuccess != null && isSuccess) { addLog('Done'); @@ -108,7 +109,17 @@ class InstallerViewModel extends BaseViewModel { void shareResult() { ApplicationInfo? selectedApp = locator().selectedApp; if (selectedApp != null) { - locator().sharePatchedFile(selectedApp.packageName); + locator().sharePatchedFile( + selectedApp.name, + selectedApp.version, + ); } } + + void cleanWorkplace() { + locator().cleanPatcher(); + locator().selectedApp = null; + locator().selectedPatches.clear(); + locator().notifyListeners(); + } } diff --git a/lib/ui/widgets/app_selector_card.dart b/lib/ui/widgets/app_selector_card.dart index 21ef4d1b..990676d9 100644 --- a/lib/ui/widgets/app_selector_card.dart +++ b/lib/ui/widgets/app_selector_card.dart @@ -45,7 +45,7 @@ class AppSelectorCard extends StatelessWidget { const SizedBox(height: 10), locator().selectedApp != null ? Text( - locator().selectedApp!.packageName, + locator().selectedApp!.name, style: robotoTextStyle, ) : I18nText( diff --git a/lib/ui/widgets/contributors_card.dart b/lib/ui/widgets/contributors_card.dart index fe79bc4e..6d755fd0 100644 --- a/lib/ui/widgets/contributors_card.dart +++ b/lib/ui/widgets/contributors_card.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:github/github.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:revanced_manager/constants.dart'; import 'package:url_launcher/url_launcher.dart'; class ContributorsCard extends StatefulWidget {