oppia-android icon indicating copy to clipboard operation
oppia-android copied to clipboard

[BUG]: Terms of Service and Privacy Policy content should still be left-aligned, even if the app is in an RTL language.

Open seanlip opened this issue 2 years ago • 20 comments

Describe the bug

In RTL languages, we are currently keeping our Terms of Service and Privacy policy content in English (so that we can have a canonical version). However, the English text should be left-aligned.

(Thanks to @KolliAnitha for the repro and images, which I took from https://github.com/oppia/oppia-android/issues/5028.)

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Home' - Options
  2. Select App language as Arabic
  3. Go back and click on Help - Terms of Service/ Privacy policy
  4. See that the content is right-aligned despite being in English.

Expected behavior The English content should be left-aligned (but not the note at the bottom of the page linking to the up-to-date policy).

Demonstration Screenshot_20230608-080139

Environment Device/emulator being used: Infinix SMART 5 Android or SDK version (e.g. Android 5 or SDK 21): Android 11 App version (you can get this through system app settings or via the admin controls menu in-app): 0.11-beta-8c81c98d8b

Additional Information

  • The proposed solution is to create a new InjectableAutolocalizedEnglishOnlyActivity.kt, in the same pattern as InjectableAutoLocalizedAppCompatActivity, which will be extended by the PoliciesActivity.
  • In InjectableSystemLocalizedAppCompatActivity.kt, we should replace the shouldOnlyUseSystemLanguage = true boolean with an enum with fields for: shouldOnlyUseSystemLanguage, shouldOnlyUseEnglishLanguage(needed for the PoliciesActivity).
  • Introduce new function in TranslationController with the signature: fun getLocaleFor(language: OppiaLanguage): DataProvider<OppiaLocale.DisplayLocale> to be used in AppLanguageWatcherMixin.kt to instatiate the InjectableAutolocalizedEnglishOnlyActivity.kt.

seanlip avatar Jun 09 '23 07:06 seanlip

Same thing is happening on the onboardimg screen.

https://github.com/oppia/oppia-android/assets/99060332/f930ef9c-95d9-4142-9680-44486ecdf254

ShubhadeepKarmakar avatar Sep 27 '23 08:09 ShubhadeepKarmakar

I would like to work on this issue. May I get assigned to it?

ShubhadeepKarmakar avatar Sep 27 '23 08:09 ShubhadeepKarmakar

I would like to work on this issue. May I get assigned to it?

What's your proposal for fixing this?

adhiamboperes avatar Sep 27 '23 12:09 adhiamboperes

https://github.com/oppia/oppia-android/assets/99060332/3fe3f8dc-9417-4edf-956b-9db8c802bd35

I would like to work on this issue. May I get assigned to it?

What's your proposal for fixing this?

PoliciesFragmentPresenter

These changes are made in the PoliciesFragmentPresenter.kt class and work perfectly but this is not the correct approach I think. DisplayLocaleImpl.kt class was final in nature but I had to make the DisplayLocaleImpl class open in nature to change the PoliciesFragmentPresenter class.

ShubhadeepKarmakar avatar Sep 28 '23 10:09 ShubhadeepKarmakar

ltr.mp4

I would like to work on this issue. May I get assigned to it?

What's your proposal for fixing this?

PoliciesFragmentPresenter

These changes are made in the PoliciesFragmentPresenter.kt class and work perfectly but this is not the correct approach I think. DisplayLocaleImpl.kt class was final in nature but I had to make the DisplayLocaleImpl class open in nature to change the PoliciesFragmentPresenter class.

I get the sense that you are trying to force the layout direction to be LTR. You don't need to modify DisplayLocaleImpl or override it's methods to retrieve Layout Direction. AppLanguageResourceHandler has a public api for that, getLayoutDirection(). See StateAssemblerMarginBindingAdapters or SurveyOnboardingBackgroundView for usage examples.

adhiamboperes avatar Sep 28 '23 19:09 adhiamboperes

Under the ListItemLeadingMarginSpan class we have the ulSpan class and the olSpan class which takes displayLocal as an input and then retrieves the direction of the layout using the getLayoutDirection() method to get the bullet drawing position. That's why I created an object of the DisplayLocaleImp class and overridden the getLayoutDirection() method to pretend it's LTR. OR We can make another class just for PoliciesTextview which implements Oppia.DisplayLocale class. Everything remains the same as in the DisplayLocaleImp class, we only need to change the getLayoutDirection() method to assert the LTR over the RTL. rtl_page-0001

@adhiamboperes any suggestion?

ShubhadeepKarmakar avatar Sep 29 '23 17:09 ShubhadeepKarmakar

Under the ListItemLeadingMarginSpan class we have the ulSpan class and the olSpan class which takes displayLocal as an input and then retrieves the direction of the layout using the getLayoutDirection() method to get the bullet drawing position. That's why I created an object of the DisplayLocaleImp class and overridden the getLayoutDirection() method to pretend it's LTR. OR We can make another class just for PoliciesTextview which implements Oppia.DisplayLocale class. Everything remains the same as in the DisplayLocaleImp class, we only need to change the getLayoutDirection() method to assert the LTR over the RTL. rtl_page-0001

@adhiamboperes any suggestion?

The layout direction retrieved will be the same regardless of the function you call to retrieve it, which is why you should use the public function from AppLanguageResourceHandler and don't reimplement DisplayLocale.

adhiamboperes avatar Oct 02 '23 10:10 adhiamboperes

is this issue fixed? @ShubhadeepKarmakar @BenHenning

neeldoshii avatar Jan 02 '24 22:01 neeldoshii

@neeldoshii, feel free to suggest a fix for this. Please also refer to https://github.com/oppia/oppia-android/pull/5181#issuecomment-1776935108 for a potential solution.

adhiamboperes avatar Jan 03 '24 06:01 adhiamboperes

Sure @adhiamboperes, I will release a fix in my PR based on the comment. Also, is there any communication channel which is used to communicate with other contributors?

neeldoshii avatar Jan 03 '24 20:01 neeldoshii

Sure @adhiamboperes, I will release a fix in my PR based on the comment. Also, is there any communication channel which is used to communicate with other contributors?

At the moment, Our discussions page is the best place to communicate.

adhiamboperes avatar Jan 03 '24 21:01 adhiamboperes

@Vishwajith-Shettigar I am still working on this. If you don't mind can I work on it?

neeldoshii avatar Jan 10 '24 22:01 neeldoshii

Hi @adhiamboperes, currently on the debug release we are not able to change the app language?

Is it some kind of issue?

neeldoshii avatar Jan 11 '24 00:01 neeldoshii

Hi @neeldoshii if you are working on any issue you should be assigned first, please take care of it, I'm closing my PR and assigning you.

Vishwajith-Shettigar avatar Jan 11 '24 03:01 Vishwajith-Shettigar

Hi @adhiamboperes, currently on the debug release we are not able to change the app language?

Is it some kind of issue?

You are using gradle to build i guess, if you want change app language you have to build app on bazel and for this issue you can change your system language to arabic or something like that.

Vishwajith-Shettigar avatar Jan 11 '24 03:01 Vishwajith-Shettigar

Hi @adhiamboperes, currently on the debug release we are not able to change the app language? Is it some kind of issue?

You are using gradle to build i guess, if you want change app language you have to build app on bazel and for this issue you can change your system language to arabic or something like that.

@neeldoshii, as @Vishwajith-Shettigar said, you can instead change your system language to RTL like Arabic which will also change the app language, if you're unable to build bazel.

adhiamboperes avatar Jan 13 '24 08:01 adhiamboperes

image

I have worked and able to make the text to have in LTR.

I get the sense that you are trying to force the layout direction to be LTR. You don't need to modify DisplayLocaleImpl or override it's methods to retrieve Layout Direction. AppLanguageResourceHandler has a public api for that, getLayoutDirection(). See StateAssemblerMarginBindingAdapters or SurveyOnboardingBackgroundView for usage examples.

I have followed the instructions based on the mentioned.

I am little confused. If you look closely html <li> tags are having issues. The bullet point are always forcefully there in RTL. If I perform any change in LiTagHandler class and make them forcefully be in left side then it will get broked on some other screen if we use li tags.

Any idea how to solve this?

@adhiamboperes @Vishwajith-Shettigar Thank You

neeldoshii avatar Jan 17 '24 20:01 neeldoshii

@neeldoshii I doubt that texts are still in proper LTR mode according to the screenshot ( look at last sentence of all paragraphs). Better you create a draft PR.

For li tag, you can overload the method related to li tag for privacy page or your can create a new object of displaylocaleimp and override getLayoutDirection to return LTR. Refer both closed PR.

Vishwajith-Shettigar avatar Jan 18 '24 02:01 Vishwajith-Shettigar