-
Notifications
You must be signed in to change notification settings - Fork 425
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-821 Fix Java and Kotlin deprecation warnings #938
base: master
Are you sure you want to change the base?
Conversation
@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? |
Oh okay @Anshul-9923 I will look into it if I can find something. |
I think this is the one which is not related to build warnings is it? ^
I came across these warnings as well in the CI build logs can you fix them with this PR only? |
openmrs-android-sdk/src/main/java/com/openmrs/android_sdk/utilities/NetworkUtils.kt
Outdated
Show resolved
Hide resolved
…ng from NetworkUtils.kt
@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 |
@LuGO0 It is because of changing compileSdkVersion and targetSdkVersion to 30. |
So
I think we dont need this change . We can simply have a build version check and have 2 different implementations for network Utils. |
@LuGO0 So, Should I change library from android.preference.PreferenceManager to androidx.preference.PreferenceManager as it is deprecated warning. |
openmrs-android-sdk/src/main/java/com/openmrs/android_sdk/utilities/NetworkUtils.kt
Outdated
Show resolved
Hide resolved
openmrs-android-sdk/src/main/java/com/openmrs/android_sdk/utilities/NetworkUtils.kt
Outdated
Show resolved
Hide resolved
openmrs-client/src/main/java/org/openmrs/mobile/activities/dashboard/DashboardFragment.kt
Show resolved
Hide resolved
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. |
val prefs = PreferenceManager.getDefaultSharedPreferences(OpenmrsAndroid.getInstance()) | ||
val toggle = prefs.getBoolean("sync", true) | ||
return if (toggle) { | ||
val prefs = OpenmrsAndroid.getInstance()?.let { android.preference.PreferenceManager.getDefaultSharedPreferences(it) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be no change here right? after you reverted your changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, reverted the changes
openmrs-android-sdk/src/main/java/com/openmrs/android_sdk/utilities/NetworkUtils.kt
Outdated
Show resolved
Hide resolved
@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! |
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? |
Not sure @Anshul-9923, you can find it on OpenMRS Talk or ask the GSOC co-ordinators like Jennifer and Moses ! |
Thanks @LuGO0 |
/** | ||
* Starts new Activity depending on which ImageView triggered it | ||
*/ | ||
private fun startNewActivity(clazz: Class<out ACBaseActivity?>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Anshul-9923 As I can see, this PR is about fixing Java & Kotlin deprecation warnings but I see some deletions for the redundant code (which is not wrong). @LuGO0 Shouldn't a separate PR be opened for removing redundant code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or better remove all the redundant code under this PR only? @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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR title is misleading. PR fixes only two deprecations i.e., Preference Manager & Recycler View. Remaining part of the PR just removes redundant code. @Anshul-9923 Either you should remove all of the project's redundant code in this PR and rename it or if @LuGO0 suggests open a new PR.
@@ -31,6 +31,7 @@ import com.openmrs.android_sdk.library.api.repository.ProviderRepository | |||
import org.openmrs.mobile.application.OpenMRS | |||
import com.openmrs.android_sdk.library.listeners.retrofitcallbacks.DefaultResponseCallback | |||
|
|||
@Suppress("UNREACHABLE_CODE") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to suppress this warning. It can be resolved.
@@ -19,6 +19,7 @@ import android.widget.EditText | |||
import com.openmrs.android_sdk.utilities.ApplicationConstants | |||
import com.openmrs.android_sdk.utilities.StringUtils.notEmpty | |||
|
|||
@Suppress("UNREACHABLE_CODE") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this too. Can be resolved.
No need to delete @LuGO0 The unreachable code's position just has to be changed |
You mean 'redundant code' or 'unreachable code'? |
Unreachable code, like the formAdmissionPresenter portion. |
I think that code can be removed as program control never reaches |
and in |
Yupp create new PRs if needed with each one for a specific use case, don't do it in this one! |
I request the maintainer to clarify the exact work that you are looking for. |
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 :)
(the number above, next to the 'Commits' tab is 1).
existing code that was well tested you do not have to add tests)