1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 * except in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the 10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11 * KIND, either express or implied. See the License for the specific language governing 12 * permissions and limitations under the License. 13 */ 14 15 package com.android.systemui.plugins.statusbar; 16 17 import android.content.Context; 18 import android.service.notification.StatusBarNotification; 19 import android.view.MotionEvent; 20 import android.view.View; 21 import android.view.ViewGroup; 22 23 import java.util.ArrayList; 24 25 import com.android.systemui.plugins.Plugin; 26 import com.android.systemui.plugins.annotations.DependsOn; 27 import com.android.systemui.plugins.annotations.ProvidesInterface; 28 import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.OnMenuEventListener; 29 import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper.SnoozeOption; 30 import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem; 31 32 @ProvidesInterface(action = NotificationMenuRowPlugin.ACTION, 33 version = NotificationMenuRowPlugin.VERSION) 34 @DependsOn(target = OnMenuEventListener.class) 35 @DependsOn(target = MenuItem.class) 36 @DependsOn(target = NotificationSwipeActionHelper.class) 37 @DependsOn(target = SnoozeOption.class) 38 public interface NotificationMenuRowPlugin extends Plugin { 39 40 public static final String ACTION = "com.android.systemui.action.PLUGIN_NOTIFICATION_MENU_ROW"; 41 public static final int VERSION = 4; 42 43 @ProvidesInterface(version = OnMenuEventListener.VERSION) 44 public interface OnMenuEventListener { 45 public static final int VERSION = 1; onMenuClicked(View row, int x, int y, MenuItem menu)46 public void onMenuClicked(View row, int x, int y, MenuItem menu); 47 onMenuReset(View row)48 public void onMenuReset(View row); 49 onMenuShown(View row)50 public void onMenuShown(View row); 51 } 52 53 @ProvidesInterface(version = MenuItem.VERSION) 54 public interface MenuItem { 55 public static final int VERSION = 1; getMenuView()56 public View getMenuView(); 57 getGutsView()58 public View getGutsView(); 59 getContentDescription()60 public String getContentDescription(); 61 } 62 63 /** 64 * @return a list of items to populate the menu 'behind' a notification. 65 */ getMenuItems(Context context)66 public ArrayList<MenuItem> getMenuItems(Context context); 67 68 /** 69 * @return the {@link MenuItem} to display when a notification is long pressed. 70 */ getLongpressMenuItem(Context context)71 public MenuItem getLongpressMenuItem(Context context); 72 73 /** 74 * @return the {@link MenuItem} to display when app ops icons are pressed. 75 */ getAppOpsMenuItem(Context context)76 public MenuItem getAppOpsMenuItem(Context context); 77 78 /** 79 * @return the {@link MenuItem} to display when snooze item is pressed. 80 */ getSnoozeMenuItem(Context context)81 public MenuItem getSnoozeMenuItem(Context context); 82 setMenuItems(ArrayList<MenuItem> items)83 public void setMenuItems(ArrayList<MenuItem> items); 84 setMenuClickListener(OnMenuEventListener listener)85 public void setMenuClickListener(OnMenuEventListener listener); 86 setSwipeActionHelper(NotificationSwipeActionHelper listener)87 public void setSwipeActionHelper(NotificationSwipeActionHelper listener); 88 setAppName(String appName)89 public void setAppName(String appName); 90 createMenu(ViewGroup parent, StatusBarNotification sbn)91 public void createMenu(ViewGroup parent, StatusBarNotification sbn); 92 getMenuView()93 public View getMenuView(); 94 isMenuVisible()95 public boolean isMenuVisible(); 96 resetMenu()97 public void resetMenu(); 98 onTranslationUpdate(float translation)99 public void onTranslationUpdate(float translation); 100 onHeightUpdate()101 public void onHeightUpdate(); 102 onNotificationUpdated(StatusBarNotification sbn)103 public void onNotificationUpdated(StatusBarNotification sbn); 104 onTouchEvent(View view, MotionEvent ev, float velocity)105 public boolean onTouchEvent(View view, MotionEvent ev, float velocity); 106 onInterceptTouchEvent(View view, MotionEvent ev)107 public default boolean onInterceptTouchEvent(View view, MotionEvent ev) { 108 return false; 109 } 110 useDefaultMenuItems()111 public default boolean useDefaultMenuItems() { 112 return false; 113 } 114 onConfigurationChanged()115 public default void onConfigurationChanged() { 116 } 117 } 118