Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Support basic back navigation in Android 13/API 33 #35678

Merged
merged 12 commits into from
Sep 2, 2022

Conversation

GaryQian
Copy link
Contributor

@GaryQian GaryQian commented Aug 24, 2022

Implements `OnBackInvoked____ in order to provide pre-13 backnavigation behavior when predictive backnav is enabled.

This PR will allow back actions to pop flutter route instead of exiting the app completely.

This also bumps some dependencies to better support API 33.

Partially addresses flutter/flutter#109558 and flutter/flutter#109513

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@GaryQian GaryQian changed the title Support basic backnav in Android 13/API 33 Support basic back navigation in Android 13/API 33 Aug 24, 2022
@@ -208,7 +211,7 @@
// A number of methods in this class have the same implementation as FlutterFragmentActivity. These
// methods are duplicated for readability purposes. Be sure to replicate any change in this class in
// FlutterFragmentActivity, too.
public class FlutterActivity extends Activity
public class FlutterActivity extends ComponentActivity
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any implications to existing third-party subclasses of FlutterActivity from changing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turns out this is not needed anymore. Thus also making the lifecycle changes unnecessary.

@@ -495,13 +496,55 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_CREATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should existing use of lifecycle change to getLifecycle()? Otherwise it seems like we're introducing the possibility of NPEs.

// test that directly exercises the OnBackInvoked APIs when API 33 is supported.
@Test
@TargetApi(33)
public void itRegistersOnBackInvokedCallbackOnCreate() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we test unregistration as well?

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

LGTM

Could you reference the issue in the PR description so we have that back-reference if/when someone is looking back at this PR or the issue to see what was done?

@GaryQian GaryQian added waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. autosubmit Merge PR when tree becomes green via auto submit App labels Sep 2, 2022
@auto-submit auto-submit bot merged commit cbcc5d3 into flutter:main Sep 2, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 2, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 2, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 2, 2022
CaseyHillers added a commit that referenced this pull request Sep 8, 2022
cfontas pushed a commit to cfontas/engine that referenced this pull request Sep 14, 2022
Oleh-Sv pushed a commit to Oleh-Sv/engine that referenced this pull request Sep 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App needs tests platform-android waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants