mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Predictive back breakage fix (flutter/engine#42789)
Fixes breakages related to setFrameworkHandlesBack, for the Predictive Back feature for Android.
This commit is contained in:
parent
d6a1b45c11
commit
7ffe595a77
@ -701,10 +701,10 @@ public class FlutterActivity extends Activity
|
||||
: 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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1689,11 +1689,6 @@ public class FlutterFragment extends Fragment
|
||||
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.");
|
||||
|
||||
@ -138,8 +138,8 @@ public class PlatformChannel {
|
||||
break;
|
||||
case "SystemNavigator.setFrameworkHandlesBack":
|
||||
{
|
||||
boolean frameworkHandlesBacks = (boolean) arguments;
|
||||
platformMessageHandler.setFrameworkHandlesBack(frameworkHandlesBacks);
|
||||
boolean frameworkHandlesBack = (boolean) arguments;
|
||||
platformMessageHandler.setFrameworkHandlesBack(frameworkHandlesBack);
|
||||
result.success(null);
|
||||
break;
|
||||
}
|
||||
@ -516,8 +516,14 @@ public class PlatformChannel {
|
||||
*/
|
||||
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) {}
|
||||
|
||||
/**
|
||||
* The Flutter application would like to pop the top item off of the Android app's navigation
|
||||
|
||||
@ -57,7 +57,14 @@ public class PlatformPlugin {
|
||||
*/
|
||||
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) {}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@ -112,8 +119,8 @@ public class PlatformPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFrameworkHandlesBack(boolean frameworkHandlesBacks) {
|
||||
PlatformPlugin.this.setFrameworkHandlesBack(frameworkHandlesBacks);
|
||||
public void setFrameworkHandlesBack(boolean frameworkHandlesBack) {
|
||||
PlatformPlugin.this.setFrameworkHandlesBack(frameworkHandlesBack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -482,8 +489,8 @@ public class PlatformPlugin {
|
||||
currentTheme = systemChromeStyle;
|
||||
}
|
||||
|
||||
private void setFrameworkHandlesBack(boolean frameworkHandlesBacks) {
|
||||
platformPluginDelegate.setFrameworkHandlesBack(frameworkHandlesBacks);
|
||||
private void setFrameworkHandlesBack(boolean frameworkHandlesBack) {
|
||||
platformPluginDelegate.setFrameworkHandlesBack(frameworkHandlesBack);
|
||||
}
|
||||
|
||||
private void popSystemNavigator() {
|
||||
|
||||
@ -419,6 +419,6 @@ public class FlutterAndroidComponentTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFrameworkHandlesBack(boolean frameworkHandlesBacks) {}
|
||||
public void setFrameworkHandlesBack(boolean frameworkHandlesBack) {}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user