Fixed minor bugs with widget and stuff

pull/14/head
Tim Su 15 years ago
parent 1d21258b0d
commit f7db4222e3

@ -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="run"/> <stringAttribute key="ch.zork.quicklaunch.mode" value="debug"/>
<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"/>

@ -329,6 +329,14 @@ public final class TaskEditActivity extends TabActivity {
/** Save task model from values in UI components */ /** Save task model from values in UI components */
private void save() { private void save() {
// abandon editing in this case
if(title.getText().length() == 0) {
if(isNewTask())
taskService.delete(model);
discardButtonClick();
return;
}
for(TaskEditControlSet controlSet : controls) for(TaskEditControlSet controlSet : controls)
controlSet.writeToModel(); controlSet.writeToModel();

@ -6,7 +6,9 @@ import java.util.Map.Entry;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.ListActivity; import android.app.ListActivity;
import android.appwidget.AppWidgetManager;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -32,6 +34,7 @@ import android.widget.EditText;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.RemoteViews;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import android.widget.AbsListView.OnScrollListener; import android.widget.AbsListView.OnScrollListener;
@ -65,6 +68,7 @@ import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.service.StartupService; import com.todoroo.astrid.service.StartupService;
import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.utility.Constants; import com.todoroo.astrid.utility.Constants;
import com.todoroo.astrid.widget.TasksWidget;
/** /**
* Primary activity for the Bente application. Shows a list of upcoming * Primary activity for the Bente application. Shows a list of upcoming
@ -370,6 +374,12 @@ public class TaskListActivity extends ListActivity implements OnScrollListener {
protected void onStop() { protected void onStop() {
super.onStop(); super.onStop();
FlurryAgent.onEndSession(this); 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);
} }
@Override @Override
@ -401,7 +411,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-" + //$NON-NLS-1$ exceptionService.reportError("receive-detail-" +
intent.getStringExtra(AstridApiConstants.EXTRAS_PLUGIN), e); intent.getStringExtra(AstridApiConstants.EXTRAS_PLUGIN), e);
} }
} }
@ -573,11 +583,11 @@ public class TaskListActivity extends ListActivity implements OnScrollListener {
R.string.TAd_contextDeleteTask); R.string.TAd_contextDeleteTask);
if(Constants.DEBUG) { if(Constants.DEBUG) {
menu.add("--- debug ---"); //$NON-NLS-1$ menu.add("--- debug ---");
menu.add(id, CONTEXT_MENU_DEBUG, Menu.NONE, menu.add(id, CONTEXT_MENU_DEBUG, Menu.NONE,
"when alarm?"); //$NON-NLS-1$ "when alarm?");
menu.add(id, CONTEXT_MENU_DEBUG + 1, Menu.NONE, menu.add(id, CONTEXT_MENU_DEBUG + 1, Menu.NONE,
"make notification"); //$NON-NLS-1$ "make notification");
} }
if(contextMenuItemCache == null) if(contextMenuItemCache == null)
@ -621,7 +631,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.", //$NON-NLS-1$ "add-ons so you could enable/disable/rearrange them.",
null); null);
return true; return true;
case MENU_SETTINGS_ID: case MENU_SETTINGS_ID:
@ -666,20 +676,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: " + //$NON-NLS-1$ Toast.makeText(TaskListActivity.this, "Scheduled Alarm: " +
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(); //$NON-NLS-1$ Toast.makeText(this, "No alarms", Toast.LENGTH_LONG).show();
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"); //$NON-NLS-1$ new Notifications().showNotification(itemId, 0, "test reminder");
return true; return true;
} }

@ -87,7 +87,7 @@ public class TasksWidget extends AppWidgetProvider {
views.setOnClickPendingIntent(R.id.taskbody, pendingIntent); views.setOnClickPendingIntent(R.id.taskbody, pendingIntent);
Filter inboxFilter = CoreFilterExposer.buildInboxFilter(getResources()); Filter inboxFilter = CoreFilterExposer.buildInboxFilter(getResources());
inboxFilter.sqlQuery += TaskService.defaultTaskOrder() + " LIMIT " + numberOfTasks; inboxFilter.sqlQuery += "ORDER BY " + TaskService.defaultTaskOrder() + " LIMIT " + numberOfTasks;
DependencyInjectionService.getInstance().inject(this); DependencyInjectionService.getInstance().inject(this);
TodorooCursor<Task> cursor = null; TodorooCursor<Task> cursor = null;
try { try {

Loading…
Cancel
Save