|
35 | 35 | import android.view.View; |
36 | 36 | import android.view.Window; |
37 | 37 | import android.view.WindowManager; |
38 | | -import android.window.OnBackInvokedCallback; |
39 | | -import android.window.OnBackInvokedDispatcher; |
40 | 38 | import androidx.annotation.NonNull; |
41 | 39 | import androidx.annotation.Nullable; |
42 | 40 | import androidx.annotation.VisibleForTesting; |
@@ -497,57 +495,13 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { |
497 | 495 |
|
498 | 496 | lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_CREATE); |
499 | 497 |
|
500 | | - registerOnBackInvokedCallback(); |
501 | | - |
502 | 498 | configureWindowForTransparency(); |
503 | 499 |
|
504 | 500 | setContentView(createFlutterView()); |
505 | 501 |
|
506 | 502 | configureStatusBarForFullscreenFlutterExperience(); |
507 | 503 | } |
508 | 504 |
|
509 | | - /** |
510 | | - * Registers the callback with OnBackInvokedDispatcher to capture back navigation gestures and |
511 | | - * pass them to the framework. |
512 | | - * |
513 | | - * <p>This replaces the deprecated onBackPressed method override in order to support API 33's |
514 | | - * predictive back navigation feature. |
515 | | - * |
516 | | - * <p>The callback must be unregistered in order to prevent unpredictable behavior once outside |
517 | | - * the Flutter app. |
518 | | - */ |
519 | | - @VisibleForTesting |
520 | | - public void registerOnBackInvokedCallback() { |
521 | | - if (Build.VERSION.SDK_INT >= 33) { |
522 | | - getOnBackInvokedDispatcher() |
523 | | - .registerOnBackInvokedCallback( |
524 | | - OnBackInvokedDispatcher.PRIORITY_DEFAULT, onBackInvokedCallback); |
525 | | - } |
526 | | - } |
527 | | - |
528 | | - /** |
529 | | - * Unregisters the callback from OnBackInvokedDispatcher. |
530 | | - * |
531 | | - * <p>This should be called when the activity is no longer in use to prevent unpredictable |
532 | | - * behavior such as being stuck and unable to press back. |
533 | | - */ |
534 | | - @VisibleForTesting |
535 | | - public void unregisterOnBackInvokedCallback() { |
536 | | - if (Build.VERSION.SDK_INT >= 33) { |
537 | | - getOnBackInvokedDispatcher().unregisterOnBackInvokedCallback(onBackInvokedCallback); |
538 | | - } |
539 | | - } |
540 | | - |
541 | | - private final OnBackInvokedCallback onBackInvokedCallback = |
542 | | - Build.VERSION.SDK_INT >= 33 |
543 | | - ? new OnBackInvokedCallback() { |
544 | | - @Override |
545 | | - public void onBackInvoked() { |
546 | | - onBackPressed(); |
547 | | - } |
548 | | - } |
549 | | - : null; |
550 | | - |
551 | 505 | /** |
552 | 506 | * Switches themes for this {@code Activity} from the theme used to launch this {@code Activity} |
553 | 507 | * to a "normal theme" that is intended for regular {@code Activity} operation. |
@@ -726,9 +680,7 @@ protected void onSaveInstanceState(Bundle outState) { |
726 | 680 | * |
727 | 681 | * <p>After calling, this activity should be disposed immediately and not be re-used. |
728 | 682 | */ |
729 | | - @VisibleForTesting |
730 | | - public void release() { |
731 | | - unregisterOnBackInvokedCallback(); |
| 683 | + private void release() { |
732 | 684 | if (delegate != null) { |
733 | 685 | delegate.release(); |
734 | 686 | delegate = null; |
|
0 commit comments