Compare commits

...

46 Commits

Author SHA1 Message Date
Alberto Ponces
ed9038ffe8 build: Bump version to v0.0.14 2022-09-19 01:47:51 +01:00
Alberto Ponces
269a71d336 fix: Improve foreground service init and disable 2022-09-19 01:46:12 +01:00
Alberto Ponces
9405334a7d fix: Fix multiple APK shares 2022-09-19 01:45:24 +01:00
Alberto Ponces
2f14746124 feat: Add install error dialogs to prevent faulty installations 2022-09-19 01:44:27 +01:00
Alberto Ponces
6c2ceed91f fix: Improve API URL handling and force init after setting a new config 2022-09-19 00:28:26 +01:00
Alberto Ponces
c333fa3c33 fix: Prefer Yes/No instead of OK/Cancel on a few dialogs 2022-09-18 22:53:04 +01:00
Alberto Ponces
79d0396630 fix: No need for an uninstall confirmation dialog as OS already handles this 2022-09-18 22:47:24 +01:00
Unknown
110c3326bd fix: navigation bar color (#197) 2022-09-18 22:20:08 +01:00
Alberto Ponces
9c5b0b9c14 fix: Readd permission_handler with a proper fix 2022-09-18 22:13:29 +01:00
Aunali321
c5ad337daa feat: Custom api endpoints. (#216)
Co-authored-by: Alberto Ponces <ponces26@gmail.com>
2022-09-18 23:12:30 +05:30
Aunali321
a9f64e449b refactor: basic prerequisites in readme. 2022-09-18 23:01:12 +05:30
Unknown
48f0bc625d feat: animate switching updates on HomeView (#209) 2022-09-18 16:49:18 +01:00
Aunali321
4c6b93320f build: Bump bump version to v0.0.13 2022-09-18 12:22:39 +05:30
Aunali321
2f3bb6cfe4 refactor: better wording. 2022-09-18 12:18:47 +05:30
oSumAtrIX
0e1fa1a5d6 build: bump patcher dependency 2022-09-18 08:38:03 +02:00
Alberto Ponces
38fb3444e4 build: Bump version to v0.0.12 2022-09-18 05:07:12 +01:00
Alberto Ponces
f10b5aebac fix: Decrease app name space a bit to prevent overflowing 2022-09-18 05:06:51 +01:00
Alberto Ponces
5a3884e159 fix: Fix uninstall apps 2022-09-18 05:06:23 +01:00
Alberto Ponces
41ac2b0df8 build: Bump version to v0.0.11 2022-09-18 04:47:23 +01:00
Alberto Ponces
52e7d76c9d fix: Fix spacing of App Info buttons 2022-09-18 04:46:21 +01:00
Alberto Ponces
3aa80cacc0 fix: Fix duplicate entries on non-root installations 2022-09-18 04:44:44 +01:00
Alberto Ponces
dd52c379b4 fix: Show updatable app item only on updatable apps listing 2022-09-18 04:12:33 +01:00
Alberto Ponces
5d073bddf2 fix: Minor i18n typo 2022-09-18 03:41:16 +01:00
Alberto Ponces
7d09169c06 build: Bump version to v0.0.10 2022-09-18 03:35:32 +01:00
Alberto Ponces
ce6f11f3f2 feat: Show recommendation version when possible 2022-09-18 03:14:48 +01:00
Alberto Ponces
d0fb6ac3c0 fix: Ignore empty results on root installed apps listing 2022-09-18 02:41:11 +01:00
Alberto Ponces
ae801a2918 fix: Fix apps reassess on root 2022-09-18 01:54:25 +01:00
Alberto Ponces
257fd46e27 fix: Improve quality of launcher and splash icons 2022-09-18 01:23:21 +01:00
Alberto Ponces
bb96c3ed63 fix: Make sure aapt lib gets extracted to native lib dir during install 2022-09-17 22:54:38 +01:00
Alberto Ponces
6bd218277d build: Bump version to v0.0.9 2022-09-17 19:40:44 +01:00
Alberto Ponces
83ad7605c4 fix: Minor improvements on App Info view 2022-09-17 19:30:04 +01:00
Alberto Ponces
5fbc8ff7a0 feat: Retrieve unsaved apps from manager's root folder and known packages from user's apps list 2022-09-17 19:29:46 +01:00
Alberto Ponces
bb4b59eee6 Disable permission_handler package for now 2022-09-17 17:42:29 +01:00
Aunali321
4cfb620d63 build: Bump version to v0.0.8. 2022-09-17 20:58:19 +05:30
Aunali321
55739a9c78 fix: background should be more opaque. 2022-09-17 20:56:44 +05:30
Alberto Ponces
482599bb4e fix: Do not import dart:html 2022-09-17 14:59:23 +01:00
Alberto Ponces
3aaf49fee0 fix: Only init foreground service if user allowed IGNORE_BATTERY_OPTIMIZATIONS permission 2022-09-17 14:55:00 +01:00
Alberto Ponces
0424ee235c build: Bump patcher dependency version 2022-09-17 14:51:09 +01:00
Alberto Ponces
a178afce99 fix: Fix typo on menu options visibility 2022-09-17 14:47:03 +01:00
Alberto Ponces
ef3685c817 fix: Add Unpatch option on App Info view 2022-09-17 14:45:43 +01:00
Alberto Ponces
e74fce8574 Merge branch 'flutter' of github.com:revanced/revanced-manager into flutter 2022-09-17 14:42:58 +01:00
Aunali321
73e4ae1416 build: restrict manager to android 8. 2022-09-17 16:14:24 +03:00
afnzmn
bcf3b36b13 feat: tweak UI 2022-09-17 16:13:41 +03:00
Alberto Ponces
9c3626c8ed fix: Request permissions a single time at boot 2022-09-16 17:29:32 +01:00
Alberto Ponces
a3dca8c142 fix: Add build mode to about widget 2022-09-16 16:39:57 +01:00
Alberto Ponces
ef0c59f693 fix: Surround isRooted with a try/catch just to be safe 2022-09-16 16:39:37 +01:00
42 changed files with 668 additions and 229 deletions

View File

@@ -13,3 +13,7 @@ If you wish to discuss the Manager, a thread has been made under the [#chat](htt
## ⚠️ Disclaimer ## ⚠️ Disclaimer
*Please note that even though we're releasing the Manager, it is an ALPHA version. Meaning there's a big chance that the Manager might not work at all for you.* *Please note that even though we're releasing the Manager, it is an ALPHA version. Meaning there's a big chance that the Manager might not work at all for you.*
## Prerequisites
1. Android 8 or higher.
2. For YouTube and YouTube Music - Vanced MicroG(Only for non-root).

View File

@@ -44,7 +44,7 @@ android {
defaultConfig { defaultConfig {
applicationId "app.revanced.manager.flutter" applicationId "app.revanced.manager.flutter"
minSdkVersion 21 minSdkVersion 26
targetSdkVersion 33 targetSdkVersion 33
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName
@@ -71,7 +71,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// ReVanced // ReVanced
implementation "app.revanced:revanced-patcher:4.4.0" implementation "app.revanced:revanced-patcher:4.4.2"
// Signing & aligning // Signing & aligning
implementation("org.bouncycastle:bcpkix-jdk15on:1.70") implementation("org.bouncycastle:bcpkix-jdk15on:1.70")

View File

@@ -1,21 +1,23 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="app.revanced.manager.flutter"> package="app.revanced.manager.flutter">
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" /> <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" /> <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" /> <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" /> <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application <application
android:label="ReVanced Manager" android:label="ReVanced Manager"
android:name="${applicationName}" android:name="${applicationName}"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:largeHeap="true"> android:largeHeap="true"
android:extractNativeLibs="true">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true" android:exported="true"

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_launcher_round</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_launcher_round</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>

View File

@@ -3,8 +3,8 @@
"cancelButton": "Cancel", "cancelButton": "Cancel",
"enabledLabel": "Enabled", "enabledLabel": "Enabled",
"disabledLabel": "Disabled", "disabledLabel": "Disabled",
"yesLabel": "Yes", "yesButton": "Yes",
"noLabel": "No", "noButton": "No",
"navigationView": { "navigationView": {
"dashboardTab": "Dashboard", "dashboardTab": "Dashboard",
"patcherTab": "Patcher", "patcherTab": "Patcher",
@@ -25,7 +25,7 @@
"downloadingMessage": "Downloading update!", "downloadingMessage": "Downloading update!",
"installingMessage": "Installing update... Hang on!", "installingMessage": "Installing update... Hang on!",
"errorDownloadMessage": "Unable to download update!", "errorDownloadMessage": "Unable to download update!",
"errorInstallMessage": "Unable to download update!", "errorInstallMessage": "Unable to install update!",
"noConnection": "No internet connection" "noConnection": "No internet connection"
}, },
"applicationItem": { "applicationItem": {
@@ -50,7 +50,10 @@
"widgetTitle": "Select application", "widgetTitle": "Select application",
"widgetTitleSelected": "Selected application", "widgetTitleSelected": "Selected application",
"widgetSubtitle": "No application selected.", "widgetSubtitle": "No application selected.",
"noAppsLabel": "No applications found." "noAppsLabel": "No applications found.",
"currentVersion": "Current",
"recommendedVersion": "Recommended",
"anyVersion": "any"
}, },
"patchSelectorCard": { "patchSelectorCard": {
"widgetTitle": "Select patches", "widgetTitle": "Select patches",
@@ -75,7 +78,7 @@
"patchItem": { "patchItem": {
"unsupportedWarningButton": "Unsupported version", "unsupportedWarningButton": "Unsupported version",
"unsupportedDialogTitle": "Warning", "unsupportedDialogTitle": "Warning",
"unsupportedDialogText": "Selecting this patch may or may not result in patching errors.\n\nApp version: {packageVersion}\nCurrent supported versions:\n{supportedVersions}" "unsupportedDialogText": "Selecting this patch may result in patching errors.\n\nApp version: {packageVersion}\nCurrent supported versions:\n{supportedVersions}"
}, },
"installerView": { "installerView": {
"widgetTitle": "Installer", "widgetTitle": "Installer",
@@ -86,7 +89,11 @@
"notificationTitle": "ReVanced Manager is patching", "notificationTitle": "ReVanced Manager is patching",
"notificationText": "Tap to return to the installer", "notificationText": "Tap to return to the installer",
"shareApkMenuOption": "Share APK", "shareApkMenuOption": "Share APK",
"shareLogMenuOption": "Share log" "shareLogMenuOption": "Share 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."
}, },
"settingsView": { "settingsView": {
"widgetTitle": "Settings", "widgetTitle": "Settings",
@@ -94,6 +101,7 @@
"patcherSectionTitle": "Patcher", "patcherSectionTitle": "Patcher",
"teamSectionTitle": "Team", "teamSectionTitle": "Team",
"infoSectionTitle": "Info", "infoSectionTitle": "Info",
"advancedSectionTitle": "Advanced",
"darkThemeLabel": "Dark Mode", "darkThemeLabel": "Dark Mode",
"darkThemeHint": "Welcome to the Dark Side", "darkThemeHint": "Welcome to the Dark Side",
"dynamicThemeLabel": "Material You", "dynamicThemeLabel": "Material You",
@@ -109,10 +117,14 @@
"sourcesIntegrationsLabel": "Integrations Source", "sourcesIntegrationsLabel": "Integrations Source",
"sourcesResetDialogTitle": "Reset", "sourcesResetDialogTitle": "Reset",
"sourcesResetDialogText": "Are you sure you want to reset custom sources to their default values?", "sourcesResetDialogText": "Are you sure you want to reset custom sources to their default values?",
"apiURLResetDialogText": "Are you sure you want to reset API URL to their default values?",
"contributorsLabel": "Contributors", "contributorsLabel": "Contributors",
"contributorsHint": "A list of contributors of ReVanced", "contributorsHint": "A list of contributors of ReVanced",
"logsLabel": "Logs", "logsLabel": "Logs",
"logsHint": "Share device debug logs", "logsHint": "Share device debug logs",
"apiURLLabel": "API URL",
"apiURLHint": "Configure your custom API URL",
"selectApiURL": "Select URL",
"aboutLabel": "About", "aboutLabel": "About",
"snackbarMessage": "Copied to clipboard" "snackbarMessage": "Copied to clipboard"
}, },
@@ -121,8 +133,8 @@
"openButton": "Open", "openButton": "Open",
"uninstallButton": "Uninstall", "uninstallButton": "Uninstall",
"patchButton": "Patch", "patchButton": "Patch",
"uninstallDialogTitle": "Uninstall", "unpatchButton": "Unpatch",
"uninstallDialogText": "Are you sure you want to uninstall this app?", "unpatchDialogText": "Are you sure you want to unpatch this app?",
"rootDialogTitle": "Error", "rootDialogTitle": "Error",
"rootDialogText": "App was installed with root mode enabled but currently root mode is disabled.\nPlease enable root mode first.", "rootDialogText": "App was installed with root mode enabled but currently root mode is disabled.\nPlease enable root mode first.",
"packageNameLabel": "Package Name", "packageNameLabel": "Package Name",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -15,9 +15,10 @@ Future main() async {
await setupLocator(); await setupLocator();
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
await locator<ManagerAPI>().initialize(); await locator<ManagerAPI>().initialize();
await locator<PatcherAPI>().initialize(); String apiUrl = locator<ManagerAPI>().getApiUrl();
locator<RevancedAPI>().initialize(); await locator<RevancedAPI>().initialize(apiUrl);
locator<GithubAPI>().initialize(); locator<GithubAPI>().initialize();
await locator<PatcherAPI>().initialize();
runApp(const MyApp()); runApp(const MyApp());
} }

View File

@@ -17,6 +17,7 @@ class PatchedApplication {
Uint8List icon; Uint8List icon;
DateTime patchDate; DateTime patchDate;
bool isRooted; bool isRooted;
bool isFromStorage;
bool hasUpdates; bool hasUpdates;
List<String> appliedPatches; List<String> appliedPatches;
List<String> changelog; List<String> changelog;
@@ -29,6 +30,7 @@ class PatchedApplication {
required this.icon, required this.icon,
required this.patchDate, required this.patchDate,
this.isRooted = false, this.isRooted = false,
this.isFromStorage = false,
this.hasUpdates = false, this.hasUpdates = false,
this.appliedPatches = const [], this.appliedPatches = const [],
this.changelog = const [], this.changelog = const [],

View File

@@ -9,8 +9,7 @@ import 'package:revanced_manager/models/patch.dart';
@lazySingleton @lazySingleton
class GithubAPI { class GithubAPI {
final String apiUrl = 'https://api.github.com'; final Dio _dio = Dio(BaseOptions(baseUrl: 'https://api.github.com'));
final Dio _dio = Dio();
final DioCacheManager _dioCacheManager = DioCacheManager(CacheConfig()); final DioCacheManager _dioCacheManager = DioCacheManager(CacheConfig());
final Options _cacheOptions = buildCacheOptions( final Options _cacheOptions = buildCacheOptions(
const Duration(days: 1), const Duration(days: 1),
@@ -37,7 +36,7 @@ class GithubAPI {
Future<Map<String, dynamic>?> _getLatestRelease(String repoName) async { Future<Map<String, dynamic>?> _getLatestRelease(String repoName) async {
try { try {
var response = await _dio.get( var response = await _dio.get(
'$apiUrl/repos/$repoName/releases/latest', '/repos/$repoName/releases/latest',
options: _cacheOptions, options: _cacheOptions,
); );
return response.data; return response.data;
@@ -55,7 +54,7 @@ class GithubAPI {
'src/main/kotlin/app/revanced/patches/${repoAppPath[packageName]}'; 'src/main/kotlin/app/revanced/patches/${repoAppPath[packageName]}';
try { try {
var response = await _dio.get( var response = await _dio.get(
'$apiUrl/repos/$repoName/commits', '/repos/$repoName/commits',
queryParameters: { queryParameters: {
'path': path, 'path': path,
'per_page': 3, 'per_page': 3,

View File

@@ -19,6 +19,7 @@ class ManagerAPI {
final String patcherRepo = 'revanced-patcher'; final String patcherRepo = 'revanced-patcher';
final String cliRepo = 'revanced-cli'; final String cliRepo = 'revanced-cli';
late SharedPreferences _prefs; late SharedPreferences _prefs;
String defaultApiUrl = 'https://revanced-releases-api.afterst0rm.xyz';
String defaultPatcherRepo = 'revanced/revanced-patcher'; String defaultPatcherRepo = 'revanced/revanced-patcher';
String defaultPatchesRepo = 'revanced/revanced-patches'; String defaultPatchesRepo = 'revanced/revanced-patches';
String defaultIntegrationsRepo = 'revanced/revanced-integrations'; String defaultIntegrationsRepo = 'revanced/revanced-integrations';
@@ -29,6 +30,19 @@ class ManagerAPI {
_prefs = await SharedPreferences.getInstance(); _prefs = await SharedPreferences.getInstance();
} }
String getApiUrl() {
return _prefs.getString('apiUrl') ?? defaultApiUrl;
}
Future<void> setApiUrl(String url) async {
if (url.isEmpty || url == ' ') {
url = defaultApiUrl;
}
await _revancedAPI.initialize(url);
await _revancedAPI.clearAllCache();
await _prefs.setString('apiUrl', url);
}
String getPatchesRepo() { String getPatchesRepo() {
return _prefs.getString('patchesRepo') ?? defaultPatchesRepo; return _prefs.getString('patchesRepo') ?? defaultPatchesRepo;
} }
@@ -110,10 +124,11 @@ class ManagerAPI {
} }
Future<List<Patch>> getPatches() async { Future<List<Patch>> getPatches() async {
if (getPatchesRepo() == defaultPatchesRepo) { String repoName = getPatchesRepo();
if (repoName == defaultPatchesRepo) {
return await _revancedAPI.getPatches(); return await _revancedAPI.getPatches();
} else { } else {
return await _githubAPI.getPatches(getPatchesRepo()); return await _githubAPI.getPatches(repoName);
} }
} }
@@ -165,46 +180,114 @@ class ManagerAPI {
return packageInfo.version; return packageInfo.version;
} }
Future<void> reAssessSavedApps() async { Future<List<PatchedApplication>> getAppsToRemove(
List<PatchedApplication> patchedApps = getPatchedApps(); List<PatchedApplication> patchedApps,
) async {
List<PatchedApplication> toRemove = []; List<PatchedApplication> toRemove = [];
for (PatchedApplication app in patchedApps) { for (PatchedApplication app in patchedApps) {
bool isRemove = await isAppUninstalled(app); bool isRemove = await isAppUninstalled(app);
if (isRemove) { if (isRemove) {
toRemove.add(app); toRemove.add(app);
} else { }
app.hasUpdates = await hasAppUpdates(app.packageName, app.patchDate); }
app.changelog = await getAppChangelog(app.packageName, app.patchDate); return toRemove;
if (!app.hasUpdates) { }
String? currentInstalledVersion =
(await DeviceApps.getApp(app.packageName))?.versionName; Future<List<PatchedApplication>> getUnsavedApps(
if (currentInstalledVersion != null) { List<PatchedApplication> patchedApps,
String currentSavedVersion = app.version; ) async {
int currentInstalledVersionInt = int.parse( List<PatchedApplication> unsavedApps = [];
currentInstalledVersion.replaceAll(RegExp('[^0-9]'), '')); bool hasRootPermissions = await _rootAPI.hasRootPermissions();
int currentSavedVersionInt = if (hasRootPermissions) {
int.parse(currentSavedVersion.replaceAll(RegExp('[^0-9]'), '')); List<String> installedApps = await _rootAPI.getInstalledApps();
if (currentInstalledVersionInt > currentSavedVersionInt) { for (String packageName in installedApps) {
app.hasUpdates = true; if (!patchedApps.any((app) => app.packageName == packageName)) {
} ApplicationWithIcon? application =
await DeviceApps.getApp(packageName, true)
as ApplicationWithIcon?;
if (application != null) {
unsavedApps.add(
PatchedApplication(
name: application.appName,
packageName: application.packageName,
version: application.versionName!,
apkFilePath: application.apkFilePath,
icon: application.icon,
patchDate: DateTime.now(),
isRooted: true,
),
);
} }
} }
} }
} }
List<Application> userApps = await DeviceApps.getInstalledApplications(
includeSystemApps: false,
includeAppIcons: false,
);
for (Application app in userApps) {
if (app.packageName.startsWith('app.revanced') &&
!app.packageName.startsWith('app.revanced.manager.') &&
!patchedApps.any((uapp) => uapp.packageName == app.packageName)) {
ApplicationWithIcon? application =
await DeviceApps.getApp(app.packageName, true)
as ApplicationWithIcon?;
if (application != null) {
unsavedApps.add(
PatchedApplication(
name: application.appName,
packageName: application.packageName,
version: application.versionName!,
apkFilePath: application.apkFilePath,
icon: application.icon,
patchDate: DateTime.now(),
isRooted: false,
),
);
}
}
}
return unsavedApps;
}
Future<void> reAssessSavedApps() async {
List<PatchedApplication> patchedApps = getPatchedApps();
List<PatchedApplication> unsavedApps = await getUnsavedApps(patchedApps);
patchedApps.addAll(unsavedApps);
List<PatchedApplication> toRemove = await getAppsToRemove(patchedApps);
patchedApps.removeWhere((a) => toRemove.contains(a)); patchedApps.removeWhere((a) => toRemove.contains(a));
for (PatchedApplication app in patchedApps) {
app.hasUpdates = await hasAppUpdates(app.packageName, app.patchDate);
app.changelog = await getAppChangelog(app.packageName, app.patchDate);
if (!app.hasUpdates) {
String? currentInstalledVersion =
(await DeviceApps.getApp(app.packageName))?.versionName;
if (currentInstalledVersion != null) {
String currentSavedVersion = app.version;
int currentInstalledVersionInt = int.parse(
currentInstalledVersion.replaceAll(RegExp('[^0-9]'), ''));
int currentSavedVersionInt =
int.parse(currentSavedVersion.replaceAll(RegExp('[^0-9]'), ''));
if (currentInstalledVersionInt > currentSavedVersionInt) {
app.hasUpdates = true;
}
}
}
}
await setPatchedApps(patchedApps); await setPatchedApps(patchedApps);
} }
Future<bool> isAppUninstalled(PatchedApplication app) async { Future<bool> isAppUninstalled(PatchedApplication app) async {
bool existsRoot = false; bool existsRoot = false;
bool existsNonRoot = await DeviceApps.isAppInstalled(app.packageName);
if (app.isRooted) { if (app.isRooted) {
bool hasRootPermissions = await _rootAPI.hasRootPermissions(); bool hasRootPermissions = await _rootAPI.hasRootPermissions();
if (hasRootPermissions) { if (hasRootPermissions) {
existsRoot = await _rootAPI.isAppInstalled(app.packageName); existsRoot = await _rootAPI.isAppInstalled(app.packageName);
} }
return !existsRoot || !existsNonRoot;
} }
bool existsNonRoot = await DeviceApps.isAppInstalled(app.packageName); return !existsNonRoot;
return !existsRoot && !existsNonRoot;
} }
Future<bool> hasAppUpdates(String packageName, DateTime patchDate) async { Future<bool> hasAppUpdates(String packageName, DateTime patchDate) async {

View File

@@ -199,10 +199,9 @@ class PatcherAPI {
String prefix = appName.toLowerCase().replaceAll(' ', '-'); String prefix = appName.toLowerCase().replaceAll(' ', '-');
String newName = '$prefix-revanced_v$version.apk'; String newName = '$prefix-revanced_v$version.apk';
int lastSeparator = _outFile!.path.lastIndexOf('/'); int lastSeparator = _outFile!.path.lastIndexOf('/');
File share = _outFile!.renameSync( String newPath = _outFile!.path.substring(0, lastSeparator + 1) + newName;
_outFile!.path.substring(0, lastSeparator + 1) + newName, File shareFile = _outFile!.copySync(newPath);
); ShareExtend.share(shareFile.path, 'file');
ShareExtend.share(share.path, 'file');
} }
} }
@@ -220,4 +219,32 @@ class PatcherAPI {
log.writeAsStringSync(logs); log.writeAsStringSync(logs);
ShareExtend.share(log.path, 'file'); ShareExtend.share(log.path, 'file');
} }
String getRecommendedVersion(String packageName) {
Map<String, int> versions = {};
for (Patch patch in _patches) {
Package? package = patch.compatiblePackages.firstWhereOrNull(
(pack) => pack.name == packageName,
);
if (package != null) {
for (String version in package.versions) {
versions.update(
version,
(value) => versions[version]! + 1,
ifAbsent: () => 1,
);
}
}
}
if (versions.isNotEmpty) {
var entries = versions.entries.toList()
..sort((a, b) => a.value.compareTo(b.value));
versions
..clear()
..addEntries(entries);
versions.removeWhere((key, value) => value != versions.values.last);
return (versions.keys.toList()..sort()).last;
}
return '';
}
} }

View File

@@ -9,15 +9,15 @@ import 'package:timeago/timeago.dart';
@lazySingleton @lazySingleton
class RevancedAPI { class RevancedAPI {
final String apiUrl = 'https://revanced-releases-api.afterst0rm.xyz'; late Dio _dio = Dio();
final Dio _dio = Dio();
final DioCacheManager _dioCacheManager = DioCacheManager(CacheConfig()); final DioCacheManager _dioCacheManager = DioCacheManager(CacheConfig());
final Options _cacheOptions = buildCacheOptions( final Options _cacheOptions = buildCacheOptions(
const Duration(days: 1), const Duration(days: 1),
maxStale: const Duration(days: 7), maxStale: const Duration(days: 7),
); );
void initialize() { Future<void> initialize(String apiUrl) async {
_dio = Dio(BaseOptions(baseUrl: apiUrl));
_dio.interceptors.add(_dioCacheManager.interceptor); _dio.interceptors.add(_dioCacheManager.interceptor);
} }
@@ -28,10 +28,7 @@ class RevancedAPI {
Future<Map<String, List<dynamic>>> getContributors() async { Future<Map<String, List<dynamic>>> getContributors() async {
Map<String, List<dynamic>> contributors = {}; Map<String, List<dynamic>> contributors = {};
try { try {
var response = await _dio.get( var response = await _dio.get('/contributors', options: _cacheOptions);
'$apiUrl/contributors',
options: _cacheOptions,
);
List<dynamic> repositories = response.data['repositories']; List<dynamic> repositories = response.data['repositories'];
for (Map<String, dynamic> repo in repositories) { for (Map<String, dynamic> repo in repositories) {
String name = repo['name']; String name = repo['name'];
@@ -45,7 +42,7 @@ class RevancedAPI {
Future<List<Patch>> getPatches() async { Future<List<Patch>> getPatches() async {
try { try {
var response = await _dio.get('$apiUrl/patches', options: _cacheOptions); var response = await _dio.get('/patches', options: _cacheOptions);
List<dynamic> patches = response.data; List<dynamic> patches = response.data;
return patches.map((patch) => Patch.fromJson(patch)).toList(); return patches.map((patch) => Patch.fromJson(patch)).toList();
} on Exception { } on Exception {
@@ -58,7 +55,7 @@ class RevancedAPI {
String repoName, String repoName,
) async { ) async {
try { try {
var response = await _dio.get('$apiUrl/tools', options: _cacheOptions); var response = await _dio.get('/tools', options: _cacheOptions);
List<dynamic> tools = response.data['tools']; List<dynamic> tools = response.data['tools'];
return tools.firstWhereOrNull( return tools.firstWhereOrNull(
(t) => (t) =>
@@ -71,10 +68,14 @@ class RevancedAPI {
} }
Future<String?> getLatestReleaseVersion( Future<String?> getLatestReleaseVersion(
String extension, String repoName) async { String extension,
String repoName,
) async {
try { try {
Map<String, dynamic>? release = Map<String, dynamic>? release = await _getLatestRelease(
await _getLatestRelease(extension, repoName); extension,
repoName,
);
if (release != null) { if (release != null) {
return release['version']; return release['version'];
} }

View File

@@ -6,8 +6,12 @@ class RootAPI {
final String _serviceDDirPath = '/data/adb/service.d'; final String _serviceDDirPath = '/data/adb/service.d';
Future<bool> hasRootPermissions() async { Future<bool> hasRootPermissions() async {
bool? isRooted = await Root.isRooted(); try {
return isRooted != null && isRooted; bool? isRooted = await Root.isRooted();
return isRooted != null && isRooted;
} on Exception {
return false;
}
} }
Future<void> setPermissions( Future<void> setPermissions(
@@ -55,15 +59,8 @@ class RootAPI {
); );
if (res != null) { if (res != null) {
List<String> apps = res.split('\n'); List<String> apps = res.split('\n');
List<String> toRemove = []; apps.removeWhere((pack) => pack.isEmpty);
for (String packageName in apps) { return apps.map((pack) => pack.trim()).toList();
bool isInstalled = await isAppInstalled(packageName);
if (!isInstalled) {
toRemove.add(packageName);
}
}
apps.removeWhere((a) => toRemove.contains(a));
return apps;
} }
} on Exception { } on Exception {
return List.empty(); return List.empty();

View File

@@ -4,6 +4,7 @@ import 'package:google_fonts/google_fonts.dart';
var lightCustomColorScheme = ColorScheme.fromSeed( var lightCustomColorScheme = ColorScheme.fromSeed(
seedColor: Colors.blue, seedColor: Colors.blue,
brightness: Brightness.light, brightness: Brightness.light,
primary: const Color(0xff1B73E8),
); );
var lightCustomTheme = ThemeData( var lightCustomTheme = ThemeData(
@@ -23,8 +24,8 @@ var lightCustomTheme = ThemeData(
var darkCustomColorScheme = ColorScheme.fromSeed( var darkCustomColorScheme = ColorScheme.fromSeed(
seedColor: Colors.blue, seedColor: Colors.blue,
brightness: Brightness.dark, brightness: Brightness.dark,
primary: const Color(0xff7792BA), primary: const Color(0xffA5CAFF),
surface: const Color(0xff0A0D11), surface: const Color(0xff1B1A1D),
); );
var darkCustomTheme = ThemeData( var darkCustomTheme = ThemeData(
@@ -38,8 +39,8 @@ var darkCustomTheme = ThemeData(
), ),
), ),
), ),
canvasColor: const Color(0xff0A0D11), canvasColor: const Color(0xff1B1A1D),
scaffoldBackgroundColor: const Color(0xff0A0D11), scaffoldBackgroundColor: const Color(0xff1B1A1D),
toggleableActiveColor: const Color(0xff7792BA), toggleableActiveColor: const Color(0xffA5CAFF),
textTheme: GoogleFonts.robotoTextTheme(ThemeData.dark().textTheme), textTheme: GoogleFonts.robotoTextTheme(ThemeData.dark().textTheme),
); );

View File

@@ -54,6 +54,7 @@ class AppSelectorViewModel extends BaseViewModel {
apkFilePath: result.files.single.path!, apkFilePath: result.files.single.path!,
icon: application.icon, icon: application.icon,
patchDate: DateTime.now(), patchDate: DateTime.now(),
isFromStorage: true,
); );
locator<PatcherViewModel>().selectedPatches.clear(); locator<PatcherViewModel>().selectedPatches.clear();
locator<PatcherViewModel>().notifyListeners(); locator<PatcherViewModel>().notifyListeners();

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:animations/animations.dart';
import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart'; import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/homeView/available_updates_card.dart'; import 'package:revanced_manager/ui/widgets/homeView/available_updates_card.dart';
@@ -83,9 +84,26 @@ class HomeView extends StatelessWidget {
], ],
), ),
const SizedBox(height: 14), const SizedBox(height: 14),
model.showUpdatableApps PageTransitionSwitcher(
? AvailableUpdatesCard() transitionBuilder:
: InstalledAppsCard(), (child, primaryAnimation, secondaryAnimation) {
return FadeThroughTransition(
animation: primaryAnimation,
secondaryAnimation: secondaryAnimation,
fillColor: Colors.transparent,
child: child,
);
},
layoutBuilder: (entries) {
return Stack(
alignment: Alignment.topCenter,
children: entries,
);
},
child: model.showUpdatableApps
? AvailableUpdatesCard()
: InstalledAppsCard(),
),
], ],
), ),
), ),

View File

@@ -74,7 +74,10 @@ class HomeViewModel extends BaseViewModel {
} }
void _getPatchedApps() { void _getPatchedApps() {
patchedInstalledApps = _managerAPI.getPatchedApps().toList(); patchedInstalledApps = _managerAPI
.getPatchedApps()
.where((app) => app.hasUpdates == false)
.toList();
patchedUpdatableApps = _managerAPI patchedUpdatableApps = _managerAPI
.getPatchedApps() .getPatchedApps()
.where((app) => app.hasUpdates == true) .where((app) => app.hasUpdates == true)
@@ -169,11 +172,11 @@ class HomeViewModel extends BaseViewModel {
actions: <Widget>[ actions: <Widget>[
CustomMaterialButton( CustomMaterialButton(
isFilled: false, isFilled: false,
label: I18nText('cancelButton'), label: I18nText('noButton'),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
CustomMaterialButton( CustomMaterialButton(
label: I18nText('okButton'), label: I18nText('yesButton'),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
updateManager(context); updateManager(context);

View File

@@ -31,7 +31,7 @@ class InstallerView extends StatelessWidget {
), ),
actions: <Widget>[ actions: <Widget>[
Visibility( Visibility(
visible: !model.isPatching && model.hasErrors, visible: !model.isPatching && !model.hasErrors,
child: CustomPopupMenu( child: CustomPopupMenu(
onSelected: (value) => model.onMenuSelection(value), onSelected: (value) => model.onMenuSelection(value),
children: { children: {
@@ -111,7 +111,10 @@ class InstallerView extends StatelessWidget {
label: label:
I18nText('installerView.installRootButton'), I18nText('installerView.installRootButton'),
isExpanded: true, isExpanded: true,
onPressed: () => model.installResult(true), onPressed: () => model.installResult(
context,
true,
),
), ),
), ),
Visibility( Visibility(
@@ -125,7 +128,10 @@ class InstallerView extends StatelessWidget {
child: CustomMaterialButton( child: CustomMaterialButton(
label: I18nText('installerView.installButton'), label: I18nText('installerView.installButton'),
isExpanded: true, isExpanded: true,
onPressed: () => model.installResult(false), onPressed: () => model.installResult(
context,
false,
),
), ),
), ),
], ],

View File

@@ -3,12 +3,14 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_background/flutter_background.dart'; import 'package:flutter_background/flutter_background.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patch.dart'; import 'package:revanced_manager/models/patch.dart';
import 'package:revanced_manager/models/patched_application.dart'; import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/patcher_api.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/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart';
import 'package:stacked/stacked.dart'; import 'package:stacked/stacked.dart';
import 'package:wakelock/wakelock.dart'; import 'package:wakelock/wakelock.dart';
@@ -29,29 +31,30 @@ class InstallerViewModel extends BaseViewModel {
bool hasErrors = false; bool hasErrors = false;
Future<void> initialize(BuildContext context) async { Future<void> initialize(BuildContext context) async {
try { if (await Permission.ignoreBatteryOptimizations.isGranted) {
await FlutterBackground.initialize( try {
androidConfig: FlutterBackgroundAndroidConfig( FlutterBackground.initialize(
notificationTitle: FlutterI18n.translate( androidConfig: FlutterBackgroundAndroidConfig(
context, notificationTitle: FlutterI18n.translate(
'installerView.notificationTitle', context,
'installerView.notificationTitle',
),
notificationText: FlutterI18n.translate(
context,
'installerView.notificationText',
),
notificationImportance: AndroidNotificationImportance.Default,
notificationIcon: const AndroidResource(
name: 'ic_notification',
defType: 'drawable',
),
), ),
notificationText: FlutterI18n.translate( ).then((value) => FlutterBackground.enableBackgroundExecution());
context, } on Exception {
'installerView.notificationText', // ignore
), }
notificationImportance: AndroidNotificationImportance.Default,
notificationIcon: const AndroidResource(
name: 'ic_notification',
defType: 'drawable',
),
),
);
await FlutterBackground.enableBackgroundExecution();
await Wakelock.enable();
} on Exception {
// ignore
} }
await Wakelock.enable();
await handlePlatformChannelMethods(); await handlePlatformChannelMethods();
await runPatcher(); await runPatcher();
} }
@@ -119,37 +122,67 @@ class InstallerViewModel extends BaseViewModel {
hasErrors = true; hasErrors = true;
update(-1.0, 'Aborting...', 'No app or patches selected! Aborting'); update(-1.0, 'Aborting...', 'No app or patches selected! Aborting');
} }
try { if (FlutterBackground.isBackgroundExecutionEnabled) {
await FlutterBackground.disableBackgroundExecution(); try {
await Wakelock.disable(); FlutterBackground.disableBackgroundExecution();
} on Exception { } on Exception {
// ignore // ignore
}
} }
await Wakelock.disable();
isPatching = false; isPatching = false;
} }
void installResult(bool installAsRoot) async { void installResult(BuildContext context, bool installAsRoot) async {
_app.isRooted = installAsRoot; _app.isRooted = installAsRoot;
update( bool hasMicroG = _patches.any((p) => p.name.endsWith('microg-support'));
1.0, bool rootMicroG = installAsRoot && hasMicroG;
'Installing...', bool rootFromStorage = installAsRoot && _app.isFromStorage;
_app.isRooted bool ytWithoutRootMicroG =
? 'Installing patched file using root method' !installAsRoot && !hasMicroG && _app.packageName.contains('youtube');
: 'Installing patched file using nonroot method', if (rootMicroG || rootFromStorage || ytWithoutRootMicroG) {
); return showDialog(
isInstalled = await _patcherAPI.installPatchedFile(_app); context: context,
if (isInstalled) { builder: (context) => AlertDialog(
update(1.0, 'Installed!', 'Installed!'); title: I18nText('installerView.installErrorDialogTitle'),
_app.patchDate = DateTime.now(); backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
_app.appliedPatches = _patches.map((p) => p.name).toList(); content: I18nText(
bool hasMicroG = _patches.any((p) => p.name.endsWith('microg-support')); rootMicroG
if (hasMicroG) { ? 'installerView.installErrorDialogText1'
_app.packageName = _app.packageName.replaceFirst( : rootFromStorage
'com.google.', ? 'installerView.installErrorDialogText3'
'app.revanced.', : 'installerView.installErrorDialogText2',
); ),
actions: <Widget>[
CustomMaterialButton(
label: I18nText('okButton'),
onPressed: () => Navigator.of(context).pop(),
)
],
),
);
} else {
update(
1.0,
'Installing...',
_app.isRooted
? 'Installing patched file using root method'
: 'Installing patched file using nonroot method',
);
isInstalled = await _patcherAPI.installPatchedFile(_app);
if (isInstalled) {
update(1.0, 'Installed!', 'Installed!');
_app.isFromStorage = false;
_app.patchDate = DateTime.now();
_app.appliedPatches = _patches.map((p) => p.name).toList();
if (hasMicroG) {
_app.packageName = _app.packageName.replaceFirst(
'com.google.',
'app.revanced.',
);
}
await _managerAPI.savePatchedApp(_app);
} }
await _managerAPI.savePatchedApp(_app);
} }
} }

View File

@@ -42,6 +42,7 @@ class NavigationView extends StatelessWidget {
context, context,
'navigationView.dashboardTab', 'navigationView.dashboardTab',
), ),
tooltip: '',
), ),
NavigationDestination( NavigationDestination(
icon: model.isIndexSelected(1) icon: model.isIndexSelected(1)
@@ -51,6 +52,7 @@ class NavigationView extends StatelessWidget {
context, context,
'navigationView.patcherTab', 'navigationView.patcherTab',
), ),
tooltip: '',
), ),
NavigationDestination( NavigationDestination(
icon: model.isIndexSelected(2) icon: model.isIndexSelected(2)
@@ -60,6 +62,7 @@ class NavigationView extends StatelessWidget {
context, context,
'navigationView.settingsTab', 'navigationView.settingsTab',
), ),
tooltip: '',
), ),
], ],
), ),

View File

@@ -15,25 +15,30 @@ import 'package:stacked/stacked.dart';
class NavigationViewModel extends IndexTrackingViewModel { class NavigationViewModel extends IndexTrackingViewModel {
void initialize(BuildContext context) async { void initialize(BuildContext context) async {
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
if (prefs.getBool('permissionsRequested') == null) {
await prefs.setBool('permissionsRequested', true);
RootAPI().hasRootPermissions().then(
(value) => Permission.requestInstallPackages.request().then(
(value) => Permission.ignoreBatteryOptimizations.request(),
),
);
}
if (prefs.getBool('useDarkTheme') == null) { if (prefs.getBool('useDarkTheme') == null) {
bool isDark = bool isDark =
MediaQuery.of(context).platformBrightness != Brightness.light; MediaQuery.of(context).platformBrightness != Brightness.light;
await prefs.setBool('useDarkTheme', isDark); await prefs.setBool('useDarkTheme', isDark);
await DynamicTheme.of(context)!.setTheme(isDark ? 1 : 0); await DynamicTheme.of(context)!.setTheme(isDark ? 1 : 0);
} }
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
SystemChrome.setSystemUIOverlayStyle( SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle( SystemUiOverlayStyle(
systemNavigationBarColor: systemNavigationBarColor: Colors.transparent,
DynamicTheme.of(context)!.theme.colorScheme.surface,
systemNavigationBarIconBrightness: systemNavigationBarIconBrightness:
DynamicTheme.of(context)!.theme.brightness == Brightness.light DynamicTheme.of(context)!.theme.brightness == Brightness.light
? Brightness.dark ? Brightness.dark
: Brightness.light, : Brightness.light,
), ),
); );
RootAPI().hasRootPermissions();
Permission.requestInstallPackages.request();
Permission.ignoreBatteryOptimizations.request();
} }
Widget getViewForIndex(int index) { Widget getViewForIndex(int index) {

View File

@@ -64,11 +64,11 @@ class PatcherViewModel extends BaseViewModel {
actions: <Widget>[ actions: <Widget>[
CustomMaterialButton( CustomMaterialButton(
isFilled: false, isFilled: false,
label: I18nText('cancelButton'), label: I18nText('noButton'),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
CustomMaterialButton( CustomMaterialButton(
label: I18nText('okButton'), label: I18nText('yesButton'),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
navigateToInstaller(); navigateToInstaller();
@@ -79,4 +79,32 @@ class PatcherViewModel extends BaseViewModel {
); );
} }
} }
String getAppSelectionString() {
String text = '${selectedApp!.name} (${selectedApp!.packageName})';
if (text.length > 32) {
text = '${text.substring(0, 32)}...)';
}
return text;
}
String getRecommendedVersionString(BuildContext context) {
String recommendedVersion =
_patcherAPI.getRecommendedVersion(selectedApp!.packageName);
if (recommendedVersion.isEmpty) {
recommendedVersion = FlutterI18n.translate(
context,
'appSelectorCard.anyVersion',
);
} else {
recommendedVersion = 'v$recommendedVersion';
}
return '${FlutterI18n.translate(
context,
'appSelectorCard.currentVersion',
)}: v${selectedApp!.version}\n${FlutterI18n.translate(
context,
'appSelectorCard.recommendedVersion',
)}: $recommendedVersion';
}
} }

View File

@@ -145,6 +145,17 @@ class SettingsView extends StatelessWidget {
const AboutWidget(), const AboutWidget(),
], ],
), ),
const Divider(thickness: 1.0),
SettingsSection(
title: 'settingsView.advancedSectionTitle',
children: <Widget>[
SettingsTileDialog(
title: 'settingsView.apiURLLabel',
subtitle: 'settingsView.apiURLHint',
onTap: () => model.showApiUrlDialog(context),
),
],
),
], ],
), ),
), ),

View File

@@ -27,6 +27,7 @@ class SettingsViewModel extends BaseViewModel {
final TextEditingController _patSourceController = TextEditingController(); final TextEditingController _patSourceController = TextEditingController();
final TextEditingController _orgIntSourceController = TextEditingController(); final TextEditingController _orgIntSourceController = TextEditingController();
final TextEditingController _intSourceController = TextEditingController(); final TextEditingController _intSourceController = TextEditingController();
final TextEditingController _apiUrlController = TextEditingController();
void setLanguage(String language) { void setLanguage(String language) {
notifyListeners(); notifyListeners();
@@ -55,12 +56,6 @@ class SettingsViewModel extends BaseViewModel {
} else { } else {
await DynamicTheme.of(context)!.setTheme(value ? 3 : 1); await DynamicTheme.of(context)!.setTheme(value ? 3 : 1);
} }
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
systemNavigationBarColor:
DynamicTheme.of(context)!.theme.colorScheme.surface,
),
);
notifyListeners(); notifyListeners();
} }
@@ -78,8 +73,6 @@ class SettingsViewModel extends BaseViewModel {
} }
SystemChrome.setSystemUIOverlayStyle( SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle( SystemUiOverlayStyle(
systemNavigationBarColor:
DynamicTheme.of(context)!.theme.colorScheme.surface,
systemNavigationBarIconBrightness: systemNavigationBarIconBrightness:
value ? Brightness.light : Brightness.dark, value ? Brightness.light : Brightness.dark,
), ),
@@ -208,6 +201,65 @@ class SettingsViewModel extends BaseViewModel {
); );
} }
Future<void> showApiUrlDialog(BuildContext context) async {
String apiUrl = _managerAPI.getApiUrl();
_apiUrlController.text = apiUrl.replaceAll('https://', '');
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: Row(
children: <Widget>[
I18nText('settingsView.apiURLLabel'),
const Spacer(),
IconButton(
icon: const Icon(Icons.manage_history_outlined),
onPressed: () => showApiUrlResetDialog(context),
color: Theme.of(context).colorScheme.secondary,
)
],
),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: SingleChildScrollView(
child: Column(
children: <Widget>[
CustomTextField(
leadingIcon: Icon(
Icons.api_outlined,
color: Theme.of(context).colorScheme.secondary,
),
inputController: _apiUrlController,
label: I18nText('settingsView.selectApiURL'),
hint: apiUrl.split('/')[0],
onChanged: (value) => notifyListeners(),
),
],
),
),
actions: <Widget>[
CustomMaterialButton(
isFilled: false,
label: I18nText('cancelButton'),
onPressed: () {
_apiUrlController.clear();
Navigator.of(context).pop();
},
),
CustomMaterialButton(
label: I18nText('okButton'),
onPressed: () {
String apiUrl = _apiUrlController.text;
if (!apiUrl.startsWith('https')) {
apiUrl = 'https://$apiUrl';
}
_managerAPI.setApiUrl(apiUrl);
Navigator.of(context).pop();
},
)
],
),
);
}
Future<void> showResetConfirmationDialog(BuildContext context) async { Future<void> showResetConfirmationDialog(BuildContext context) async {
return showDialog( return showDialog(
context: context, context: context,
@@ -218,11 +270,11 @@ class SettingsViewModel extends BaseViewModel {
actions: <Widget>[ actions: <Widget>[
CustomMaterialButton( CustomMaterialButton(
isFilled: false, isFilled: false,
label: I18nText('cancelButton'), label: I18nText('noButton'),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
CustomMaterialButton( CustomMaterialButton(
label: I18nText('okButton'), label: I18nText('yesButton'),
onPressed: () { onPressed: () {
_managerAPI.setPatchesRepo(''); _managerAPI.setPatchesRepo('');
_managerAPI.setIntegrationsRepo(''); _managerAPI.setIntegrationsRepo('');
@@ -235,6 +287,32 @@ class SettingsViewModel extends BaseViewModel {
); );
} }
Future<void> showApiUrlResetDialog(BuildContext context) async {
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: I18nText('settingsView.sourcesResetDialogTitle'),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText('settingsView.apiURLResetDialogText'),
actions: <Widget>[
CustomMaterialButton(
isFilled: false,
label: I18nText('noButton'),
onPressed: () => Navigator.of(context).pop(),
),
CustomMaterialButton(
label: I18nText('yesButton'),
onPressed: () {
_managerAPI.setApiUrl('');
Navigator.of(context).pop();
Navigator.of(context).pop();
},
)
],
),
);
}
Future<int> getSdkVersion() async { Future<int> getSdkVersion() async {
AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo; AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo;
return info.version.sdkInt ?? -1; return info.version.sdkInt ?? -1;

View File

@@ -64,8 +64,9 @@ class AppInfoView extends StatelessWidget {
CustomCard( CustomCard(
child: IntrinsicHeight( child: IntrinsicHeight(
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
!app.isRooted ? const Spacer() : Container(),
InkWell( InkWell(
onTap: () => model.openApp(app), onTap: () => model.openApp(app),
child: Column( child: Column(
@@ -92,12 +93,17 @@ class AppInfoView extends StatelessWidget {
], ],
), ),
), ),
const Spacer(),
VerticalDivider( VerticalDivider(
color: Theme.of(context).canvasColor, color: Theme.of(context).canvasColor,
), ),
const Spacer(),
InkWell( InkWell(
onTap: () => onTap: () => model.showUninstallDialog(
model.showUninstallAlertDialog(context, app), context,
app,
false,
),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
@@ -122,9 +128,11 @@ class AppInfoView extends StatelessWidget {
], ],
), ),
), ),
const Spacer(),
VerticalDivider( VerticalDivider(
color: Theme.of(context).canvasColor, color: Theme.of(context).canvasColor,
), ),
const Spacer(),
InkWell( InkWell(
onTap: () { onTap: () {
model.navigateToPatcher(app); model.navigateToPatcher(app);
@@ -154,6 +162,49 @@ class AppInfoView extends StatelessWidget {
], ],
), ),
), ),
app.isRooted ? const Spacer() : Container(),
app.isRooted
? VerticalDivider(
color: Theme.of(context).canvasColor,
)
: Container(),
app.isRooted ? const Spacer() : Container(),
app.isRooted
? InkWell(
onTap: () => model.showUninstallDialog(
context,
app,
true,
),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons
.settings_backup_restore_outlined,
color: Theme.of(context)
.colorScheme
.primary,
),
const SizedBox(height: 10),
I18nText(
'appInfoView.unpatchButton',
child: Text(
'',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.primary,
fontWeight: FontWeight.bold,
),
),
),
],
),
)
: Container(),
!app.isRooted ? const Spacer() : Container(),
], ],
), ),
), ),

View File

@@ -1,3 +1,4 @@
// ignore_for_file: use_build_context_synchronously
import 'package:device_apps/device_apps.dart'; import 'package:device_apps/device_apps.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
@@ -19,16 +20,20 @@ class AppInfoViewModel extends BaseViewModel {
final PatcherAPI _patcherAPI = locator<PatcherAPI>(); final PatcherAPI _patcherAPI = locator<PatcherAPI>();
final RootAPI _rootAPI = RootAPI(); final RootAPI _rootAPI = RootAPI();
Future<void> uninstallApp(PatchedApplication app) async { Future<void> uninstallApp(PatchedApplication app, bool onlyUnpatch) async {
if (app.isRooted) { if (app.isRooted) {
bool hasRootPermissions = await _rootAPI.hasRootPermissions(); bool hasRootPermissions = await _rootAPI.hasRootPermissions();
if (hasRootPermissions) { if (hasRootPermissions) {
_rootAPI.deleteApp(app.packageName, app.apkFilePath); _rootAPI.deleteApp(app.packageName, app.apkFilePath);
_managerAPI.deletePatchedApp(app); _managerAPI.deletePatchedApp(app);
if (!onlyUnpatch) {
DeviceApps.uninstallApp(app.packageName);
}
} }
} else { } else {
DeviceApps.uninstallApp(app.packageName); DeviceApps.uninstallApp(app.packageName).then(
_managerAPI.deletePatchedApp(app); (value) => _managerAPI.deletePatchedApp(app),
);
} }
} }
@@ -40,53 +45,62 @@ class AppInfoViewModel extends BaseViewModel {
locator<NavigationViewModel>().setIndex(1); locator<NavigationViewModel>().setIndex(1);
} }
Future<void> showUninstallAlertDialog( Future<void> showUninstallDialog(
BuildContext context, BuildContext context,
PatchedApplication app, PatchedApplication app,
bool onlyUnpatch,
) async { ) async {
if (app.isRooted) { bool hasRootPermissions = await _rootAPI.hasRootPermissions();
bool hasRootPermissions = await _rootAPI.hasRootPermissions(); if (app.isRooted && !hasRootPermissions) {
if (!hasRootPermissions) {
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: I18nText('appInfoView.rootDialogTitle'),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText('appInfoView.rootDialogText'),
actions: <Widget>[
CustomMaterialButton(
label: I18nText('okButton'),
onPressed: () => Navigator.of(context).pop(),
)
],
),
);
}
} else {
return showDialog( return showDialog(
context: context, context: context,
builder: (context) => AlertDialog( builder: (context) => AlertDialog(
title: I18nText('appInfoView.uninstallDialogTitle'), title: I18nText('appInfoView.rootDialogTitle'),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer, backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText('appInfoView.uninstallDialogText'), content: I18nText('appInfoView.rootDialogText'),
actions: <Widget>[ actions: <Widget>[
CustomMaterialButton(
isFilled: false,
label: I18nText('cancelButton'),
onPressed: () => Navigator.of(context).pop(),
),
CustomMaterialButton( CustomMaterialButton(
label: I18nText('okButton'), label: I18nText('okButton'),
onPressed: () { onPressed: () => Navigator.of(context).pop(),
uninstallApp(app);
locator<HomeViewModel>().initialize(context);
Navigator.of(context).pop();
Navigator.of(context).pop();
},
) )
], ],
), ),
); );
} else {
if (onlyUnpatch) {
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: I18nText(
'appInfoView.unpatchButton',
),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText(
'appInfoView.unpatchDialogText',
),
actions: <Widget>[
CustomMaterialButton(
isFilled: false,
label: I18nText('noButton'),
onPressed: () => Navigator.of(context).pop(),
),
CustomMaterialButton(
label: I18nText('yesButton'),
onPressed: () {
uninstallApp(app, onlyUnpatch);
locator<HomeViewModel>().initialize(context);
Navigator.of(context).pop();
Navigator.of(context).pop();
},
)
],
),
);
} else {
uninstallApp(app, onlyUnpatch);
locator<HomeViewModel>().initialize(context);
Navigator.of(context).pop();
}
} }
} }

View File

@@ -71,7 +71,7 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
future: locator<HomeViewModel>().hasManagerUpdates(), future: locator<HomeViewModel>().hasManagerUpdates(),
initialData: false, initialData: false,
builder: (context, snapshot) => Opacity( builder: (context, snapshot) => Opacity(
opacity: snapshot.hasData && snapshot.data! ? 1.0 : 0.5, opacity: snapshot.hasData && snapshot.data! ? 1.0 : 0.25,
child: CustomMaterialButton( child: CustomMaterialButton(
isExpanded: false, isExpanded: false,
label: I18nText('latestCommitCard.updateButton'), label: I18nText('latestCommitCard.updateButton'),

View File

@@ -39,7 +39,7 @@ class AppSelectorCard extends StatelessWidget {
: Row( : Row(
children: <Widget>[ children: <Widget>[
SizedBox( SizedBox(
height: 16.0, height: 18.0,
child: ClipOval( child: ClipOval(
child: Image.memory( child: Image.memory(
locator<PatcherViewModel>().selectedApp == null locator<PatcherViewModel>().selectedApp == null
@@ -49,8 +49,23 @@ class AppSelectorCard extends StatelessWidget {
), ),
), ),
), ),
const SizedBox(width: 4), const SizedBox(width: 6),
Text(_getAppSelection()), Text(locator<PatcherViewModel>().getAppSelectionString()),
],
),
locator<PatcherViewModel>().selectedApp == null
? Container()
: Column(
children: [
const SizedBox(height: 10),
Padding(
padding: const EdgeInsets.only(left: 20),
child: Text(
locator<PatcherViewModel>()
.getRecommendedVersionString(context),
style: const TextStyle(fontStyle: FontStyle.italic),
),
),
], ],
), ),
], ],
@@ -58,10 +73,4 @@ class AppSelectorCard extends StatelessWidget {
), ),
); );
} }
String _getAppSelection() {
String name = locator<PatcherViewModel>().selectedApp!.name;
String version = locator<PatcherViewModel>().selectedApp!.version;
return '$name (v$version)';
}
} }

View File

@@ -61,6 +61,13 @@ class _AboutWidgetState extends State<AboutWidget> {
fontWeight: FontWeight.w300, fontWeight: FontWeight.w300,
), ),
), ),
Text(
'Build: ${snapshot.data!['flavor']}',
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w300,
),
),
Text( Text(
'Model: ${snapshot.data!['model']}', 'Model: ${snapshot.data!['model']}',
style: const TextStyle( style: const TextStyle(

View File

@@ -64,34 +64,43 @@ class _ApplicationItemState extends State<ApplicationItem>
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
SizedBox( SizedBox(
width: 60, width: 40,
child: Image.memory(widget.icon, height: 39, width: 39), child: Image.memory(widget.icon, height: 40, width: 40),
), ),
const SizedBox(width: 4), const SizedBox(width: 4),
Column( Padding(
crossAxisAlignment: CrossAxisAlignment.start, padding: const EdgeInsets.only(left: 15.0),
children: <Widget>[ child: Column(
Text( crossAxisAlignment: CrossAxisAlignment.start,
widget.name, children: <Widget>[
style: const TextStyle( Text(
fontSize: 16, widget.name.length > 9
fontWeight: FontWeight.w500, ? '${widget.name.substring(0, 9)}...'
: widget.name,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
), ),
), Text(format(widget.patchDate)),
Text(format(widget.patchDate)), ],
], ),
), ),
const Spacer(), const Spacer(),
RotationTransition( Padding(
turns: Tween(begin: 0.0, end: 0.50).animate(_animationController), padding: const EdgeInsets.only(right: 5.0),
child: IconButton( child: RotationTransition(
onPressed: () { turns:
expController.toggle(); Tween(begin: 0.0, end: 0.50).animate(_animationController),
_animationController.isCompleted child: IconButton(
? _animationController.reverse() onPressed: () {
: _animationController.forward(); expController.toggle();
}, _animationController.isCompleted
icon: const Icon(Icons.arrow_drop_down), ? _animationController.reverse()
: _animationController.forward();
},
icon: const Icon(Icons.arrow_drop_down),
),
), ),
), ),
Column( Column(
@@ -111,7 +120,7 @@ class _ApplicationItemState extends State<ApplicationItem>
), ),
collapsed: const Text(''), collapsed: const Text(''),
expanded: Padding( expanded: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0), padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 16.0),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[

View File

@@ -16,7 +16,7 @@ class CustomCard extends StatelessWidget {
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16), borderRadius: BorderRadius.circular(16),
color: isFilled color: isFilled
? Theme.of(context).colorScheme.secondaryContainer ? Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.40)
: Colors.transparent, : Colors.transparent,
border: isFilled border: isFilled
? null ? null

View File

@@ -22,7 +22,7 @@ class DashboardChip extends StatelessWidget {
color: isSelected color: isSelected
? Theme.of(context).colorScheme.primary ? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.secondary, : Theme.of(context).colorScheme.secondary,
fontWeight: FontWeight.bold, fontWeight: FontWeight.w500,
), ),
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
selectedColor: Theme.of(context).colorScheme.secondaryContainer, selectedColor: Theme.of(context).colorScheme.secondaryContainer,

View File

@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart';
import 'package:device_info_plus/device_info_plus.dart'; import 'package:device_info_plus/device_info_plus.dart';
@@ -7,6 +8,7 @@ class AboutInfo {
final info = await DeviceInfoPlugin().androidInfo; final info = await DeviceInfoPlugin().androidInfo;
return { return {
'version': packageInfo.version, 'version': packageInfo.version,
'flavor': kReleaseMode ? 'release' : 'debug',
'model': info.model, 'model': info.model,
'androidVersion': info.version.release, 'androidVersion': info.version.release,
'arch': info.supportedAbis.first 'arch': info.supportedAbis.first

View File

@@ -4,7 +4,7 @@ homepage: https://github.com/revanced/revanced-manager
publish_to: 'none' publish_to: 'none'
version: 0.0.7+7 version: 0.0.14+14
environment: environment:
sdk: ">=2.17.5 <3.0.0" sdk: ">=2.17.5 <3.0.0"
@@ -75,13 +75,6 @@ dev_dependencies:
injectable_generator: ^1.5.4 injectable_generator: ^1.5.4
json_serializable: ^6.3.1 json_serializable: ^6.3.1
flutter_icons:
android: true
ios: false
image_path: "assets/images/ic_launcher_round.png"
adaptive_icon_background: "#1B1B1B"
adaptive_icon_foreground: "assets/images/ic_launcher.png"
flutter: flutter:
uses-material-design: true uses-material-design: true
assets: assets: