Skip to content

Commit 24bb7c2

Browse files
committed
force flash
1 parent b0d24e7 commit 24bb7c2

3 files changed

Lines changed: 39 additions & 35 deletions

File tree

lib/l10n/app_en.arb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@
216216
"pleaseSelectClipart": "Please draw or select a clipart before saving",
217217
"secureConnection": "Secure Connection (PIN)",
218218
"pinInformation": "PIN Information",
219-
"pinInformationMessage": "Activating this option the app will request a PIN code before each transfer.\n\n⚠️ NOTE: To work correctly, this setting must also be activated on the Badge Magic firmware (DOWNLOAD mode with on-screen code).",
219+
"pinInformationMessage": "Activating this option the app will request a PIN code before each transfer.\n\n⚠️ NOTE: To activate this feature, you need to go to the badge menu > Security > Enable.",
220220
"iUnderstand": "I understand",
221221
"requestPinBeforeSending": "Request PIN before sending",
222-
"secureConnectionDescription": "Increases security by preventing unauthorized transfers"
222+
"secureConnectionDescription": "Increases security by preventing unauthorized transfers",
223223
"importFromFile": "Import from file",
224224
"scanQrCode": "Scan QR code",
225225
"couldNotImportBadgeFromQr": "Could not import badge from QR code.",

lib/providers/badge_message_provider.dart

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ class BadgeMessageProvider {
6363

6464
void resetSessionAuth() {
6565
isHardwareUnlocked = false;
66-
logger.i("🔒 Sessione di sblocco hardware resettata.");
6766
}
6867

6968
Future<Data> getBadgeData(String text, bool flash, bool marq, Speed speed,
@@ -179,42 +178,47 @@ class BadgeMessageProvider {
179178
bool usePin = prefs.getBool('secure_connection_pin') ?? false;
180179

181180
if (usePin) {
182-
String? currentPin;
183-
184-
if (savedPin != null && savedPin!.isNotEmpty) {
185-
currentPin = savedPin;
186-
} else {
187-
currentPin = await showPinAuthDialog(context);
181+
bool isTransferred = false;
182+
while (!isTransferred) {
183+
String? currentPin;
184+
185+
if (savedPin != null && savedPin!.isNotEmpty) {
186+
currentPin = savedPin;
187+
} else {
188+
currentPin = await showPinAuthDialog(context);
189+
190+
if (currentPin == null) {
191+
ToastUtils().showToast('Transfer canceled by user');
192+
return;
193+
}
194+
}
188195

189-
if (currentPin == null) {
190-
ToastUtils().showToast('Transfer canceled by user');
191-
return;
196+
Data textData;
197+
if (jsonData != null) {
198+
textData = fileHelper.jsonToData(jsonData);
199+
} else {
200+
textData = await generateData(
201+
text, flash, marq, isInverted, speedMap[speed], mode, jsonData);
192202
}
193-
}
194203

195-
Data textData;
196-
if (jsonData != null) {
197-
textData = fileHelper.jsonToData(jsonData);
198-
} else {
199-
textData = await generateData(
200-
text, flash, marq, isInverted, speedMap[speed], mode, jsonData);
201-
}
204+
RawDataTransferManager combinedManager = RawDataTransferManager(
205+
pin: currentPin!,
206+
textData: textData,
207+
);
202208

203-
RawDataTransferManager combinedManager = RawDataTransferManager(
204-
pin: currentPin!,
205-
textData: textData,
206-
);
209+
bool success = await transferData(combinedManager, context: context);
207210

208-
bool success = await transferData(combinedManager, context: context);
209-
if (success) {
210-
savedPin = currentPin;
211-
isHardwareUnlocked = true;
212-
ToastUtils().showToast('Data transferred successfully!');
213-
} else {
214-
savedPin = null;
215-
isHardwareUnlocked = false;
211+
if (success) {
212+
savedPin = currentPin;
213+
isHardwareUnlocked = true;
214+
isTransferred = true;
215+
ToastUtils().showToast('Data transferred successfully!');
216+
} else {
217+
savedPin = null;
218+
isHardwareUnlocked = false;
216219

217-
await Future.delayed(const Duration(milliseconds: 1000));
220+
await Future.delayed(const Duration(milliseconds: 1500));
221+
}
218222
}
219223
} else {
220224
Data data;

lib/view/widgets/auth_pin_dialog.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ Future<String?> showPinAuthDialog(BuildContext context) async {
5858
child: const Text('Cancel', style: TextStyle(color: Colors.grey)),
5959
onPressed: () => Navigator.of(context).pop(null),
6060
),
61-
ElevatedButton(
62-
child: const Text('Verify & Send'),
61+
TextButton(
62+
child: const Text('Send'),
6363
onPressed: () {
6464
if (formKey.currentState!.validate()) {
6565
Navigator.of(context).pop(pinController.text);

0 commit comments

Comments
 (0)