Fixed some issues, added undelete, etc.

pull/14/head
Tim Su 16 years ago
parent 652fe11827
commit 07cccb4214

@ -1,4 +1,4 @@
#Wed Jun 30 18:54:52 PDT 2010 #Wed Jul 07 18:43:41 PDT 2010
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
@ -11,7 +11,7 @@ org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
org.eclipse.jdt.core.compiler.problem.deadCode=warning org.eclipse.jdt.core.compiler.problem.deadCode=ignore
org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled

@ -4,7 +4,7 @@
<booleanAttribute key="ch.zork.quicklaunch" value="true"/> <booleanAttribute key="ch.zork.quicklaunch" value="true"/>
<stringAttribute key="ch.zork.quicklaunch.icon" value="14.gif"/> <stringAttribute key="ch.zork.quicklaunch.icon" value="14.gif"/>
<intAttribute key="ch.zork.quicklaunch.index" value="0"/> <intAttribute key="ch.zork.quicklaunch.index" value="0"/>
<stringAttribute key="ch.zork.quicklaunch.mode" value="debug"/> <stringAttribute key="ch.zork.quicklaunch.mode" value="run"/>
<intAttribute key="com.android.ide.eclipse.adt.action" value="0"/> <intAttribute key="com.android.ide.eclipse.adt.action" value="0"/>
<stringAttribute key="com.android.ide.eclipse.adt.avd" value="android-22"/> <stringAttribute key="com.android.ide.eclipse.adt.avd" value="android-22"/>
<stringAttribute key="com.android.ide.eclipse.adt.commandline" value="-scale 0.7"/> <stringAttribute key="com.android.ide.eclipse.adt.commandline" value="-scale 0.7"/>

