Skip to content

Fix locale-dependent digits in padded version strings#399

Merged
ianrumac merged 2 commits intodevelopfrom
armin/fix/app-version-padded-locale-digits
Apr 24, 2026
Merged

Fix locale-dependent digits in padded version strings#399
ianrumac merged 2 commits intodevelopfrom
armin/fix/app-version-padded-locale-digits

Conversation

@drvarmin
Copy link
Copy Markdown
Contributor

@drvarmin drvarmin commented Apr 23, 2026

Changes in this pull request

  • Fix device.appVersionPadded and device.sdkVersionPadded emitting non-ASCII digits on devices whose default locale uses a non-Latin numbering system (e.g. ar-EG, fa-IR, bn-BD).
  • Added CHANGELOG.md entry under 2.7.13.

Checklist

  • All unit tests pass.
  • All UI tests pass. (Not run — fix is a pure string-formatting change with no UI surface.)
  • Demo project builds and runs. (Not manually verified — no UI or runtime-behavior change.)
  • I added/updated tests or detailed why my change isn't tested. (6 new unit tests in DeviceHelperAsPaddedTest.kt covering ar-EG, fa-IR, bn-BD, and the beta-appendix / non-numeric-appendix branches.)
  • I added an entry to the CHANGELOG.md for any breaking changes, enhancements, or bug fixes.
  • I have run ktlint in the main directory and fixed any issues.
  • I have updated the SDK documentation as well as the online docs. (N/A — no public API change; the affected fields are internal to the device template and already documented.)
  • I have reviewed the contributing guide

Greptile Summary

This PR fixes locale-dependent digit rendering in asPadded() by pinning all four String.format calls to Locale.US, and widens the function visibility from private to internal to enable unit testing. Six new tests cover Arabic-Indic, Extended Arabic-Indic, and Bengali locales, plus the beta-appendix and non-numeric-appendix branches.

Confidence Score: 5/5

Safe to merge — targeted, well-tested fix with no behavioral changes outside locale-digit normalization.

All four String.format calls are correctly pinned to Locale.US, java.util.Locale was already imported, and six new unit tests cover every affected branch including edge-locale cases. No P0 or P1 findings.

No files require special attention.

Important Files Changed

Filename Overview
superwall/src/main/java/com/superwall/sdk/network/device/DeviceHelper.kt Adds Locale.US to all four String.format calls in asPadded() and widens visibility to internal for testing; java.util.Locale was already imported.
superwall/src/test/java/com/superwall/sdk/network/device/DeviceHelperAsPaddedTest.kt New test class with 6 unit tests; correctly saves/restores the default Locale in @Before/@after and exercises all branches affected by the fix.
CHANGELOG.md Adds 2.7.13 entry describing the locale-digit fix; no issues.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["asPadded() called on version string"] --> B["split on '-'"]
    B --> C{Has appendix?}
    C -- yes --> D["split appendix on '.'"]
    D --> E{Numeric suffix?}
    E -- yes --> F["String.format(Locale.US, '%03d', num)"]
    E -- no --> G["Keep label as-is"]
    C -- no --> H["Split version on '.'"]
    F --> H
    G --> H
    H --> I["String.format(Locale.US, '%03d', major)"]
    I --> J{minor present?}
    J -- yes --> K["String.format(Locale.US, '%03d', minor)"]
    J -- no --> M
    K --> L{patch present?}
    L -- yes --> N["String.format(Locale.US, '%03d', patch)"]
    L -- no --> M
    N --> M["Concatenate newVersion + appendix"]
    M --> O["Return ASCII-only padded string"]
Loading

Reviews (1): Last reviewed commit: "Fix locale-dependent digits in padded ve..." | Re-trigger Greptile

@drvarmin drvarmin requested a review from ianrumac April 23, 2026 16:03
@ianrumac ianrumac merged commit 6dbe50f into develop Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants