summaryrefslogtreecommitdiff
path: root/core/java/android/window/OnBackAnimationCallback.java
diff options
context:
space:
mode:
authorVadim Caen <caen@google.com>2022-03-31 18:29:26 +0200
committerVadim Caen <caen@google.com>2022-04-01 20:09:26 +0000
commitc627777ddac2dd764dfb7ad7baf3706a9052c44b (patch)
tree23abd8c265d7359a3aa310a6aef22eebf15c7618 /core/java/android/window/OnBackAnimationCallback.java
parent924b02bb035c18a79966e4f35177547ab31b9942 (diff)
Split animation methods out of OnBackInvokedCallback
This makes OnBackInvokedCallback SAM compatible Bug: 227789359 Test: atest \ CtsWindowManagerDeviceTestCases:android.server.wm.BackNavigationLegacyTest \ CtsWindowManagerDeviceTestCases:android.server.wm.BackNavigationTests \ WmTests:com.android.server.wm.BackNavigationControllerTests \ FrameworksCoreTests:android.window.BackNavigationTest \ FrameworksCoreTests:android.window.WindowOnBackInvokedDispatcherTest \ CtsViewTestCases:android.view.cts.OnBackInvokedDispatcherTest Change-Id: Iab86b0488f1b3048eb02042191acaeb6a645a0bc
Diffstat (limited to 'core/java/android/window/OnBackAnimationCallback.java')
-rw-r--r--core/java/android/window/OnBackAnimationCallback.java61
1 files changed, 61 insertions, 0 deletions
diff --git a/core/java/android/window/OnBackAnimationCallback.java b/core/java/android/window/OnBackAnimationCallback.java
new file mode 100644
index 000000000000..1a37e57df403
--- /dev/null
+++ b/core/java/android/window/OnBackAnimationCallback.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.window;
+
+import android.annotation.NonNull;
+import android.app.Activity;
+import android.app.Dialog;
+import android.view.View;
+
+/**
+ * Interface for applications to register back animation callbacks along their custom back
+ * handling.
+ * <p>
+ * This allows the client to customize various back behaviors by overriding the corresponding
+ * callback methods.
+ * <p>
+ * Callback instances can be added to and removed from {@link OnBackInvokedDispatcher}, held
+ * by classes that implement {@link OnBackInvokedDispatcherOwner} (such as {@link Activity},
+ * {@link Dialog} and {@link View}).
+ * <p>
+ * When back is triggered, callbacks on the in-focus window are invoked in reverse order in which
+ * they are added within the same priority. Between different priorities, callbacks with higher
+ * priority are invoked first.
+ * <p>
+ * @see OnBackInvokedCallback
+ * @hide
+ */
+public interface OnBackAnimationCallback extends OnBackInvokedCallback {
+ /**
+ * Called when a back gesture has been started, or back button has been pressed down.
+ */
+ default void onBackStarted() { }
+
+ /**
+ * Called on back gesture progress.
+ *
+ * @param backEvent An {@link BackEvent} object describing the progress event.
+ *
+ * @see BackEvent
+ */
+ default void onBackProgressed(@NonNull BackEvent backEvent) { }
+
+ /**
+ * Called when a back gesture or back button press has been cancelled.
+ */
+ default void onBackCancelled() { }
+}