Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce western arabic numerals for Stats #17160

Merged
merged 10 commits into from Sep 16, 2022

Conversation

ovitrif
Copy link
Contributor

@ovitrif ovitrif commented Sep 15, 2022

Fixes Partially #17002 — Handles only the Stats screens and the Today Stats card on My Site Dashboard

This PR introduces a wrapper over MaterialTextView that enforces the use of Western Arabic numerals by replacing Eastern Arabic and Persian/Urdu numerals to their Western Arabic counterparts.

This UI component was then applied to every stats widget which uses MaterialTextView and displays numerals.

The purpose of this PR is to make sure we're always displaying Western Arabic numerals on the Stats screens, to mainly address the remark from the issue:

This looks especially strange on screens where we use both types of numerals

To test:

1️⃣ Test Case 1 : WordPress App Stats
  1. Open the WordPress App, Go to MeApp SettingsInterface Language and select Arabic.
  2. Go back to My SiteHome tab
    • Expect the numbers on Today's Stats card to be western arabic.
  3. Go to Stats & explore the first tab (Insights)
    • Expect all displayed numbers to be western arabic.
  4. Go to any other Stats tab (Days/Weeks/...)
    • Expect all displayed numbers to be western arabic.
1️⃣ Test Case 2 : Jetpack App Stats
  1. Open the Jetpack App, Go to MeApp SettingsInterface Language and select Arabic.
  2. Repeat steps 2-4 from Test Case 1
  3. Tap "View More" on one of the stats cards having a different value than 0
    • Expect numbers to be Western Arabic
    • Expect the numeral inside the Pie Chart to be of larger font size than the word Totals
Preview Test Case 2 — Step 3

Note For easier understanding the screenshot is in English. Same result should be expected in Arabic.


Previews

Stats → Insights tab

Before After
stats_insights stats_followers_fix

Regression Notes

  1. Potential unintended areas of impact
    Unexpected, since we're only replacing Indo-Arabic and Persian/Urdu numerals with the normal (Western) Arabic numerals.

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Tested manually in Chinese & English languages.

  3. What automated tests I added (or what prevented me from doing so)
    N/a, we're only touching the view layer with these changes.

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@ovitrif ovitrif added this to the 20.8 milestone Sep 15, 2022
@ovitrif ovitrif requested a review from antonis Sep 15, 2022
@ovitrif ovitrif self-assigned this Sep 15, 2022
@ovitrif ovitrif modified the milestones: 20.8, 20.9 Sep 15, 2022
@wpmobilebot
Copy link

wpmobilebot commented Sep 15, 2022

You can test the WordPress changes on this Pull Request by downloading an installable build (wordpress-installable-build-pr17160-5e245d3.apk), or scanning this QR code:

@wpmobilebot
Copy link

wpmobilebot commented Sep 15, 2022

You can test the Jetpack changes on this Pull Request by downloading an installable build (jetpack-installable-build-pr17160-5e245d3.apk), or scanning this QR code:

Copy link
Member

@antonis antonis left a comment

Great work @ovitrif 👍
The code LGTM and the app behaves as expected in most cases. I've noticed an issue with zero not being transformed.

Arabic English
Screenshot_20220915_161555 Screenshot_20220915_161609

I've also left a comment which is more of a suggestion 🙏

@ovitrif
Copy link
Contributor Author

ovitrif commented Sep 15, 2022

Great work @ovitrif 👍 The code LGTM and the app behaves as expected in most cases. I've noticed an issue with zero not being transformed.

I'm trying to figure out how to add the views from your screenshot to my Stats. On the emulator that I'm testing (Pixel 5, Api 28) the issue doesn't seem to be specific to 0, which makes me guess if there's some different views where I didn't replace MaterialTextView with MaterialTextViewWithNumerals 🤷

I added a few more stats cards but couldn't yet replicate the ones in your screenshot:

English Arabic
stats_en stats_ar

I'll try with the Jetpack App 👍

@ovitrif
Copy link
Contributor Author

ovitrif commented Sep 15, 2022

I'll try with the Jetpack App 👍

I was able to reproduce the issue with the Jetpack App. Working on a fix 👍

@antonis
Copy link
Member

antonis commented Sep 15, 2022

Thank you for iterating on this @ovitrif 👍

On the emulator that I'm testing (Pixel 5, Api 28) the issue doesn't seem to be specific to 0

Sorry for not providing more info on my testing setup. I've tested on a Pixel 5 with Android 13 (API level 33). I wonder if this can be Android version specific.

which makes me guess if there's some different views where I didn't replace MaterialTextView with MaterialTextViewWithNumerals 🤷

That might be the case since I was replicating this on the first/insights screen. The other screens LGTM

device-2022-09-15-172712.mp4

@ovitrif
Copy link
Contributor Author

ovitrif commented Sep 15, 2022

@antonis Thank you for testing this with the Jetpack app. There were indeed different views where we had to use the MaterialTextViewWithNumerals instead of the MaterialTextView.

I've updated all views I could find on the Jetpack App

JP Stats - Top JP Stats - Bottom
stats_jp_top stats_jp_bottom

There was a special case I had to fix, this appears when going to the details of a stats card which has a different value than zero (see screenshot):

In the view that appears when tapping the highlighted button, the text in the middle of the pie chart was decorated with Spans (it's a SpannableString). I had to update MaterialTextViewWithNumerals to preserve the spans.

Previews:

Before preserving Spans After
stats_jp_details_fix stats_jp_details_fix_spans

I updated the testing steps and added a test case for the Jetpack App 🙇

@ovitrif ovitrif requested a review from antonis Sep 15, 2022
Copy link
Member

@antonis antonis left a comment

Great work @ovitrif 👍
I've retested the App CI builds with the latest changes and everything worked as expected on my Pixel 5 (Android 13). The code changes also LGTM 🎉
Thank you for tackling this 🙇

@ovitrif
Copy link
Contributor Author

ovitrif commented Sep 16, 2022

Great work @ovitrif 👍 I've retested the App CI builds with the latest changes and everything worked as expected on my Pixel 5 (Android 13). The code changes also LGTM 🎉 Thank you for tackling this 🙇

Awesome! Many thanks for your help on this PR Antonis 🙇

I'll fix the conflicts in RELEASE-NOTES.txt then we can merge the enhancement 🚀

P.S. I've updated the milestone to 20.8 since we're going to make it in time 🐇

@ovitrif ovitrif changed the title Enforce western arabic numerals in Stats widgets Enforce western arabic numerals for Stats Sep 16, 2022
@ovitrif ovitrif enabled auto-merge Sep 16, 2022
@ovitrif ovitrif modified the milestones: 20.9, 20.8 Sep 16, 2022
@ovitrif ovitrif merged commit 29cbcb0 into trunk Sep 16, 2022
12 of 14 checks passed
@ovitrif ovitrif deleted the issue/17002-use-western-arabic-numerals branch Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants