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.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
notifyIntent.putExtra(TaskListActivity.TOKEN_SOURCE, Constants.SOURCE_C2DM);
PendingIntent pendingIntent = PendingIntent.getActivity(context,
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.gtasks.auth.ModernAuthManager;
import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TaskService;
/**
@ -162,6 +163,7 @@ public class ActFmLoginActivity extends Activity implements AuthListener {
public void onClick(DialogInterface dialog, int which) {
authenticate(email.getText().toString(), name.getText().toString(),
ActFmInvoker.PROVIDER_PASSWORD, password.getText().toString());
StatisticsService.reportEvent("actfm-signup-pw"); //$NON-NLS-1$
}
})
.setNegativeButton(android.R.string.cancel, null)
@ -197,6 +199,7 @@ public class ActFmLoginActivity extends Activity implements AuthListener {
public void onClick(DialogInterface dialog, int which) {
authenticate(email.getText().toString(), null,
ActFmInvoker.PROVIDER_PASSWORD, password.getText().toString());
StatisticsService.reportEvent("actfm-login-pw"); //$NON-NLS-1$
}
})
.setNegativeButton(android.R.string.cancel, null)
@ -253,6 +256,7 @@ public class ActFmLoginActivity extends Activity implements AuthListener {
authenticate(email, name, ActFmInvoker.PROVIDER_FACEBOOK,
facebook.getAccessToken());
StatisticsService.reportEvent("actfm-login-fb"); //$NON-NLS-1$
} catch (FacebookError e) {
handleError(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.Task;
import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.service.ThemeService;
@ -452,10 +453,11 @@ public class EditPeopleActivity extends Activity {
int count = result.optInt("shared", 0);
final String toast;
if(count > 0)
if(count > 0) {
toast = getString(R.string.actfm_EPA_emailed_toast,
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);
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.data.TagData;
import com.todoroo.astrid.data.Update;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.ui.PeopleContainer;
@ -621,6 +622,8 @@ public class TagViewActivity extends TaskListActivity implements OnTabChangeList
addCommentField.setText(""); //$NON-NLS-1$
refreshUpdatesList();
StatisticsService.reportEvent("actfm-tag-comment"); //$NON-NLS-1$
}
@Override

@ -29,6 +29,7 @@ import com.todoroo.astrid.actfm.ActFmLoginActivity;
import com.todoroo.astrid.actfm.ActFmPreferences;
import com.todoroo.astrid.actfm.sync.ActFmSyncService.JsonHelper;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.notes.NoteMetadata;
@ -277,6 +278,13 @@ public class ActFmSyncProvider extends SyncProvider<ActFmTaskContainer> {
@Override
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);
}

@ -49,6 +49,7 @@ import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.Update;
import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.tags.TagService;
@ -464,6 +465,14 @@ public final class ActFmSyncService {
readIds(locals, item, remote);
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);
taskService.save(remote);
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.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.StatisticsService;
/**
* 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
protected void onResume() {
super.onResume();
@ -246,6 +259,7 @@ public class CustomFilterActivity extends ListActivity {
@Override
protected void onPause() {
StatisticsService.sessionPause();
super.onPause();
unregisterReceiver(filterCriteriaReceiver);
}

@ -547,8 +547,12 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
protected void write(GtasksTaskContainer task) throws IOException {
// merge astrid dates with google dates
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);
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);

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

@ -33,6 +33,7 @@ import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.activity.ShortcutActivity;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.StoreObject;
import com.todoroo.astrid.data.Task;
@ -615,6 +616,13 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
@Override
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);
}

@ -50,6 +50,7 @@ import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.repeats.RepeatControlSet;
import com.todoroo.astrid.service.StartupService;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.ui.NumberPicker;
/**
@ -75,10 +76,14 @@ public class NotificationActivity extends TaskListActivity implements OnTimeSetL
StartupService.bypassInitialization();
super.onCreate(savedInstanceState);
displayNotificationPopup();
}
@Override
protected void onTaskCompleted(Task item) {
StatisticsService.reportEvent("task-completed-notification"); //$NON-NLS-1$
}
@Override
protected void onNewIntent(Intent intent) {
populateFilter(intent);
@ -231,6 +236,7 @@ public class NotificationActivity extends TaskListActivity implements OnTimeSetL
task.setValue(Task.REMINDER_SNOOZE, time);
PluginServices.getTaskService().save(task);
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.DateUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.AstridDependencyInjector;
@ -161,6 +162,7 @@ public class Notifications extends BroadcastReceiver {
notifyIntent.setAction("NOTIFY" + id); //$NON-NLS-1$
notifyIntent.putExtra(NotificationActivity.TOKEN_ID, id);
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);
return true;

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

@ -19,6 +19,7 @@ import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.utility.Constants;
public class TimerPlugin extends BroadcastReceiver {
@ -44,14 +45,17 @@ public class TimerPlugin extends BroadcastReceiver {
*/
public static void updateTimer(Context context, Task task, boolean start) {
if(start) {
if(task.getValue(Task.TIMER_START) == 0)
if(task.getValue(Task.TIMER_START) == 0) {
task.setValue(Task.TIMER_START, DateUtilities.now());
StatisticsService.reportEvent("timer-start"); //$NON-NLS-1$
}
} else {
if(task.getValue(Task.TIMER_START) > 0) {
int newElapsed = (int)((DateUtilities.now() - task.getValue(Task.TIMER_START)) / 1000L);
task.setValue(Task.TIMER_START, 0L);
task.setValue(Task.ELAPSED_SECONDS,
task.getValue(Task.ELAPSED_SECONDS) + newElapsed);
StatisticsService.reportEvent("timer-stop"); //$NON-NLS-1$
}
}
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.Preferences;
import com.todoroo.astrid.service.StartupService;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TaskService;
/**
@ -95,6 +96,7 @@ public final class Eula {
@SuppressWarnings("unused")
private static void accept(Activity activity) {
Preferences.setBoolean(PREFERENCE_EULA_ACCEPTED, true);
StatisticsService.reportEvent("eula-accepted"); //$NON-NLS-1$
}
private static void refuse(Activity activity) {

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

@ -87,6 +87,9 @@ public class ShortcutActivity extends Activity {
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)) {
taskListIntent.setComponent(ComponentName.unflattenFromString(extras.getString(TOKEN_CUSTOM_CLASS)));
taskListIntent.putExtras(intent.getExtras());

@ -69,6 +69,7 @@ import com.todoroo.andlib.widget.GestureService;
import com.todoroo.andlib.widget.GestureService.GestureInterface;
import com.todoroo.astrid.activity.SortSelectionActivity.OnSortSelectedListener;
import com.todoroo.astrid.adapter.TaskAdapter;
import com.todoroo.astrid.adapter.TaskAdapter.OnCompletedTaskListener;
import com.todoroo.astrid.adapter.TaskAdapter.ViewHolder;
import com.todoroo.astrid.api.AstridApiConstants;
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 */
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
@Autowired ExceptionService exceptionService;
@ -172,7 +176,7 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
private EditText quickAddBox;
private Timer backgroundTimer;
private final LinkedHashSet<SyncAction> syncActions = new LinkedHashSet<SyncAction>();
private boolean isInbox;
private final TaskListContextMenuExtensionLoader contextMenuExtensionLoader = new TaskListContextMenuExtensionLoader();
private VoiceInputAssistant voiceInputAssistant;
@ -218,6 +222,26 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
onNewIntent(getIntent());
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
@ -227,10 +251,12 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
Bundle extras = intent.getExtras();
if(extras != null && extras.containsKey(TOKEN_FILTER)) {
filter = extras.getParcelable(TOKEN_FILTER);
isInbox = true;
} else {
filter = CoreFilterExposer.buildInboxFilter(getResources());
findViewById(R.id.headerLogo).setVisibility(View.VISIBLE);
findViewById(R.id.listLabel).setVisibility(View.GONE);
isInbox = false;
}
setUpTaskList();
@ -671,7 +697,13 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
// set up list adapters
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);
getListView().setOnScrollListener(this);
registerForContextMenu(getListView());
@ -727,6 +759,18 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
* ============================================================== 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
* @param title
@ -748,6 +792,7 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
selectCustomId(task.getId());
}
StatisticsService.reportEvent("task-created-tasklist");
return task;
} catch (Exception e) {
exceptionService.displayAndReportError(this, "quick-add-task", e);
@ -975,22 +1020,27 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
// handle my own menus
switch (item.getItemId()) {
case MENU_ADDONS_ID:
StatisticsService.reportEvent("tla-menu-addons"); //$NON-NLS-1$
intent = new Intent(this, AddOnActivity.class);
startActivityForResult(intent, ACTIVITY_ADDONS);
return true;
case MENU_SETTINGS_ID:
StatisticsService.reportEvent("tla-menu-settings"); //$NON-NLS-1$
intent = new Intent(this, EditPreferences.class);
startActivityForResult(intent, ACTIVITY_SETTINGS);
return true;
case MENU_SORT_ID:
StatisticsService.reportEvent("tla-menu-sort"); //$NON-NLS-1$
AlertDialog dialog = SortSelectionActivity.createDialog(this,
this, sortFlags, sortSort);
dialog.show();
return true;
case MENU_SYNC_ID:
StatisticsService.reportEvent("tla-menu-sync"); //$NON-NLS-1$
performSyncAction();
return true;
case MENU_HELP_ID:
StatisticsService.reportEvent("tla-menu-help"); //$NON-NLS-1$
intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(Constants.HELP_URL));
startActivity(intent);

@ -22,6 +22,7 @@ import android.widget.TextView;
import com.timsu.astrid.R;
import com.todoroo.astrid.data.AddOn;
import com.todoroo.astrid.service.StatisticsService;
/**
* Adapter for {@link AddOn}s
@ -50,9 +51,11 @@ public class AddOnAdapter extends ArrayAdapter<AddOn> {
View.OnClickListener intentClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = (Intent) v.getTag();
if(intent != null)
activity.startActivity(intent);
ButtonTag buttonTag = (ButtonTag) v.getTag();
if(buttonTag != null) {
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;
}
private class ButtonTag {
String event;
Intent intent;
public ButtonTag(String message, Intent intent) {
this.event = message;
this.intent = intent;
}
}
private void initializeView(View convertView) {
ViewHolder viewHolder = (ViewHolder) convertView.getTag();
AddOn item = viewHolder.item;
@ -105,7 +117,8 @@ public class AddOnAdapter extends ArrayAdapter<AddOn> {
viewHolder.web.setVisibility(View.VISIBLE);
Intent webPageIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse(item.getWebPage()));
viewHolder.web.setTag(webPageIntent);
viewHolder.web.setTag(new ButtonTag("web-" + item.getPackageName(), //$NON-NLS-1$
webPageIntent));
Drawable icon = getIntentIcon(webPageIntent);
if(icon == null)
viewHolder.web.setImageResource(
@ -125,7 +138,8 @@ public class AddOnAdapter extends ArrayAdapter<AddOn> {
Intent marketIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("market://search?q=pname:" + //$NON-NLS-1$
item.getPackageName()));
viewHolder.market.setTag(marketIntent);
viewHolder.market.setTag(new ButtonTag("market-" + item.getPackageName(), //$NON-NLS-1$
marketIntent));
Drawable icon = getIntentIcon(marketIntent);
if(icon == null)
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) {
boolean saveSuccessful;
ContentValues values = task.getSetValues();
if (task.getId() == Task.NO_ID) {
saveSuccessful = createNew(task);
} else {
saveSuccessful = saveExisting(task);
}
if(saveSuccessful) {
task.markSaved();
afterSave(task, values);
}
return saveSuccessful;
}
@ -213,7 +207,11 @@ public class TaskDao extends DatabaseDao<Task> {
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
@ -226,7 +224,10 @@ public class TaskDao extends DatabaseDao<Task> {
if(!values.containsKey(Task.MODIFICATION_DATE.name))
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)
return;
task.markSaved();
if(values.containsKey(Task.COMPLETION_DATE.name) && task.isCompleted())
afterComplete(task, values);
else {
@ -260,8 +262,8 @@ public class TaskDao extends DatabaseDao<Task> {
* @param values
*/
private static void afterComplete(Task task, ContentValues values) {
StatisticsService.reportEvent("task-completed"); //$NON-NLS-1$
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.Task;
import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.tags.TagService;
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));
if(values.containsKey(IMPORTANCE))
task.setValue(Task.IMPORTANCE, values.getAsInteger(IMPORTANCE));
if(values.containsKey(COMPLETED))
if(values.containsKey(COMPLETED)) {
task.setValue(Task.COMPLETION_DATE,
values.getAsBoolean(COMPLETED) ? DateUtilities.now() : 0);
if(task.isCompleted())
StatisticsService.reportEvent("task-completed-api2");
}
// map selection criteria
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.TaskApiDao;
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:
@ -324,6 +325,10 @@ public class Astrid3ContentProvider extends ContentProvider {
helper.model.setId(id);
helper.update();
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);

@ -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$
// --- 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 Manager id for sync notifications */
@ -59,4 +68,5 @@ public final class Constants {
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.TaskService;
import com.todoroo.astrid.utility.AstridPreferences;
import com.todoroo.astrid.utility.Constants;
public class TasksWidget extends AppWidgetProvider {
@ -204,6 +205,7 @@ public class TasksWidget extends AppWidgetProvider {
Intent listIntent = new Intent(context, TaskListActivity.class);
listIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
listIntent.putExtra(TaskListActivity.TOKEN_SOURCE, Constants.SOURCE_WIDGET);
if(filter != null) {
listIntent.putExtra(TaskListActivity.TOKEN_FILTER, filter);
listIntent.setType(filter.sqlQuery);

Loading…
Cancel
Save