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 /** Plugin to handle navigation edge gestures for Back. */ 26 @ProvidesInterface( 27 action = NavigationEdgeBackPlugin.ACTION, 28 version = NavigationEdgeBackPlugin.VERSION) 29 public interface NavigationEdgeBackPlugin extends Plugin { 30 String ACTION = "com.android.systemui.action.PLUGIN_NAVIGATION_EDGE_BACK_ACTION"; 31 int VERSION = 1; 32 33 34 /** Specifies if the UI should be rendered on the left side of the screen. */ setIsLeftPanel(boolean isLeftPanel)35 void setIsLeftPanel(boolean isLeftPanel); 36 37 /** Sets the insets for the gesture handling area. */ setInsets(int leftInset, int rightInset)38 void setInsets(int leftInset, int rightInset); 39 40 /** Sets the display size. */ setDisplaySize(Point displaySize)41 void setDisplaySize(Point displaySize); 42 43 /** Sets the callback that should be invoked when a Back gesture is detected. */ setBackCallback(BackCallback callback)44 void setBackCallback(BackCallback callback); 45 46 /** Sets the base LayoutParams for the UI. */ setLayoutParams(WindowManager.LayoutParams layoutParams)47 void setLayoutParams(WindowManager.LayoutParams layoutParams); 48 49 /** Updates the UI based on the motion events passed in device coordinates. */ onMotionEvent(MotionEvent motionEvent)50 void onMotionEvent(MotionEvent motionEvent); 51 52 /** Callback to let the system react to the detected back gestures. */ 53 interface BackCallback { 54 /** Indicates that a Back gesture was recognized and the system should go back. */ triggerBack()55 void triggerBack(); 56 57 /** Indicates that the gesture was cancelled and the system should not go back. */ cancelBack()58 void cancelBack(); 59 } 60 } 61