Now when you trigger timer, new decoration overrides old one to show you timer progress

pull/14/head
Tim Su 15 years ago
parent 3423ae184d
commit 36207a9c55

@ -56,4 +56,9 @@ public class GtasksDecorationExposer implements TaskDecorationExposer {
return new TaskDecoration(decoration, TaskDecoration.POSITION_LEFT, 0); return new TaskDecoration(decoration, TaskDecoration.POSITION_LEFT, 0);
} }
@Override
public String getAddon() {
return GtasksPreferenceService.IDENTIFIER;
}
} }

@ -3,6 +3,8 @@
*/ */
package com.todoroo.astrid.timers; package com.todoroo.astrid.timers;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.os.SystemClock; import android.os.SystemClock;
import android.text.format.DateUtils; import android.text.format.DateUtils;
@ -12,6 +14,7 @@ import android.widget.RemoteViews;
import com.timsu.astrid.R; import com.timsu.astrid.R;
import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.TaskDecoration; import com.todoroo.astrid.api.TaskDecoration;
import com.todoroo.astrid.api.TaskDecorationExposer; import com.todoroo.astrid.api.TaskDecorationExposer;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
@ -59,8 +62,25 @@ public class TimerDecorationExposer implements TaskDecorationExposer {
return decoration; return decoration;
} }
public void updateDecoration(Context context, Task task) {
TaskDecoration decoration = expose(task);
if(decoration == null)
return;
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_DECORATIONS);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, TimerPlugin.IDENTIFIER);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, decoration);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, task.getId());
context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
}
private String buildFormat(long elapsed) { private String buildFormat(long elapsed) {
return DateUtils.formatElapsedTime(elapsed / 1000L); return DateUtils.formatElapsedTime(elapsed / 1000L);
} }
@Override
public String getAddon() {
return TimerPlugin.IDENTIFIER;
}
} }

@ -58,6 +58,7 @@ public class TimerPlugin extends BroadcastReceiver {
Intent intent = new Intent(AstridApiConstants.BROADCAST_REQUEST_ACTIONS); Intent intent = new Intent(AstridApiConstants.BROADCAST_REQUEST_ACTIONS);
intent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, task.getId()); intent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, task.getId());
new TimerActionExposer().onReceive(context, intent); new TimerActionExposer().onReceive(context, intent);
new TimerDecorationExposer().updateDecoration(context, task);
// update notification // update notification
TimerPlugin.updateNotifications(context); TimerPlugin.updateNotifications(context);

@ -647,7 +647,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
for(TaskDecorationExposer exposer : exposers) { for(TaskDecorationExposer exposer : exposers) {
TaskDecoration deco = exposer.expose(viewHolder.task); TaskDecoration deco = exposer.expose(viewHolder.task);
if(deco != null) if(deco != null)
addNew(viewHolder.task.getId(), exposer.getClass().getName(), deco); addNew(viewHolder.task.getId(), exposer.getAddon(), deco);
} }
return true; return true;

@ -18,4 +18,6 @@ public interface TaskDecorationExposer {
*/ */
public TaskDecoration expose(Task task); public TaskDecoration expose(Task task);
public String getAddon();
} }

Loading…
Cancel
Save