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 all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,10 @@ public void onBackInvoked() {
: null;

@Override
public void setFrameworkHandlesBack(boolean frameworkHandlesBacks) {
if (frameworkHandlesBacks && !hasRegisteredBackCallback) {
public void setFrameworkHandlesBack(boolean frameworkHandlesBack) {
if (frameworkHandlesBack && !hasRegisteredBackCallback) {
registerOnBackInvokedCallback();
} else if (!frameworkHandlesBacks && hasRegisteredBackCallback) {
} else if (!frameworkHandlesBack && hasRegisteredBackCallback) {
unregisterOnBackInvokedCallback();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1689,11 +1689,6 @@ boolean shouldDelayFirstAndroidViewDraw() {
return getArguments().getBoolean(ARG_SHOULD_DELAY_FIRST_ANDROID_VIEW_DRAW);
}

@Override
public void setFrameworkHandlesBack(boolean frameworkHandlesBacks) {
// Irrelevant to FlutterFragment.
}

private boolean stillAttachedForEvent(String event) {
if (delegate == null) {
Log.w(TAG, "FlutterFragment " + hashCode() + " " + event + " called after release.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
break;
case "SystemNavigator.setFrameworkHandlesBack":
{
boolean frameworkHandlesBacks = (boolean) arguments;
platformMessageHandler.setFrameworkHandlesBack(frameworkHandlesBacks);
boolean frameworkHandlesBack = (boolean) arguments;
platformMessageHandler.setFrameworkHandlesBack(frameworkHandlesBack);
result.success(null);
break;
}
Expand Down Expand Up @@ -516,8 +516,14 @@ public interface PlatformMessageHandler {
*/
void setSystemUiOverlayStyle(@NonNull SystemChromeStyle systemUiOverlayStyle);

/** The Flutter application would or would not like to handle navigation pop events itself. */
void setFrameworkHandlesBack(boolean frameworkHandlesBack);
/**
* The Flutter application would or would not like to handle navigation pop events itself.
*
* <p>Relevant for registering and unregistering the app's OnBackInvokedCallback for the
* Predictive Back feature, for example as in {@link
* io.flutter.embedding.android.FlutterActivity}.
*/
default void setFrameworkHandlesBack(boolean frameworkHandlesBack) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes sense to me since it is only used in a particular place. I'd suggest expanding the doc to mention where exactly this is relevant currently (FlutterActivity), just so it's clear we don't expect it to work or be used elsewhere.


/**
* 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,14 @@ public interface PlatformPluginDelegate {
*/
boolean popSystemNavigator();

void setFrameworkHandlesBack(boolean frameworkHandlesBacks);
/**
* The Flutter application would or would not like to handle navigation pop events itself.
*
* <p>Relevant for registering and unregistering the app's OnBackInvokedCallback for the
* Predictive Back feature, for example as in {@link
* io.flutter.embedding.android.FlutterActivity}.
*/
default void setFrameworkHandlesBack(boolean frameworkHandlesBack) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this works as a good alternative to the empty implementation in FlutterFragment. Maybe the doc can expand on where this is currently relevant (FlutterActivity alone now I suppose)?

}

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

@Override
public void setFrameworkHandlesBack(boolean frameworkHandlesBacks) {
PlatformPlugin.this.setFrameworkHandlesBack(frameworkHandlesBacks);
public void setFrameworkHandlesBack(boolean frameworkHandlesBack) {
PlatformPlugin.this.setFrameworkHandlesBack(frameworkHandlesBack);
}

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

private void setFrameworkHandlesBack(boolean frameworkHandlesBacks) {
platformPluginDelegate.setFrameworkHandlesBack(frameworkHandlesBacks);
private void setFrameworkHandlesBack(boolean frameworkHandlesBack) {
platformPluginDelegate.setFrameworkHandlesBack(frameworkHandlesBack);
}

private void popSystemNavigator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,6 @@ public boolean popSystemNavigator() {
}

@Override
public void setFrameworkHandlesBack(boolean frameworkHandlesBacks) {}
public void setFrameworkHandlesBack(boolean frameworkHandlesBack) {}
}
}