got widget completing working. also updated the look slightly.

pull/14/head
Tim Su 14 years ago
parent 50229bed6b
commit 401125c187

@ -112,7 +112,7 @@
android:layout_height="wrap_content"
android:layout_weight="100"
android:layout_gravity="center_vertical"
android:textSize="14sp" android:paddingLeft="5dip" />
android:textSize="14sp" android:textStyle="bold" android:paddingLeft="5dip" />
<TextView
android:id="@+id/task_due1"
android:layout_width="wrap_content"
@ -142,7 +142,7 @@
android:layout_height="wrap_content"
android:layout_weight="100"
android:layout_gravity="center_vertical"
android:textSize="14sp" android:paddingLeft="5dip" />
android:textSize="14sp" android:textStyle="bold" android:paddingLeft="5dip" />
<TextView
android:id="@+id/task_due2"
android:layout_width="wrap_content"
@ -172,7 +172,7 @@
android:layout_height="wrap_content"
android:layout_weight="100"
android:layout_gravity="center_vertical"
android:textSize="14sp" android:paddingLeft="5dip" />
android:textSize="14sp" android:textStyle="bold" android:paddingLeft="5dip" />
<TextView
android:id="@+id/task_due3"
android:layout_width="wrap_content"
@ -202,7 +202,7 @@
android:layout_height="wrap_content"
android:layout_weight="100"
android:layout_gravity="center_vertical"
android:textSize="14sp" android:paddingLeft="5dip" />
android:textSize="14sp" android:textStyle="bold" android:paddingLeft="5dip" />
<TextView
android:id="@+id/task_due4"
android:layout_width="wrap_content"
@ -232,7 +232,7 @@
android:layout_height="wrap_content"
android:layout_weight="100"
android:layout_gravity="center_vertical"
android:textSize="14sp" android:paddingLeft="5dip" />
android:textSize="14sp" android:textStyle="bold" android:paddingLeft="5dip" />
<TextView
android:id="@+id/task_due5"
android:layout_width="wrap_content"
@ -262,7 +262,7 @@
android:layout_height="wrap_content"
android:layout_weight="100"
android:layout_gravity="center_vertical"
android:textSize="14sp" android:paddingLeft="5dip" />
android:textSize="14sp" android:textStyle="bold" android:paddingLeft="5dip" />
<TextView
android:id="@+id/task_due6"
android:layout_width="wrap_content"
@ -292,7 +292,7 @@
android:layout_height="wrap_content"
android:layout_weight="100"
android:layout_gravity="center_vertical"
android:textSize="14sp" android:paddingLeft="5dip" />
android:textSize="14sp" android:textStyle="bold" android:paddingLeft="5dip" />
<TextView
android:id="@+id/task_due7"
android:layout_width="wrap_content"
@ -322,7 +322,7 @@
android:layout_height="wrap_content"
android:layout_weight="100"
android:layout_gravity="center_vertical"
android:textSize="14sp" android:paddingLeft="5dip" />
android:textSize="14sp" android:textStyle="bold" android:paddingLeft="5dip" />
<TextView
android:id="@+id/task_due8"
android:layout_width="wrap_content"
@ -352,7 +352,7 @@
android:layout_height="wrap_content"
android:layout_weight="100"
android:layout_gravity="center_vertical"
android:textSize="14sp" android:paddingLeft="5dip" />
android:textSize="14sp" android:textStyle="bold" android:paddingLeft="5dip" />
<TextView
android:id="@+id/task_due9"
android:layout_width="wrap_content"
@ -382,7 +382,7 @@
android:layout_height="wrap_content"
android:layout_weight="100"
android:layout_gravity="center_vertical"
android:textSize="14sp" android:paddingLeft="5dip" />
android:textSize="14sp" android:textStyle="bold" android:paddingLeft="5dip" />
<TextView
android:id="@+id/task_due10"
android:layout_width="wrap_content"
@ -401,14 +401,14 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/encouragement"
android:layout_alignParentBottom="true">
android:layout_alignParentBottom="true"
android:gravity="center_horizontal">
<!-- if no encouragement -->
<LinearLayout
android:id="@+id/button_plus"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:gravity="center_horizontal">
android:layout_height="36dp">
<ImageView
android:src="@drawable/button_plus"
android:layout_width="17dp"

