diff --git a/app/src/main/java/protect/card_locker/BarcodeSelectorAdapter.java b/app/src/main/java/protect/card_locker/BarcodeSelectorAdapter.java index 783b82ab2..4339be12b 100644 --- a/app/src/main/java/protect/card_locker/BarcodeSelectorAdapter.java +++ b/app/src/main/java/protect/card_locker/BarcodeSelectorAdapter.java @@ -10,6 +10,7 @@ import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import protect.card_locker.async.TaskHandler; @@ -74,6 +75,9 @@ public class BarcodeSelectorAdapter extends ArrayAdapter return viewHolder.image.getTag() != null && (boolean) viewHolder.image.getTag(); } + // FIXME: The examples in the selector activity are always rendering using ISO-8859-1, even if UTF-8 is the selected type + // This needs some refactoring to properly retrieve the barcode encoding when rendering an active barcode + // This is the case for example when editing an active card, pressing the "Edit barcode" button, then "More options" and then "Enter the barcode manually" private void createBarcodeOption(final ImageView image, final String formatType, final String cardId, final TextView text) { final CatimaBarcode format = CatimaBarcode.fromName(formatType); @@ -92,13 +96,13 @@ public class BarcodeSelectorAdapter extends ArrayAdapter Log.d(TAG, "Generating barcode for type " + formatType); - BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getContext(), image, cardId, format, null, text, true, null, true, false); + BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getContext(), image, cardId, format, StandardCharsets.ISO_8859_1, text, true, null, true, false); mTasks.executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter); } }); } else { Log.d(TAG, "Generating barcode for type " + formatType); - BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getContext(), image, cardId, format, null, text, true, null, true, false); + BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getContext(), image, cardId, format, StandardCharsets.ISO_8859_1, text, true, null, true, false); mTasks.executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter); } }