• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.deskclock.events;
18 
19 import androidx.annotation.StringRes;
20 
21 import com.android.deskclock.R;
22 import com.android.deskclock.controller.Controller;
23 
24 /**
25  * This thin layer over {@link Controller#sendEvent} eases the API usage.
26  */
27 public final class Events {
28 
29     /** Extra describing the entity responsible for the action being performed. */
30     public static final String EXTRA_EVENT_LABEL = "com.android.deskclock.extra.EVENT_LABEL";
31 
32     /**
33      * Tracks an alarm event.
34      *
35      * @param action resource id of event action
36      * @param label resource id of event label
37      */
sendAlarmEvent(@tringRes int action, @StringRes int label)38     public static void sendAlarmEvent(@StringRes int action, @StringRes int label) {
39         sendEvent(R.string.category_alarm, action, label);
40     }
41 
42     /**
43      * Tracks a clock event.
44      *
45      * @param action resource id of event action
46      * @param label resource id of event label
47      */
sendClockEvent(@tringRes int action, @StringRes int label)48     public static void sendClockEvent(@StringRes int action, @StringRes int label) {
49         sendEvent(R.string.category_clock, action, label);
50     }
51 
52     /**
53      * Tracks a timer event.
54      *
55      * @param action resource id of event action
56      * @param label resource id of event label
57      */
sendTimerEvent(@tringRes int action, @StringRes int label)58     public static void sendTimerEvent(@StringRes int action, @StringRes int label) {
59         sendEvent(R.string.category_timer, action, label);
60     }
61 
62     /**
63      * Tracks a stopwatch event.
64      *
65      * @param action resource id of event action
66      * @param label resource id of event label
67      */
sendStopwatchEvent(@tringRes int action, @StringRes int label)68     public static void sendStopwatchEvent(@StringRes int action, @StringRes int label) {
69         sendEvent(R.string.category_stopwatch, action, label);
70     }
71 
72     /**
73      * Tracks a screensaver event.
74      *
75      * @param action resource id of event action
76      * @param label resource id of event label
77      */
sendScreensaverEvent(@tringRes int action, @StringRes int label)78     public static void sendScreensaverEvent(@StringRes int action, @StringRes int label) {
79         sendEvent(R.string.category_screensaver, action, label);
80     }
81 
82     /**
83      * Tracks an event. Events have a category, action, label and value. This
84      * method can be used to track events such as button presses or other user
85      * interactions with your application (value is not used in this app).
86      *
87      * @param category resource id of event category
88      * @param action resource id of event action
89      * @param label resource id of event label
90      */
sendEvent(@tringRes int category, @StringRes int action, @StringRes int label)91     public static void sendEvent(@StringRes int category, @StringRes int action,
92             @StringRes int label) {
93         Controller.getController().sendEvent(category, action, label);
94     }
95 }