Event Instrumentation

pull/14/head
Tim Su 14 years ago
parent 64241c5dfe
commit 433545904e

@ -89,6 +89,7 @@ public class C2DMReceiver extends BroadcastReceiver {
notifyIntent = ShortcutActivity.createIntent(CoreFilterExposer.buildInboxFilter(context.getResources())); notifyIntent = ShortcutActivity.createIntent(CoreFilterExposer.buildInboxFilter(context.getResources()));
notifyIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); notifyIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
notifyIntent.putExtra(TaskListActivity.TOKEN_SOURCE, Constants.SOURCE_C2DM);
PendingIntent pendingIntent = PendingIntent.getActivity(context, PendingIntent pendingIntent = PendingIntent.getActivity(context,
Constants.NOTIFICATION_ACTFM, notifyIntent, 0); Constants.NOTIFICATION_ACTFM, notifyIntent, 0);

@ -63,6 +63,7 @@ import com.todoroo.astrid.actfm.sync.ActFmInvoker;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.gtasks.auth.ModernAuthManager; import com.todoroo.astrid.gtasks.auth.ModernAuthManager;
import com.todoroo.astrid.service.AstridDependencyInjector; import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.service.TaskService;
/** /**
@ -162,6 +163,7 @@ public class ActFmLoginActivity extends Activity implements AuthListener {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
authenticate(email.getText().toString(), name.getText().toString(), authenticate(email.getText().toString(), name.getText().toString(),
ActFmInvoker.PROVIDER_PASSWORD, password.getText().toString()); ActFmInvoker.PROVIDER_PASSWORD, password.getText().toString());
StatisticsService.reportEvent("actfm-signup-pw"); //$NON-NLS-1$
} }
}) })
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
@ -197,6 +199,7 @@ public class ActFmLoginActivity extends Activity implements AuthListener {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
authenticate(email.getText().toString(), null, authenticate(email.getText().toString(), null,
ActFmInvoker.PROVIDER_PASSWORD, password.getText().toString()); ActFmInvoker.PROVIDER_PASSWORD, password.getText().toString());
StatisticsService.reportEvent("actfm-login-pw"); //$NON-NLS-1$
} }
}) })
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
@ -253,6 +256,7 @@ public class ActFmLoginActivity extends Activity implements AuthListener {
authenticate(email, name, ActFmInvoker.PROVIDER_FACEBOOK, authenticate(email, name, ActFmInvoker.PROVIDER_FACEBOOK,
facebook.getAccessToken()); facebook.getAccessToken());
StatisticsService.reportEvent("actfm-login-fb"); //$NON-NLS-1$
} catch (FacebookError e) { } catch (FacebookError e) {
handleError(e); handleError(e);
} catch (JSONException e) { } catch (JSONException e) {

@ -43,6 +43,7 @@ import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.MetadataService; import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TagDataService; import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.service.ThemeService; import com.todoroo.astrid.service.ThemeService;
@ -452,10 +453,11 @@ public class EditPeopleActivity extends Activity {
int count = result.optInt("shared", 0); int count = result.optInt("shared", 0);
final String toast; final String toast;
if(count > 0) if(count > 0) {
toast = getString(R.string.actfm_EPA_emailed_toast, toast = getString(R.string.actfm_EPA_emailed_toast,
getResources().getQuantityString(R.plurals.Npeople, count, count)); getResources().getQuantityString(R.plurals.Npeople, count, count));
else StatisticsService.reportEvent("actfm-task-shared"); //$NON-NLS-1$
} else
toast = getString(R.string.actfm_EPA_saved_toast); toast = getString(R.string.actfm_EPA_saved_toast);
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH); Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH);

@ -64,6 +64,7 @@ import com.todoroo.astrid.core.SortHelper;
import com.todoroo.astrid.dao.UpdateDao; import com.todoroo.astrid.dao.UpdateDao;
import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Update; import com.todoroo.astrid.data.Update;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TagDataService; import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.tags.TagService; import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.ui.PeopleContainer; import com.todoroo.astrid.ui.PeopleContainer;
@ -621,6 +622,8 @@ public class TagViewActivity extends TaskListActivity implements OnTabChangeList
addCommentField.setText(""); //$NON-NLS-1$ addCommentField.setText(""); //$NON-NLS-1$
refreshUpdatesList(); refreshUpdatesList();
StatisticsService.reportEvent("actfm-tag-comment"); //$NON-NLS-1$
} }
@Override @Override

@ -29,6 +29,7 @@ import com.todoroo.astrid.actfm.ActFmLoginActivity;
import com.todoroo.astrid.actfm.ActFmPreferences; import com.todoroo.astrid.actfm.ActFmPreferences;
import com.todoroo.astrid.actfm.sync.ActFmSyncService.JsonHelper; import com.todoroo.astrid.actfm.sync.ActFmSyncService.JsonHelper;
import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.notes.NoteMetadata; import com.todoroo.astrid.notes.NoteMetadata;
@ -277,6 +278,13 @@ public class ActFmSyncProvider extends SyncProvider<ActFmTaskContainer> {
@Override @Override
protected void write(ActFmTaskContainer task) throws IOException { protected void write(ActFmTaskContainer task) throws IOException {
if(task.task.isSaved()) {
Task local = PluginServices.getTaskService().fetchById(task.task.getId(), Task.COMPLETION_DATE);
if(task.task.isCompleted() && !local.isCompleted())
StatisticsService.reportEvent("actfm-task-completed"); //$NON-NLS-1$
} else {
StatisticsService.reportEvent("actfm-task-created"); //$NON-NLS-1$
}
actFmDataService.saveTaskAndMetadata(task); actFmDataService.saveTaskAndMetadata(task);
} }

@ -49,6 +49,7 @@ import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.Update; import com.todoroo.astrid.data.Update;
import com.todoroo.astrid.service.MetadataService; import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TagDataService; import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.tags.TagService; import com.todoroo.astrid.tags.TagService;
@ -464,6 +465,14 @@ public final class ActFmSyncService {
readIds(locals, item, remote); readIds(locals, item, remote);
JsonHelper.taskFromJson(item, remote, metadata); JsonHelper.taskFromJson(item, remote, metadata);
if(remote.getValue(Task.USER_ID) == 0) {
if(!remote.isSaved())
StatisticsService.reportEvent("actfm-task-created");
else if(remote.isCompleted())
StatisticsService.reportEvent("actfm-task-completed");
}
Flags.set(Flags.SUPPRESS_SYNC); Flags.set(Flags.SUPPRESS_SYNC);
taskService.save(remote); taskService.save(remote);
metadataService.synchronizeMetadata(remote.getId(), metadata, MetadataCriteria.withKey(TagService.KEY)); metadataService.synchronizeMetadata(remote.getId(), metadata, MetadataCriteria.withKey(TagService.KEY));

@ -48,6 +48,7 @@ import com.todoroo.astrid.api.TextInputCriterion;
import com.todoroo.astrid.dao.Database; import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria; import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.StatisticsService;
/** /**
* Activity that allows users to build custom filters * Activity that allows users to build custom filters
@ -237,6 +238,18 @@ public class CustomFilterActivity extends ListActivity {
} }
} }
@Override
protected void onStart() {
super.onStart();
StatisticsService.sessionStart(this);
}
@Override
protected void onStop() {
StatisticsService.sessionStop(this);
super.onStop();
}
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
@ -246,6 +259,7 @@ public class CustomFilterActivity extends ListActivity {
@Override @Override
protected void onPause() { protected void onPause() {
StatisticsService.sessionPause();
super.onPause(); super.onPause();
unregisterReceiver(filterCriteriaReceiver); unregisterReceiver(filterCriteriaReceiver);
} }

@ -547,8 +547,12 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
protected void write(GtasksTaskContainer task) throws IOException { protected void write(GtasksTaskContainer task) throws IOException {
// merge astrid dates with google dates // merge astrid dates with google dates
if(task.task.isSaved()) { if(task.task.isSaved()) {
Task local = PluginServices.getTaskService().fetchById(task.task.getId(), Task.DUE_DATE); Task local = PluginServices.getTaskService().fetchById(task.task.getId(), Task.DUE_DATE, Task.COMPLETION_DATE);
mergeDates(task.task, local); mergeDates(task.task, local);
if(task.task.isCompleted() && !local.isCompleted())
StatisticsService.reportEvent("gtasks-task-completed"); //$NON-NLS-1$
} else {
StatisticsService.reportEvent("gtasks-task-created"); //$NON-NLS-1$
} }
gtasksMetadataService.saveTaskAndMetadata(task); gtasksMetadataService.saveTaskAndMetadata(task);

@ -47,6 +47,7 @@ import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.Update; import com.todoroo.astrid.data.Update;
import com.todoroo.astrid.service.MetadataService; import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.utility.Flags; import com.todoroo.astrid.utility.Flags;
public class EditNoteActivity extends ListActivity { public class EditNoteActivity extends ListActivity {
@ -236,6 +237,8 @@ public class EditNoteActivity extends ListActivity {
commentField.setText(""); //$NON-NLS-1$ commentField.setText(""); //$NON-NLS-1$
setUpListAdapter(); setUpListAdapter();
StatisticsService.reportEvent("actfm-task-comment"); //$NON-NLS-1$
} }
@Override @Override

@ -33,6 +33,7 @@ import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.activity.ShortcutActivity; import com.todoroo.astrid.activity.ShortcutActivity;
import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.StoreObject; import com.todoroo.astrid.data.StoreObject;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
@ -615,6 +616,13 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
@Override @Override
protected void write(ProducteevTaskContainer task) throws IOException { protected void write(ProducteevTaskContainer task) throws IOException {
if(task.task.isSaved()) {
Task local = PluginServices.getTaskService().fetchById(task.task.getId(), Task.COMPLETION_DATE);
if(task.task.isCompleted() && !local.isCompleted())
StatisticsService.reportEvent("pdv-task-completed"); //$NON-NLS-1$
} else {
StatisticsService.reportEvent("pdv-task-created"); //$NON-NLS-1$
}
dataService.saveTaskAndMetadata(task); dataService.saveTaskAndMetadata(task);
} }

@ -50,6 +50,7 @@ import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.repeats.RepeatControlSet; import com.todoroo.astrid.repeats.RepeatControlSet;
import com.todoroo.astrid.service.StartupService; import com.todoroo.astrid.service.StartupService;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.ui.NumberPicker; import com.todoroo.astrid.ui.NumberPicker;
/** /**
@ -75,10 +76,14 @@ public class NotificationActivity extends TaskListActivity implements OnTimeSetL
StartupService.bypassInitialization(); StartupService.bypassInitialization();
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
displayNotificationPopup(); displayNotificationPopup();
} }
@Override
protected void onTaskCompleted(Task item) {
StatisticsService.reportEvent("task-completed-notification"); //$NON-NLS-1$
}
@Override @Override
protected void onNewIntent(Intent intent) { protected void onNewIntent(Intent intent) {
populateFilter(intent); populateFilter(intent);
@ -231,6 +236,7 @@ public class NotificationActivity extends TaskListActivity implements OnTimeSetL
task.setValue(Task.REMINDER_SNOOZE, time); task.setValue(Task.REMINDER_SNOOZE, time);
PluginServices.getTaskService().save(task); PluginServices.getTaskService().save(task);
finish(); finish();
StatisticsService.reportEvent("task-snooze"); //$NON-NLS-1$
} }
} }

@ -24,6 +24,7 @@ import com.todoroo.andlib.service.NotificationManager.AndroidNotificationManager
import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences; import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.AstridDependencyInjector; import com.todoroo.astrid.service.AstridDependencyInjector;
@ -161,6 +162,7 @@ public class Notifications extends BroadcastReceiver {
notifyIntent.setAction("NOTIFY" + id); //$NON-NLS-1$ notifyIntent.setAction("NOTIFY" + id); //$NON-NLS-1$
notifyIntent.putExtra(NotificationActivity.TOKEN_ID, id); notifyIntent.putExtra(NotificationActivity.TOKEN_ID, id);
notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
notifyIntent.putExtra(TaskListActivity.TOKEN_SOURCE, Constants.SOURCE_NOTIFICATION);
showNotification((int)id, notifyIntent, type, title, text, ringTimes); showNotification((int)id, notifyIntent, type, title, text, ringTimes);
return true; return true;

@ -21,6 +21,7 @@ import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.utility.Flags; import com.todoroo.astrid.utility.Flags;
public class RepeatTaskCompleteListener extends BroadcastReceiver { public class RepeatTaskCompleteListener extends BroadcastReceiver {
@ -41,6 +42,8 @@ public class RepeatTaskCompleteListener extends BroadcastReceiver {
if(task.getValue(Task.REMOTE_ID) > 0) if(task.getValue(Task.REMOTE_ID) > 0)
return; return;
StatisticsService.reportEvent("task-repeat"); //$NON-NLS-1$
String recurrence = task.getValue(Task.RECURRENCE); String recurrence = task.getValue(Task.RECURRENCE);
if(recurrence != null && recurrence.length() > 0) { if(recurrence != null && recurrence.length() > 0) {
long newDueDate; long newDueDate;

@ -19,6 +19,7 @@ import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.utility.Constants; import com.todoroo.astrid.utility.Constants;
public class TimerPlugin extends BroadcastReceiver { public class TimerPlugin extends BroadcastReceiver {
@ -44,14 +45,17 @@ public class TimerPlugin extends BroadcastReceiver {
*/ */
public static void updateTimer(Context context, Task task, boolean start) { public static void updateTimer(Context context, Task task, boolean start) {
if(start) { if(start) {
if(task.getValue(Task.TIMER_START) == 0) if(task.getValue(Task.TIMER_START) == 0) {
task.setValue(Task.TIMER_START, DateUtilities.now()); task.setValue(Task.TIMER_START, DateUtilities.now());
StatisticsService.reportEvent("timer-start"); //$NON-NLS-1$
}
} else { } else {
if(task.getValue(Task.TIMER_START) > 0) { if(task.getValue(Task.TIMER_START) > 0) {
int newElapsed = (int)((DateUtilities.now() - task.getValue(Task.TIMER_START)) / 1000L); int newElapsed = (int)((DateUtilities.now() - task.getValue(Task.TIMER_START)) / 1000L);
task.setValue(Task.TIMER_START, 0L); task.setValue(Task.TIMER_START, 0L);
task.setValue(Task.ELAPSED_SECONDS, task.setValue(Task.ELAPSED_SECONDS,
task.getValue(Task.ELAPSED_SECONDS) + newElapsed); task.getValue(Task.ELAPSED_SECONDS) + newElapsed);
StatisticsService.reportEvent("timer-stop"); //$NON-NLS-1$
} }
} }
PluginServices.getTaskService().save(task); PluginServices.getTaskService().save(task);

@ -26,6 +26,7 @@ import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.Preferences; import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.service.StartupService; import com.todoroo.astrid.service.StartupService;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.service.TaskService;
/** /**
@ -95,6 +96,7 @@ public final class Eula {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static void accept(Activity activity) { private static void accept(Activity activity) {
Preferences.setBoolean(PREFERENCE_EULA_ACCEPTED, true); Preferences.setBoolean(PREFERENCE_EULA_ACCEPTED, true);
StatisticsService.reportEvent("eula-accepted"); //$NON-NLS-1$
} }
private static void refuse(Activity activity) { private static void refuse(Activity activity) {

@ -241,9 +241,11 @@ public class FilterListActivity extends ExpandableListActivity {
AndroidUtilities.callApiMethod(5, this, "overridePendingTransition", //$NON-NLS-1$ AndroidUtilities.callApiMethod(5, this, "overridePendingTransition", //$NON-NLS-1$
new Class<?>[] { Integer.TYPE, Integer.TYPE }, new Class<?>[] { Integer.TYPE, Integer.TYPE },
R.anim.slide_left_in, R.anim.slide_left_out); R.anim.slide_left_in, R.anim.slide_left_out);
StatisticsService.reportEvent("filter-list"); //$NON-NLS-1$
return true; return true;
} else if(item instanceof SearchFilter) { } else if(item instanceof SearchFilter) {
onSearchRequested(); onSearchRequested();
StatisticsService.reportEvent("filter-search"); //$NON-NLS-1$
} else if(item instanceof IntentFilter) { } else if(item instanceof IntentFilter) {
try { try {
((IntentFilter)item).intent.send(); ((IntentFilter)item).intent.send();

@ -87,6 +87,9 @@ public class ShortcutActivity extends Activity {
Intent taskListIntent = new Intent(this, TaskListActivity.class); Intent taskListIntent = new Intent(this, TaskListActivity.class);
if(extras != null && extras.containsKey(TaskListActivity.TOKEN_SOURCE))
taskListIntent.putExtra(TaskListActivity.TOKEN_SOURCE, extras.getInt(TaskListActivity.TOKEN_SOURCE));
if(extras != null && extras.containsKey(TOKEN_CUSTOM_CLASS)) { if(extras != null && extras.containsKey(TOKEN_CUSTOM_CLASS)) {
taskListIntent.setComponent(ComponentName.unflattenFromString(extras.getString(TOKEN_CUSTOM_CLASS))); taskListIntent.setComponent(ComponentName.unflattenFromString(extras.getString(TOKEN_CUSTOM_CLASS)));
taskListIntent.putExtras(intent.getExtras()); taskListIntent.putExtras(intent.getExtras());

@ -69,6 +69,7 @@ import com.todoroo.andlib.widget.GestureService;
import com.todoroo.andlib.widget.GestureService.GestureInterface; import com.todoroo.andlib.widget.GestureService.GestureInterface;
import com.todoroo.astrid.activity.SortSelectionActivity.OnSortSelectedListener; import com.todoroo.astrid.activity.SortSelectionActivity.OnSortSelectedListener;
import com.todoroo.astrid.adapter.TaskAdapter; import com.todoroo.astrid.adapter.TaskAdapter;
import com.todoroo.astrid.adapter.TaskAdapter.OnCompletedTaskListener;
import com.todoroo.astrid.adapter.TaskAdapter.ViewHolder; import com.todoroo.astrid.adapter.TaskAdapter.ViewHolder;
import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
@ -141,6 +142,9 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
/** token for passing a {@link Filter} object through extras */ /** token for passing a {@link Filter} object through extras */
public static final String TOKEN_FILTER = "filter"; //$NON-NLS-1$ public static final String TOKEN_FILTER = "filter"; //$NON-NLS-1$
/** token for indicating source of TLA launch */
public static final String TOKEN_SOURCE = "source"; //$NON-NLS-1$
// --- instance variables // --- instance variables
@Autowired ExceptionService exceptionService; @Autowired ExceptionService exceptionService;
@ -172,7 +176,7 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
private EditText quickAddBox; private EditText quickAddBox;
private Timer backgroundTimer; private Timer backgroundTimer;
private final LinkedHashSet<SyncAction> syncActions = new LinkedHashSet<SyncAction>(); private final LinkedHashSet<SyncAction> syncActions = new LinkedHashSet<SyncAction>();
private boolean isInbox;
private final TaskListContextMenuExtensionLoader contextMenuExtensionLoader = new TaskListContextMenuExtensionLoader(); private final TaskListContextMenuExtensionLoader contextMenuExtensionLoader = new TaskListContextMenuExtensionLoader();
private VoiceInputAssistant voiceInputAssistant; private VoiceInputAssistant voiceInputAssistant;
@ -218,6 +222,26 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
onNewIntent(getIntent()); onNewIntent(getIntent());
Eula.showEula(this); Eula.showEula(this);
if(getIntent().hasExtra(TOKEN_SOURCE)) {
switch(getIntent().getIntExtra(TOKEN_SOURCE, Constants.SOURCE_DEFAULT)) {
case Constants.SOURCE_NOTIFICATION:
StatisticsService.reportEvent("launch-from-notification"); //$NON-NLS-1$
break;
case Constants.SOURCE_OTHER:
StatisticsService.reportEvent("launch-from-other"); //$NON-NLS-1$
break;
case Constants.SOURCE_PPWIDGET:
StatisticsService.reportEvent("launch-from-ppw"); //$NON-NLS-1$
break;
case Constants.SOURCE_WIDGET:
StatisticsService.reportEvent("launch-from-widget"); //$NON-NLS-1$
break;
case Constants.SOURCE_C2DM:
StatisticsService.reportEvent("launch-from-c2dm"); //$NON-NLS-1$
break;
}
}
} }
@Override @Override
@ -227,10 +251,12 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
Bundle extras = intent.getExtras(); Bundle extras = intent.getExtras();
if(extras != null && extras.containsKey(TOKEN_FILTER)) { if(extras != null && extras.containsKey(TOKEN_FILTER)) {
filter = extras.getParcelable(TOKEN_FILTER); filter = extras.getParcelable(TOKEN_FILTER);
isInbox = true;
} else { } else {
filter = CoreFilterExposer.buildInboxFilter(getResources()); filter = CoreFilterExposer.buildInboxFilter(getResources());
findViewById(R.id.headerLogo).setVisibility(View.VISIBLE); findViewById(R.id.headerLogo).setVisibility(View.VISIBLE);
findViewById(R.id.listLabel).setVisibility(View.GONE); findViewById(R.id.listLabel).setVisibility(View.GONE);
isInbox = false;
} }
setUpTaskList(); setUpTaskList();
@ -671,7 +697,13 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
// set up list adapters // set up list adapters
taskAdapter = new TaskAdapter(this, R.layout.task_adapter_row, taskAdapter = new TaskAdapter(this, R.layout.task_adapter_row,
currentCursor, sqlQueryTemplate, false, null); currentCursor, sqlQueryTemplate, false, new OnCompletedTaskListener() {
@Override
public void onCompletedTask(Task item, boolean newState) {
if(newState == true)
onTaskCompleted(item);
}
});
setListAdapter(taskAdapter); setListAdapter(taskAdapter);
getListView().setOnScrollListener(this); getListView().setOnScrollListener(this);
registerForContextMenu(getListView()); registerForContextMenu(getListView());
@ -727,6 +759,18 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
* ============================================================== actions * ============================================================== actions
* ====================================================================== */ * ====================================================================== */
/**
* A task was completed from the task adapter
* @param item task that was completed
*/
@SuppressWarnings("nls")
protected void onTaskCompleted(Task item) {
if(isInbox)
StatisticsService.reportEvent("task-completed-inbox");
else
StatisticsService.reportEvent("task-completed-filter");
}
/** /**
* Quick-add a new task * Quick-add a new task
* @param title * @param title
@ -748,6 +792,7 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
selectCustomId(task.getId()); selectCustomId(task.getId());
} }
StatisticsService.reportEvent("task-created-tasklist");
return task; return task;
} catch (Exception e) { } catch (Exception e) {
exceptionService.displayAndReportError(this, "quick-add-task", e); exceptionService.displayAndReportError(this, "quick-add-task", e);
@ -975,22 +1020,27 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
// handle my own menus // handle my own menus
switch (item.getItemId()) { switch (item.getItemId()) {
case MENU_ADDONS_ID: case MENU_ADDONS_ID:
StatisticsService.reportEvent("tla-menu-addons"); //$NON-NLS-1$
intent = new Intent(this, AddOnActivity.class); intent = new Intent(this, AddOnActivity.class);
startActivityForResult(intent, ACTIVITY_ADDONS); startActivityForResult(intent, ACTIVITY_ADDONS);
return true; return true;
case MENU_SETTINGS_ID: case MENU_SETTINGS_ID:
StatisticsService.reportEvent("tla-menu-settings"); //$NON-NLS-1$
intent = new Intent(this, EditPreferences.class); intent = new Intent(this, EditPreferences.class);
startActivityForResult(intent, ACTIVITY_SETTINGS); startActivityForResult(intent, ACTIVITY_SETTINGS);
return true; return true;
case MENU_SORT_ID: case MENU_SORT_ID:
StatisticsService.reportEvent("tla-menu-sort"); //$NON-NLS-1$
AlertDialog dialog = SortSelectionActivity.createDialog(this, AlertDialog dialog = SortSelectionActivity.createDialog(this,
this, sortFlags, sortSort); this, sortFlags, sortSort);
dialog.show(); dialog.show();
return true; return true;
case MENU_SYNC_ID: case MENU_SYNC_ID:
StatisticsService.reportEvent("tla-menu-sync"); //$NON-NLS-1$
performSyncAction(); performSyncAction();
return true; return true;
case MENU_HELP_ID: case MENU_HELP_ID:
StatisticsService.reportEvent("tla-menu-help"); //$NON-NLS-1$
intent = new Intent(Intent.ACTION_VIEW, intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(Constants.HELP_URL)); Uri.parse(Constants.HELP_URL));
startActivity(intent); startActivity(intent);

@ -22,6 +22,7 @@ import android.widget.TextView;
import com.timsu.astrid.R; import com.timsu.astrid.R;
import com.todoroo.astrid.data.AddOn; import com.todoroo.astrid.data.AddOn;
import com.todoroo.astrid.service.StatisticsService;
/** /**
* Adapter for {@link AddOn}s * Adapter for {@link AddOn}s
@ -50,9 +51,11 @@ public class AddOnAdapter extends ArrayAdapter<AddOn> {
View.OnClickListener intentClickListener = new View.OnClickListener() { View.OnClickListener intentClickListener = new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = (Intent) v.getTag(); ButtonTag buttonTag = (ButtonTag) v.getTag();
if(intent != null) if(buttonTag != null) {
activity.startActivity(intent); activity.startActivity(buttonTag.intent);
StatisticsService.reportEvent("addon-" + buttonTag.event); //$NON-NLS-1$
}
} }
}; };
@ -91,6 +94,15 @@ public class AddOnAdapter extends ArrayAdapter<AddOn> {
public ImageView installedIcon; public ImageView installedIcon;
} }
private class ButtonTag {
String event;
Intent intent;
public ButtonTag(String message, Intent intent) {
this.event = message;
this.intent = intent;
}
}
private void initializeView(View convertView) { private void initializeView(View convertView) {
ViewHolder viewHolder = (ViewHolder) convertView.getTag(); ViewHolder viewHolder = (ViewHolder) convertView.getTag();
AddOn item = viewHolder.item; AddOn item = viewHolder.item;
@ -105,7 +117,8 @@ public class AddOnAdapter extends ArrayAdapter<AddOn> {
viewHolder.web.setVisibility(View.VISIBLE); viewHolder.web.setVisibility(View.VISIBLE);
Intent webPageIntent = new Intent(Intent.ACTION_VIEW, Intent webPageIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse(item.getWebPage())); Uri.parse(item.getWebPage()));
viewHolder.web.setTag(webPageIntent); viewHolder.web.setTag(new ButtonTag("web-" + item.getPackageName(), //$NON-NLS-1$
webPageIntent));
Drawable icon = getIntentIcon(webPageIntent); Drawable icon = getIntentIcon(webPageIntent);
if(icon == null) if(icon == null)
viewHolder.web.setImageResource( viewHolder.web.setImageResource(
@ -125,7 +138,8 @@ public class AddOnAdapter extends ArrayAdapter<AddOn> {
Intent marketIntent = new Intent(Intent.ACTION_VIEW, Intent marketIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("market://search?q=pname:" + //$NON-NLS-1$ Uri.parse("market://search?q=pname:" + //$NON-NLS-1$
item.getPackageName())); item.getPackageName()));
viewHolder.market.setTag(marketIntent); viewHolder.market.setTag(new ButtonTag("market-" + item.getPackageName(), //$NON-NLS-1$
marketIntent));
Drawable icon = getIntentIcon(marketIntent); Drawable icon = getIntentIcon(marketIntent);
if(icon == null) if(icon == null)
viewHolder.market.setImageResource( viewHolder.market.setImageResource(

@ -1023,4 +1023,23 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
} }
} }
/**
* Add a new listener
* @param newListener
*/
public void addOnCompletedTaskListener(final OnCompletedTaskListener newListener) {
if(this.onCompletedTaskListener == null)
this.onCompletedTaskListener = newListener;
else {
final OnCompletedTaskListener old = this.onCompletedTaskListener;
this.onCompletedTaskListener = new OnCompletedTaskListener() {
@Override
public void onCompletedTask(Task item, boolean newState) {
old.onCompletedTask(item, newState);
newListener.onCompletedTask(item, newState);
}
};
}
}
} }

@ -167,18 +167,12 @@ public class TaskDao extends DatabaseDao<Task> {
public boolean save(Task task) { public boolean save(Task task) {
boolean saveSuccessful; boolean saveSuccessful;
ContentValues values = task.getSetValues();
if (task.getId() == Task.NO_ID) { if (task.getId() == Task.NO_ID) {
saveSuccessful = createNew(task); saveSuccessful = createNew(task);
} else { } else {
saveSuccessful = saveExisting(task); saveSuccessful = saveExisting(task);
} }
if(saveSuccessful) {
task.markSaved();
afterSave(task, values);
}
return saveSuccessful; return saveSuccessful;
} }
@ -213,7 +207,11 @@ public class TaskDao extends DatabaseDao<Task> {
Task.NOTIFY_AT_DEADLINE | Task.NOTIFY_AFTER_DEADLINE)); Task.NOTIFY_AT_DEADLINE | Task.NOTIFY_AFTER_DEADLINE));
} }
return super.createNew(item); ContentValues values = item.getSetValues();
boolean result = super.createNew(item);
if(result)
afterSave(item, values);
return result;
} }
@Override @Override
@ -226,7 +224,10 @@ public class TaskDao extends DatabaseDao<Task> {
if(!values.containsKey(Task.MODIFICATION_DATE.name)) if(!values.containsKey(Task.MODIFICATION_DATE.name))
item.setValue(Task.MODIFICATION_DATE, DateUtilities.now()); item.setValue(Task.MODIFICATION_DATE, DateUtilities.now());
} }
return super.saveExisting(item); boolean result = super.saveExisting(item);
if(result)
afterSave(item, values);
return result;
} }
/** /**
@ -238,6 +239,7 @@ public class TaskDao extends DatabaseDao<Task> {
if(values == null) if(values == null)
return; return;
task.markSaved();
if(values.containsKey(Task.COMPLETION_DATE.name) && task.isCompleted()) if(values.containsKey(Task.COMPLETION_DATE.name) && task.isCompleted())
afterComplete(task, values); afterComplete(task, values);
else { else {
@ -260,8 +262,8 @@ public class TaskDao extends DatabaseDao<Task> {
* @param values * @param values
*/ */
private static void afterComplete(Task task, ContentValues values) { private static void afterComplete(Task task, ContentValues values) {
StatisticsService.reportEvent("task-completed"); //$NON-NLS-1$
Notifications.cancelNotifications(task.getId()); Notifications.cancelNotifications(task.getId());
StatisticsService.reportEvent("complete-task"); //$NON-NLS-1$
} }
} }

@ -25,6 +25,7 @@ import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.AstridDependencyInjector; import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.tags.TagService; import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.tags.TagService.Tag; import com.todoroo.astrid.tags.TagService.Tag;
@ -263,9 +264,12 @@ public class Astrid2TaskProvider extends ContentProvider {
task.setValue(Task.DUE_DATE, values.getAsLong(DEFINITE_DUE_DATE)); task.setValue(Task.DUE_DATE, values.getAsLong(DEFINITE_DUE_DATE));
if(values.containsKey(IMPORTANCE)) if(values.containsKey(IMPORTANCE))
task.setValue(Task.IMPORTANCE, values.getAsInteger(IMPORTANCE)); task.setValue(Task.IMPORTANCE, values.getAsInteger(IMPORTANCE));
if(values.containsKey(COMPLETED)) if(values.containsKey(COMPLETED)) {
task.setValue(Task.COMPLETION_DATE, task.setValue(Task.COMPLETION_DATE,
values.getAsBoolean(COMPLETED) ? DateUtilities.now() : 0); values.getAsBoolean(COMPLETED) ? DateUtilities.now() : 0);
if(task.isCompleted())
StatisticsService.reportEvent("task-completed-api2");
}
// map selection criteria // map selection criteria
String criteria = selection.replace(NAME, Task.TITLE.name). String criteria = selection.replace(NAME, Task.TITLE.name).

@ -31,6 +31,7 @@ import com.todoroo.astrid.data.StoreObject;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.TaskApiDao; import com.todoroo.astrid.data.TaskApiDao;
import com.todoroo.astrid.service.AstridDependencyInjector; import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.service.StatisticsService;
/** /**
* Astrid 3 Content Provider. There are two ways to use this content provider: * Astrid 3 Content Provider. There are two ways to use this content provider:
@ -324,6 +325,10 @@ public class Astrid3ContentProvider extends ContentProvider {
helper.model.setId(id); helper.model.setId(id);
helper.update(); helper.update();
helper.model.clear(); helper.model.clear();
if(values.containsKey(Task.COMPLETION_DATE.name) &&
values.getAsLong(Task.COMPLETION_DATE.name) > 0)
StatisticsService.reportEvent("task-completed-api3");
} }
getContext().getContentResolver().notifyChange(uri, null); getContext().getContentResolver().notifyChange(uri, null);

@ -41,6 +41,15 @@ public final class Constants {
*/ */
public static final String HELP_URL = "http://weloveastrid.com/help-user-guide-astrid-v3/active-tasks/"; //$NON-NLS-1$ public static final String HELP_URL = "http://weloveastrid.com/help-user-guide-astrid-v3/active-tasks/"; //$NON-NLS-1$
// --- task list activity source strings
public static final int SOURCE_OTHER = -1;
public static final int SOURCE_DEFAULT = 0;
public static final int SOURCE_NOTIFICATION = 1;
public static final int SOURCE_WIDGET = 2;
public static final int SOURCE_PPWIDGET = 3;
public static final int SOURCE_C2DM = 4;
// --- notification id's // --- notification id's
/** Notification Manager id for sync notifications */ /** Notification Manager id for sync notifications */
@ -59,4 +68,5 @@ public final class Constants {
public static final int NOTIFICATION_ACTFM = -5; public static final int NOTIFICATION_ACTFM = -5;
} }

@ -35,6 +35,7 @@ import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.AstridDependencyInjector; import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.utility.AstridPreferences; import com.todoroo.astrid.utility.AstridPreferences;
import com.todoroo.astrid.utility.Constants;
public class TasksWidget extends AppWidgetProvider { public class TasksWidget extends AppWidgetProvider {
@ -204,6 +205,7 @@ public class TasksWidget extends AppWidgetProvider {
Intent listIntent = new Intent(context, TaskListActivity.class); Intent listIntent = new Intent(context, TaskListActivity.class);
listIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); listIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
listIntent.putExtra(TaskListActivity.TOKEN_SOURCE, Constants.SOURCE_WIDGET);
if(filter != null) { if(filter != null) {
listIntent.putExtra(TaskListActivity.TOKEN_FILTER, filter); listIntent.putExtra(TaskListActivity.TOKEN_FILTER, filter);
listIntent.setType(filter.sqlQuery); listIntent.setType(filter.sqlQuery);

Loading…
Cancel
Save