| 1 | /* |
| 2 | * Copyright (C) 2021 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.wm.shell.back; |
| 18 | |
| 19 | import android.view.KeyEvent; |
| 20 | import android.view.MotionEvent; |
| 21 | import android.window.BackEvent; |
| 22 | |
| 23 | import com.android.wm.shell.common.annotations.ExternalThread; |
| 24 | |
| 25 | /** |
| 26 | * Interface for external process to get access to the Back animation related methods. |
| 27 | */ |
| 28 | @ExternalThread |
| 29 | public interface BackAnimation { |
| 30 | |
| 31 | /** |
| 32 | * Called when a {@link MotionEvent} is generated by a back gesture. |
| 33 | * |
| 34 | * @param touchX the X touch position of the {@link MotionEvent}. |
| 35 | * @param touchY the Y touch position of the {@link MotionEvent}. |
| 36 | * @param keyAction the original {@link KeyEvent#getAction()} when the event was dispatched to |
| 37 | * the process. This is forwarded separately because the input pipeline may mutate |
| 38 | * the {#event} action state later. |
| 39 | * @param swipeEdge the edge from which the swipe begins. |
| 40 | */ |
| 41 | void onBackMotion(float touchX, float touchY, int keyAction, |
| 42 | @BackEvent.SwipeEdge int swipeEdge); |
| 43 | |
| 44 | /** |
| 45 | * Sets whether the back gesture is past the trigger threshold or not. |
| 46 | */ |
| 47 | void setTriggerBack(boolean triggerBack); |
| 48 | |
| 49 | /** |
| 50 | * Sets the threshold values that defining edge swipe behavior. |
| 51 | * @param triggerThreshold the min threshold to trigger back. |
| 52 | * @param progressThreshold the max threshold to keep progressing back animation. |
| 53 | */ |
| 54 | void setSwipeThresholds(float triggerThreshold, float progressThreshold); |
| 55 | } |