From ff82ed105d37dc05203b74ab505880fbb27dad62 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 11 Dec 2024 13:12:30 +1100 Subject: [PATCH 1/3] Fix recreation of scanned data - Ensure RS and GS characters are correctly observed --- lib/barcode/camera_controller.dart | 31 +++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/barcode/camera_controller.dart b/lib/barcode/camera_controller.dart index 2e40ef48..fb88a626 100644 --- a/lib/barcode/camera_controller.dart +++ b/lib/barcode/camera_controller.dart @@ -1,4 +1,6 @@ import "dart:math"; +import "dart:typed_data"; + import "package:flutter/material.dart"; import "package:flutter_tabler_icons/flutter_tabler_icons.dart"; import "package:inventree/app_colors.dart"; @@ -93,17 +95,36 @@ class _CameraBarcodeControllerState extends InvenTreeBarcodeControllerState { return; } - String barcode_data = code?.text ?? ""; + Uint8List raw_data = code?.rawBytes ?? Uint8List(0); + + // Reconstruct barcode from raw data + String barcode; + + if (raw_data.isNotEmpty) { + barcode = ""; + + final buffer = StringBuffer(); + + for (int i = 0; i < raw_data.length; i++) { + buffer.writeCharCode(raw_data[i]); + } + + barcode = buffer.toString(); + + } else { + barcode = code?.text ?? ""; + } if (mounted) { setState(() { - scanned_code = barcode_data; - scanning_paused = barcode_data.isNotEmpty; + scanned_code = barcode; + scanning_paused = barcode.isNotEmpty; }); } - if (barcode_data.isNotEmpty) { - handleBarcodeData(barcode_data).then((_) { + if (barcode.isNotEmpty) { + + handleBarcodeData(barcode).then((_) { if (!single_scanning && mounted) { // Resume next scan setState(() { From a893d51e3cd1f50c57822b7300c82c3dc9ada0a8 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 11 Dec 2024 13:40:39 +1100 Subject: [PATCH 2/3] Cleanup --- lib/barcode/camera_controller.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/barcode/camera_controller.dart b/lib/barcode/camera_controller.dart index fb88a626..0932995c 100644 --- a/lib/barcode/camera_controller.dart +++ b/lib/barcode/camera_controller.dart @@ -203,13 +203,19 @@ class _CameraBarcodeControllerState extends InvenTreeBarcodeControllerState { String info_text = scanning_paused ? L10().barcodeScanPaused : L10().barcodeScanPause; + String text = scanned_code.isNotEmpty ? scanned_code : info_text; + + if (text.length > 50) { + text = text.substring(0, 50) + "..."; + } + return SafeArea( child: Align( alignment: Alignment.bottomCenter, child: Padding( padding: EdgeInsets.all(10), child: Text( - scanned_code.isNotEmpty ? scanned_code : info_text, + text, textAlign: TextAlign.center, style: TextStyle( color: Colors.white, From 8f802209a7a14a26f59f373251e32f3739da7901 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 11 Dec 2024 13:41:12 +1100 Subject: [PATCH 3/3] Update release notes --- assets/release_notes.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/assets/release_notes.md b/assets/release_notes.md index 4f75c9cd..e4367d53 100644 --- a/assets/release_notes.md +++ b/assets/release_notes.md @@ -1,6 +1,7 @@ -### 0.17.1 - January 2025 +### 0.17.1 - December 2024 --- +- Fixes barcode scanning bug which prevents scanning of DataMatrix codes - Adds "assigned to me" filter for Purchase Order list - Adds "assigned to me" filter for Sales Order list