From 70f80c74bb6c06eace6a005f0f98791a431e93c4 Mon Sep 17 00:00:00 2001 From: aAbed Date: Thu, 4 Jan 2024 11:37:39 +0545 Subject: [PATCH 1/3] fix: incorrect strings and logics --- lib/services/manager_api.dart | 10 ++++---- lib/ui/views/home/home_viewmodel.dart | 3 +-- .../settings_manage_api_url.dart | 5 +++- .../settings_manage_sources.dart | 25 +++++++++++-------- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/lib/services/manager_api.dart b/lib/services/manager_api.dart index 437abf3595..17072b0417 100644 --- a/lib/services/manager_api.dart +++ b/lib/services/manager_api.dart @@ -41,11 +41,11 @@ class ManagerAPI { String defaultKeystorePassword = 's3cur3p@ssw0rd'; String defaultApiUrl = 'https://api.revanced.app/'; String defaultRepoUrl = 'https://api.github.com'; - String defaultPatcherRepo = 'ReVanced/revanced-patcher'; - String defaultPatchesRepo = 'ReVanced/revanced-patches'; - String defaultIntegrationsRepo = 'ReVanced/revanced-integrations'; - String defaultCliRepo = 'ReVanced/revanced-cli'; - String defaultManagerRepo = 'ReVanced/revanced-manager'; + String defaultPatcherRepo = 'revanced/revanced-patcher'; + String defaultPatchesRepo = 'revanced/revanced-patches'; + String defaultIntegrationsRepo = 'revanced/revanced-integrations'; + String defaultCliRepo = 'revanced/revanced-cli'; + String defaultManagerRepo = 'revanced/revanced-manager'; String? patchesVersion = ''; String? integrationsVersion = ''; diff --git a/lib/ui/views/home/home_viewmodel.dart b/lib/ui/views/home/home_viewmodel.dart index e5448c5e84..6913e409e1 100644 --- a/lib/ui/views/home/home_viewmodel.dart +++ b/lib/ui/views/home/home_viewmodel.dart @@ -40,12 +40,11 @@ class HomeViewModel extends BaseViewModel { Future initialize(BuildContext context) async { _managerAPI.rePatchedSavedApps().then((_) => _getPatchedApps()); + _latestManagerVersion = await _managerAPI.getLatestManagerVersion(); if (!_managerAPI.getPatchesConsent()) { await showPatchesConsent(context); } - _latestManagerVersion = await _managerAPI.getLatestManagerVersion(); - await _patcherAPI.initialize(); await flutterLocalNotificationsPlugin.initialize( diff --git a/lib/ui/views/settings/settingsFragment/settings_manage_api_url.dart b/lib/ui/views/settings/settingsFragment/settings_manage_api_url.dart index 899f49bc1e..4185408972 100644 --- a/lib/ui/views/settings/settingsFragment/settings_manage_api_url.dart +++ b/lib/ui/views/settings/settingsFragment/settings_manage_api_url.dart @@ -44,7 +44,10 @@ class SManageApiUrl extends BaseViewModel { color: Theme.of(context).colorScheme.onSurfaceVariant, ), border: const OutlineInputBorder(), - labelText: I18nText('settingsView.selectApiURL').toString(), + labelText: FlutterI18n.translate( + context, + 'settingsView.selectApiURL', + ), hintText: apiUrl, ), ), diff --git a/lib/ui/views/settings/settingsFragment/settings_manage_sources.dart b/lib/ui/views/settings/settingsFragment/settings_manage_sources.dart index 9cf33bbc91..363dab8af4 100644 --- a/lib/ui/views/settings/settingsFragment/settings_manage_sources.dart +++ b/lib/ui/views/settings/settingsFragment/settings_manage_sources.dart @@ -58,9 +58,10 @@ class SManageSources extends BaseViewModel { color: Theme.of(context).colorScheme.onSurfaceVariant, ), border: const OutlineInputBorder(), - labelText: I18nText( + labelText: FlutterI18n.translate( + context, 'settingsView.hostRepositoryLabel', - ).toString(), + ), hintText: hostRepository, ), ), @@ -76,9 +77,10 @@ class SManageSources extends BaseViewModel { color: Theme.of(context).colorScheme.onSurfaceVariant, ), border: const OutlineInputBorder(), - labelText: I18nText( + labelText: FlutterI18n.translate( + context, 'settingsView.orgPatchesLabel', - ).toString(), + ), hintText: patchesRepo.split('/')[0], ), ), @@ -94,9 +96,10 @@ class SManageSources extends BaseViewModel { color: Colors.transparent, ), border: const OutlineInputBorder(), - labelText: I18nText( + labelText: FlutterI18n.translate( + context, 'settingsView.sourcesPatchesLabel', - ).toString(), + ), hintText: patchesRepo.split('/')[1], ), ), @@ -112,9 +115,10 @@ class SManageSources extends BaseViewModel { color: Theme.of(context).colorScheme.onSurfaceVariant, ), border: const OutlineInputBorder(), - labelText: I18nText( + labelText: FlutterI18n.translate( + context, 'settingsView.orgIntegrationsLabel', - ).toString(), + ), hintText: integrationsRepo.split('/')[0], ), ), @@ -130,9 +134,10 @@ class SManageSources extends BaseViewModel { color: Colors.transparent, ), border: const OutlineInputBorder(), - labelText: I18nText( + labelText: FlutterI18n.translate( + context, 'settingsView.sourcesIntegrationsLabel', - ).toString(), + ), hintText: integrationsRepo.split('/')[1], ), ), From 51d71bcc6fd9796ccb93a182c4bf2ee790bd112f Mon Sep 17 00:00:00 2001 From: aAbed Date: Wed, 10 Jan 2024 17:34:58 +0545 Subject: [PATCH 2/3] fix: use same casing while comparing repo --- lib/services/manager_api.dart | 4 ++-- lib/services/revanced_api.dart | 4 ++-- lib/ui/views/contributors/contributors_viewmodel.dart | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/services/manager_api.dart b/lib/services/manager_api.dart index c4a7ccd514..e753a9b72e 100644 --- a/lib/services/manager_api.dart +++ b/lib/services/manager_api.dart @@ -52,12 +52,12 @@ class ManagerAPI { String? integrationsVersion = ''; bool isDefaultPatchesRepo() { - return getPatchesRepo().toLowerCase() == 'revanced/revanced-patches'; + return getPatchesRepo().toLowerCase() == defaultPatchesRepo.toLowerCase(); } bool isDefaultIntegrationsRepo() { return getIntegrationsRepo().toLowerCase() == - 'revanced/revanced-integrations'; + defaultIntegrationsRepo.toLowerCase(); } Future initialize() async { diff --git a/lib/services/revanced_api.dart b/lib/services/revanced_api.dart index 70d2064c98..2f5c210b70 100644 --- a/lib/services/revanced_api.dart +++ b/lib/services/revanced_api.dart @@ -32,7 +32,7 @@ class RevancedAPI { final response = await _dio.get('/contributors'); final List repositories = response.data['repositories']; for (final Map repo in repositories) { - final String name = repo['name']; + final String name = repo['name'].toLowerCase(); contributors[name] = repo['contributors']; } } on Exception catch (e) { @@ -54,7 +54,7 @@ class RevancedAPI { final List tools = response.data['tools']; return tools.firstWhereOrNull( (t) => - t['repository'] == repoName && + (t['repository'] as String).toLowerCase() == repoName.toLowerCase() && (t['name'] as String).endsWith(extension), ); } on Exception catch (e) { diff --git a/lib/ui/views/contributors/contributors_viewmodel.dart b/lib/ui/views/contributors/contributors_viewmodel.dart index c8c7975fd8..3085683c54 100644 --- a/lib/ui/views/contributors/contributors_viewmodel.dart +++ b/lib/ui/views/contributors/contributors_viewmodel.dart @@ -14,9 +14,9 @@ class ContributorsViewModel extends BaseViewModel { final Map> contributors = await _managerAPI.getContributors(); patcherContributors = contributors[_managerAPI.defaultPatcherRepo] ?? []; - patchesContributors = contributors[_managerAPI.getPatchesRepo()] ?? []; + patchesContributors = contributors[_managerAPI.getPatchesRepo().toLowerCase()] ?? []; integrationsContributors = - contributors[_managerAPI.getIntegrationsRepo()] ?? []; + contributors[_managerAPI.getIntegrationsRepo().toLowerCase()] ?? []; cliContributors = contributors[_managerAPI.defaultCliRepo] ?? []; managerContributors = contributors[_managerAPI.defaultManagerRepo] ?? []; notifyListeners(); From 41d99c5b16933a05c5e2837db19ea88c8fceb042 Mon Sep 17 00:00:00 2001 From: aAbed Date: Wed, 10 Jan 2024 17:37:26 +0545 Subject: [PATCH 3/3] refactor: default repo names are lowercase already --- lib/services/manager_api.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/services/manager_api.dart b/lib/services/manager_api.dart index e753a9b72e..72c6fa46e4 100644 --- a/lib/services/manager_api.dart +++ b/lib/services/manager_api.dart @@ -52,12 +52,12 @@ class ManagerAPI { String? integrationsVersion = ''; bool isDefaultPatchesRepo() { - return getPatchesRepo().toLowerCase() == defaultPatchesRepo.toLowerCase(); + return getPatchesRepo().toLowerCase() == defaultPatchesRepo; } bool isDefaultIntegrationsRepo() { return getIntegrationsRepo().toLowerCase() == - defaultIntegrationsRepo.toLowerCase(); + defaultIntegrationsRepo; } Future initialize() async {