-
Notifications
You must be signed in to change notification settings - Fork 6k
Support basic back navigation in Android 13/API 33 #35678
Conversation
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. |
@@ -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 |
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.
Are there any implications to existing third-party subclasses of FlutterActivity from changing this?
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.
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); |
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.
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() { |
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.
Shouldn't we test unregistration as well?
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.
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?
This reverts commit cbcc5d3.
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