feat(session): swap the AI export button for a per-session switch

The end-of-session dialog no longer carries a second "finish" button.
"TERMINER TOUT" is now the only way out, and what it does with the target
depends on the AI training setting:

- setting on: the target is always sent, with a discreet reminder saying so;
- setting off: a "CONTRIBUER À L'IA" switch (off by default, never
  remembered) decides whether the target is sent or kept on the device;
- banned account or failed analysis: neither switch nor upload.

Turning the switch on for the first time shows the full program disclaimer
(what is sent, pseudonymity, banning rules); refusing leaves it off. That
text moved to a shared showAiConsentDialog() so the settings switch and the
session switch cannot drift apart, and a new is_ai_terms_accepted flag
remembers the acceptance without silently enabling the global setting.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
qlionbleusam
2026-09-09 14:15:03 +02:00
co-authored by Claude Opus 5
parent a9651588bb
commit ba58cf8efc
5 changed files with 342 additions and 145 deletions
+24
View File
@@ -10,6 +10,7 @@ import 'package:flutter/foundation.dart';
class WalletIdentityService {
static const String _prefsKey = 'wallet_identity_phrase';
static const String _uploadEnabledKey = 'is_ai_upload_enabled';
static const String _termsAcceptedKey = 'is_ai_terms_accepted';
static const String _bannedKey = 'wallet_is_banned';
static const String _banReasonKey = 'wallet_ban_reason';
static const String _serverUrlKey = 'ai_server_url';
@@ -76,6 +77,9 @@ class WalletIdentityService {
}
/// Active ou désactive l'envoi de données
///
/// L'activation n'est proposée qu'après lecture des règles du programme :
/// on mémorise donc au passage que l'avertissement a été accepté.
Future<void> setUploadEnabled(bool enabled) async {
final prefs = await SharedPreferences.getInstance();
final isBanned = prefs.getBool(_bannedKey) ?? false;
@@ -84,6 +88,26 @@ class WalletIdentityService {
return;
}
await prefs.setBool(_uploadEnabledKey, enabled);
if (enabled) {
await prefs.setBool(_termsAcceptedKey, true);
}
}
/// Indique si les règles du programme IA ont déjà été lues et acceptées.
///
/// Utilisé par le switch « Contribuer à l'IA » de la fin de session :
/// l'avertissement (contenu envoyé, pseudonymat, bannissement) n'est
/// présenté qu'une seule fois, même si l'option globale des Paramètres
/// reste désactivée.
Future<bool> hasAcceptedAiTerms() async {
final prefs = await SharedPreferences.getInstance();
return prefs.getBool(_termsAcceptedKey) ?? false;
}
/// Mémorise l'acceptation des règles du programme IA.
Future<void> setAiTermsAccepted(bool accepted) async {
final prefs = await SharedPreferences.getInstance();
await prefs.setBool(_termsAcceptedKey, accepted);
}
/// Vérifie si ce wallet/utilisateur est banni en local