-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Update compileSdkVersion to 33 #17842
Conversation
CompatExtensions contains extension functions for deprecated functions of Bundle and Intent.
These functions are changed with Android 13.
These functions are changed with Android 13.
These functions are changed with Android 13.
These functions are changed with Android 13.
This comment was marked as off-topic.
This comment was marked as off-topic.
📲 You can test these changes on WordPress by downloading wordpress-installable-build-pr17842-34085d4.apk
|
📲 You can test these changes on Jetpack by downloading jetpack-installable-build-pr17842-34085d4.apk
|
These functions were deprecated on Android 13.
Fix failing LoginNoSitesViewModelTest
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.
👋 @irfano !
First of all, a big bravo for working on this compileSdkVersion = 33
upgrade and creating this PR, this work of yours will unblock many things for us, and it wasn't easy, I bet! 💯 🙇 ❤️
This contains a lot of changes, but they are small and similar. I could publish this via multiple PRs, but multiple PRs would create a burden of merging in order and creating multiple branches based on others. I believe it won't be hard to review this if you follow the commits.
Ah, actually, I would have still advised you to create multiple PRs. You will understand why I am saying that after you read through my code review change requests and comments below.
FYI: It took me almost a day to review this PR and more so to gather some feedback for you, that is, in a way that can make it easier for you to apply any of those changes I identified and can recommend to you. Also, I created some code batches for you, just to make it that bit easier for you to review those and apply them.
Another FYI, the fact that some commits, especially the big ones (9446c7f and d8deb99) weren't split into multiple commits, made it a bit more difficult for me to review this PR, so apologies for the delay.
- For example, for the
SiteCreationActivity
change, included in 9446c7f, you could have split the changes there into two commits, one for the SAM changes, and one for the mainonBackPressed
change. - Another example, for the
DomainSuggestionsFragment
change, included in d8deb99, you could have split the changes there into 2 commits, one for the DI changes, and one for the mainCompatExtensions
change.
For the future, I would really recommend that kind of changes to be split into multiple commits, just so that to keep the main commit on focus on the actual change that warranties a bit more thoughtful code review in case things got slipped.
I reviewed this PR but not tested it as much as I would have liked. But, I did that on purpose, this is because:
- Ideally, I would like us to bring a QE to the rescue here and have them test this PR thoroughly as well. For example, I did the same with the
AndroidX Core
dependency updates (seepdcxQM-1HP-p2
) and I think this update deserves the same level of testing before merging. There are lots of changes here and even if they don't seem to big, they have the potential to break things. - I have some a few code review change requests for you. I would like them to be handled first before I can begin the testing part on my side.
Request Changes:
- Warning (
⚠️ ): For the d8deb99 change, I suggest redoing that change, almost reverting half of it. Instead, I recommend explicitly adding therequireNotNull(...)
on all the changes that require a non-null value, that is, instead of guarding that and checking for nullability before proceeding forward. This is because by guarding that line and then checking whether that value is not null, instead of crashing the app, the flow will continue, but that will create more confusion and unexpected behavior later on. It is better to crash the app at that point, just like it would have crashed even before this update anyway. Wdyt? PS: I have created a patch for you on that just to make those change a bit more easier on you.
[Compile_SDK_33]_Compat_Extensions_Related_Code_Review_Changes.patch
- Suggestion (💡) I also recommend you add the same
CompatExtensions.kt
file on theimage-editor
lib module and then use that onCropViewModel.kt
andPreviewImageFragment.kt
, the same way you did for theWordPress
module. I understand that you didn't do it because you didn't want to create a duplication of extension files, but I believe it is better you do that now and then when the1.10.0
becomes ready, to delete both files and use thoseIntentCompat
andBundleCompat
instead. Thus, I believe it is better to have those 2 temp extension files for now, as this will mean that when1.10.0
becomes ready there would be no code changes, nowhere, only import changes. Wdyt? PS: The patch above includes this suggestion change as well. - Suggestion (💡): Consider explicitly setting the type on all the
CompatExtensions.kt
function calls, that is, instead of let it be referred sometimes. PS: The patch above includes this suggestion change as well. - Warning (
⚠️ ): I did search for all usages ofonBackPressed
in order to verify that all of them have been updated away from their deprecated usage and into the new recommended custom back navigation, using theonBackPressedDispatcher
. I found a few instances where this wasn't done and I recommend those Kotlin related activities and fragments to get that update too, no matter if the build doesn't complain about it (for an unknown to me reason). I also recommend we do the same change on all the Java related activities and fragments, no matter if our build succeeds without failing, just because it only complains on Kotlin classes, the idea is the same, later on, newer APIs and updates would no longer allow for these deprecated calls. Thus, if we can update them now, we should do that, especially given the fact that there are not that many such Java classes anyway, about 10 of them. Wdyt? PS: I have created a patch for you on that just to make those change a bit more easier on you, excluding the Java related changes.
[Compile_SDK_33]_On_Back_Pressed_Related_Code_Review_Changes.patch
- Suggestion (💡): Also, I recommend refactor some classes that are using the old way of utilizing the
onBackPressedDispatcher
callback, like theLoginNoSitesFragment
class. PS: The patch above includes this suggestion change as well. - Suggestion (💡): Consider reusing the
PackageManagerWrapper.getPackageInfo(...)
helper function instead of duplicating this logic in multiple places. I also suggest creating another suchPackageManagerWrapper.getActivityInfo(...)
helper function and reusing that were necessary. Wdyt? PS: I have created a patch for you on that just to make those change a bit more easier on you.
[Compile_SDK_33]_Package_Manager_Related_Code_Review_Changes.patch
I'll avoid writing any more comments for now, that is, until we discuss all the above first.
PS: Apologies for the wall of text and for adding lots on your plate before giving the 🟢 to merge this to trunk
. But, I do believe this it is better for us to be careful with this change and invest some extra time to make sure this change is (a.) safe for merging and (b.) includes all of the necessary updates. I am here to support you on all that, all the way, so feel free to reach out for help with whatever you might need. 💯
// must mutate the drawable to avoid affecting other instances of it | ||
val icon = menuItem.icon.mutate() | ||
val icon = currentIcon.mutate() |
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.
Minor (🔍): Consider using it.mutate
instead.
null -> error("PublishSettingsViewModel not initialized") | ||
} | ||
|
||
val is24HrFormat = DateFormat.is24HourFormat(activity) | ||
val context = ContextThemeWrapper(activity, style.PostSettingsCalendar) | ||
val timePickerDialog = TimePickerDialog( | ||
context, | ||
OnTimeSetListener { _, selectedHour, selectedMinute -> | ||
{ _, selectedHour, selectedMinute -> |
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.
Minor (🔍): Consider making this lambda a one-liner.
Enormous effort @irfano 👏 Is this supposed to go on a separate branch at first, not on the trunk direct! Would it compile though, if it is split into multiple PRs (As @ParaskP7 suggested), unless the changes required are made first in separate PRs and then upgrade the compileSdkVersion at last. |
👋 @ravishanker @irfano !
Actually, you can do this the other way around, create a feature branch with the following "required" changes first:
Maybe the above should be a PR of its own, so as for it to get reviewed first before it become the "feature branch" that all other PRs will target. With the above, the project will compile. Then, you could create multiple PRs on top of those changes, PRs that are not depending to each other, but directly targeting this feature branch to resolve the other "major" warnings:
Upon those 3 PRs merged into that feature branch, then revert the Let me know if the above makes sense. 🙏 PS: With the above, I am just sharing one alternative strategy to progress with such work. That doesn't mean that I would like us to redo the work that was already done in this PR. We can progress with this PR now to keep things flowing. This is just an FYI for any future such work. |
Thank you for your reviews, @ParaskP7 and @ravishanker! ❤️
If I did this, I'd need to fix the conflict to merge the 2nd PR after the 1st PR is merged. I was about to start the rotation, and I wouldn't be able to work on conflicts. That's why I wanted to publish this work with a single PR. But after @ParaskP7's comments, I saw that multiple PRs would be better. I'm converting this PR to the draft. As Petros suggested, I'll divide this PR into multiple PRs by making changes Petros requested next week after my rotation. |
👋 @irfano !
👍
Coolio, deal, but don't just do that because I suggested it. If you feel that it is better to included all these changes in this PR, please do that instead. No matter way you chose to progress with this work, I am here to support you all the way! 🚀 ❤️ THANK YOU! 🙇 🥇 🙏 |
I am closing this draft PR because the work has been reorganized, improved, and merged in #17947. |
Fixes #17790
This PR updates compileSdkVersion to 33 and fixes errors and warnings caused by the update.
This contains a lot of changes, but they are small and similar. I could publish this via multiple PRs, but multiple PRs would create a burden of merging in order and creating multiple branches based on others. I believe it won't be hard to review this if you follow the commits.
I've added @ravishanker, but he'll be on support rotation next week. I'd appreciate it if you could review, @ParaskP7.
Commits
onBackPressed
was deprecated on Android 13. It's updated only on Kotlin files. Because only errors on Kotlin files prevent the build.onBackPressed
on Java files can be updated while converting them to Kotlin.CompatExtensions
was added to use in the next commit.Bundle
andIntent
was deprecated. To update them for Android 13, there are functions inIntentCompat
andBundleCompat
but they're available on the1.10.0-alpha
version which is not stable yet. I usedCompatExtensions
that I created to update deprecated functions.AnimatorListener
parameters which are not nullable anymore.MenuItem
parameters which are not nullable anymore.SimpleOnGestureListener
parameters which are not nullable anymore.androidx.core
version to1.9.0
because we'll need newParcelCompat
functions in the next commit.ParcelCompat
for deprecated functions.PackageManager
functions.android.permission.POST_NOTIFICATIONS
to fix the build error. NowNotificationManagerCompat.from(context).notify(id, notification)
shows the error "Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with checkPermission) or explicitly handle a potential SecurityException
" but notifications still works on Android 13 and lower versions. Runtime permission for notifications #17714 will be handled later.T
nullable inCompatExtensions
. This also fixes possible null exceptions on runtime.To test:
Being able to build and basic smoke test should be enough.
Regression Notes
Potential unintended areas of impact
Since this touches a lot of classes, every screen can be impacted, but no change is expected on runtime. But especially back gestures, passing data between screens and notifications.
What I did to test those areas of impact (or what existing automated tests I relied on)
I tested the back gesture manually to verify it's still working.
What automated tests I added (or what prevented me from doing so)
None. This is just a library and deprecated functions update.
PR submission checklist:
RELEASE-NOTES.txt
if necessary.