Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Show a dialog when an update is available #1654

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 18 additions & 8 deletions assets/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"noShowAgain": "Don't show this again",
"add": "Add",
"remove": "Remove",
"showChangelogButton": "Show changelog",
"showUpdateButton": "Show update",
"navigationView": {
"dashboardTab": "Dashboard",
"patcherTab": "Patcher",
Expand All @@ -27,6 +29,7 @@

"updatesSubtitle": "Updates",
"patchedSubtitle": "Patched apps",
"changeLaterSubtitle": "You can change this in the settings at a later time.",

"noUpdates": "No updates available",

Expand All @@ -35,20 +38,25 @@
"noInstallations": "No patched apps installed",
"installUpdate": "Continue to install the update?",

"updateDialogTitle": "Update Manager",
"updatePatchesDialogTitle": "Update ReVanced Patches",
"updateSheetTitle": "Update ReVanced Manager",
"updateDialogTitle": "New update available",
"updatePatchesSheetTitle": "Update ReVanced Patches",
"updateChangelogTitle": "Changelog",

"patchesConsentDialogText": "ReVanced Patches needs to be downloaded.",
"patchesConsentDialogText2": "This will connect you to {url}.",
"patchesConsentDialogText3": "Auto update?",
"patchesConsentDialogText3Sub": "You can change this in settings at a later time.",
"updateDialogText": "A new update is available for {file}.\n\nThe currently installed version is {version}.",

"downloadConsentDialogTitle": "Download necessary files?",
"downloadConsentDialogText": "ReVanced Manager needs to download necessary files to to work properly.",
"downloadConsentDialogText2": "This will connect you to {url}.",

"checkUpdateDialogTitle": "Check for updates?",
"checkUpdateDialogText": "Do you want ReVanced Manager to check for updates automatically?",

"notificationTitle": "Update downloaded",
"notificationText": "Tap to install the update",

"downloadingMessage": "Downloading update...",
"downloadedMessage": "Update downloaded!",
"downloadedMessage": "Update downloaded",

"installingMessage": "Installing update...",

Expand Down Expand Up @@ -157,7 +165,7 @@
"unsupportedPatchVersion": "Patch is not supported for this app version.",
"unsupportedRequiredOption": "This patch contains a required option that is not supported by this app",

"patchesChangeWarningDialogText": "It is recommended to use the default patch selection and options. Changing them may result in unexpected issues.\n\nYou'll need to turn on \"Allow changing patch selection\" in settings before changing any patch selection.",
"patchesChangeWarningDialogText": "It is recommended to use the default patch selection and options. Changing them may result in unexpected issues.\n\nYou'll need to turn on \"Allow changing patch selection\" in the settings before changing any patch selection.",
"patchesChangeWarningDialogButton": "Use default selection"
},
"installerView": {
Expand Down Expand Up @@ -235,6 +243,8 @@

"autoUpdatePatchesLabel": "Auto update patches",
"autoUpdatePatchesHint": "Automatically update patches to the latest version",
"showUpdateDialogLabel": "Show update dialog",
"showUpdateDialogHint": "Show a dialog when a new update is available",
"universalPatchesLabel": "Show universal patches",
"universalPatchesHint": "Display all apps and universal patches (may slow down the app list)",

Expand Down
2 changes: 1 addition & 1 deletion lib/services/github_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class GithubAPI {
int updates = 0;
final String currentVersion =
await _managerAPI.getCurrentManagerVersion();
while (response.data[updates]['tag_name'] != 'v$currentVersion') {
while (response.data[updates]['tag_name'] != currentVersion) {
updates++;
}
for (int i = 1; i < updates; i++) {
Expand Down
26 changes: 19 additions & 7 deletions lib/services/manager_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ class ManagerAPI {
await _prefs.setString('patchesRepo', value);
}

bool getPatchesConsent() {
return _prefs.getBool('patchesConsent') ?? false;
bool getDownloadConsent() {
return _prefs.getBool('downloadConsent') ?? false;
}

Future<void> setPatchesConsent(bool consent) async {
await _prefs.setBool('patchesConsent', consent);
void setDownloadConsent(bool consent) {
_prefs.setBool('downloadConsent', consent);
}

bool isPatchesAutoUpdate() {
Expand All @@ -156,6 +156,14 @@ class ManagerAPI {
_prefs.setBool('showPatchesChangeWarning', !value);
}

bool showUpdateDialog() {
return _prefs.getBool('showUpdateDialog') ?? true;
}

void setShowUpdateDialog(bool value) {
_prefs.setBool('showUpdateDialog', value);
}

bool isChangingToggleModified() {
return _prefs.getBool('isChangingToggleModified') ?? false;
}
Expand All @@ -164,8 +172,8 @@ class ManagerAPI {
_prefs.setBool('isChangingToggleModified', value);
}

Future<void> setPatchesAutoUpdate(bool value) async {
await _prefs.setBool('patchesAutoUpdate', value);
void setPatchesAutoUpdate(bool value) {
_prefs.setBool('patchesAutoUpdate', value);
}

List<Patch> getSavedPatches(String packageName) {
Expand Down Expand Up @@ -508,7 +516,11 @@ class ManagerAPI {

Future<String> getCurrentManagerVersion() async {
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
return packageInfo.version;
String version = packageInfo.version;
if (!version.startsWith('v')) {
version = 'v$version';
}
return version;
}

Future<String> getCurrentPatchesVersion() async {
Expand Down
4 changes: 4 additions & 0 deletions lib/services/revanced_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:injectable/injectable.dart';
import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/services/download_manager.dart';
import 'package:revanced_manager/services/manager_api.dart';
import 'package:synchronized/synchronized.dart';
import 'package:timeago/timeago.dart';

Expand Down Expand Up @@ -48,6 +49,9 @@ class RevancedAPI {
String extension,
String repoName,
) {
if (!locator<ManagerAPI>().getDownloadConsent()) {
return Future(() => null);
}
return getToolsLock.synchronized(() async {
try {
final response = await _dio.get('/tools');
Expand Down