Merge "Add 'Snooze' to local context menu for notifications" into pi-dev
This commit is contained in:
@@ -38,7 +38,7 @@ import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem
|
||||
public interface NotificationMenuRowPlugin extends Plugin {
|
||||
|
||||
public static final String ACTION = "com.android.systemui.action.PLUGIN_NOTIFICATION_MENU_ROW";
|
||||
public static final int VERSION = 3;
|
||||
public static final int VERSION = 4;
|
||||
|
||||
@ProvidesInterface(version = OnMenuEventListener.VERSION)
|
||||
public interface OnMenuEventListener {
|
||||
@@ -75,6 +75,11 @@ public interface NotificationMenuRowPlugin extends Plugin {
|
||||
*/
|
||||
public MenuItem getAppOpsMenuItem(Context context);
|
||||
|
||||
/**
|
||||
* @return the {@link MenuItem} to display when snooze item is pressed.
|
||||
*/
|
||||
public MenuItem getSnoozeMenuItem(Context context);
|
||||
|
||||
public void setMenuItems(ArrayList<MenuItem> items);
|
||||
|
||||
public void setMenuClickListener(OnMenuEventListener listener);
|
||||
|
||||
@@ -99,6 +99,7 @@
|
||||
<item type="id" name="action_snooze_long"/>
|
||||
<item type="id" name="action_snooze_longer"/>
|
||||
<item type="id" name="action_snooze_assistant_suggestion_1"/>
|
||||
<item type="id" name="action_snooze"/>
|
||||
|
||||
<!-- For StatusBarIconContainer to tag its icon views -->
|
||||
<item type="id" name="status_bar_view_state_tag" />
|
||||
|
||||
@@ -54,6 +54,7 @@ import android.view.ViewGroup;
|
||||
import android.view.ViewStub;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
|
||||
import android.widget.Chronometer;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
@@ -1599,6 +1600,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
||||
public void doLongClickCallback(int x, int y) {
|
||||
createMenu();
|
||||
MenuItem menuItem = getProvider().getLongpressMenuItem(mContext);
|
||||
doLongClickCallback(x, y, menuItem);
|
||||
}
|
||||
|
||||
private void doLongClickCallback(int x, int y, MenuItem menuItem) {
|
||||
if (mLongPressListener != null && menuItem != null) {
|
||||
mLongPressListener.onLongPress(this, x, y, menuItem);
|
||||
}
|
||||
@@ -2707,6 +2712,16 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
||||
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_EXPAND);
|
||||
}
|
||||
}
|
||||
NotificationMenuRowPlugin provider = getProvider();
|
||||
if (provider != null) {
|
||||
MenuItem snoozeMenu = provider.getSnoozeMenuItem(getContext());
|
||||
if (snoozeMenu != null) {
|
||||
AccessibilityAction action = new AccessibilityAction(R.id.action_snooze,
|
||||
getContext().getResources()
|
||||
.getString(R.string.notification_menu_snooze_action));
|
||||
info.addAction(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2725,6 +2740,16 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
||||
case AccessibilityNodeInfo.ACTION_LONG_CLICK:
|
||||
doLongClickCallback();
|
||||
return true;
|
||||
case R.id.action_snooze:
|
||||
NotificationMenuRowPlugin provider = getProvider();
|
||||
if (provider == null) {
|
||||
provider = createMenu();
|
||||
}
|
||||
MenuItem snoozeMenu = provider.getSnoozeMenuItem(getContext());
|
||||
if (snoozeMenu != null) {
|
||||
doLongClickCallback(getWidth() / 2, getHeight() / 2, snoozeMenu);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
|
||||
private FrameLayout mMenuContainer;
|
||||
private MenuItem mInfoItem;
|
||||
private MenuItem mAppOpsItem;
|
||||
private MenuItem mSnoozeItem;
|
||||
private ArrayList<MenuItem> mMenuItems;
|
||||
private OnMenuEventListener mMenuListener;
|
||||
|
||||
@@ -127,6 +128,11 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
|
||||
return mAppOpsItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuItem getSnoozeMenuItem(Context context) {
|
||||
return mSnoozeItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSwipeActionHelper(NotificationSwipeActionHelper helper) {
|
||||
mSwipeHelper = helper;
|
||||
@@ -190,7 +196,8 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
|
||||
boolean isForeground = (flags & Notification.FLAG_FOREGROUND_SERVICE) != 0;
|
||||
if (!isForeground) {
|
||||
// Only show snooze for non-foreground notifications
|
||||
mMenuItems.add(createSnoozeItem(mContext));
|
||||
mSnoozeItem = createSnoozeItem(mContext);
|
||||
mMenuItems.add(mSnoozeItem);
|
||||
}
|
||||
}
|
||||
mInfoItem = createInfoItem(mContext);
|
||||
|
||||
Reference in New Issue
Block a user