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