diff --git a/appcast.xml b/appcast.xml
new file mode 100644
index 00000000..8ccbcb8d
--- /dev/null
+++ b/appcast.xml
@@ -0,0 +1,33 @@
+
+
+
+ Release
+ -
+ Version 0.10.0
+ Sat, 28 Oct 2023 12:00:00 +0000
+
+
+ -
+ Version 0.10.0
+ Sat, 28 Oct 2023 12:00:00 +0000
+
+
+ -
+ Version 0.10.0
+ Sat, 28 Oct 2023 12:00:00 +0000
+
+
+ -
+ Version 0.10.0
+ Sat, 28 Oct 2023 12:00:00 +0000
+
+
+
+
\ No newline at end of file
diff --git a/lib/core/app/app_view.dart b/lib/core/app/app_view.dart
index 35129467..98eb2b64 100644
--- a/lib/core/app/app_view.dart
+++ b/lib/core/app/app_view.dart
@@ -5,9 +5,11 @@ import 'package:hiddify/core/core_providers.dart';
import 'package:hiddify/core/prefs/prefs.dart';
import 'package:hiddify/core/router/router.dart';
import 'package:hiddify/domain/constants.dart';
+import 'package:hiddify/features/common/app_update_notifier.dart';
import 'package:hiddify/features/common/common_controllers.dart';
import 'package:hiddify/utils/utils.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
+import 'package:upgrader/upgrader.dart';
class AppView extends HookConsumerWidget with PresLogger {
const AppView({super.key});
@@ -20,6 +22,8 @@ class AppView extends HookConsumerWidget with PresLogger {
ref.watch(commonControllersProvider);
+ final upgrader = ref.watch(upgraderProvider);
+
return MaterialApp.router(
// builder: (context, child) {
// return AccessibilityTools(
@@ -37,13 +41,16 @@ class AppView extends HookConsumerWidget with PresLogger {
theme: theme.light(),
darkTheme: theme.dark(),
title: Constants.appName,
-
// https://github.com/ponnamkarthik/FlutterToast/issues/393
builder: (context, child) => Overlay(
initialEntries: [
if (child != null) ...[
OverlayEntry(
- builder: (context) => child,
+ builder: (context) => UpgradeAlert(
+ upgrader: upgrader,
+ navigatorKey: router.routerDelegate.navigatorKey,
+ child: child,
+ ),
),
],
],
diff --git a/lib/domain/constants.dart b/lib/domain/constants.dart
index f7bf76b8..ec42f191 100644
--- a/lib/domain/constants.dart
+++ b/lib/domain/constants.dart
@@ -9,6 +9,8 @@ abstract class Constants {
"https://api.github.com/repos/hiddify/hiddify-next/releases";
static const githubLatestReleaseUrl =
"https://github.com/hiddify/hiddify-next/releases/latest";
+ static const appCastUrl =
+ "https://github.com/hiddify/hiddify-next/appcast.xml";
static const telegramChannelUrl = "https://t.me/hiddify";
static const privacyPolicyUrl = "https://hiddify.com/en/privacy-policy/";
static const termsAndConditionsUrl = "https://hiddify.com/terms/";
diff --git a/lib/features/common/app_update_notifier.dart b/lib/features/common/app_update_notifier.dart
index 72d57fd7..e390ee6c 100644
--- a/lib/features/common/app_update_notifier.dart
+++ b/lib/features/common/app_update_notifier.dart
@@ -1,18 +1,30 @@
+import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:hiddify/core/core_providers.dart';
import 'package:hiddify/core/prefs/prefs.dart';
-import 'package:hiddify/core/router/router.dart';
import 'package:hiddify/data/data_providers.dart';
import 'package:hiddify/domain/app/app.dart';
-import 'package:hiddify/features/common/new_version_dialog.dart';
-import 'package:hiddify/services/service_providers.dart';
+import 'package:hiddify/domain/constants.dart';
import 'package:hiddify/utils/pref_notifier.dart';
import 'package:hiddify/utils/utils.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
+import 'package:upgrader/upgrader.dart';
part 'app_update_notifier.freezed.dart';
part 'app_update_notifier.g.dart';
+const _debugUpgrader = true;
+
+@riverpod
+Upgrader upgrader(UpgraderRef ref) => Upgrader(
+ appcastConfig: AppcastConfiguration(url: Constants.appCastUrl),
+ debugLogging: _debugUpgrader && kDebugMode,
+ durationUntilAlertAgain: const Duration(hours: 12),
+ messages: UpgraderMessages(
+ code: ref.watch(localeNotifierProvider).languageCode,
+ ),
+ );
+
@freezed
class AppUpdateState with _$AppUpdateState {
const factory AppUpdateState.initial() = AppUpdateStateInitial;
@@ -30,7 +42,7 @@ class AppUpdateState with _$AppUpdateState {
class AppUpdateNotifier extends _$AppUpdateNotifier with AppLogger {
@override
AppUpdateState build() {
- _schedule();
+ // _schedule();
return const AppUpdateState.initial();
}
@@ -85,25 +97,25 @@ class AppUpdateNotifier extends _$AppUpdateNotifier with AppLogger {
state = AppUpdateStateIgnored(versionInfo);
}
- Future _schedule() async {
- loggy.debug("scheduling app update checker");
- return ref.read(cronServiceProvider).schedule(
- key: 'app_update',
- duration: const Duration(hours: 8),
- callback: () async {
- await Future.delayed(const Duration(seconds: 5));
- final updateState = await check();
- final context = rootNavigatorKey.currentContext;
- if (context != null && context.mounted) {
- if (updateState
- case AppUpdateStateAvailable(:final versionInfo)) {
- await NewVersionDialog(
- ref.read(appInfoProvider).presentVersion,
- versionInfo,
- ).show(context);
- }
- }
- },
- );
- }
+ // Future _schedule() async {
+ // loggy.debug("scheduling app update checker");
+ // return ref.read(cronServiceProvider).schedule(
+ // key: 'app_update',
+ // duration: const Duration(hours: 8),
+ // callback: () async {
+ // await Future.delayed(const Duration(seconds: 5));
+ // final updateState = await check();
+ // final context = rootNavigatorKey.currentContext;
+ // if (context != null && context.mounted) {
+ // if (updateState
+ // case AppUpdateStateAvailable(:final versionInfo)) {
+ // await NewVersionDialog(
+ // ref.read(appInfoProvider).presentVersion,
+ // versionInfo,
+ // ).show(context);
+ // }
+ // }
+ // },
+ // );
+ // }
}
diff --git a/lib/features/common/common_controllers.dart b/lib/features/common/common_controllers.dart
index 25993d89..7d8b394c 100644
--- a/lib/features/common/common_controllers.dart
+++ b/lib/features/common/common_controllers.dart
@@ -28,11 +28,11 @@ void commonControllers(CommonControllersRef ref) {
(previous, next) {},
fireImmediately: true,
);
- ref.listen(
- appUpdateNotifierProvider,
- (previous, next) {},
- fireImmediately: true,
- );
+ // ref.listen(
+ // appUpdateNotifierProvider,
+ // (previous, next) {},
+ // fireImmediately: true,
+ // );
ref.listen(
profilesUpdateNotifierProvider,
(previous, next) {},
diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift
index 69211250..c21cdd79 100644
--- a/macos/Flutter/GeneratedPluginRegistrant.swift
+++ b/macos/Flutter/GeneratedPluginRegistrant.swift
@@ -5,6 +5,7 @@
import FlutterMacOS
import Foundation
+import device_info_plus
import mobile_scanner
import package_info_plus
import path_provider_foundation
@@ -19,6 +20,7 @@ import url_launcher_macos
import window_manager
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
+ DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
MobileScannerPlugin.register(with: registry.registrar(forPlugin: "MobileScannerPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
diff --git a/pubspec.lock b/pubspec.lock
index f94eef29..ead4db0e 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -313,6 +313,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.3"
+ device_info_plus:
+ dependency: transitive
+ description:
+ name: device_info_plus
+ sha256: "7035152271ff67b072a211152846e9f1259cf1be41e34cd3e0b5463d2d6b8419"
+ url: "https://pub.dev"
+ source: hosted
+ version: "9.1.0"
+ device_info_plus_platform_interface:
+ dependency: transitive
+ description:
+ name: device_info_plus_platform_interface
+ sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64
+ url: "https://pub.dev"
+ source: hosted
+ version: "7.0.0"
dio:
dependency: "direct main"
description:
@@ -797,6 +813,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.1"
+ os_detect:
+ dependency: transitive
+ description:
+ name: os_detect
+ sha256: faf3bcf39515e64da8ff76b2f2805b20a6ff47ae515393e535f8579ff91d6b7f
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.1"
package_config:
dependency: transitive
description:
@@ -1394,6 +1418,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.2.2"
+ upgrader:
+ dependency: "direct main"
+ description:
+ name: upgrader
+ sha256: "889c1ece7af143df32e8ee2126f2ef17b2ab6bb7ed8fc3b1b022d7faa4fdab20"
+ url: "https://pub.dev"
+ source: hosted
+ version: "8.2.0"
url_launcher:
dependency: "direct main"
description:
@@ -1506,6 +1538,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
+ version:
+ dependency: transitive
+ description:
+ name: version
+ sha256: "3d4140128e6ea10d83da32fef2fa4003fccbf6852217bb854845802f04191f94"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.0.2"
vm_service:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index 1671d095..16837a42 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -66,6 +66,7 @@ dependencies:
sliver_tools: ^0.2.12
flutter_adaptive_scaffold: ^0.1.7+1
humanizer: ^2.2.0
+ upgrader: ^8.2.0
dev_dependencies:
flutter_test: