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 com.android.systemui.plugins.annotations.DependsOn;
18 import com.android.systemui.plugins.annotations.ProvidesInterface;
19 import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper.SnoozeOption;
20 
21 import android.service.notification.SnoozeCriterion;
22 import android.service.notification.StatusBarNotification;
23 import android.view.MotionEvent;
24 import android.view.View;
25 
26 @ProvidesInterface(version = NotificationSwipeActionHelper.VERSION)
27 @DependsOn(target = SnoozeOption.class)
28 public interface NotificationSwipeActionHelper {
29     public static final String ACTION = "com.android.systemui.action.PLUGIN_NOTIFICATION_SWIPE_ACTION";
30 
31     public static final int VERSION = 1;
32 
33     /**
34      * Call this to dismiss a notification.
35      */
dismiss(View animView, float velocity)36     public void dismiss(View animView, float velocity);
37 
38     /**
39      * Call this to snap a notification to provided {@code targetLeft}.
40      */
snap(View animView, float velocity, float targetLeft)41     public void snap(View animView, float velocity, float targetLeft);
42 
43     /**
44      * Call this to snooze a notification based on the provided {@link SnoozeOption}.
45      */
snooze(StatusBarNotification sbn, SnoozeOption snoozeOption)46     public void snooze(StatusBarNotification sbn, SnoozeOption snoozeOption);
47 
getMinDismissVelocity()48     public float getMinDismissVelocity();
49 
isDismissGesture(MotionEvent ev)50     public boolean isDismissGesture(MotionEvent ev);
51 
isFalseGesture(MotionEvent ev)52     public boolean isFalseGesture(MotionEvent ev);
53 
swipedFarEnough(float translation, float viewSize)54     public boolean swipedFarEnough(float translation, float viewSize);
55 
swipedFastEnough(float translation, float velocity)56     public boolean swipedFastEnough(float translation, float velocity);
57 
58     @ProvidesInterface(version = SnoozeOption.VERSION)
59     public static class SnoozeOption {
60         public static final int VERSION = 1;
61         public int snoozeForMinutes;
62         public SnoozeCriterion criterion;
63         public CharSequence description;
64         public CharSequence confirmation;
65 
SnoozeOption(SnoozeCriterion crit, int minsToSnoozeFor, CharSequence desc, CharSequence confirm)66         public SnoozeOption(SnoozeCriterion crit, int minsToSnoozeFor, CharSequence desc,
67                 CharSequence confirm) {
68             criterion = crit;
69             snoozeForMinutes = minsToSnoozeFor;
70             description = desc;
71             confirmation = confirm;
72         }
73     }
74 }
75