Skip to content

Update deprecated back pressed event#18019

Merged
ParaskP7 merged 12 commits intofeature/update-compile-sdk-33from
update-deprecated-onbackpressed
Mar 6, 2023
Merged

Update deprecated back pressed event#18019
ParaskP7 merged 12 commits intofeature/update-compile-sdk-33from
update-deprecated-onbackpressed

Conversation

@irfano
Copy link
Copy Markdown
Member

@irfano irfano commented Feb 28, 2023

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.

onBackPressedDispatcher.addCallback(this) {
     ...
     // The code below disables this callback and lets the system handle the back pressed (e.g., by finishing the activity)
     isEnabled = false
     onBackPressedDispatcher.onBackPressed()
}
  • Migrate dialogs to OnBackPressedCallback: We need to cast dialogs to ComponentDialog to be able to use OnBackPressedDispatcher. For this purpose, Dialog(requireContext(), theme) is converted to super.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

  1. Potential unintended areas of impact
    The back navigation function could be broken on some screens.

  2. 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.

  3. 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:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@irfano irfano added this to the 22.1 milestone Feb 28, 2023
@irfano irfano requested a review from ParaskP7 February 28, 2023 00:37
@irfano irfano self-assigned this Feb 28, 2023
@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented Feb 28, 2023

WordPress📲 You can test these changes on WordPress by downloading wordpress-installable-build-pr18019-bfcf01d.apk
💡 Scan this QR code with your Android phone to download and install the APK directly on it.
AppWordPress
Build FlavorJalapeno
Build TypeDebug
Commitbfcf01d
Note: This installable build uses the JalapenoDebug build flavor, and does not support Google Login.

@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented Feb 28, 2023

Jetpack📲 You can test these changes on Jetpack by downloading jetpack-installable-build-pr18019-bfcf01d.apk
💡 Scan this QR code with your Android phone to download and install the APK directly on it.
AppJetpack
Build FlavorJalapeno
Build TypeDebug
Commitbfcf01d
Note: This installable build uses the JalapenoDebug build flavor, and does not support Google Login.

@ParaskP7 ParaskP7 self-assigned this Feb 28, 2023
Copy link
Copy Markdown
Contributor

@ParaskP7 ParaskP7 left a comment

Choose a reason for hiding this comment

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

👋 @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 ⚠️) and also posted few questions that I would like to discuss with you (see ❓), that is, before us merging this to its parent branch.

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. 👍

@peril-wordpress-mobile
Copy link
Copy Markdown

Warnings
⚠️ PR has more than 300 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS

Copy link
Copy Markdown
Contributor

@ParaskP7 ParaskP7 left a comment

Choose a reason for hiding this comment

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

👋 @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! 🚀

@irfano
Copy link
Copy Markdown
Member Author

irfano commented Mar 6, 2023

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.

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.
Thank you for your thorough review! You can merge it as the reviewer. 🚀

@ParaskP7 ParaskP7 merged commit 5364166 into feature/update-compile-sdk-33 Mar 6, 2023
@ParaskP7 ParaskP7 deleted the update-deprecated-onbackpressed branch March 6, 2023 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants