private void handleAnalytics(Intent intent) { String action = null, label = ""; switch (intent.getAction()) { case ACTION_START: case ACTION_STOP: case ACTION_FINISH_ALARM: case ACTION_RESET: action = intent.getAction().replace("com.vngrs.android.pomodoro.action.", ""); if (intent.getAction().equals(ACTION_START)) { label = ActivityType.fromValue(intent.getIntExtra(EXTRA_ACTIVITY_TYPE, 0)).toString(); } else { label = pomodoroMaster.getActivityType().toString(); } break; default: break; } if (action != null) { /* [ANALYTICS:EVENT] * TRIGGER: Taking one of the Pomodoro Actions. * CATEGORY: 'Pomodoro' * ACTION: 'Feedback' * LABEL: Activity Type if the action is Start * [/ANALYTICS] */ analytics.get().sendEvent("Pomodoro", action, label); ContentValues values = new ContentValues(); values.put(PomodoroDatabase.PomodoroColumns.ACTION, action); values.put(PomodoroDatabase.PomodoroColumns.ACTIVITY_TYPE, label); getContentResolver().insert(Pomodoros.CONTENT_URI, values); } }
public NotificationCompat.Action buildStartAction( @NonNull Context context, @NonNull ActivityType activityType) { final Intent startActionIntent = BaseNotificationService.START_INTENT; startActionIntent.putExtra(BaseNotificationService.EXTRA_ACTIVITY_TYPE, activityType.value()); final PendingIntent startActionPendingIntent = PendingIntent.getBroadcast( context, ID_START, startActionIntent, PendingIntent.FLAG_CANCEL_CURRENT); return new NotificationCompat.Action.Builder( actionStartIcon, context.getString(R.string.start), startActionPendingIntent) .build(); }