Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added res/drawable-hdpi/itso_card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/main/java/com/codebutler/farebot/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.StringWriter;
import java.util.Formatter;
import java.util.List;

public class Utils {
Expand Down Expand Up @@ -109,6 +110,30 @@ public static String getHexString (byte[] b, String defaultResult) {
}
}

/**
* Turn bytes into hex string representation. Also useful for decoding BCD
*
* @param b The data to convert
* @param offset
* @param length
* @return
*/
public static String getHexString(byte[] b, int offset, int length) {
if (b.length < length + offset)
throw new IllegalArgumentException(
"length must be less than or equal to b.length");

StringBuilder sb = new StringBuilder(length * 2);

Formatter formatter = new Formatter(sb);
for (int i = 0; i < length; i++) {
formatter.format("%02x", b[offset + i]);
}

formatter.close();
return sb.toString();
}

public static byte[] hexStringToByteArray (String s) {
if ((s.length() % 2) != 0) {
throw new IllegalArgumentException("Bad input string: " + s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public CardsAdapter(Context context) {
add(new CardInfo(R.drawable.ovchip_card, "OV-chipkaart", R.string.location_the_netherlands, R.string.card_note_ovchip));
add(new CardInfo(R.drawable.bilheteunicosp_card, "Bilhete Único", R.string.location_sao_paulo, R.string.card_note_bilheteunicosp));
add(new CardInfo(R.drawable.hsl_card, "HSL", R.string.location_helsinki_finland));
add(new CardInfo(R.drawable.itso_card, "ITSO", R.string.location_united_kingdom));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.codebutler.farebot.transit.ClipperTransitData;
import com.codebutler.farebot.transit.HSLTransitData;
import com.codebutler.farebot.transit.OrcaTransitData;
import com.codebutler.farebot.transit.ItsoTransitData;
import com.codebutler.farebot.transit.TransitData;
import com.codebutler.farebot.transit.TransitIdentity;
import org.w3c.dom.Document;
Expand Down Expand Up @@ -122,6 +123,8 @@ public TransitIdentity parseTransitIdentity() {
return ClipperTransitData.parseTransitIdentity(this);
if (HSLTransitData.check(this))
return HSLTransitData.parseTransitIdentity(this);
if (ItsoTransitData.check(this))
return ItsoTransitData.parseTransitIdentity(this);
return null;
}

Expand All @@ -133,6 +136,8 @@ public TransitData parseTransitData() {
return new ClipperTransitData(this);
if (HSLTransitData.check(this))
return new HSLTransitData(this);
if (ItsoTransitData.check(this))
return new ItsoTransitData(this);
return null;
}

Expand Down
Loading