card-io / card.io-Android-SDK

card.io provides fast, easy credit card scanning in mobile apps
Other
1.99k stars 532 forks source link

RTL support fails on some versions of Android #207

Open pieczatek opened 6 years ago

pieczatek commented 6 years ago

General information

SDK/Library version: 5.5.1 Testing environments:

  1. Nexus 5X Emulator / Android 4.4.2 (API 19 KitKat)
  2. Galaxy Ace Style LTE / Android 4.4.4 (API 19 KitKat)
  3. Nexus 5X Emulator / Android 6.0 (API 23 Marshmallow)
  4. Nexus 5X Emulator / Android 8.0 (API 26 Oreo)

All set to RTL Layout in OS Settings (With or without Hebrew language which is written right to left)

My code: https://github.com/pieczatek/CardIOExample/blob/master/app/src/main/java/com/bi/cardioexample/MainActivity.java

Issue description

I'm launching CardIOActivity for card scanning. Then I skip scanning and go straight to manual typing. Let's say I'm going to type 378282246310005 (American Express). When correct it should display 3782 822463 10005, so whitespace separating blocks of digits does not cause any trouble. Unfortunately in some cases I get reverse words on my input field

type 3 -> displays 3 7 -> 37 8 -> 378 2 -> 3782 8 -> 8 3782 2 -> 82 3782 2 -> 822 3782 4 -> 8224 3782 6 -> 82246 3782 3 -> 822463 3782 1 -> 1 822463 3782 0 -> 10 822463 3782 0 -> 100 822463 3782 0 -> 1000 822463 3782 5 -> 10005 822463 3782

After I click "done" I get the result with resultDisplayStr = "Card Number: " + scanResult.getFormattedCardNumber() + "\n"; and it is correct: Card Number: 3782 822463 10005

The weirdest thing is when I get the result without any string modification, that is resultDisplayStr = scanResult.getFormattedCardNumber();, I get reversed words again: 10005 822463 3782

I run the same code on 4 different testing environments specified above. Works fine on Android 4.4.4 and 8.0, fails on Android 4.4.2 and 6.0