1 /*
2  * Copyright (C) 2019 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 package com.android.systemui.plugins;
17 
18 import android.view.MotionEvent;
19 
20 import com.android.systemui.plugins.annotations.ProvidesInterface;
21 
22 /**
23  * Implement this interface to receive a callback when the user swipes right
24  * to left on the gesture area. It won't fire if the user has quick switched to a previous app
25  * (swiped right) and the current app isn't yet the active one (i.e., if swiping left would take
26  * the user to a more recent app).
27  */
28 @ProvidesInterface(action = com.android.systemui.plugins.OverscrollPlugin.ACTION,
29         version = com.android.systemui.plugins.OverscrollPlugin.VERSION)
30 public interface OverscrollPlugin extends Plugin {
31 
32     String ACTION = "com.android.systemui.action.PLUGIN_LAUNCHER_OVERSCROLL";
33     int VERSION = 4;
34 
35     String DEVICE_STATE_LOCKED = "Locked";
36     String DEVICE_STATE_LAUNCHER = "Launcher";
37     String DEVICE_STATE_APP = "App";
38     String DEVICE_STATE_UNKNOWN = "Unknown";
39 
40     /**
41      * @return true if the plugin is active and will accept overscroll gestures
42      */
isActive()43     boolean isActive();
44 
45     /**
46      * Called when a touch has been recognized as an overscroll gesture.
47      * @param horizontalDistancePx Horizontal distance from the last finger location to the finger
48      *                               location when it first touched the screen.
49      * @param verticalDistancePx Horizontal distance from the last finger location to the finger
50      *                             location when it first touched the screen.
51      * @param thresholdPx Minimum distance for gesture.
52      * @param flingDistanceThresholdPx Minimum distance for gesture by fling.
53      * @param flingVelocityThresholdPx Minimum velocity for gesture by fling.
54      * @param deviceState String representing the current device state
55      * @param underlyingActivity String representing the currently active Activity
56      */
onTouchEvent(MotionEvent event, int horizontalDistancePx, int verticalDistancePx, int thresholdPx, int flingDistanceThresholdPx, int flingVelocityThresholdPx, String deviceState, String underlyingActivity)57     void onTouchEvent(MotionEvent event,
58                       int horizontalDistancePx,
59                       int verticalDistancePx,
60                       int thresholdPx,
61                       int flingDistanceThresholdPx,
62                       int flingVelocityThresholdPx,
63                       String deviceState,
64                       String underlyingActivity);
65 
66     /**
67      * @return `true` if overscroll gesture handling should override all other gestures.
68      */
blockOtherGestures()69     boolean blockOtherGestures();
70 
71     /**
72      * @return `true` if the overscroll gesture can pan the underlying app.
73      */
allowsUnderlyingActivityOverscroll()74     boolean allowsUnderlyingActivityOverscroll();
75 }
76