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

AC-742 refactoring code for better support for localization #723

Merged
merged 4 commits into from
Jun 1, 2020

Conversation

LuGO0
Copy link
Collaborator

@LuGO0 LuGO0 commented Apr 16, 2020

Description of what I changed

  1. refactoring and extracting string resources for better support of localization in the client.
  2. updated the ApplicationConstants

Issue I worked on

JIRA Issue: https://issues.openmrs.org/projects/AC/issues/AC-742

Checklist: I completed these to help reviewers :)

  • My pull request only contains ONE single commit
    (the number above, next to the 'Commits' tab is 1).

  • I have added tests to cover my changes. (If you refactored
    existing code that was well tested you do not have to add tests)

  • All new and existing tests passed.

  • My pull request is based on the latest changes of the master branch.

@LuGO0
Copy link
Collaborator Author

LuGO0 commented Apr 16, 2020

@f4ww4z Sir please review the strings I have added to the resources file ,after which I will add the translations for them!!.

@LuGO0 LuGO0 force-pushed the string_localization_refactoring branch from fe0b72d to c6b0f0e Compare April 16, 2020 22:56
Copy link
Collaborator

@f4ww4z f4ww4z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LuGO0 See my comments below.

@LuGO0 LuGO0 force-pushed the string_localization_refactoring branch 4 times, most recently from 623dedf to ad4e246 Compare April 23, 2020 14:08
@LuGO0
Copy link
Collaborator Author

LuGO0 commented Apr 23, 2020

@f4ww4z can you please review again so that I can finally add translations to the added string resources!!

@LuGO0
Copy link
Collaborator Author

LuGO0 commented May 7, 2020

@f4ww4z any updates on this ??

Copy link
Collaborator

@f4ww4z f4ww4z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LuGO0 Sorry for the delay, see my comments below.

@LuGO0 LuGO0 force-pushed the string_localization_refactoring branch from 0c21bed to f527260 Compare May 7, 2020 23:16
@LuGO0
Copy link
Collaborator Author

LuGO0 commented May 7, 2020

some translations were tough I had to use google Translate XD !!
@rishabh-997 please review the translations.
@f4ww4z please review the changes I will squash my commits .

@LuGO0 LuGO0 marked this pull request as ready for review May 7, 2020 23:20
@LuGO0 LuGO0 requested a review from f4ww4z May 7, 2020 23:22
@rishabh-997
Copy link
Collaborator

some translations were tough I had to use google Translate XD !!
@rishabh-997 please review the translations.
@f4ww4z please review the changes I will squash my commits .

The Hindi translations are appropriate. Make sure to add JIRA ticket to the title and resolve the ci errors.

@LuGO0 LuGO0 changed the title refactoring code for better support for localization AC-742 refactoring code for better support for localization May 8, 2020
@LuGO0 LuGO0 force-pushed the string_localization_refactoring branch from f527260 to 5ed26c7 Compare May 9, 2020 23:05
@LuGO0
Copy link
Collaborator Author

LuGO0 commented May 9, 2020

merge conflicts resolved and the build works fine for me idk why the CI build fails

@rishabh-997
Copy link
Collaborator

merge conflicts resolved and the build works fine for me idk why the CI build fails

You can click on CI details to see which particular test is failing and then run that test locally to check for exact error... You can run the entire presenter folder all together to see if all the tests are passing or not.

@f4ww4z
Copy link
Collaborator

f4ww4z commented May 10, 2020

@LuGO0 Please fix the merge conflicts and also take a look at these null pointer exceptions in the CI.

@LuGO0
Copy link
Collaborator Author

LuGO0 commented May 10, 2020

@LuGO0 Please fix the merge conflicts and also take a look at these null pointer exceptions in the CI.

@f4ww4z I am looking into these errors !! and will resolve conflicts

@LuGO0
Copy link
Collaborator Author

LuGO0 commented May 10, 2020

@f4ww4z I found out thatResources.getSystem() is null in the tests bt it works fine when app executes should I make changes in the testFile ? I will resolve conflicts once these tests pass !

@f4ww4z
Copy link
Collaborator

f4ww4z commented May 14, 2020

@f4ww4z I found out thatResources.getSystem() is null in the tests bt it works fine when app executes should I make changes in the testFile ? I will resolve conflicts once these tests pass !

@LuGO0 Yes you need to change test files. You can either use mocks to mock the getString part or create instrumentation tests.

@LuGO0
Copy link
Collaborator Author

LuGO0 commented May 14, 2020

Okay @f4ww4z

@LuGO0
Copy link
Collaborator Author

LuGO0 commented May 20, 2020

@rishabh-997 @f4ww4z I have removed all instances of Resources.getSystem() from all the presenters and instead delegated the views those are attached to it to display the strings.
but what should I do with the Repository class which uses ToastUtil.error to toast a lot of errors I couldnt find a work around for repository classes

@LuGO0
Copy link
Collaborator Author

LuGO0 commented May 20, 2020

@rishabh-997 @f4ww4z I have removed all instances of Resources.getSystem() from all the presenters and instead delegated the views those are attached to it to display the strings.
but what should I do with the Repository class which uses ToastUtil.error to toast a lot of errors I couldnt find a work around for repository classes

