From 3471c82c61128dab623f5f2b403a4abcc166221b Mon Sep 17 00:00:00 2001 From: neckfire Date: Mon, 13 Jul 2026 09:53:14 +0200 Subject: [PATCH] =?UTF-8?q?fix(android):=20ota=5Fupdate=20=E2=86=92=20url?= =?UTF-8?q?=5Flauncher=20(r=C3=A9sout=20lStar/compileSdk)=20=E2=86=92=20AP?= =?UTF-8?q?K=20sign=C3=A9e=20OK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 --- lib/screens/servers_screen.dart | 18 ++++---- lib/services/update_service.dart | 13 +++--- lib/theme.dart | 2 +- pubspec.lock | 72 ++++++++++++++++++++++++++++---- pubspec.yaml | 2 +- 5 files changed, 81 insertions(+), 26 deletions(-) diff --git a/lib/screens/servers_screen.dart b/lib/screens/servers_screen.dart index d7d2925..f7ca6b1 100644 --- a/lib/screens/servers_screen.dart +++ b/lib/screens/servers_screen.dart @@ -78,18 +78,14 @@ class _ServersScreenState extends State { ], ), ); - if (go == true) _applyUpdate(info); - } - - void _applyUpdate(UpdateInfo info) { - UpdateService(widget.api.baseUrl).apply(info).listen((_) {}, onError: (e) { - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('MAJ échouée : $e'))); + if (go == true) { + final ok = await UpdateService(widget.api.baseUrl).apply(info); + if (mounted && !ok) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Impossible d\'ouvrir le téléchargement.')), + ); } - }); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('Téléchargement de la mise à jour…')), - ); + } } Future _openSettings() async { diff --git a/lib/services/update_service.dart b/lib/services/update_service.dart index a3b2059..c8906df 100644 --- a/lib/services/update_service.dart +++ b/lib/services/update_service.dart @@ -1,11 +1,12 @@ import 'dart:convert'; import 'package:http/http.dart' as http; -import 'package:ota_update/ota_update.dart'; import 'package:package_info_plus/package_info_plus.dart'; +import 'package:url_launcher/url_launcher.dart'; /// Vérifie s'il existe une version plus récente (API `/version`) et, si oui, -/// télécharge + installe l'APK (hors Play Store). +/// ouvre l'URL de l'APK (le navigateur télécharge, l'utilisateur installe — +/// robuste, sans dépendance de packaging fragile). class UpdateService { UpdateService(this._baseUrl); final Future _baseUrl; @@ -30,9 +31,11 @@ class UpdateService { return null; } - /// Lance le téléchargement + l'installation ; renvoie le flux de progression. - Stream apply(UpdateInfo info) => - OtaUpdate().execute(info.apkUrl, destinationFilename: 'gamemanager.apk'); + Future apply(UpdateInfo info) async { + final uri = Uri.parse(info.apkUrl); + if (!await canLaunchUrl(uri)) return false; + return launchUrl(uri, mode: LaunchMode.externalApplication); + } } class UpdateInfo { diff --git a/lib/theme.dart b/lib/theme.dart index e7482e1..7afcd7e 100644 --- a/lib/theme.dart +++ b/lib/theme.dart @@ -25,7 +25,7 @@ class AppTheme { letterSpacing: -0.5, ), ), - cardTheme: CardThemeData( + cardTheme: CardTheme( clipBehavior: Clip.antiAlias, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(22)), elevation: 0, diff --git a/pubspec.lock b/pubspec.lock index 5d83c94..57330c4 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -187,14 +187,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.15.0" - ota_update: - dependency: "direct main" - description: - name: ota_update - sha256: "8c47531b655f8fcf9961dc7758a933a9ccbcbe1c77a7ec52e5c5cfc2ec367ba7" - url: "https://pub.dev" - source: hosted - version: "6.0.0" package_info_plus: dependency: "direct main" description: @@ -376,6 +368,70 @@ packages: url: "https://pub.dev" source: hosted version: "1.4.0" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + sha256: "9d06212b1362abc2f0f0d78e6f09f726608c74e3b9462e8368bb03314aa8d603" + url: "https://pub.dev" + source: hosted + version: "6.3.1" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "6fc2f56536ee873eeb867ad176ae15f304ccccc357848b351f6f0d8d4a40d193" + url: "https://pub.dev" + source: hosted + version: "6.3.14" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: "7f2022359d4c099eea7df3fdf739f7d3d3b9faf3166fb1dd390775176e0b76cb" + url: "https://pub.dev" + source: hosted + version: "6.3.3" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: "4e9ba368772369e3e08f231d2301b4ef72b9ff87c31192ef471b380ef29a4935" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: "17ba2000b847f334f16626a574c702b196723af2a289e7a93ffcb79acff855c2" + url: "https://pub.dev" + source: hosted + version: "3.2.2" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "772638d3b34c779ede05ba3d38af34657a05ac55b06279ea6edd409e323dca8e" + url: "https://pub.dev" + source: hosted + version: "2.3.3" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "3284b6d2ac454cf34f114e1d3319866fdd1e19cdc329999057e44ffe936cfa77" + url: "https://pub.dev" + source: hosted + version: "3.1.4" vector_math: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 662c96b..bc8e38e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: flutter_secure_storage: ^9.2.2 shared_preferences: ^2.3.2 package_info_plus: ^8.1.1 - ota_update: ^6.0.0 + url_launcher: ^6.3.1 cupertino_icons: ^1.0.8 dev_dependencies: