2394425147 / astrodx

930 stars 39 forks source link

`&first=` value is incorrectly parsed depending on the locale #44

Closed TwoQuantumBits closed 1 year ago

TwoQuantumBits commented 1 year ago

Describe the bug AstroDX incorrectly parses the &first= value if the decimal point used in the value is different from the decimal point of the device's locale

Reproduction Steps to reproduce the behavior:

  1. Prepare and load any chart with &first= attribute
  2. Set device locale to one that uses a different decimal point from the &first= attribute
    • e.g. if the maidata.txt file has &first=1.32 then switch device locale to Vietnamese (Vietnam), which uses comma , as decimal point instead of dot .
  3. Launch AstroDX and play the chart

Expected behavior The chart is offset correctly (in the above example, it will be offset by 1.32s).

Actual behavior The chart is offset incorrectly (in the above example, it will be offset by 132s instead).

Device specs

Additional context It appears that instead of throwing an error when the incorrect decimal point is detected, the parser just removes the invalid (decimal point) character from the value string before parsing.

Further suggestion Given that most charts nowadays use the dot . decimal point for float values, we should make it the standard and make float parsing in the maidata file independent from app and device locale.

Soneoylys commented 1 year ago

With the maidata file triggers the bug is ",&first=1.32" written in 1.32 or 1,32? want determine if this problem trigger by maidata in different format or the Android itself

Soneoylys commented 1 year ago

Should fixed in new version. Thanks!