diff --git a/astrid/AndroidManifest.xml b/astrid/AndroidManifest.xml index 639091fda..c9673f522 100644 --- a/astrid/AndroidManifest.xml +++ b/astrid/AndroidManifest.xml @@ -54,7 +54,7 @@ + android:label="@string/app_name" android:debuggable="true"> @@ -189,6 +189,12 @@ + + + + + + @@ -202,6 +208,12 @@ + + + + + + @@ -217,6 +229,12 @@ + + + + + + @@ -255,6 +273,12 @@ + + + + + + - + + + + + + + @@ -374,6 +404,12 @@ + + + + + + diff --git a/astrid/astrid.launch b/astrid/astrid.launch index 19f7df00c..89ae0a49d 100644 --- a/astrid/astrid.launch +++ b/astrid/astrid.launch @@ -12,7 +12,7 @@ - + diff --git a/astrid/common-src/com/todoroo/andlib/data/GenericDao.java b/astrid/common-src/com/todoroo/andlib/data/GenericDao.java index 7c80b6a4f..da3a59c22 100644 --- a/astrid/common-src/com/todoroo/andlib/data/GenericDao.java +++ b/astrid/common-src/com/todoroo/andlib/data/GenericDao.java @@ -196,6 +196,20 @@ public class GenericDao { AbstractModel.ID_PROPERTY.eq(item.getId()).toString(), null) > 0; } + /** + * Updates multiple rows of the database based on model set values + * + * @param item + * item model + * @param criterion + * @return returns true on success. + */ + public int updateMultiple(ContentValues values, Criterion criterion) { + if(values.size() == 0) // nothing changed + return 0; + return database.update(table.name, values, criterion.toString(), null); + } + // --- helper methods diff --git a/astrid/common-src/com/todoroo/andlib/widget/Api4GestureDetector.java b/astrid/common-src/com/todoroo/andlib/widget/Api4GestureDetector.java index 957f81772..11a110081 100644 --- a/astrid/common-src/com/todoroo/andlib/widget/Api4GestureDetector.java +++ b/astrid/common-src/com/todoroo/andlib/widget/Api4GestureDetector.java @@ -34,7 +34,7 @@ public class Api4GestureDetector implements OnGesturePerformedListener { if (predictions.size() > 0) { Prediction prediction = predictions.get(0); // We want at least some confidence in the result - if (prediction.score > 1.0) { + if (prediction.score > 2.0) { listener.gesturePerformed(prediction.name); } } diff --git a/astrid/plugin-src/com/todoroo/astrid/alarms/AlarmDetailExposer.java b/astrid/plugin-src/com/todoroo/astrid/alarms/AlarmDetailExposer.java index b8596da3b..4a25599e1 100644 --- a/astrid/plugin-src/com/todoroo/astrid/alarms/AlarmDetailExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/alarms/AlarmDetailExposer.java @@ -12,7 +12,6 @@ import com.timsu.astrid.R; import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.api.AstridApiConstants; -import com.todoroo.astrid.api.DetailExposer; import com.todoroo.astrid.model.Metadata; /** @@ -21,7 +20,7 @@ import com.todoroo.astrid.model.Metadata; * @author Tim Su * */ -public class AlarmDetailExposer extends BroadcastReceiver implements DetailExposer { +public class AlarmDetailExposer extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { @@ -44,7 +43,6 @@ public class AlarmDetailExposer extends BroadcastReceiver implements DetailExpos context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ); } - @Override public String getTaskDetails(Context context, long id, boolean extended) { if(extended) return null; @@ -71,9 +69,4 @@ public class AlarmDetailExposer extends BroadcastReceiver implements DetailExpos } } - @Override - public String getPluginIdentifier() { - return AlarmService.IDENTIFIER; - } - } diff --git a/astrid/plugin-src/com/todoroo/astrid/common/SyncProvider.java b/astrid/plugin-src/com/todoroo/astrid/common/SyncProvider.java index a01b8287b..5b27684b7 100644 --- a/astrid/plugin-src/com/todoroo/astrid/common/SyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/common/SyncProvider.java @@ -295,6 +295,12 @@ public abstract class SyncProvider { length = data.remoteUpdated.size(); for(int i = 0; i < length; i++) { TYPE remote = data.remoteUpdated.get(i); + + // don't synchronize new & deleted / completed tasks + if(!remote.task.isSaved() && (remote.task.isDeleted() || + remote.task.isCompleted())) + continue; + try { write(remote); } catch (Exception e) { diff --git a/astrid/plugin-src/com/todoroo/astrid/notes/NoteDetailExposer.java b/astrid/plugin-src/com/todoroo/astrid/notes/NoteDetailExposer.java index ba9a879c0..29df48da9 100644 --- a/astrid/plugin-src/com/todoroo/astrid/notes/NoteDetailExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/notes/NoteDetailExposer.java @@ -10,7 +10,6 @@ import android.content.Intent; import com.timsu.astrid.R; import com.todoroo.astrid.api.AstridApiConstants; -import com.todoroo.astrid.api.DetailExposer; import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.model.Task; import com.todoroo.astrid.utility.Preferences; @@ -21,7 +20,7 @@ import com.todoroo.astrid.utility.Preferences; * @author Tim Su * */ -public class NoteDetailExposer extends BroadcastReceiver implements DetailExposer { +public class NoteDetailExposer extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { @@ -44,7 +43,6 @@ public class NoteDetailExposer extends BroadcastReceiver implements DetailExpose context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ); } - @Override public String getTaskDetails(Context context, long id, boolean extended) { if(Preferences.getBoolean(R.string.p_showNotes, false)) { @@ -65,9 +63,4 @@ public class NoteDetailExposer extends BroadcastReceiver implements DetailExpose return " " + notes; //$NON-NLS-1$ } - @Override - public String getPluginIdentifier() { - return NotesPlugin.IDENTIFIER; - } - } diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevControlSet.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevControlSet.java index 29293bc62..26e7feeac 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevControlSet.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevControlSet.java @@ -13,11 +13,11 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; -import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; +import android.widget.AdapterView.OnItemSelectedListener; import com.timsu.astrid.R; import com.todoroo.andlib.service.Autowired; @@ -94,10 +94,10 @@ public class ProducteevControlSet implements TaskEditControlSet { dialog.cancel(); } else { // create the real dashboard, select it in the spinner and refresh responsiblespinner - ProgressDialog progressDialog = null; + ProgressDialog progressDialog = dialogUtilites.progressDialog(context, + context.getString(R.string.DLG_wait)); try { - progressDialog = dialogUtilites.progressDialog(context, - context.getString(R.string.DLG_wait)); + progressDialog.show(); JSONObject newDashJSON = ProducteevSyncProvider.getInvoker().dashboardsCreate(newDashboardName).getJSONObject("dashboard"); StoreObject local = ProducteevDataService.getInstance().updateDashboards(newDashJSON, true); if (local != null) { diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java index 545a3f822..69f14ccfd 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java @@ -11,7 +11,6 @@ import com.timsu.astrid.R; import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.astrid.adapter.TaskAdapter; import com.todoroo.astrid.api.AstridApiConstants; -import com.todoroo.astrid.api.DetailExposer; import com.todoroo.astrid.model.Metadata; import com.todoroo.astrid.model.StoreObject; import com.todoroo.astrid.producteev.sync.ProducteevDashboard; @@ -27,7 +26,7 @@ import com.todoroo.astrid.utility.Preferences; * @author Tim Su * */ -public class ProducteevDetailExposer extends BroadcastReceiver implements DetailExposer{ +public class ProducteevDetailExposer extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { @@ -52,7 +51,6 @@ public class ProducteevDetailExposer extends BroadcastReceiver implements Detail context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ); } - @Override public String getTaskDetails(Context context, long id, boolean extended) { Metadata metadata = ProducteevDataService.getInstance().getTaskMetadata(id); if(metadata == null) @@ -133,9 +131,4 @@ public class ProducteevDetailExposer extends BroadcastReceiver implements Detail return null; } - @Override - public String getPluginIdentifier() { - return ProducteevUtilities.IDENTIFIER; - } - } diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevFilterExposer.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevFilterExposer.java index a5bc993a0..384547c5c 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevFilterExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevFilterExposer.java @@ -3,8 +3,8 @@ */ package com.todoroo.astrid.producteev; -import java.util.Map.Entry; import java.util.TreeMap; +import java.util.Map.Entry; import android.content.BroadcastReceiver; import android.content.ContentValues; @@ -39,7 +39,7 @@ public class ProducteevFilterExposer extends BroadcastReceiver { /** * @param context */ - private Filter filterFromList(Context context, ProducteevDashboard dashboard) { + public static Filter filterFromList(Context context, ProducteevDashboard dashboard) { String dashboardTitle = dashboard.getName(); String title = dashboard.getName(); ContentValues values = new ContentValues(); diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java index f73a39823..6d3e0e669 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java @@ -41,6 +41,10 @@ public class ProducteevUtilities extends SyncProviderUtilities { public static final String PREF_SERVER_LAST_SYNC = IDENTIFIER + "_last_server"; //$NON-NLS-1$ + public static final String PREF_SERVER_LAST_NOTIFICATION = IDENTIFIER + "_last_notification"; //$NON-NLS-1$ + + public static final String PREF_SERVER_LAST_ACTIVITY = IDENTIFIER + "_last_activity"; //$NON-NLS-1$ + /** Producteev user's default dashboard. This is different from the * preference key, which indicates where user wants to put new tasks */ public static final String PREF_DEFAULT_DASHBOARD = IDENTIFIER + "_defaultdash"; //$NON-NLS-1$ diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/api/ProducteevInvoker.java b/astrid/plugin-src/com/todoroo/astrid/producteev/api/ProducteevInvoker.java index 1448456b9..349ca292a 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/api/ProducteevInvoker.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/api/ProducteevInvoker.java @@ -111,6 +111,31 @@ public class ProducteevInvoker { "since", since), "dashboards"); } + /** + * create a dasbhoard + * + * @param name + * @return the new created dashboard as JSONObject + */ + public JSONObject dashboardsCreate(String name) throws ApiServiceException, IOException { + return callAuthenticated("dashboards/create.json", + "token", token, + "title", name); + } + + /** + * return the list of users who can access a specific dashboard + * + * @param idDashboard + * @param dashboard array-information about the dashboard, if this ... + */ + public JSONArray dashboardsAccess(long idDashboard, String dashboard) throws ApiServiceException, IOException { + return getResponse(callAuthenticated("dashboards/access.json", + "token", token, + "id_dashboard", idDashboard, + "dashboard", dashboard),"dashboard"); + } + // --- tasks /** @@ -217,14 +242,16 @@ public class ProducteevInvoker { * * @param idTask * @param deadline + * @param allDay (optional), 1: all day task (time specified in deadline will be ignored), 0: deadline with time * * @return array tasks/view */ - public JSONObject tasksSetDeadline(long idTask, String deadline) throws ApiServiceException, IOException { + public JSONObject tasksSetDeadline(long idTask, String deadline, Integer allDay) throws ApiServiceException, IOException { return callAuthenticated("tasks/set_deadline.json", "token", token, "id_task", idTask, - "deadline", deadline); + "deadline", deadline, + "all_day", allDay); } /** @@ -374,44 +401,49 @@ public class ProducteevInvoker { "title", title); } - // --- users + // --- notifications/activities /** - * get a user + * get every activities * - * @param idColleague - * - * @return array information about the user + * @param dashboardId (optional) if not null, this function only returns notifications for this specific dashboard + * @param lastId (optional) this function returns only activities later than this id */ - public JSONObject usersView(Long idColleague) throws ApiServiceException, IOException { - return callAuthenticated("users/view.json", + public JSONArray activitiesShowActivities(Long dashboardId, Long lastId) throws ApiResponseParseException, ApiServiceException, IOException { + return getResponse(callAuthenticated("activities/show_activities.json", "token", token, - "id_colleague", idColleague); + "id_dashboard", dashboardId, + "last_id", lastId), "activities"); } /** - * create a dasbhoard - * - * @param name - * @return the new created dashboard as JSONObject + * get every notification for the current user + * @param dashboardId + * @param lastId + * @return + * @throws ApiResponseParseException + * @throws ApiServiceException + * @throws IOException */ - public JSONObject dashboardsCreate(String name) throws ApiServiceException, IOException { - return callAuthenticated("dashboards/create.json", - "token", token, - "title", name); + public JSONArray activitiesShowNotifications(Long dashboardId, Long lastId) throws ApiResponseParseException, ApiServiceException, IOException { + return getResponse(callAuthenticated("activities/show_notifications.json", + "token", token, + "id_dashboard", dashboardId, + "last_id", lastId), "activities"); } + // --- users /** - * return the list of users who can access a specific dashboard + * get a user * - * @param idDashboard - * @param dashboard array-information about the dashboard, if this ... + * @param idColleague + * + * @return array information about the user */ - public JSONArray dashboardsAccess(long idDashboard, String dashboard) throws ApiServiceException, IOException { - return getResponse(callAuthenticated("dashboards/access.json", - "token", token, - "id_dashboard", idDashboard, - "dashboard", dashboard),"dashboard"); + public JSONObject usersView(Long idColleague) throws ApiServiceException, IOException { + return callAuthenticated("users/view.json", + "token", token, + "id_colleague", idColleague); } // --- invocation diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevDataService.java b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevDataService.java index 50df90fc8..19ca28fec 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevDataService.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevDataService.java @@ -20,15 +20,17 @@ import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Join; import com.todoroo.andlib.sql.Query; -import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria; +import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.dao.StoreObjectDao; -import com.todoroo.astrid.dao.StoreObjectDao.StoreObjectCriteria; import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria; +import com.todoroo.astrid.dao.StoreObjectDao.StoreObjectCriteria; import com.todoroo.astrid.dao.TaskDao.TaskCriteria; import com.todoroo.astrid.model.Metadata; import com.todoroo.astrid.model.StoreObject; import com.todoroo.astrid.model.Task; import com.todoroo.astrid.producteev.ProducteevUtilities; +import com.todoroo.astrid.producteev.api.ApiUtilities; import com.todoroo.astrid.rmilk.data.MilkNote; import com.todoroo.astrid.service.MetadataService; import com.todoroo.astrid.tags.TagService; @@ -81,6 +83,7 @@ public final class ProducteevDataService { metadataService.deleteWhere(Metadata.KEY.eq(ProducteevTask.METADATA_KEY)); metadataService.deleteWhere(Metadata.KEY.eq(ProducteevNote.METADATA_KEY)); storeObjectDao.deleteWhere(StoreObject.TYPE.eq(ProducteevDashboard.TYPE)); + PluginServices.getTaskService().clearDetails(); } /** @@ -272,15 +275,15 @@ public final class ProducteevDataService { local = new StoreObject(); local.setValue(StoreObject.TYPE, ProducteevDashboard.TYPE); local.setValue(ProducteevDashboard.REMOTE_ID, id); - local.setValue(ProducteevDashboard.NAME, remote.getString("title")); + local.setValue(ProducteevDashboard.NAME, ApiUtilities.decode(remote.getString("title"))); StringBuilder users = new StringBuilder(); JSONArray accessList = remote.getJSONArray("accesslist"); for(int j = 0; j < accessList.length(); j++) { JSONObject user = accessList.getJSONObject(j).getJSONObject("user"); users.append(user.getLong("id_user")).append(','); - String name = user.optString("firstname", "") + ' ' + - user.optString("lastname", ""); + String name = ApiUtilities.decode(user.optString("firstname", "") + ' ' + + user.optString("lastname", "")); users.append(name.trim()).append(';'); } local.setValue(ProducteevDashboard.USERS, users.toString()); diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java index 2677d198f..35622814e 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java @@ -28,16 +28,21 @@ import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.service.ExceptionService; +import com.todoroo.andlib.service.NotificationManager; import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.DialogUtilities; +import com.todoroo.astrid.activity.ShortcutActivity; import com.todoroo.astrid.api.AstridApiConstants; +import com.todoroo.astrid.api.Filter; +import com.todoroo.astrid.api.TaskContainer; import com.todoroo.astrid.common.SyncProvider; import com.todoroo.astrid.common.TaskContainer; import com.todoroo.astrid.model.Metadata; import com.todoroo.astrid.model.StoreObject; import com.todoroo.astrid.model.Task; import com.todoroo.astrid.producteev.ProducteevBackgroundService; +import com.todoroo.astrid.producteev.ProducteevFilterExposer; import com.todoroo.astrid.producteev.ProducteevLoginActivity; import com.todoroo.astrid.producteev.ProducteevPreferences; import com.todoroo.astrid.producteev.ProducteevUtilities; @@ -48,6 +53,7 @@ import com.todoroo.astrid.producteev.api.ProducteevInvoker; import com.todoroo.astrid.rmilk.data.MilkNote; import com.todoroo.astrid.service.AstridDependencyInjector; import com.todoroo.astrid.tags.TagService; +import com.todoroo.astrid.utility.Constants; import com.todoroo.astrid.utility.Preferences; @SuppressWarnings("nls") @@ -213,6 +219,8 @@ public class ProducteevSyncProvider extends SyncProvider 0) { + lastNotificationId = ""+notifications.getJSONObject(0).getJSONObject("activity").getLong("id_activity"); + } + + // display notifications from producteev-log + Context context = ContextManager.getContext(); + final NotificationManager nm = new NotificationManager.AndroidNotificationManager(context); + for (int i = 0; i< notificationsList.length; i++) { + long id_dashboard = notifications.getJSONObject(i).getJSONObject("activity").getLong("id_dashboard"); + String dashboardName = null; + StoreObject[] dashboardsData = ProducteevDataService.getInstance().getDashboards(); + ProducteevDashboard dashboard = null; + if (dashboardsData != null) { + for (int j=0; i]+>", ""); + PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); + notification.setLatestEventInfo(context, contentTitle, message, contentIntent); + + nm.notify(Constants.NOTIFICATION_PRODUCTEEV_NOTIFICATIONS-i, notification); + } + } + + // store lastIds in Preferences + Preferences.setString(ProducteevUtilities.PREF_SERVER_LAST_NOTIFICATION, lastNotificationId); + Preferences.setString(ProducteevUtilities.PREF_SERVER_LAST_ACTIVITY, lastActivityId); + FlurryAgent.onEvent("pdv-sync-finished"); //$NON-NLS-1$ } catch (IllegalStateException e) { // occurs when application was closed @@ -268,6 +326,23 @@ public class ProducteevSyncProvider extends SyncProvider * */ -public class RepeatDetailExposer extends BroadcastReceiver implements DetailExposer { +public class RepeatDetailExposer extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { @@ -119,7 +118,6 @@ public class RepeatDetailExposer extends BroadcastReceiver implements DetailExpo return null; } - @Override public String getPluginIdentifier() { return RepeatsPlugin.IDENTIFIER; } diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkDetailExposer.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkDetailExposer.java index 6f0eebdd4..4348f354d 100644 --- a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkDetailExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkDetailExposer.java @@ -11,7 +11,6 @@ import com.timsu.astrid.R; import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.astrid.adapter.TaskAdapter; import com.todoroo.astrid.api.AstridApiConstants; -import com.todoroo.astrid.api.DetailExposer; import com.todoroo.astrid.model.Metadata; import com.todoroo.astrid.rmilk.data.MilkDataService; import com.todoroo.astrid.rmilk.data.MilkNote; @@ -26,7 +25,7 @@ import com.todoroo.astrid.rmilk.data.MilkTask; * @author Tim Su * */ -public class MilkDetailExposer extends BroadcastReceiver implements DetailExposer{ +public class MilkDetailExposer extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { @@ -51,7 +50,6 @@ public class MilkDetailExposer extends BroadcastReceiver implements DetailExpose context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ); } - @Override public String getTaskDetails(Context context, long id, boolean extended) { Metadata metadata = MilkDataService.getInstance().getTaskMetadata(id); if(metadata == null) @@ -92,9 +90,4 @@ public class MilkDetailExposer extends BroadcastReceiver implements DetailExpose return result.substring(0, result.length() - TaskAdapter.DETAIL_SEPARATOR.length()); } - @Override - public String getPluginIdentifier() { - return MilkUtilities.IDENTIFIER; - } - } diff --git a/astrid/plugin-src/com/todoroo/astrid/tags/TagDetailExposer.java b/astrid/plugin-src/com/todoroo/astrid/tags/TagDetailExposer.java index 21172fe2e..a4f0b26fe 100644 --- a/astrid/plugin-src/com/todoroo/astrid/tags/TagDetailExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/tags/TagDetailExposer.java @@ -8,7 +8,6 @@ import android.content.Context; import android.content.Intent; import com.todoroo.astrid.api.AstridApiConstants; -import com.todoroo.astrid.api.DetailExposer; /** * Exposes Task Detail for tags, i.e. "Tags: frogs, animals" @@ -16,7 +15,7 @@ import com.todoroo.astrid.api.DetailExposer; * @author Tim Su * */ -public class TagDetailExposer extends BroadcastReceiver implements DetailExposer { +public class TagDetailExposer extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { @@ -39,7 +38,6 @@ public class TagDetailExposer extends BroadcastReceiver implements DetailExposer context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ); } - @Override public String getTaskDetails(Context context, long id, boolean extended) { if(extended) return null; @@ -51,9 +49,4 @@ public class TagDetailExposer extends BroadcastReceiver implements DetailExposer return " " + tagList; //$NON-NLS-1$ } - @Override - public String getPluginIdentifier() { - return TagsPlugin.IDENTIFIER; - } - } diff --git a/astrid/plugin-src/com/todoroo/astrid/timers/TimerDecorationExposer.java b/astrid/plugin-src/com/todoroo/astrid/timers/TimerDecorationExposer.java index 499f78e64..45b5159ac 100644 --- a/astrid/plugin-src/com/todoroo/astrid/timers/TimerDecorationExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/timers/TimerDecorationExposer.java @@ -11,6 +11,7 @@ import android.content.Intent; import android.graphics.Color; import android.os.SystemClock; import android.text.format.DateUtils; +import android.view.View; import android.widget.RemoteViews; import com.timsu.astrid.R; @@ -33,8 +34,12 @@ public class TimerDecorationExposer extends BroadcastReceiver { private static HashMap decorations = new HashMap(); - public static void removeFromCache(long taskId) { + private static HashMap tasksNeedingUpdate = + new HashMap(); + + public static void updateTimer(long taskId) { decorations.remove(taskId); + tasksNeedingUpdate.put(taskId, true); } @Override @@ -45,11 +50,15 @@ public class TimerDecorationExposer extends BroadcastReceiver { Task task; try { - task = PluginServices.getTaskService().fetchById(taskId, Task.ELAPSED_SECONDS, Task.TIMER_START); + if(tasksNeedingUpdate.containsKey(taskId)) + task = PluginServices.getTaskService().fetchById(taskId, Task.ID, Task.ELAPSED_SECONDS, Task.TIMER_START); + else + task = intent.getParcelableExtra("model"); //$NON-NLS-1$ } catch (IllegalStateException e) { return; } - if(task == null || (task.getValue(Task.ELAPSED_SECONDS) == 0 && + + if(task == null || task.getId() != taskId || (task.getValue(Task.ELAPSED_SECONDS) == 0 && task.getValue(Task.TIMER_START) == 0)) return; @@ -70,12 +79,16 @@ public class TimerDecorationExposer extends BroadcastReceiver { elapsed += DateUtilities.now() - task.getValue(Task.TIMER_START); decoration.decoration.setChronometer(R.id.timer, SystemClock.elapsedRealtime() - elapsed, null, true); + decoration.decoration.setViewVisibility(R.id.timer, View.VISIBLE); + decoration.decoration.setViewVisibility(R.id.label, View.GONE); } else { // if timer is not started, make the chronometer just a text label, // since we don't want the time to be displayed relative to elapsed String format = buildFormat(elapsed); - decoration.decoration.setChronometer(R.id.timer, SystemClock.elapsedRealtime() - - elapsed, format, false); + decoration.color = 0; + decoration.decoration.setTextViewText(R.id.label, format); + decoration.decoration.setViewVisibility(R.id.timer, View.GONE); + decoration.decoration.setViewVisibility(R.id.label, View.VISIBLE); } diff --git a/astrid/plugin-src/com/todoroo/astrid/timers/TimerPlugin.java b/astrid/plugin-src/com/todoroo/astrid/timers/TimerPlugin.java index 9a437ee2d..ab1439959 100644 --- a/astrid/plugin-src/com/todoroo/astrid/timers/TimerPlugin.java +++ b/astrid/plugin-src/com/todoroo/astrid/timers/TimerPlugin.java @@ -53,7 +53,7 @@ public class TimerPlugin extends BroadcastReceiver { } } PluginServices.getTaskService().save(task); - TimerDecorationExposer.removeFromCache(task.getId()); + TimerDecorationExposer.updateTimer(task.getId()); // transmit new intents Intent intent = new Intent(AstridApiConstants.BROADCAST_REQUEST_ACTIONS); diff --git a/astrid/res/drawable/ic_producteev_notification.png b/astrid/res/drawable/ic_producteev_notification.png new file mode 100644 index 000000000..368ae96b6 Binary files /dev/null and b/astrid/res/drawable/ic_producteev_notification.png differ diff --git a/astrid/res/drawable/icon_producteev.png b/astrid/res/drawable/icon_producteev.png index 51d8f09f0..5901763ca 100644 Binary files a/astrid/res/drawable/icon_producteev.png and b/astrid/res/drawable/icon_producteev.png differ diff --git a/astrid/res/layout/task_adapter_row.xml b/astrid/res/layout/task_adapter_row.xml index 40c201cac..5dcf7f89d 100644 --- a/astrid/res/layout/task_adapter_row.xml +++ b/astrid/res/layout/task_adapter_row.xml @@ -8,13 +8,13 @@ android:paddingBottom="4dip" android:paddingLeft="4dip" android:paddingRight="4dip" - android:minHeight="40dip" android:orientation="vertical"> @@ -62,6 +62,7 @@ + android:paddingLeft="4dip" + android:orientation="horizontal"> + +