Update deprecated back pressed event#18019
Update deprecated back pressed event#18019ParaskP7 merged 12 commits intofeature/update-compile-sdk-33from
Conversation
Activity's onBackPressed was deprecated on Android 13.
Activity's onBackPressed was deprecated on Android 13.
This just makes the code shorter by using an extension function.
|
|||||||||||
| 💡 Scan this QR code with your Android phone to download and install the APK directly on it. | ||
| App | WordPress | |
| Build Flavor | Jalapeno | |
| Build Type | Debug | |
| Commit | bfcf01d | |
|
|||||||||||
| 💡 Scan this QR code with your Android phone to download and install the APK directly on it. | ||
| App | Jetpack | |
| Build Flavor | Jalapeno | |
| Build Type | Debug | |
| Commit | bfcf01d | |
ParaskP7
left a comment
There was a problem hiding this comment.
👋 @irfano !
Thank you so much for opening this PR, the work you did here really take us to the next level. This work will (hopefully) help us avoid redoing any such onBackPressed work in the future, and, no more dealing with deprecation such as that, win-win! 🎉
I reviewed and quickly tested your changes, I did identify some problems (I think, see
Thus, at this point I am going to request changes, but don't be alarmed too much. After we resolve/discuss on them, I am going to do another round of testing to verify that everything works as expected and we'll then merge this to its parent branch asap. 👍
WordPress/src/main/java/org/wordpress/android/ui/history/HistoryDetailActivity.kt
Outdated
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationActivity.kt
Outdated
Show resolved
Hide resolved
...ndroid/ui/jpfullplugininstall/onboarding/JetpackFullPluginInstallOnboardingDialogFragment.kt
Outdated
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/CollapseFullScreenDialogFragment.java
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsDetailActivity.java
Outdated
Show resolved
Hide resolved
...ress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkingIntentReceiverActivity.java
Show resolved
Hide resolved
OnBackPressedCallback was temporarily disabled to allow the system to handle the back button event.
Generated by 🚫 dangerJS |
ParaskP7
left a comment
There was a problem hiding this comment.
👋 @irfano and once more, thank you so much for all the work you did with this PR, research and coding included! 🥇
After reviewing the update, I now feel much more comfortable hitting the ✅ button! 🎉
Thus, at this point I am going to request changes, but don't be alarmed too much. After we resolve/discuss on them, I am going to do another round of testing to verify that everything works as expected and we'll then merge this to its parent branch asap. 👍
I did another round of testing and can verify that everything worked as expected, I didn't at least notice a crash... 💯
But, be mindful that I didn't go through all the screens/functionality to verify every back pressed logic. As such, and as discussed/planned already, I recommend that when the parent feature/update-compile-sdk-33 gets ready we take it for another spin of testing, this time thoroughly, while asking from QE to help us on that too.
Let's merge this! 🚀
I am about to submit a request for a QE. I'll mention that back navigation is an important change that needs to be tested. |


This PR is part of a parent PR to update compileSdk to 33.
onBackPressed()was deprecated on Android 13. This updates deprecated usages of onBackPressed.onBackPressed()calls are removed and updated withOnBackPressedDispatchersonBackPressed().onBackPressedare removed. Instead, a callback is added toonBackPressedDispatcher. When I want to triggersuper.onBackPressed(), I disabled the callback and triggeredOnBackPressedDispatcher'sonBackPressed()gain.ComponentDialogto be able to useOnBackPressedDispatcher. For this purpose,Dialog(requireContext(), theme)is converted tosuper.onCreateDialog(savedInstanceState)To test:
Make sure the project is buildable and test back navigation on screens. It's very time-consuming to test all screens. But please test at least some screens from different cases, like a screen from an activity and a DialogFragment.
Regression Notes
Potential unintended areas of impact
The back navigation function could be broken on some screens.
What I did to test those areas of impact (or what existing automated tests I relied on)
I haven't tested all screens, but I tested some activities and all
DialogFragments.What automated tests I added (or what prevented me from doing so)
No new feature was added, and the existing tests were relied upon.
PR submission checklist:
RELEASE-NOTES.txtif necessary.