fix(android): ota_update → url_launcher (résout lStar/compileSdk) → APK signée OK
Build APK / build (push) Successful in 2m33s

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
neckfire
2026-07-13 09:53:14 +02:00
co-authored by Claude Opus 4.8
parent fac757d9a0
commit 3471c82c61
5 changed files with 81 additions and 26 deletions
+7 -11
View File
@@ -78,18 +78,14 @@ class _ServersScreenState extends State<ServersScreen> {
],
),
);
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<void> _openSettings() async {
+8 -5
View File
@@ -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<String> _baseUrl;
@@ -30,9 +31,11 @@ class UpdateService {
return null;
}
/// Lance le téléchargement + l'installation ; renvoie le flux de progression.
Stream<OtaEvent> apply(UpdateInfo info) =>
OtaUpdate().execute(info.apkUrl, destinationFilename: 'gamemanager.apk');
Future<bool> apply(UpdateInfo info) async {
final uri = Uri.parse(info.apkUrl);
if (!await canLaunchUrl(uri)) return false;
return launchUrl(uri, mode: LaunchMode.externalApplication);
}
}
class UpdateInfo {
+1 -1
View File
@@ -25,7 +25,7 @@ class AppTheme {
letterSpacing: -0.5,
),
),
cardTheme: CardThemeData(
cardTheme: CardTheme(
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(22)),
elevation: 0,