From 2b6a36f2d11578b720912b10d5d87b448c791a75 Mon Sep 17 00:00:00 2001 From: ilengyel Date: Mon, 17 Nov 2014 20:05:19 +0100 Subject: [PATCH] Update ApplePassbookQuirkCorrector.java This should format the main title to be something like VALENC.JSO -> MADRID-P.A Which indicates the city/train terminal for source and destination given the Json: { "formatVersion":1, ... "organizationName":"RENFE OPERADORA", "description":"Billete de tren", ... "boardingPass":{ "headerFields":[{"key":"destinofecha","label":"Viaje a: MADRID-P.A","value":"20/06/2014"}], "primaryFields":[ {"key":"boardingTime","label":"VALENC.JSO","value":"17:10","changeMessage":"La hora de salida ha cambiado a %@"}, {"key":"destino","label":"MADRID-P.A","value":"18:48"}], ... --- .../model/ApplePassbookQuirkCorrector.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/ligi/passandroid/model/ApplePassbookQuirkCorrector.java b/src/main/java/org/ligi/passandroid/model/ApplePassbookQuirkCorrector.java index d99960e0..830bba7d 100644 --- a/src/main/java/org/ligi/passandroid/model/ApplePassbookQuirkCorrector.java +++ b/src/main/java/org/ligi/passandroid/model/ApplePassbookQuirkCorrector.java @@ -15,8 +15,24 @@ public class ApplePassbookQuirkCorrector { careForVirginAustralia(pass); careForCathayPacific(pass); careForSWISS(pass); + careForRenfe(pass); } - + + private static void careForRenfe(PassImpl pass) { + if (!pass.getOrganisation().isPresent() || !pass.getOrganisation().get().equals("RENFE OPERADORA")) { + return; + } + Tracker.get().trackEvent("quirk_fix", "description_replace", "RENFE OPERADORA", 0L); + + final Optional optionalDepart = pass.getPrimaryFields().getPassFieldForKey("boardingTime"); + final Optional optionalArrive = pass.getPrimaryFields().getPassFieldForKey("destino"); + + if (optionalDepart.isPresent() && optionalArrive.isPresent()) { + Tracker.get().trackEvent("quirk_fix", "description_replace", "RENFE OPERADORA", 1L); + pass.setDescription(optionalDepart.get().label + " -> " + optionalArrive.get().label); + } + } + private static void careForSWISS(PassImpl pass) { if (!pass.getOrganisation().isPresent() || !pass.getOrganisation().get().equals("SWISS")) { return;