openmrs-contrib-android-client
openmrs-contrib-android-client copied to clipboard
AC-821 Fix Java and Kotlin deprecation warnings
Description of what I changed
In Travis-ci while building this project many Java and Kotlin deprecation warnings were arising so to fix all those warnings, I have made changes in 4 files.
Issue I worked on
JIRA Issue: https://issues.openmrs.org/browse/AC-821
Checklist: I completed these to help reviewers :)
- [X] My pull request only contains ONE single commit (the number above, next to the 'Commits' tab is 1).
- [x] I have added tests to cover my changes. (If you refactored existing code that was well tested you do not have to add tests)
- [X] All new and existing tests passed.
- [X] My pull request is based on the latest changes of the master branch.
@LuGO0 Please review my code and merge PR, if any changes are required let me know.
@Anshul-9923 few warnings are still left just supress them if you think they are not critical
@LuGO0 Should I also have to fix deprecated build features and can you please tell me which other files are needed to be changed to fix the remaining warnings? I am not able to get which other files needed to be changed seeing the Travis-ci build.
Oh okay @Anshul-9923 I will look into it if I can find something.
public abstract class AppDatabase extends RoomDatabase {
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 warning
I think this is the one which is not related to build warnings is it? ^
w: C:\projects\openmrs-contrib-android-client\openmrs-client\src\main\java\org\openmrs\mobile\activities\dashboard\DashboardFragment.kt: (116, 13): Condition 'root != null' is always 'true'
w: C:\projects\openmrs-contrib-android-client\openmrs-client\src\main\java\org\openmrs\mobile\activities\formadmission\FormAdmissionPresenter.kt: (142, 21): Unreachable code
w: C:\projects\openmrs-contrib-android-client\openmrs-client\src\main\java\org\openmrs\mobile\activities\formlist\FormListFragment.kt: (57, 51): Parameter 'parent' is never used, could be renamed to _
w: C:\projects\openmrs-contrib-android-client\openmrs-client\src\main\java\org\openmrs\mobile\activities\formlist\FormListFragment.kt: (57, 103): Parameter 'id' is never used, could be renamed to _
w: C:\projects\openmrs-contrib-android-client\openmrs-client\src\main\java\org\openmrs\mobile\activities\formlist\FormListFragment.kt: (72, 48): Parameter 'v' is never used, could be renamed to _
w: C:\projects\openmrs-contrib-android-client\openmrs-client\src\main\java\org\openmrs\mobile\activities\formlist\FormListFragment.kt: (168, 29): Variable 'json' initializer is redundant
w: C:\projects\openmrs-contrib-android-client\openmrs-client\src\main\java\org\openmrs\mobile\activities\formlist\FormListFragment.kt: (180, 32): Variable 'obj' initializer is redundant
w: C:\projects\openmrs-contrib-android-client\openmrs-client\src\main\java\org\openmrs\mobile\activities\logs\LogsFragment.kt: (51, 30): Parameter 'context' is never used
w: C:\projects\openmrs-contrib-android-client\openmrs-client\src\main\java\org\openmrs\mobile\listeners\watcher\PatientBirthdateValidatorWatcher.kt: (39, 13): Unreachable code
w: C:\projects\openmrs-contrib-android-client\openmrs-client\src\main\java\org\openmrs\mobile\listeners\watcher\PatientBirthdateValidatorWatcher.kt: (40, 13): Unreachable code
w: C:\projects\openmrs-contrib-android-client\openmrs-client\src\main\java\org\openmrs\mobile\listeners\watcher\PatientBirthdateValidatorWatcher.kt: (45, 17): Unreachable code
w: C:\projects\openmrs-contrib-android-client\openmrs-client\src\main\java\org\openmrs\mobile\listeners\watcher\PatientBirthdateValidatorWatcher.kt: (46, 17): Unreachable code
w: C:\projects\openmrs-contrib-android-client\openmrs-client\src\main\java\org\openmrs\mobile\utilities\NotificationUtil.kt: (30, 43): 'constructor Builder(Context!)' is deprecated. Deprecated in Java
I came across these warnings as well in the CI build logs can you fix them with this PR only?
@LuGO0 I have fixed the remaining deprecated warnings. Please review my code.
@LuGO0 I did changes as told by you. PTAL
Please check the build is failing
Please check the build is failing
@LuGO0 It is because of changing compileSdkVersion and targetSdkVersion to 30.
Please check the build is failing
@LuGO0 It is because of changing compileSdkVersion and targetSdkVersion to 30.
So
Please check the build is failing
@LuGO0 It is because of changing compileSdkVersion and targetSdkVersion to 30.
I think we dont need this change . We can simply have a build version check and have 2 different implementations for network Utils. Suppress the older implementation using a method level supress annotation, does it help?
Please check the build is failing
@LuGO0 It is because of changing compileSdkVersion and targetSdkVersion to 30.
So
Please check the build is failing
@LuGO0 It is because of changing compileSdkVersion and targetSdkVersion to 30.
I think we dont need this change . We can simply have a build version check and have 2 different implementations for network Utils. Suppress the older implementation using a method level supress annotation, does it help?
@LuGO0 So, Should I change library from android.preference.PreferenceManager to androidx.preference.PreferenceManager as it is deprecated warning.
I think we dont need this change . We can simply have a build version check and have 2 different implementations for network Utils. Suppress the older implementation using a method level supress annotation, does it help?
@LuGO0 So, Should I change library from android.preference.PreferenceManager to androidx.preference.PreferenceManager as it is deprecated warning.
Yes, just add a supress annotation locally if the build is failing and you are unable to fix it.
I think we dont need this change . We can simply have a build version check and have 2 different implementations for network Utils. Suppress the older implementation using a method level supress annotation, does it help?
@LuGO0 So, Should I change library from android.preference.PreferenceManager to androidx.preference.PreferenceManager as it is deprecated warning.
Yes, just add a supress annotation locally if the build is failing and you are unable to fix it.
@LuGO0 After importing it build fails and asks for changing minCompileSdk to 31.
@LuGO0 Done with the changes as told by you.
@LuGO0 I have reverted the changes wherever told by you. PTAL
Few warnings are still there but we can merge this will try running the application locally then merge this PR Thanks!
Few warnings are still there but we can merge this will try running the application locally then merge this PR Thanks!
Ok @LuGO0
@LuGO0 You have not merged my PR, do I need to do any changes?
Will run it locally then merge it.
@shubhamsgit need some help verifying this PR locally, and let me know if it works fine? Thanks!
@LuGO0 When will the idealist release for GSoC projects by openmrs?
@LuGO0 When will the idealist release for GSoC projects by openmrs?
Not sure @Anshul-9923, you can find it on OpenMRS Talk or ask the GSOC co-ordinators like Jennifer and Moses ! Also sorry for the delay in this PR's review haven't got a chance to run it locally once !
@LuGO0 When will the idealist release for GSoC projects by openmrs?
Not sure @Anshul-9923, you can find it on OpenMRS Talk or ask the GSOC co-ordinators like Jennifer and Moses ! Also sorry for the delay in this PR's review haven't got a chance to run it locally once !
Thanks @LuGO0
Please dont delete any unreachable code since these are probably part of some unfinished module. I would be happy to keep them as they are for now with a warning supression.
Please dont delete any unreachable code since these are probably part of some unfinished module. I would be happy to keep them as they are for now with a warning supression.
No need to delete @LuGO0 The unreachable code's position just has to be changed
Please dont delete any unreachable code since these are probably part of some unfinished module. I would be happy to keep them as they are for now with a warning supression.
You mean 'redundant code' or 'unreachable code'?
Unreachable code, like the formAdmissionPresenter portion.
Unreachable code, like the formAdmissionPresenter portion.
I think that code can be removed as program control never reaches view.enableSubmitButton(true)
because error(errorMessage)
throws IllegalStateException
and program terminates.
and in PatientBirthdateValidatorWatcher
, edmonth.text.clear()
and edyr.text.clear()
these two lines should be moved before the error()
function. This can be counted as a bug though. Can open a new PR if you want.
Yupp create new PRs if needed with each one for a specific use case, don't do it in this one!