Skip to content

Commit

Permalink
refactor: restructure codebase. (#501)
Browse files Browse the repository at this point in the history
* refactor: separate language selection to own widget.

* feat: separate theme changer to own widget.

* refactor: move Appearance UI to separate class.

* refactor: move language selection UI to separate class.

* refactor: move sources selection to separate file.

* refactor: move sources selection to separate file.

* refactor: split settings sections in separate files.

* refactor: move logging section to separate file.

* fix: show toast on bottom.

* fix: recommended patches not being selected by default.

* fix: patch selection selecting non recommended patches.

* fix: experimental toggle not updating.
  • Loading branch information
Aunali321 authored Nov 12, 2022
1 parent ee68992 commit 0faf86c
Show file tree
Hide file tree
Showing 23 changed files with 1,050 additions and 716 deletions.
6 changes: 1 addition & 5 deletions assets/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"disabledLabel": "Disabled",
"yesButton": "Yes",
"noButton": "No",
"warning": "Warning",
"navigationView": {
"dashboardTab": "Dashboard",
"patcherTab": "Patcher",
Expand Down Expand Up @@ -45,7 +46,6 @@
"patcherView": {
"widgetTitle": "Patcher",
"patchButton": "Patch",
"patchDialogTitle": "Warning",
"patchDialogText": "You have selected a resource patch and a split APK installation has been detected, so patching errors may occur.\nAre you sure you want to proceed?"
},
"appSelectorCard": {
Expand Down Expand Up @@ -80,12 +80,9 @@
"loadPatchesSelection": "Load patches selection",
"noSavedPatches": "No saved patches for the selected app\nPress Done to save current selection",
"noPatchesFound": "No patches found for the selected app",
"selectAllPatchesWarningTitle": "Warning",
"selectAllPatchesWarningContent": "You are about to select all patches, that includes unrecommended patches and can cause unwanted behavior."
},
"patchItem": {
"unsupportedWarningButton": "Warning",
"unsupportedDialogTitle": "Warning",
"unsupportedDialogText": "Selecting this patch may result in patching errors.\n\nApp version: {packageVersion}\nSupported versions:\n{supportedVersions}",
"unsupportedPatchVersion": "Patch is not supported for this app version. Enable experimental toggle in settings to proceed."
},
Expand Down Expand Up @@ -119,7 +116,6 @@
"dynamicThemeHint": "Enjoy an experience closer to your device",
"languageLabel": "Language",
"englishOption": "English",
"frenchOption": "French",
"sourcesLabel": "Sources",
"sourcesLabelHint": "Configure your custom sources",
"orgPatchesLabel": "Patches organization",
Expand Down
197 changes: 197 additions & 0 deletions assets/i18n/hi_IN.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
{
"okButton": "ठीक है",
"cancelButton": "रद्द करें",
"enabledLabel": "सक्रिय",
"disabledLabel": "निष्क्रिय",
"yesButton": "हाँ",
"noButton": "नहीं",
"navigationView": {
"dashboardTab": "नियंत्रण-पट्ट",
"patcherTab": "पैचर",
"settingsTab": "सेटिंग्स"
},
"homeView": {
"widgetTitle": "नियंत्रण पट्ट",
"updatesSubtitle": "अपडेट",
"patchedSubtitle": "Patched applications",
"updatesAvailable": "अपडेट उपलब्ध है",
"noUpdates": "कोई अपडेट उपलब्ध नहीं",
"WIP": "Work in progress...",
"noInstallations": "कोई पैबंद किये हुआ अनुप्रयोग नहीं है।",
"installed": "इंस्टॉल किया हुआ",
"updateDialogTitle": "अपडेट Manager",
"updateDialogText": "क्या आप ReVanced Manager को डाउनलोड और अपडेट करना चाहते है?",
"notificationTitle": "Update downloaded",
"notificationText": "Tap to install the update",
"downloadingMessage": "अपडेट डाउनलोड हो रहा है",
"installingMessage": "अपडेट इंस्टॉल हो रहा है",
"errorDownloadMessage": "अपडेट डाउनलोड करने मे असफल",
"errorInstallMessage": "अपडेट इंस्टॉल करने में असफल",
"noConnection": "कोई इंटरनेट कनेक्शन नहीं",
"updatesDisabled": "पैच किए गए ऐप को अपडेट करना वर्तमान में अक्षम है। ऐप को फिर से रीपैच करें।"
},
"applicationItem": {
"patchButton": "पैबंद",
"infoButton": "जानकारी",
"changelogLabel": "परिवर्तन पत्र"
},
"latestCommitCard": {
"loadingLabel": "लोड हो रहा है...",
"timeagoLabel": "{time} पहले",
"patcherLabel": "पैबंद: ",
"managerLabel": "Manager: ",
"updateButton": "Manager अपडेट करे"
},
"patcherView": {
"widgetTitle": "पैचर",
"patchButton": "पैबंद",
"patchDialogTitle": "चेतावनी",
"patchDialogText": "You have selected a resource patch and a split APK installation has been detected, so patching errors may occur.\nAre you sure you want to proceed?"
},
"appSelectorCard": {
"widgetTitle": "Select an application",
"widgetTitleSelected": "चुना हुआ ऐप्लकैशन",
"widgetSubtitle": "कोई ऐप्लकैशन चुना हुआ नहीं",
"noAppsLabel": "No applications found",
"currentVersion": "वर्तमान",
"recommendedVersion": "अनुशंसित",
"anyVersion": "कोई"
},
"patchSelectorCard": {
"widgetTitle": "पैच चुने",
"widgetTitleSelected": "चुने हुए पैच",
"widgetSubtitle": "पहले किसी एप्लिकेशन को चुने",
"widgetEmptySubtitle": "कोई पैच चुना हुआ नहीं"
},
"socialMediaCard": {
"widgetTitle": "सामाजिक",
"widgetSubtitle": "हम ऑनलाइन है"
},
"appSelectorView": {
"viewTitle": "Select an application",
"searchBarHint": "ऐप्लकैशन खोजे",
"storageButton": "स्टोरेज",
"errorMessage": "Unable to use selected application"
},
"patchesSelectorView": {
"viewTitle": "पैच चुने",
"searchBarHint": "पैच खोजे",
"doneButton": "पूर्ण",
"loadPatchesSelection": "Load patches selection",
"noSavedPatches": "No saved patches for the selected app\nPress Done to save current selection",
"noPatchesFound": "चुने हुए ऐप्लकैशन के लिए कोई पैच नहीं मिले",
"selectAllPatchesWarningTitle": "चेतावनी",
"selectAllPatchesWarningContent": "आप सभी पैच का चयन करने वाले हैं, जिसमें अनुशंसित पैच शामिल हैं और अवांछित व्यवहार का कारण बन सकते हैं।"
},
"patchItem": {
"unsupportedWarningButton": "चेतावनी",
"unsupportedDialogTitle": "चेतावनी",
"unsupportedDialogText": "Selecting this patch may result in patching errors.\n\nApp version: {packageVersion}\nSupported versions:\n{supportedVersions}",
"unsupportedPatchVersion": "इस ऐप संस्करण के लिए पैच समर्थित नहीं है। आगे बढ़ने के लिए सेटिंग में प्रयोगात्मक टॉगल सक्षम करें."
},
"installerView": {
"widgetTitle": "इंस्टॉल कर्ता",
"installButton": "इंस्टॉल करे",
"installRootButton": "रूट के रूप मे इंस्टॉल करे",
"openButton": "खोलें",
"shareButton": "फाइल शेयर करे",
"notificationTitle": "ReVanced Manager पैच कर रहा है",
"notificationText": "इंस्टॉल कर्ता पर जाने के लिए टैप करे",
"shareApkMenuOption": "APK शेयर करे",
"exportApkMenuOption": "निर्यात APK",
"shareLogMenuOption": "लॉग शेयर करें",
"installErrorDialogTitle": "त्रुटि",
"installErrorDialogText1": "वर्तमान पैच चयन के साथ रूट इंस्टॉल संभव नहीं है।\nअपने ऐप को रीपैच करें या नॉन-रूट इंस्टॉल चुनें।",
"installErrorDialogText2": "वर्तमान पैच चयन के साथ नॉन-रूट इंस्टॉल संभव नहीं है।\nयदि आपने अपना डिवाइस रूट किया है तो अपने ऐप को रीपैच करें या रूट इंस्टॉल चुनें।",
"installErrorDialogText3": "रूट इंस्टॉल संभव नहीं है क्योंकि मूल APK को स्टोरेज से चुना गया था।\nएक इंस्टॉल किया गया ऐप चुनें या नॉन-रूट इंस्टॉल चुनें।",
"noExit": "Installer is still running, cannot exit..."
},
"settingsView": {
"widgetTitle": "सेटिंग्स",
"appearanceSectionTitle": "स्वरूप",
"teamSectionTitle": "टीम",
"infoSectionTitle": "जानकारी",
"advancedSectionTitle": "एडवांसड",
"logsSectionTitle": "लॉग्स",
"darkThemeLabel": "Dark mode",
"darkThemeHint": "Welcome to the dark side",
"dynamicThemeLabel": "मेटीरियल यू",
"dynamicThemeHint": "अपने डिवाइस के करीब एक अनुभव का आनंद लें",
"languageLabel": "भाषा",
"englishOption": "अंग्रेज़ी",
"frenchOption": "फ्रेंच",
"sourcesLabel": "स्रोत",
"sourcesLabelHint": "अपने कस्टम साधन कॉन्फ़िगर करे",
"orgPatchesLabel": "Patches organization",
"sourcesPatchesLabel": "Patches source",
"orgIntegrationsLabel": "Integrations organization",
"sourcesIntegrationsLabel": "Integrations source",
"sourcesResetDialogTitle": "रीसेट करें",
"sourcesResetDialogText": "क्या आप वाकई कस्टम साधन को डिफ़ॉल्ट वैल्यू पर रीसेट करना चाहते हैं?",
"apiURLResetDialogText": "क्या आप वाकई कस्टम API URL को डिफ़ॉल्ट वैल्यू पर रीसेट करना चाहते हैं?",
"contributorsLabel": "योगदानकर्ता",
"contributorsHint": "ReVanced के योगदानकर्ताओ की सूची",
"logsLabel": "लॉग्स",
"logsHint": "Share Manager's logs",
"apiURLLabel": "API URL",
"apiURLHint": "अपनी कस्टम API URL कॉन्फ़िगर करे",
"selectApiURL": "API URL",
"experimentalPatchesLabel": "Experimental patches support",
"experimentalPatchesHint": "Enable usage of unsupported patches in any app version",
"enabledExperimentalPatches": "Experimental patches support enabled",
"exportSectionTitle": "Import & export",
"aboutLabel": "विवरण",
"snackbarMessage": "क्लिपबोर्ड में कॉपी हो गया है",
"sentryLabel": "Sentry logging",
"sentryHint": "उन्नत प्रबंधक को बेहतर बनाने में हमारी सहायता करने के लिए अनाम लॉग भेजें",
"restartAppForChanges": "Restart the app to apply changes",
"deleteKeystoreLabel": "कीस्टोर मिटाएं",
"deleteKeystoreHint": "ऐप पर हस्ताक्षर करने के लिए उपयोग की जाने वाली कीस्टोर हटाएं",
"deletedKeystore": "कीस्टोर हटा दिया गया",
"deleteTempDirLabel": "Delete temporary files",
"deleteTempDirHint": "Delete the unused temporary files",
"deletedTempDir": "Temporary files deleted",
"exportPatchesLabel": "Export patches selection",
"exportPatchesHint": "Export patches selection to a JSON file",
"exportedPatches": "Patches selection exported",
"noExportFileFound": "No patches selection to export",
"importPatchesLabel": "Import patches selection",
"importPatchesHint": "Import patches selection from a JSON file",
"importedPatches": "Patches selection imported",
"resetStoredPatchesLabel": "Reset patches",
"resetStoredPatchesHint": "Reset the stored patches selection",
"resetStoredPatches": "Patches selection has been reset",
"jsonSelectorErrorMessage": "Unable to use selected JSON file",
"deleteLogsLabel": "लॉग हटाएं",
"deleteLogsHint": "एकत्रित प्रबंधक लॉग हटाएं",
"deletedLogs": "लॉग हटा दिए गए"
},
"appInfoView": {
"widgetTitle": "App info",
"openButton": "खोलें",
"uninstallButton": "अनइंस्टॉल करें",
"patchButton": "पैच",
"unpatchButton": "अनपैच करे",
"unpatchDialogText": "क्या वाकई आप इस एप को अनपैच करना चाहते हैं?",
"rootDialogTitle": "त्रुटि",
"rootDialogText": "App was installed with superuser permissions, but currently ReVanced Manager has no permissions.\nPlease grant superuser permissions first.",
"packageNameLabel": "Package name",
"originalPackageNameLabel": "Original package name",
"installTypeLabel": "Installation type",
"rootTypeLabel": "रूट",
"nonRootTypeLabel": "नॉन-रूट",
"patchedDateLabel": "Patched date",
"patchedDateHint": "{date} {time} पर",
"appliedPatchesLabel": "Applied patches",
"appliedPatchesHint": "{quantity} लागू किए हुआ पैच",
"updateNotImplemented": "This feature has not been implemented yet"
},
"contributorsView": {
"widgetTitle": "योगदानकर्ता",
"patcherContributors": "Patcher contributors",
"patchesContributors": "Patches contributors",
"integrationsContributors": "Integrations contributors",
"cliContributors": "CLI contributors",
"managerContributors": "Manager contributors"
}
}
12 changes: 6 additions & 6 deletions lib/services/manager_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ class ManagerAPI {
await _prefs.setBool('useDarkTheme', value);
}

// bool isSentryEnabled() {
// return _prefs.getBool('sentryEnabled') ?? true;
// }
bool isSentryEnabled() {
return _prefs.getBool('sentryEnabled') ?? true;
}

// Future<void> setSentryStatus(bool value) async {
// await _prefs.setBool('sentryEnabled', value);
// }
Future<void> setSentryStatus(bool value) async {
await _prefs.setBool('sentryEnabled', value);
}

bool areExperimentalPatchesEnabled() {
return _prefs.getBool('experimentalPatchesEnabled') ?? false;
Expand Down
10 changes: 7 additions & 3 deletions lib/ui/views/app_selector/app_selector_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ class AppSelectorViewModel extends BaseViewModel {
List<String> pathSplit = result.files.single.path!.split("/");
pathSplit.removeLast();
Directory filePickerCacheDir = Directory(pathSplit.join("/"));
Iterable<File> deletableFiles = (await filePickerCacheDir.list().toList()).whereType<File>();
for (var file in deletableFiles) { if (file.path != apkFile.path && file.path.endsWith(".apk")) file.delete(); }
Iterable<File> deletableFiles =
(await filePickerCacheDir.list().toList()).whereType<File>();
for (var file in deletableFiles) {
if (file.path != apkFile.path && file.path.endsWith(".apk"))
file.delete();
}
ApplicationWithIcon? application = await DeviceApps.getAppFromStorage(
apkFile.path,
true,
Expand All @@ -72,7 +76,7 @@ class AppSelectorViewModel extends BaseViewModel {
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
_toast.show('appSelectorView.errorMessage');
_toast.showBottom('appSelectorView.errorMessage');
}
}

Expand Down
12 changes: 6 additions & 6 deletions lib/ui/views/home/home_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class HomeViewModel extends BaseViewModel {
?.requestPermission();
bool isConnected = await Connectivity().checkConnection();
if (!isConnected) {
_toast.show('homeView.noConnection');
_toast.showBottom('homeView.noConnection');
}
_getPatchedApps();
_managerAPI.reAssessSavedApps().then((_) => _getPatchedApps());
Expand Down Expand Up @@ -105,7 +105,7 @@ class HomeViewModel extends BaseViewModel {

Future<void> updateManager(BuildContext context) async {
try {
_toast.show('homeView.downloadingMessage');
_toast.showBottom('homeView.downloadingMessage');
File? managerApk = await _managerAPI.downloadManager();
if (managerApk != null) {
await flutterLocalNotificationsPlugin.zonedSchedule(
Expand All @@ -132,19 +132,19 @@ class HomeViewModel extends BaseViewModel {
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime,
);
_toast.show('homeView.installingMessage');
_toast.showBottom('homeView.installingMessage');
await AppInstaller.installApk(managerApk.path);
} else {
_toast.show('homeView.errorDownloadMessage');
_toast.showBottom('homeView.errorDownloadMessage');
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
_toast.show('homeView.errorInstallMessage');
_toast.showBottom('homeView.errorInstallMessage');
}
}

void updatesAreDisabled() {
_toast.show('homeView.updatesDisabled');
_toast.showBottom('homeView.updatesDisabled');
}

Future<void> showUpdateConfirmationDialog(BuildContext parentContext) async {
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/installer/installer_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class InstallerViewModel extends BaseViewModel {

Future<bool> onWillPop(BuildContext context) async {
if (isPatching) {
_toast.show('installerView.noExit');
_toast.showBottom('installerView.noExit');
return false;
}
cleanPatcher();
Expand Down
5 changes: 3 additions & 2 deletions lib/ui/views/patcher/patcher_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class PatcherViewModel extends BaseViewModel {
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: I18nText('patcherView.patchDialogTitle'),
title: I18nText('warning'),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText('patcherView.patchDialogText'),
actions: <Widget>[
Expand Down Expand Up @@ -114,7 +114,8 @@ class PatcherViewModel extends BaseViewModel {
await _managerAPI.getSelectedPatches(selectedApp!.originalPackageName);
List<Patch> patches =
await _patcherAPI.getFilteredPatches(selectedApp!.originalPackageName);
this.selectedPatches
this
.selectedPatches
.addAll(patches.where((patch) => selectedPatches.contains(patch.name)));
notifyListeners();
}
Expand Down
Loading

0 comments on commit 0faf86c

Please sign in to comment.