• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package com.android.systemui.plugins;
18 
19 import android.graphics.Point;
20 import android.view.MotionEvent;
21 import android.view.WindowManager;
22 
23 import com.android.systemui.plugins.annotations.ProvidesInterface;
24 
25 import java.io.PrintWriter;
26 
27 /** Plugin to handle navigation edge gestures for Back. */
28 @ProvidesInterface(
29         action = NavigationEdgeBackPlugin.ACTION,
30         version = NavigationEdgeBackPlugin.VERSION)
31 public interface NavigationEdgeBackPlugin extends Plugin {
32     String ACTION = "com.android.systemui.action.PLUGIN_NAVIGATION_EDGE_BACK_ACTION";
33     int VERSION = 1;
34 
35 
36     /** Specifies if the UI should be rendered on the left side of the screen. */
setIsLeftPanel(boolean isLeftPanel)37     void setIsLeftPanel(boolean isLeftPanel);
38 
39     /** Sets the insets for the gesture handling area. */
setInsets(int leftInset, int rightInset)40     void setInsets(int leftInset, int rightInset);
41 
42     /** Sets the display size. */
setDisplaySize(Point displaySize)43     void setDisplaySize(Point displaySize);
44 
45     /** Sets the callback that should be invoked when a Back gesture is detected. */
setBackCallback(BackCallback callback)46     void setBackCallback(BackCallback callback);
47 
48     /** Sets the base LayoutParams for the UI. */
setLayoutParams(WindowManager.LayoutParams layoutParams)49     void setLayoutParams(WindowManager.LayoutParams layoutParams);
50 
51     /** Updates the UI based on the motion events passed in device coordinates. */
onMotionEvent(MotionEvent motionEvent)52     void onMotionEvent(MotionEvent motionEvent);
53 
54     /** Dumps info about the back gesture plugin. */
dump(PrintWriter pw)55     void dump(PrintWriter pw);
56 
57     /** Callback to let the system react to the detected back gestures. */
58     interface BackCallback {
59         /** Indicates that a Back gesture was recognized and the system should go back. */
triggerBack()60         void triggerBack();
61 
62         /** Indicates that the gesture was cancelled and the system should not go back. */
cancelBack()63         void cancelBack();
64 
65         /**
66          * Indicates if back will be triggered if committed in current state.
67          *
68          * @param triggerBack if back will be triggered in current state.
69          */
setTriggerBack(boolean triggerBack)70         void setTriggerBack(boolean triggerBack);
71     }
72 }
73