wordpress-mobile / WordPress-Android

WordPress for Android
http://android.wordpress.org
GNU General Public License v2.0
2.92k stars 1.3k forks source link

Fix negative percent issue on Stats for RTL languages #20656

Closed irfano closed 4 weeks ago

irfano commented 4 weeks ago

Fixes #17447

When the device language is set to Arabic, numbers with the percentage were being displayed as "%96-". This was the output of android.icu.text.NumberFormat function. I couldn't find any documentation related to this issue, but using java.text.NumberFormat resolves it. See the screenshot below:

before after

Ignore the inaccurate chart. I manipulated the code to display the negative percentage.


To Test:

  1. Set your device language to Arabic.
  2. Open the Jetpack app and head to Stats > Insights, on a site that has less traffic this week than last week.
  3. Verify that the negative percentage is displayed correctly.

Regression Notes

  1. Potential unintended areas of impact

    • Other languages.
  2. What I did to test those areas of impact (or what existing automated tests I relied on)

    • Tested in Turkish. The percent is displayed as "(-%96)", as expected.
  3. What automated tests I added (or what prevented me from doing so)

    • Added PercentFormatterTest.

PR Submission Checklist:


Testing Checklist (strike-out the not-applying and unnecessary ones):

wpmobilebot commented 4 weeks ago
WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr20656-8fddc15
Commit8fddc153cf8ad278850a211d324768ba24258e82
Direct Downloadwordpress-prototype-build-pr20656-8fddc15.apk
Note: Google Login is not supported on these builds.
wpmobilebot commented 4 weeks ago
Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr20656-8fddc15
Commit8fddc153cf8ad278850a211d324768ba24258e82
Direct Downloadjetpack-prototype-build-pr20656-8fddc15.apk
Note: Google Login is not supported on these builds.
codecov[bot] commented 4 weeks ago

Codecov Report

Attention: Patch coverage is 87.50000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 40.47%. Comparing base (3f7287b) to head (8fddc15). Report is 27 commits behind head on trunk.

Files Patch % Lines
...rg/wordpress/android/util/text/PercentFormatter.kt 85.71% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## trunk #20656 +/- ## ======================================= Coverage 40.46% 40.47% ======================================= Files 1485 1485 Lines 68443 68450 +7 Branches 11312 11312 ======================================= + Hits 27696 27704 +8 + Misses 38246 38245 -1 Partials 2501 2501 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sonarcloud[bot] commented 4 weeks ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud