From 48993f0486a1a1711c178fc7c90d2bb057c9d0c3 Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Sun, 4 Jan 2026 20:48:42 +0100 Subject: [PATCH] On initial upgrade, force all automatic cards to ISO-8859-1 This fixes old pkpass files imported before Catima 2.41.0 to be forced to "Automatic", which may guess UTF-8. New pkpass files will have the encoding read from the file and newly scanned barcodes will use Automatic. This does have the unfortunate side effect of everyone who already scanned a QR code with UTF-8 data since Catima 2.41.0 to have it forced to ISO-8859-1, but it will fix Deutschlandtickets imported before 2.41.0 which is a rather large amount of the Catima userbase. --- app/src/main/java/protect/card_locker/DBHelper.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/protect/card_locker/DBHelper.java b/app/src/main/java/protect/card_locker/DBHelper.java index 23b59d56b..493e6f329 100644 --- a/app/src/main/java/protect/card_locker/DBHelper.java +++ b/app/src/main/java/protect/card_locker/DBHelper.java @@ -26,7 +26,7 @@ import java.util.Set; public class DBHelper extends SQLiteOpenHelper { public static final String DATABASE_NAME = "Catima.db"; public static final int ORIGINAL_DATABASE_VERSION = 1; - public static final int DATABASE_VERSION = 18; + public static final int DATABASE_VERSION = 19; // NB: changing these values requires a migration public static final int DEFAULT_ZOOM_LEVEL = 100; @@ -345,6 +345,17 @@ public class DBHelper extends SQLiteOpenHelper { db.execSQL("ALTER TABLE " + LoyaltyCardDbIds.TABLE + " ADD COLUMN " + LoyaltyCardDbIds.BARCODE_ENCODING + " TEXT"); } + + // On upgrade to 2.41.3, force all existing "Automatic" cards to ISO-8859-1. + // UTF-8 support was only added in 2.42.0, before that, all barcodes were saved without + // any encoding info. As many scanners deal badly with ECI info, automatically guessing + // UTF-8 for old barcodes may break them. + // + // New cards will be saved using either "Automatic" encoding to guess or, for pkpass files, + // whatever encoding is specified. + if (oldVersion < 19 && newVersion >= 19) { + db.execSQL("UPDATE " + LoyaltyCardDbIds.TABLE + " SET " + LoyaltyCardDbIds.BARCODE_ENCODING + " = 'ISO-8859-1' WHERE " + LoyaltyCardDbIds.BARCODE_ENCODING + " IS NULL"); + } } public static Set imageFiles(Context context, final SQLiteDatabase database) {