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.view.MotionEvent; 19 import android.view.View; 20 import android.view.ViewGroup; 21 22 import java.util.ArrayList; 23 24 import com.android.systemui.plugins.Plugin; 25 import com.android.systemui.plugins.annotations.DependsOn; 26 import com.android.systemui.plugins.annotations.ProvidesInterface; 27 import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.OnMenuEventListener; 28 import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper.SnoozeOption; 29 import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem; 30 31 @ProvidesInterface(action = NotificationMenuRowPlugin.ACTION, 32 version = NotificationMenuRowPlugin.VERSION) 33 @DependsOn(target = OnMenuEventListener.class) 34 @DependsOn(target = MenuItem.class) 35 @DependsOn(target = NotificationSwipeActionHelper.class) 36 @DependsOn(target = SnoozeOption.class) 37 public interface NotificationMenuRowPlugin extends Plugin { 38 39 public static final String ACTION = "com.android.systemui.action.PLUGIN_NOTIFICATION_MENU_ROW"; 40 public static final int VERSION = 2; 41 42 @ProvidesInterface(version = OnMenuEventListener.VERSION) 43 public interface OnMenuEventListener { 44 public static final int VERSION = 1; onMenuClicked(View row, int x, int y, MenuItem menu)45 public void onMenuClicked(View row, int x, int y, MenuItem menu); 46 onMenuReset(View row)47 public void onMenuReset(View row); 48 onMenuShown(View row)49 public void onMenuShown(View row); 50 } 51 52 @ProvidesInterface(version = MenuItem.VERSION) 53 public interface MenuItem { 54 public static final int VERSION = 1; getMenuView()55 public View getMenuView(); 56 getGutsView()57 public View getGutsView(); 58 getContentDescription()59 public String getContentDescription(); 60 } 61 62 /** 63 * @return a list of items to populate the menu 'behind' a notification. 64 */ getMenuItems(Context context)65 public ArrayList<MenuItem> getMenuItems(Context context); 66 67 /** 68 * @return the {@link MenuItem} to display when a notification is long pressed. 69 */ getLongpressMenuItem(Context context)70 public MenuItem getLongpressMenuItem(Context context); 71 setMenuItems(ArrayList<MenuItem> items)72 public void setMenuItems(ArrayList<MenuItem> items); 73 setMenuClickListener(OnMenuEventListener listener)74 public void setMenuClickListener(OnMenuEventListener listener); 75 setSwipeActionHelper(NotificationSwipeActionHelper listener)76 public void setSwipeActionHelper(NotificationSwipeActionHelper listener); 77 setAppName(String appName)78 public void setAppName(String appName); 79 createMenu(ViewGroup parent)80 public void createMenu(ViewGroup parent); 81 getMenuView()82 public View getMenuView(); 83 isMenuVisible()84 public boolean isMenuVisible(); 85 resetMenu()86 public void resetMenu(); 87 onTranslationUpdate(float translation)88 public void onTranslationUpdate(float translation); 89 onHeightUpdate()90 public void onHeightUpdate(); 91 onNotificationUpdated()92 public void onNotificationUpdated(); 93 onTouchEvent(View view, MotionEvent ev, float velocity)94 public boolean onTouchEvent(View view, MotionEvent ev, float velocity); 95 useDefaultMenuItems()96 public default boolean useDefaultMenuItems() { 97 return false; 98 } 99 onConfigurationChanged()100 public default void onConfigurationChanged() { 101 } 102 } 103