the best I could think was a callback interface which would be implemented in the view and delegated down uptill the repository class or add a appContext to repository class.

@LuGO0 LuGO0 force-pushed the string_localization_refactoring branch from bdda201 to 67b0ee8 Compare May 21, 2020 09:25
@LuGO0
Copy link
Collaborator Author

LuGO0 commented May 21, 2020

@rishabh-997 I coudnt test it on my phone how do we log in when demo server is down is there any way ??

@codecov-commenter
Copy link

codecov-commenter commented May 21, 2020

Codecov Report

Merging #723 into master will decrease coverage by 0.06%.
The diff coverage is 17.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #723      +/-   ##
==========================================
- Coverage   11.84%   11.77%   -0.07%     
==========================================
  Files         237      238       +1     
  Lines       10571    10641      +70     
  Branches     1018     1028      +10     
==========================================
+ Hits         1252     1253       +1     
- Misses       9237     9306      +69     
  Partials       82       82              
Impacted Files Coverage Δ
.../org/openmrs/mobile/activities/ACBaseActivity.java 0.00% <0.00%> (ø)
.../org/openmrs/mobile/activities/ACBaseFragment.java 10.00% <ø> (ø)
...a/org/openmrs/mobile/activities/BasePresenter.java 55.55% <0.00%> (ø)
.../activities/activevisits/ActiveVisitsActivity.java 0.00% <0.00%> (ø)
.../activities/activevisits/ActiveVisitsFragment.java 0.00% <ø> (ø)
...ivities/addeditpatient/AddEditPatientActivity.java 0.00% <0.00%> (ø)
...ivities/addeditpatient/AddEditPatientFragment.java 0.00% <0.00%> (ø)
...ditpatient/SimilarPatientsRecyclerViewAdapter.java 0.00% <0.00%> (ø)
...ctivities/community/contact/ContactUsActivity.java 0.00% <0.00%> (ø)
...ctivities/community/contact/ContactUsContract.java 0.00% <ø> (ø)
... and 180 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9c8e3ca...7fe0821. Read the comment docs.

@rishabh-997
Copy link
Collaborator

@rishabh-997 I coudnt test it on my phone how do we log in when demo server is down is there any way ??

You can use alternative server.

@LuGO0
Copy link
Collaborator Author

LuGO0 commented May 21, 2020

@rishabh-997 I coudnt test it on my phone how do we log in when demo server is down is there any way ??

You can use alternative server.

thanks Rishabh Ill check the app now and then request review !!

@LuGO0 LuGO0 force-pushed the string_localization_refactoring branch from 67b0ee8 to a2c0bd1 Compare May 22, 2020 08:04
@LuGO0
Copy link
Collaborator Author

LuGO0 commented May 22, 2020

@f4ww4z @rishabh-997 I have run all the tests locally now it works fine and the app also runs fine as far as I have tested please review !!

@LuGO0 LuGO0 requested a review from rishabh-997 May 25, 2020 06:46
Copy link
Collaborator

@rishabh-997 rishabh-997 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed the Activities package, kindly address the above comments. Also pull recent changes and resolve merge conflicts.
Also, make sure to edit only the required files next time so we can be specific to the files that have to reviewed...

@LuGO0
Copy link
Collaborator Author

LuGO0 commented May 25, 2020

@rishabh-997 I was doing a code parsing for all the hard coded string and it did code reformatting I dont know how bt It was good so I let it that way.
I will take care of this from next time
Thanks for reviewing :)

@LuGO0 LuGO0 force-pushed the string_localization_refactoring branch from a2c0bd1 to 177cb49 Compare May 26, 2020 04:29
@LuGO0 LuGO0 requested a review from rishabh-997 May 26, 2020 18:50
@LuGO0
Copy link
Collaborator Author

LuGO0 commented May 28, 2020

@f4ww4z @rishabh-997 please further review it .Its getting difficult to merge conflicts with this PR and keep it upto date with master 😅

Copy link
Collaborator

@f4ww4z f4ww4z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LuGO0 Yes, fixing code formatting should be in another issue and now it's difficult to review your changes. Please address my comments and then we should be good to merge.

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.*;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change to star imports.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed this @f4ww4z Sir.

DateTime dateTime;
String nullDateAsString = null;
DateTimeFormatter formatter = DateTimeFormat
@RunWith(PowerMockRunner.class)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to reindent this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done @f4ww4z Sir.

@LuGO0 LuGO0 force-pushed the string_localization_refactoring branch from 4d36a9f to 7fe0821 Compare May 30, 2020 08:20
@LuGO0
Copy link
Collaborator Author

LuGO0 commented May 30, 2020

@f4ww4z Sir I have made requested changes and will sqash changes once you approve of them!!

@LuGO0 LuGO0 requested a review from f4ww4z May 31, 2020 09:08
Copy link
Collaborator

@f4ww4z f4ww4z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @LuGO0 !

@f4ww4z f4ww4z merged commit fba7fe2 into openmrs:master Jun 1, 2020
@f4ww4z f4ww4z mentioned this pull request Jun 1, 2020
4 tasks
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.

5 participants