@ -1,7 +1,5 @@
package com.todoroo.astrid.widget;
import java.util.Date;
import android.app.PendingIntent;
import android.app.Service;
import android.appwidget.AppWidgetManager;
@ -164,6 +162,9 @@ public class PowerWidget extends AppWidgetProvider {
public static class UpdateService extends Service {
private static final Property<?>[] properties = new Property<?>[] { Task.ID, Task.TITLE,
Task.DUE_DATE, Task.IMPORTANCE, Task.COMPLETION_DATE };
@Autowired
private Database database;
@ -234,8 +235,6 @@ public class PowerWidget extends AppWidgetProvider {
public RemoteViews buildUpdate(Context context, int appWidgetId, int scrollOffset) {
DependencyInjectionService.getInstance().inject(this);
System.err.println("BUILD UPDATE " + DateUtilities.now());
RemoteViews views = new RemoteViews(context.getPackageName(),
R.layout.widget_power_44);
@ -329,29 +328,24 @@ public class PowerWidget extends AppWidgetProvider {
query = query.replaceAll("[lL][iI][mM][iI][tT] +[^ ]+", "") + " LIMIT " +
scrollOffset + "," + ROW_LIMIT;
System.err.println("PRE LOAD DATA " + DateUtilities.now());
// load last completed task
Task lastCompleted = null;
int lastCompletedPosition = 0;
if(DateUtilities.now() - Preferences.getLong(PREF_LAST_COMPLETED_DATE+appWidgetId, 0) < 120000L) {
lastCompleted = taskService.fetchById(Preferences.getLong(PREF_LAST_COMPLETED_ID+appWidgetId, -1L),
properties);
lastCompletedPosition = Preferences.getInt(PREF_LAST_COMPLETED_POS+appWidgetId, 0);
if(lastCompleted != null)
query = query.replace("WHERE", "WHERE " + Task.ID.neq(lastCompleted.getId()) + " AND ");
}
database.openForReading();
final Property<?>[] properties = new Property<?>[] { Task.ID, Task.TITLE,
Task.DUE_DATE, Task.IMPORTANCE, Task.COMPLETION_DATE };
cursor = taskService.fetchFiltered(query, null, properties);
boolean canScrollDown = cursor.getCount() > 1;
if(importanceColors == null) {
importanceColors = Task.getImportanceColors(getResources());
System.err.println("loaded importance");
}
// load last completed task
Task lastCompleted = null;
int lastCompletedPosition = 0;
System.err.println("last completed for " + appWidgetId + ": " +
new Date(Preferences.getLong(PREF_LAST_COMPLETED_DATE+appWidgetId, 0)));
if(DateUtilities.now() - Preferences.getLong(PREF_LAST_COMPLETED_DATE+appWidgetId, 0) < 120000L) {
lastCompleted = taskService.fetchById(Preferences.getLong(PREF_LAST_COMPLETED_ID+appWidgetId, -1L),
properties);
lastCompletedPosition = Preferences.getInt(PREF_LAST_COMPLETED_POS+appWidgetId, 0);
}
Task task = new Task();
@ -376,7 +370,8 @@ public class PowerWidget extends AppWidgetProvider {
markCompleteIntent.putExtra(COMPLETED_TASK_ID, taskId);
markCompleteIntent.putExtra(COMPLETED_TASK_POSITION, scrollOffset + position);
markCompleteIntent.setType(COMPLETED_TASK_ID + taskId);
PendingIntent pMarkCompleteIntent = PendingIntent.getBroadcast(context, 0, markCompleteIntent, 0);
PendingIntent pMarkCompleteIntent = PendingIntent.getBroadcast(context, 0, markCompleteIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(TASK_CHECKBOX[position], pMarkCompleteIntent);
if(task.isCompleted()) {
@ -405,7 +400,7 @@ public class PowerWidget extends AppWidgetProvider {
viewTaskIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
viewTaskIntent.putExtra(ShortcutActivity.TOKEN_SINGLE_TASK, taskId);
viewTaskIntent.setType(ShortcutActivity.TOKEN_SINGLE_TASK + taskId);
PendingIntent pEditTask = PendingIntent.getActivity(context, 0, viewTaskIntent, PendingIntent.FLAG_CANCEL_CURRENT);
PendingIntent pEditTask = PendingIntent.getActivity(context, 0, viewTaskIntent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(TASK_TITLE[position], pEditTask);
// due date
@ -467,8 +462,6 @@ public class PowerWidget extends AppWidgetProvider {
cursor.close();
}
System.err.println("END UPDATE " + DateUtilities.now());
return views;
}

Loading…
Cancel
Save