Fixed some issues, added undelete, etc.

pull/14/head
Tim Su 15 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
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
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.autoboxing=ignore
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.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled

@ -4,7 +4,7 @@
<booleanAttribute key="ch.zork.quicklaunch" value="true"/>
<stringAttribute key="ch.zork.quicklaunch.icon" value="14.gif"/>
<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"/>
<stringAttribute key="com.android.ide.eclipse.adt.avd" value="android-22"/>
<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$
}
protected final void initializeHelper() {
protected synchronized final void initializeHelper() {
if(helper == null)
helper = new DatabaseHelper(ContextManager.getContext(),
getName(), null, getVersion());
@ -109,9 +109,6 @@ abstract public class AbstractDatabase {
try {
database = helper.getWritableDatabase();
} catch (NullPointerException e) {
// try again
database = helper.getWritableDatabase();
} catch (SQLiteException writeException) {
Log.e("database-" + getName(), "Error opening db",
writeException);

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

@ -2,8 +2,8 @@ package com.todoroo.astrid.tags;
import java.util.ArrayList;
import com.todoroo.andlib.data.Property.CountProperty;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.data.Property.CountProperty;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.Criterion;
@ -75,7 +75,8 @@ public class TagService {
public QueryTemplate queryTemplate() {
return new QueryTemplate().join(Join.inner(Metadata.TABLE,
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:background="@android:drawable/list_selector_background"
android:paddingLeft="4dip"
android:paddingRight="4dip"
android:paddingRight="6dip"
android:paddingTop="4dip"
android:paddingBottom="4dip"
android:minHeight="48dip"

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

@ -386,6 +386,13 @@ public final class TaskEditActivity extends TabActivity {
protected void discardButtonClick() {
shouldSaveState = false;
// abandon editing in this case
if(title.getText().length() == 0) {
if(isNewTask())
taskService.delete(model);
}
showCancelToast();
setResult(RESULT_CANCELED);
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_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 */
private static final int CONTEXT_MENU_DEBUG = Menu.FIRST + 8;
private static final int CONTEXT_MENU_DEBUG = Menu.FIRST + 9;
// --- constants
@ -372,14 +373,14 @@ public class TaskListActivity extends ListActivity implements OnScrollListener {
@Override
protected void onStop() {
super.onStop();
FlurryAgent.onEndSession(this);
// update the widget
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
RemoteViews views = new TasksWidget.UpdateService().buildUpdate(this);
ComponentName widgetName = new ComponentName(this, TasksWidget.class);
appWidgetManager.updateAppWidget(widgetName, views);
super.onStop();
FlurryAgent.onEndSession(this);
}
@Override
@ -411,7 +412,7 @@ public class TaskListActivity extends ListActivity implements OnScrollListener {
for(Parcelable detail : details)
taskAdapter.addDetails(getListView(), taskId, (TaskDetail)detail);
} catch (Exception e) {
exceptionService.reportError("receive-detail-" +
exceptionService.reportError("receive-detail-" + //$NON-NLS-1$
intent.getStringExtra(AstridApiConstants.EXTRAS_PLUGIN), e);
}
}
@ -568,6 +569,7 @@ public class TaskListActivity extends ListActivity implements OnScrollListener {
}
}
@SuppressWarnings("nls")
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
@ -576,31 +578,35 @@ public class TaskListActivity extends ListActivity implements OnScrollListener {
int id = (int)task.getId();
menu.setHeaderTitle(task.getValue(Task.TITLE));
menu.add(id, CONTEXT_MENU_EDIT_TASK_ID, Menu.NONE,
R.string.TAd_contextEditTask);
menu.add(id, CONTEXT_MENU_DELETE_TASK_ID, Menu.NONE,
R.string.TAd_contextDeleteTask);
if(Constants.DEBUG) {
menu.add("--- debug ---");
menu.add(id, CONTEXT_MENU_DEBUG, Menu.NONE,
"when alarm?");
menu.add(id, CONTEXT_MENU_DEBUG + 1, Menu.NONE,
"make notification");
}
if(task.isDeleted()) {
menu.add(id, CONTEXT_MENU_UNDELETE_TASK_ID, Menu.NONE,
R.string.TAd_contextUndeleteTask);
} else {
menu.add(id, CONTEXT_MENU_EDIT_TASK_ID, Menu.NONE,
R.string.TAd_contextEditTask);
menu.add(id, CONTEXT_MENU_DELETE_TASK_ID, Menu.NONE,
R.string.TAd_contextDeleteTask);
if(Constants.DEBUG) {
menu.add("--- debug ---");
menu.add(id, CONTEXT_MENU_DEBUG, Menu.NONE,
"when alarm?");
menu.add(id, CONTEXT_MENU_DEBUG + 1, Menu.NONE,
"make notification");
}
if(contextMenuItemCache == null)
return;
if(contextMenuItemCache == null)
return;
// ask about plug-ins
long taskId = task.getId();
for(int i = 0; i < contextMenuItemCache.length; i++) {
Intent intent = contextMenuItemCache[i].getRight();
MenuItem item = menu.add(id, CONTEXT_MENU_ADDON_INTENT_ID, Menu.NONE,
contextMenuItemCache[i].getLeft());
intent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
item.setIntent(intent);
// ask about plug-ins
long taskId = task.getId();
for(int i = 0; i < contextMenuItemCache.length; i++) {
Intent intent = contextMenuItemCache[i].getRight();
MenuItem item = menu.add(id, CONTEXT_MENU_ADDON_INTENT_ID, Menu.NONE,
contextMenuItemCache[i].getLeft());
intent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
item.setIntent(intent);
}
}
}
@ -631,7 +637,7 @@ public class TaskListActivity extends ListActivity implements OnScrollListener {
dialogUtilities.okDialog(
this,
"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);
return true;
case MENU_SETTINGS_ID:
@ -666,6 +672,16 @@ public class TaskListActivity extends ListActivity implements OnScrollListener {
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
case CONTEXT_MENU_DEBUG: {
@ -676,20 +692,20 @@ public class TaskListActivity extends ListActivity implements OnScrollListener {
reminderService.setScheduler(new AlarmScheduler() {
@Override
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();
reminderService.setScheduler(null);
}
});
reminderService.scheduleAlarm(task);
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;
}
case CONTEXT_MENU_DEBUG + 1: {
itemId = item.getGroupId();
new Notifications().showNotification(itemId, 0, "test reminder");
new Notifications().showNotification(itemId, 0, "test reminder"); //$NON-NLS-1$
return true;
}

@ -15,6 +15,7 @@ import android.widget.RemoteViews;
import com.timsu.astrid.R;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.activity.TaskEditActivity;
@ -57,7 +58,13 @@ public class TasksWidget extends AppWidgetProvider {
@Override
public void onStart(Intent intent, int startId) {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
return;
}
RemoteViews updateViews = buildUpdate(this);
ContextManager.setContext(this);
ComponentName thisWidget = new ComponentName(this,
TasksWidget.class);
@ -86,12 +93,13 @@ public class TasksWidget extends AppWidgetProvider {
listIntent, 0);
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;
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);
Task task = new Task();
for (int i = 0; i < cursor.getCount(); i++) {

Loading…
Cancel
Save