Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9b25e71
Log everywhere I see onBackPressed... And it doesn't log anything!
justinmc Jan 27, 2023
b10efe3
Just hackily remove all usage of onBack, and predictive back does wor…
justinmc Jan 27, 2023
75d8e38
Undid all of the commenting and deleting and located the one call tha…
justinmc Jan 27, 2023
e8a5130
No logging verbose
justinmc Jan 27, 2023
9c0e7cc
WIP A platform channel API to declare that the nav stack is empty
justinmc Jan 28, 2023
205d1e5
navigationStackIsEmpty method to enable predictive back
justinmc Feb 1, 2023
66d1f84
Migrate to updateNavigationStackStatus, works for inner routes
justinmc Feb 9, 2023
9e8e230
Clean up logs and todos
justinmc Feb 9, 2023
0ed2bec
Rename hasMultiple to frameworkHandlesPop for clarity
justinmc Mar 7, 2023
2afbbad
Merge branch 'main' into predictive-back-root
justinmc Mar 7, 2023
8aeba57
Analyzer fix
justinmc Mar 7, 2023
5e89211
WIP some debugging
justinmc Apr 7, 2023
015f2a5
Merge branch 'main' into predictive-back-root
justinmc Apr 7, 2023
b7b2f17
Merge branch 'main' into predictive-back-root
justinmc May 12, 2023
6bc7d5e
Rename to frameworkHandlesBacks
justinmc May 26, 2023
01a22a2
Clean up
justinmc May 26, 2023
6f22009
Confirmed that it works on my old (API 24) samsung device
justinmc May 26, 2023
440a6ee
I dont think I need to modify flutterfragment(activity)
justinmc May 30, 2023
e075275
Tests and empty implementation for FlutterFragment
justinmc Jun 2, 2023
af98e2c
Merge remote-tracking branch 'upstream/main' into predictive-back-root
justinmc Jun 5, 2023
1db22e5
More specific name for hasRegisteredCallback
justinmc Jun 7, 2023
4701d66
Backs to Back
justinmc Jun 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename to frameworkHandlesBacks
  • Loading branch information
justinmc committed May 26, 2023
commit 6bc7d5ed6a23064bc71337d7e43178c994579b17
Original file line number Diff line number Diff line change
Expand Up @@ -705,14 +705,14 @@ public void onBackInvoked() {
}
: null;

// TODO(justinmc): Do the same thing in other embedding strategies (justin FlutterFragment?
// TODO(justinmc): Do the same thing in other embedding strategies (just FlutterFragment?
// FlutterFragmentActivity?).
@Override
public void updateNavigationStackStatus(boolean frameworkHandlesPop) {
if (frameworkHandlesPop && !hasRegisteredCallback) {
public void setFrameworkHandlesBacks(boolean frameworkHandlesBacks) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do people feel about this name?

Copy link
Member

Choose a reason for hiding this comment

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

suggestion: setFrameworkHandlesBack (without the plural s)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe something to indicate it registers/unregisters a callback based on frameworkHandlesBacks since it isn't actually setting that, e.g. toggleOnBackRegistry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to go with setFrameworkHandlesBack for now.

I kind of wanted to be generic about what is actually happening under the hood in case that changes, or in case we ever needed to do this on another platform that handles it differently. I think setFrameworkHandlesBack works well enough since it at least sounds declarative, like it's setting some state that decides what should happen to back gestures.

Let me know if anyone has other thoughts though.

if (frameworkHandlesBacks && !hasRegisteredCallback) {
Log.e("justin", "Stopping predictive back");
registerOnBackInvokedCallback();
} else if (!frameworkHandlesPop && hasRegisteredCallback) {
} else if (!frameworkHandlesBacks && hasRegisteredCallback) {
Log.e("justin", "Enabling predictive back");
unregisterOnBackInvokedCallback();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1687,7 +1687,7 @@ public boolean popSystemNavigator() {
}

@Override
public void updateNavigationStackStatus(boolean hasMultiple) {
public void setFrameworkHandlesBacks(boolean frameworkHandlesBacks) {
// TODO(justinmc): Implement. Implementing in FlutterActivity first.
// unregisterOnBackInvokedCallback();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,10 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
result.error("error", exception.getMessage(), null);
}
break;
// TODO(justinmc): Potentially rename this.
case "SystemNavigator.updateNavigationStackStatus":
case "SystemNavigator.setFrameworkHandlesBacks":
{
boolean frameworkHandlesPop = (boolean) arguments;
platformMessageHandler.updateNavigationStackStatus(frameworkHandlesPop);
boolean frameworkHandlesBacks = (boolean) arguments;
platformMessageHandler.setFrameworkHandlesBacks(frameworkHandlesBacks);
result.success(null);
break;
}
Expand Down Expand Up @@ -518,7 +517,7 @@ public interface PlatformMessageHandler {
void setSystemUiOverlayStyle(@NonNull SystemChromeStyle systemUiOverlayStyle);

/** The Flutter application would or would not like to handle navigation pop events itself. */
void updateNavigationStackStatus(boolean frameworkHandlesPop);
void setFrameworkHandlesBacks(boolean frameworkHandlesPop);

/**
* The Flutter application would like to pop the top item off of the Android app's navigation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public interface PlatformPluginDelegate {
*/
boolean popSystemNavigator();

void updateNavigationStackStatus(boolean frameworkHandlesPop);
void setFrameworkHandlesBacks(boolean frameworkHandlesBacks);
}

@VisibleForTesting
Expand Down Expand Up @@ -112,8 +112,8 @@ public void setSystemUiOverlayStyle(
}

@Override
public void updateNavigationStackStatus(boolean frameworkHandlesPop) {
PlatformPlugin.this.updateNavigationStackStatus(frameworkHandlesPop);
public void setFrameworkHandlesBacks(boolean frameworkHandlesBacks) {
PlatformPlugin.this.setFrameworkHandlesBacks(frameworkHandlesBacks);
}

@Override
Expand Down Expand Up @@ -482,8 +482,8 @@ private void setSystemChromeSystemUIOverlayStyle(
currentTheme = systemChromeStyle;
}

private void updateNavigationStackStatus(boolean frameworkHandlesPop) {
platformPluginDelegate.updateNavigationStackStatus(frameworkHandlesPop);
private void setFrameworkHandlesBacks(boolean frameworkHandlesBacks) {
platformPluginDelegate.setFrameworkHandlesBacks(frameworkHandlesBacks);
}

private void popSystemNavigator() {
Expand Down