3 Commits
Author SHA1 Message Date
neckfireandClaude Opus 4.8 a971204b80 fix(ci): signature release réellement appliquée + maj in-app (open_filex)
Build APK / build (push) Successful in 2m28s
- patch_android.py: gère 'signingConfig = signingConfigs.debug' (Flutter 3.24
  utilise le '='), sans quoi le build restait signé en clé debug éphémère
  → signature différente à chaque run → 'conflit' à l'install de MAJ. Échoue
  désormais le build si la ligne n'est pas patchée (garde-fou).
- update_service: télécharge l'APK in-app + lance l'installeur (open_filex),
  fallback navigateur ; barre de progression dans l'écran serveurs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-13 11:44:54 +02:00
neckfireandClaude Opus 4.8 0257f0fa05 feat(ui): preprod dans un onglet séparé (TabBar Production / Preprod)
Build APK / build (push) Successful in 2m27s
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-13 11:33:12 +02:00
neckfireandClaude Opus 4.8 25890d7bbc feat: section preprod (env prod/preprod) + intégration ANTS (prod+preprod, jeu web)
Build APK / build (push) Successful in 2m27s
- servers groupés par environnement (Production / Preprod) avec en-têtes
- ANTS prod (ants-web) + preprod (ants-web-rd) intégrés : jeu web, bouton Ouvrir
- The Cycle preprod (the-cycle-api-rd) ajouté
- badge PREPROD sur les cartes concernées, thème ANTS (fourmi/ambre)
- supprime le widget_test.dart par défaut (cassé, non compilé dans l'APK)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-13 11:28:22 +02:00
6 changed files with 202 additions and 45 deletions
+13
View File
@@ -8,6 +8,9 @@ class GameServer {
final String? subtitle;
final String? connect;
final bool onDemand;
final String env; // prod | preprod
final bool web; // jeu web → bouton « Ouvrir »
final String? openUrl;
final String status; // stopped | starting | running | online | partial
final int? players;
final int? maxPlayers;
@@ -21,6 +24,9 @@ class GameServer {
this.subtitle,
this.connect,
this.onDemand = false,
this.env = 'prod',
this.web = false,
this.openUrl,
required this.status,
this.players,
this.maxPlayers,
@@ -35,6 +41,9 @@ class GameServer {
subtitle: json['subtitle'] as String?,
connect: json['connect'] as String?,
onDemand: json['on_demand'] as bool? ?? false,
env: json['env'] as String? ?? 'prod',
web: json['web'] as bool? ?? false,
openUrl: json['open_url'] as String?,
status: json['status'] as String? ?? 'stopped',
players: json['players'] as int?,
maxPlayers: json['max_players'] as int?,
@@ -44,6 +53,7 @@ class GameServer {
bool get isUp => status == 'online' || status == 'running';
bool get isBusy => status == 'starting' || status == 'partial';
bool get isPreprod => env == 'preprod';
/// Couleur d'accent thématique par jeu (visuel sans dépendance externe).
({Color start, Color end, IconData icon}) get theme {
@@ -57,6 +67,9 @@ class GameServer {
if (g.contains('cycle')) {
return (start: const Color(0xFF00BCD4), end: const Color(0xFF1A237E), icon: Icons.rocket_launch);
}
if (g.contains('swarm') || g.contains('ants')) {
return (start: const Color(0xFFF9A825), end: const Color(0xFF6D4C00), icon: Icons.bug_report);
}
return (start: const Color(0xFF7E57C2), end: const Color(0xFF311B92), icon: Icons.sports_esports);
}
+64 -18
View File
@@ -78,15 +78,37 @@ class _ServersScreenState extends State<ServersScreen> {
],
),
);
if (go == true) {
final ok = await UpdateService(widget.api.baseUrl).apply(info);
if (go != true || !mounted) return;
final progress = ValueNotifier<double?>(0);
showDialog(
context: context,
barrierDismissible: false,
builder: (_) => AlertDialog(
title: const Text('Téléchargement…'),
content: ValueListenableBuilder<double?>(
valueListenable: progress,
builder: (_, p, __) => Column(
mainAxisSize: MainAxisSize.min,
children: [
LinearProgressIndicator(value: p),
const SizedBox(height: 10),
Text(p == null ? '' : '${(p * 100).round()} %'),
],
),
),
),
);
final ok = await UpdateService(widget.api.baseUrl)
.apply(info, onProgress: (p) => progress.value = p);
if (mounted) Navigator.of(context, rootNavigator: true).pop(); // ferme la progression
if (mounted && !ok) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Impossible d\'ouvrir le téléchargement.')),
const SnackBar(content: Text('Mise à jour impossible.')),
);
}
}
}
Future<void> _openSettings() async {
await Navigator.push(context,
@@ -101,17 +123,23 @@ class _ServersScreenState extends State<ServersScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
return DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
title: const Text('Serveurs'),
actions: [
IconButton(onPressed: _openSettings, icon: const Icon(Icons.settings_outlined)),
IconButton(onPressed: _logout, icon: const Icon(Icons.logout)),
],
bottom: const TabBar(
tabs: [
Tab(icon: Icon(Icons.public), text: 'Production'),
Tab(icon: Icon(Icons.science_outlined), text: 'Preprod'),
],
),
body: RefreshIndicator(
onRefresh: _refresh,
child: _buildBody(),
),
body: _buildBody(),
),
);
}
@@ -130,13 +158,33 @@ class _ServersScreenState extends State<ServersScreen> {
if (_servers == null) {
return const Center(child: CircularProgressIndicator());
}
return ListView.separated(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 24),
itemCount: _servers!.length,
separatorBuilder: (_, __) => const SizedBox(height: 14),
itemBuilder: (_, i) {
final s = _servers![i];
return FutureBuilder<String>(
final prod = _servers!.where((s) => !s.isPreprod).toList();
final preprod = _servers!.where((s) => s.isPreprod).toList();
return TabBarView(
children: [_envList(prod), _envList(preprod)],
);
}
Widget _envList(List<GameServer> list) {
return RefreshIndicator(
onRefresh: _refresh,
child: list.isEmpty
? ListView(children: const [
SizedBox(height: 120),
Center(child: Text('Aucun serveur dans cet environnement.')),
])
: ListView(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 24),
children: list.map(_card).toList(),
),
);
}
Widget _card(GameServer s) => Padding(
padding: const EdgeInsets.only(bottom: 14),
child: FutureBuilder<String>(
future: widget.api.iconUrl(s.id),
builder: (_, snap) => ServerCard(
server: s,
@@ -144,8 +192,6 @@ class _ServersScreenState extends State<ServersScreen> {
busy: _busy.contains(s.id),
onToggle: () => _toggle(s),
),
);
},
),
);
}
}
+39 -4
View File
@@ -1,12 +1,15 @@
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:open_filex/open_filex.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart';
import 'package:url_launcher/url_launcher.dart';
/// Vérifie s'il existe une version plus récente (API `/version`) et, si oui,
/// ouvre l'URL de l'APK (le navigateur télécharge, l'utilisateur installe —
/// robuste, sans dépendance de packaging fragile).
/// Détecte une version plus récente (`/version`) et l'installe **in-app** :
/// télécharge l'APK dans le stockage de l'app puis lance l'installeur système
/// (un seul tap « Installer »). Fallback navigateur si l'install directe échoue.
class UpdateService {
UpdateService(this._baseUrl);
final Future<String> _baseUrl;
@@ -31,7 +34,39 @@ class UpdateService {
return null;
}
Future<bool> apply(UpdateInfo info) async {
/// Télécharge l'APK puis lance l'installeur. `onProgress` : 0.0 → 1.0
/// (ou null si la taille est inconnue). Renvoie true si l'installeur s'ouvre.
Future<bool> apply(UpdateInfo info, {void Function(double?)? onProgress}) async {
try {
final dir = await getExternalStorageDirectory() ?? await getTemporaryDirectory();
final file = File('${dir.path}/gamemanager-update.apk');
final req = http.Request('GET', Uri.parse(info.apkUrl));
final resp = await req.send().timeout(const Duration(seconds: 30));
if (resp.statusCode != 200) return _fallback(info);
final total = resp.contentLength ?? 0;
var received = 0;
final sink = file.openWrite();
await for (final chunk in resp.stream) {
sink.add(chunk);
received += chunk.length;
onProgress?.call(total > 0 ? received / total : null);
}
await sink.close();
final result = await OpenFilex.open(
file.path,
type: 'application/vnd.android.package-archive',
);
if (result.type == ResultType.done) return true;
return _fallback(info); // l'installeur n'a pas pris → navigateur
} catch (_) {
return _fallback(info);
}
}
Future<bool> _fallback(UpdateInfo info) async {
final uri = Uri.parse(info.apkUrl);
if (!await canLaunchUrl(uri)) return false;
return launchUrl(uri, mode: LaunchMode.externalApplication);
+54 -1
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import '../models.dart';
@@ -41,13 +42,23 @@ class ServerCard extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(server.name,
Row(
children: [
Flexible(
child: Text(server.name,
style: const TextStyle(
color: Colors.white,
fontSize: 19,
fontWeight: FontWeight.w800),
maxLines: 1,
overflow: TextOverflow.ellipsis),
),
if (server.isPreprod) ...[
const SizedBox(width: 8),
const _Tag(label: 'PREPROD'),
],
],
),
if (server.subtitle != null)
Text(server.subtitle!,
style: TextStyle(
@@ -80,6 +91,10 @@ class ServerCard extends StatelessWidget {
)
else
const Spacer(),
if (server.web && server.openUrl != null) ...[
_OpenButton(url: server.openUrl!),
const SizedBox(width: 8),
],
_ToggleButton(up: server.isUp, busy: busy, onToggle: onToggle),
],
),
@@ -118,6 +133,44 @@ class _Icon extends StatelessWidget {
);
}
class _Tag extends StatelessWidget {
const _Tag({required this.label});
final String label;
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 2),
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.28),
borderRadius: BorderRadius.circular(6),
border: Border.all(color: Colors.white.withOpacity(0.5), width: 1),
),
child: Text(label,
style: const TextStyle(
color: Colors.white, fontSize: 10, fontWeight: FontWeight.w800, letterSpacing: 0.6)),
);
}
}
class _OpenButton extends StatelessWidget {
const _OpenButton({required this.url});
final String url;
@override
Widget build(BuildContext context) {
return OutlinedButton.icon(
onPressed: () => launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication),
style: OutlinedButton.styleFrom(
foregroundColor: Colors.white,
side: BorderSide(color: Colors.white.withOpacity(0.7)),
),
icon: const Icon(Icons.open_in_new, size: 18),
label: const Text('Ouvrir'),
);
}
}
class _StatusPill extends StatelessWidget {
const _StatusPill({required this.label, required this.color, required this.pulse});
final String label;
+2
View File
@@ -16,6 +16,8 @@ dependencies:
shared_preferences: ^2.3.2
package_info_plus: ^8.1.1
url_launcher: ^6.3.1
path_provider: ^2.1.4
open_filex: ^4.5.0
cupertino_icons: ^1.0.8
dev_dependencies:
+13 -5
View File
@@ -62,14 +62,22 @@ if "signingConfigs {" not in s:
r"(\n\s*buildTypes\s*\{)",
'\n signingConfigs {\n'
' release {\n'
' keyAlias keystoreProperties["keyAlias"]\n'
' keyPassword keystoreProperties["keyPassword"]\n'
' storeFile file(keystoreProperties["storeFile"])\n'
' storePassword keystoreProperties["storePassword"]\n'
' keyAlias = keystoreProperties["keyAlias"]\n'
' keyPassword = keystoreProperties["keyPassword"]\n'
' storeFile = file(keystoreProperties["storeFile"])\n'
' storePassword = keystoreProperties["storePassword"]\n'
' }\n }\n\\1',
s,
count=1,
)
# Flutter 3.24 génère `signingConfig = signingConfigs.debug` (AVEC `=`). On gère
# les deux formes pour ne jamais laisser le build release signé en clé debug
# (sinon signature différente à chaque run CI → « conflit » à l'install de MAJ).
before = s
s = s.replace("signingConfig = signingConfigs.debug", "signingConfig = signingConfigs.release")
s = s.replace("signingConfig signingConfigs.debug", "signingConfig signingConfigs.release")
if s == before:
raise SystemExit("patch_android: ERREUR — ligne 'signingConfig ... debug' introuvable, "
"signature release NON appliquée (build annulé)")
open(gr, "w").write(s)
print("patch_android: OK")
print("patch_android: OK (signature release appliquee)")