@ -94,7 +94,7 @@ abstract public class AbstractDatabase {
throw new UnsupportedOperationException("Unknown model class " + modelType); //$NON-NLS-1$ throw new UnsupportedOperationException("Unknown model class " + modelType); //$NON-NLS-1$
} }
protected final void initializeHelper() { protected synchronized final void initializeHelper() {
if(helper == null) if(helper == null)
helper = new DatabaseHelper(ContextManager.getContext(), helper = new DatabaseHelper(ContextManager.getContext(),
getName(), null, getVersion()); getName(), null, getVersion());
@ -109,9 +109,6 @@ abstract public class AbstractDatabase {
try { try {
database = helper.getWritableDatabase(); database = helper.getWritableDatabase();
} catch (NullPointerException e) {
// try again
database = helper.getWritableDatabase();
} catch (SQLiteException writeException) { } catch (SQLiteException writeException) {
Log.e("database-" + getName(), "Error opening db", Log.e("database-" + getName(), "Error opening db",
writeException); writeException);

@ -107,6 +107,8 @@ public final class ReminderService {
task.readFromCursor(cursor); task.readFromCursor(cursor);
scheduleAlarm(task, false); scheduleAlarm(task, false);
} }
} catch (Exception e) {
// suppress
} finally { } finally {
cursor.close(); cursor.close();
} }

@ -2,8 +2,8 @@ package com.todoroo.astrid.tags;
import java.util.ArrayList; import java.util.ArrayList;
import com.todoroo.andlib.data.Property.CountProperty;
import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.data.Property.CountProperty;
import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Criterion;
@ -75,7 +75,8 @@ public class TagService {
public QueryTemplate queryTemplate() { public QueryTemplate queryTemplate() {
return new QueryTemplate().join(Join.inner(Metadata.TABLE, return new QueryTemplate().join(Join.inner(Metadata.TABLE,
Task.ID.eq(Metadata.TASK))).where(Criterion.and( Task.ID.eq(Metadata.TASK))).where(Criterion.and(
MetadataCriteria.withKey(KEY), Metadata.VALUE.eq(tag))); MetadataCriteria.withKey(KEY), Metadata.VALUE.eq(tag),
TaskCriteria.isActive()));
} }
} }

@ -4,7 +4,7 @@
android:orientation="horizontal" android:orientation="horizontal"
android:background="@android:drawable/list_selector_background" android:background="@android:drawable/list_selector_background"
android:paddingLeft="4dip" android:paddingLeft="4dip"
android:paddingRight="4dip" android:paddingRight="6dip"
android:paddingTop="4dip" android:paddingTop="4dip"
android:paddingBottom="4dip" android:paddingBottom="4dip"
android:minHeight="48dip" android:minHeight="48dip"

@ -187,6 +187,9 @@ button: add task & go to the edit page.
<!-- Context Item: delete task --> <!-- Context Item: delete task -->
<string name="TAd_contextDeleteTask">Delete Task</string> <string name="TAd_contextDeleteTask">Delete Task</string>
<!-- Context Item: undelete task -->
<string name="TAd_contextUndeleteTask">Undelete Task</string>
<!-- ======================= FilterListActivity ======================== --> <!-- ======================= FilterListActivity ======================== -->
<!-- Title --> <!-- Title -->

@ -386,6 +386,13 @@ public final class TaskEditActivity extends TabActivity {
protected void discardButtonClick() { protected void discardButtonClick() {
shouldSaveState = false; shouldSaveState = false;
// abandon editing in this case
if(title.getText().length() == 0) {
if(isNewTask())
taskService.delete(model);
}
showCancelToast(); showCancelToast();
setResult(RESULT_CANCELED); setResult(RESULT_CANCELED);
finish(); finish();

@ -94,10 +94,11 @@ public class TaskListActivity extends ListActivity implements OnScrollListener {
private static final int CONTEXT_MENU_EDIT_TASK_ID = Menu.FIRST + 5; private static final int CONTEXT_MENU_EDIT_TASK_ID = Menu.FIRST + 5;
private static final int CONTEXT_MENU_DELETE_TASK_ID = Menu.FIRST + 6; private static final int CONTEXT_MENU_DELETE_TASK_ID = Menu.FIRST + 6;
private static final int CONTEXT_MENU_ADDON_INTENT_ID = Menu.FIRST + 7; private static final int CONTEXT_MENU_UNDELETE_TASK_ID = Menu.FIRST + 7;
private static final int CONTEXT_MENU_ADDON_INTENT_ID = Menu.FIRST + 8;
/** menu code indicating the end of the context menu */ /** menu code indicating the end of the context menu */
private static final int CONTEXT_MENU_DEBUG = Menu.FIRST + 8; private static final int CONTEXT_MENU_DEBUG = Menu.FIRST + 9;
// --- constants // --- constants
@ -372,14 +373,14 @@ public class TaskListActivity extends ListActivity implements OnScrollListener {
@Override @Override
protected void onStop() { protected void onStop() {
super.onStop();
FlurryAgent.onEndSession(this);
// update the widget // update the widget
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
RemoteViews views = new TasksWidget.UpdateService().buildUpdate(this); RemoteViews views = new TasksWidget.UpdateService().buildUpdate(this);
ComponentName widgetName = new ComponentName(this, TasksWidget.class); ComponentName widgetName = new ComponentName(this, TasksWidget.class);
appWidgetManager.updateAppWidget(widgetName, views); appWidgetManager.updateAppWidget(widgetName, views);
super.onStop();
FlurryAgent.onEndSession(this);
} }
@Override @Override
@ -411,7 +412,7 @@ public class TaskListActivity extends ListActivity implements OnScrollListener {
for(Parcelable detail : details) for(Parcelable detail : details)
taskAdapter.addDetails(getListView(), taskId, (TaskDetail)detail); taskAdapter.addDetails(getListView(), taskId, (TaskDetail)detail);
} catch (Exception e) { } catch (Exception e) {
exceptionService.reportError("receive-detail-" + exceptionService.reportError("receive-detail-" + //$NON-NLS-1$
intent.getStringExtra(AstridApiConstants.EXTRAS_PLUGIN), e); intent.getStringExtra(AstridApiConstants.EXTRAS_PLUGIN), e);
} }
} }
@ -568,6 +569,7 @@ public class TaskListActivity extends ListActivity implements OnScrollListener {
} }
} }
@SuppressWarnings("nls")
@Override @Override
public void onCreateContextMenu(ContextMenu menu, View v, public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) { ContextMenuInfo menuInfo) {
@ -576,31 +578,35 @@ public class TaskListActivity extends ListActivity implements OnScrollListener {
int id = (int)task.getId(); int id = (int)task.getId();
menu.setHeaderTitle(task.getValue(Task.TITLE)); menu.setHeaderTitle(task.getValue(Task.TITLE));
menu.add(id, CONTEXT_MENU_EDIT_TASK_ID, Menu.NONE, if(task.isDeleted()) {
R.string.TAd_contextEditTask); menu.add(id, CONTEXT_MENU_UNDELETE_TASK_ID, Menu.NONE,
R.string.TAd_contextUndeleteTask);
menu.add(id, CONTEXT_MENU_DELETE_TASK_ID, Menu.NONE, } else {
R.string.TAd_contextDeleteTask); menu.add(id, CONTEXT_MENU_EDIT_TASK_ID, Menu.NONE,
R.string.TAd_contextEditTask);
if(Constants.DEBUG) { menu.add(id, CONTEXT_MENU_DELETE_TASK_ID, Menu.NONE,
menu.add("--- debug ---"); R.string.TAd_contextDeleteTask);
menu.add(id, CONTEXT_MENU_DEBUG, Menu.NONE,
"when alarm?"); if(Constants.DEBUG) {
menu.add(id, CONTEXT_MENU_DEBUG + 1, Menu.NONE, menu.add("--- debug ---");
"make notification"); menu.add(id, CONTEXT_MENU_DEBUG, Menu.NONE,
} "when alarm?");
menu.add(id, CONTEXT_MENU_DEBUG + 1, Menu.NONE,
"make notification");
}
if(contextMenuItemCache == null) if(contextMenuItemCache == null)
return; return;
// ask about plug-ins // ask about plug-ins
long taskId = task.getId(); long taskId = task.getId();
for(int i = 0; i < contextMenuItemCache.length; i++) { for(int i = 0; i < contextMenuItemCache.length; i++) {
Intent intent = contextMenuItemCache[i].getRight(); Intent intent = contextMenuItemCache[i].getRight();
MenuItem item = menu.add(id, CONTEXT_MENU_ADDON_INTENT_ID, Menu.NONE, MenuItem item = menu.add(id, CONTEXT_MENU_ADDON_INTENT_ID, Menu.NONE,
contextMenuItemCache[i].getLeft()); contextMenuItemCache[i].getLeft());
intent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId); intent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
item.setIntent(intent); item.setIntent(intent);
}
} }
} }
@ -631,7 +637,7 @@ public class TaskListActivity extends ListActivity implements OnScrollListener {
dialogUtilities.okDialog( dialogUtilities.okDialog(
this, this,
"if this were real life, I would display your " + //$NON-NLS-1$ "if this were real life, I would display your " + //$NON-NLS-1$
"add-ons so you could enable/disable/rearrange them.", "add-ons so you could enable/disable/rearrange them.", //$NON-NLS-1$
null); null);
return true; return true;
case MENU_SETTINGS_ID: case MENU_SETTINGS_ID:
@ -666,6 +672,16 @@ public class TaskListActivity extends ListActivity implements OnScrollListener {
return true; return true;
} }
case CONTEXT_MENU_UNDELETE_TASK_ID: {
itemId = item.getGroupId();
Task task = new Task();
task.setId(itemId);
task.setValue(Task.DELETION_DATE, 0L);
taskService.save(task, false);
loadTaskListContent(true);
return true;
}
// --- debug // --- debug
case CONTEXT_MENU_DEBUG: { case CONTEXT_MENU_DEBUG: {
@ -676,20 +692,20 @@ public class TaskListActivity extends ListActivity implements OnScrollListener {
reminderService.setScheduler(new AlarmScheduler() { reminderService.setScheduler(new AlarmScheduler() {
@Override @Override
public void createAlarm(Task theTask, long time, int type) { public void createAlarm(Task theTask, long time, int type) {
Toast.makeText(TaskListActivity.this, "Scheduled Alarm: " + Toast.makeText(TaskListActivity.this, "Scheduled Alarm: " + //$NON-NLS-1$
new Date(time), Toast.LENGTH_LONG).show(); new Date(time), Toast.LENGTH_LONG).show();
reminderService.setScheduler(null); reminderService.setScheduler(null);
} }
}); });
reminderService.scheduleAlarm(task); reminderService.scheduleAlarm(task);
if(reminderService.getScheduler() != null) if(reminderService.getScheduler() != null)
Toast.makeText(this, "No alarms", Toast.LENGTH_LONG).show(); Toast.makeText(this, "No alarms", Toast.LENGTH_LONG).show(); //$NON-NLS-1$
return true; return true;
} }
case CONTEXT_MENU_DEBUG + 1: { case CONTEXT_MENU_DEBUG + 1: {
itemId = item.getGroupId(); itemId = item.getGroupId();
new Notifications().showNotification(itemId, 0, "test reminder"); new Notifications().showNotification(itemId, 0, "test reminder"); //$NON-NLS-1$
return true; return true;
} }

@ -15,6 +15,7 @@ import android.widget.RemoteViews;
import com.timsu.astrid.R; import com.timsu.astrid.R;
import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.activity.TaskEditActivity; import com.todoroo.astrid.activity.TaskEditActivity;
@ -57,7 +58,13 @@ public class TasksWidget extends AppWidgetProvider {
@Override @Override
public void onStart(Intent intent, int startId) { public void onStart(Intent intent, int startId) {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
return;
}
RemoteViews updateViews = buildUpdate(this); RemoteViews updateViews = buildUpdate(this);
ContextManager.setContext(this);
ComponentName thisWidget = new ComponentName(this, ComponentName thisWidget = new ComponentName(this,
TasksWidget.class); TasksWidget.class);
@ -86,12 +93,13 @@ public class TasksWidget extends AppWidgetProvider {
listIntent, 0); listIntent, 0);
views.setOnClickPendingIntent(R.id.taskbody, pendingIntent); views.setOnClickPendingIntent(R.id.taskbody, pendingIntent);
Filter inboxFilter = CoreFilterExposer.buildInboxFilter(getResources());
inboxFilter.sqlQuery += "ORDER BY " + TaskService.defaultTaskOrder() + " LIMIT " + numberOfTasks;
DependencyInjectionService.getInstance().inject(this);
TodorooCursor<Task> cursor = null; TodorooCursor<Task> cursor = null;
try { try {
database.openForWriting(); Filter inboxFilter = CoreFilterExposer.buildInboxFilter(getResources());
inboxFilter.sqlQuery += "ORDER BY " + TaskService.defaultTaskOrder() + " LIMIT " + numberOfTasks;
DependencyInjectionService.getInstance().inject(this);
database.openForReading();
cursor = taskService.fetchFiltered(inboxFilter, Task.TITLE, Task.DUE_DATE); cursor = taskService.fetchFiltered(inboxFilter, Task.TITLE, Task.DUE_DATE);
Task task = new Task(); Task task = new Task();
for (int i = 0; i < cursor.getCount(); i++) { for (int i = 0; i < cursor.getCount(); i++) {

Loading…
Cancel
Save