From de43051ee15efe6bfe3434d41e4b5d7230f13b01 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Thu, 19 Aug 2010 12:44:12 -0700 Subject: [PATCH 01/10] Adding 'created by' detail to producteev tasks, fix for not fully logging out, don't read null's from database --- .../todoroo/andlib/data/AbstractModel.java | 7 +++- .../producteev/ProducteevDetailExposer.java | 33 +++++++++++++++---- .../sync/ProducteevSyncProvider.java | 1 + astrid/res/values/strings-producteev.xml | 3 ++ 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/astrid/common-src/com/todoroo/andlib/data/AbstractModel.java b/astrid/common-src/com/todoroo/andlib/data/AbstractModel.java index 7bba4e675..cd3a3f6db 100644 --- a/astrid/common-src/com/todoroo/andlib/data/AbstractModel.java +++ b/astrid/common-src/com/todoroo/andlib/data/AbstractModel.java @@ -338,7 +338,12 @@ public abstract class AbstractModel implements Parcelable { public synchronized void save(Property property, ContentValues newStore, Object value) { this.store = newStore; - property.accept(this, value); + + // we don't allow null values, as they indicate unset properties + // when the database was written + + if(value != null) + property.accept(this, value); } public Void visitDouble(Property property, Object value) { diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java index 5362eaa45..aecd45464 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java @@ -7,6 +7,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import com.timsu.astrid.R; import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.astrid.adapter.TaskAdapter; import com.todoroo.astrid.api.AstridApiConstants; @@ -64,6 +65,9 @@ public class ProducteevDetailExposer extends BroadcastReceiver implements Detail long responsibleId = -1; if(metadata.containsNonNullValue(ProducteevTask.RESPONSIBLE_ID)) responsibleId = metadata.getValue(ProducteevTask.RESPONSIBLE_ID); + long creatorId = -1; + if(metadata.containsNonNullValue(ProducteevTask.CREATOR_ID)) + responsibleId = metadata.getValue(ProducteevTask.CREATOR_ID); // display dashboard if not "no sync" or "default" StoreObject ownerDashboard = null; @@ -86,14 +90,21 @@ public class ProducteevDetailExposer extends BroadcastReceiver implements Detail // display responsible user if not current one if(responsibleId > 0 && ownerDashboard != null && responsibleId != Preferences.getLong(ProducteevUtilities.PREF_USER_ID, 0L)) { - String users = ";" + ownerDashboard.getValue(ProducteevDashboard.USERS); //$NON-NLS-1$ - int index = users.indexOf(";" + responsibleId + ","); //$NON-NLS-1$ //$NON-NLS-2$ - if(index > -1) { - String user = users.substring(users.indexOf(',', index) + 1, - users.indexOf(';', index + 1)); + String user = getUserFromDashboard(ownerDashboard, responsibleId); + if(user != null) builder.append(" ").append(user).append(TaskAdapter.DETAIL_SEPARATOR); //$NON-NLS-1$ - } } + + // display creator user if not the current one + if(creatorId > 0 && ownerDashboard != null && creatorId != + Preferences.getLong(ProducteevUtilities.PREF_USER_ID, 0L)) { + String user = getUserFromDashboard(ownerDashboard, responsibleId); + if(user != null) + builder.append(" ").append( //$NON-NLS-1$ + context.getString(R.string.producteev_PDE_task_from, user)). + append(TaskAdapter.DETAIL_SEPARATOR); + } + } else { TodorooCursor notesCursor = ProducteevDataService.getInstance().getTaskNotesCursor(id); try { @@ -112,6 +123,16 @@ public class ProducteevDetailExposer extends BroadcastReceiver implements Detail return result.substring(0, result.length() - TaskAdapter.DETAIL_SEPARATOR.length()); } + /** Try and find user in the dashboard. return null if un-findable */ + private String getUserFromDashboard(StoreObject dashboard, long userId) { + String users = ";" + dashboard.getValue(ProducteevDashboard.USERS); //$NON-NLS-1$ + int index = users.indexOf(";" + userId + ","); //$NON-NLS-1$ //$NON-NLS-2$ + if(index > -1) + return users.substring(users.indexOf(',', index) + 1, + users.indexOf(';', index + 1)); + return null; + } + @Override public String getPluginIdentifier() { return ProducteevUtilities.IDENTIFIER; 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 29dbdcd12..dc0f653a0 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java @@ -85,6 +85,7 @@ public class ProducteevSyncProvider extends SyncProvider dashboardname) --> Assigned To \'%s\' + + + from %s From ed8efb1e223a1034f571e67d74b094df29dd3d99 Mon Sep 17 00:00:00 2001 From: Arne Jans Date: Thu, 19 Aug 2010 10:01:52 +0800 Subject: [PATCH 02/10] dashboards can now be created and assigned from within astrid. setting responsible person is now sent to server, too (fixin missing parameter in invoker.tasksCreate) --- .../producteev/ProducteevControlSet.java | 84 +++++++++++++++++-- .../producteev/ProducteevUtilities.java | 3 + .../producteev/api/ProducteevInvoker.java | 14 +++- .../producteev/sync/ProducteevDashboard.java | 2 +- .../sync/ProducteevDataService.java | 70 +++++++++------- .../sync/ProducteevSyncProvider.java | 4 +- astrid/res/values/strings-producteev.xml | 9 ++ 7 files changed, 146 insertions(+), 40 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevControlSet.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevControlSet.java index dc7cbd2a9..86e6de628 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevControlSet.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevControlSet.java @@ -2,27 +2,35 @@ package com.todoroo.astrid.producteev; import java.util.ArrayList; +import org.json.JSONObject; + import android.app.Activity; +import android.app.ProgressDialog; +import android.content.DialogInterface; +import android.content.DialogInterface.OnClickListener; import android.util.Log; 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; import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.utility.DateUtilities; +import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.astrid.activity.TaskEditActivity.TaskEditControlSet; import com.todoroo.astrid.model.Metadata; import com.todoroo.astrid.model.StoreObject; import com.todoroo.astrid.model.Task; import com.todoroo.astrid.producteev.sync.ProducteevDashboard; import com.todoroo.astrid.producteev.sync.ProducteevDataService; +import com.todoroo.astrid.producteev.sync.ProducteevSyncProvider; import com.todoroo.astrid.producteev.sync.ProducteevTask; import com.todoroo.astrid.producteev.sync.ProducteevUser; import com.todoroo.astrid.service.MetadataService; @@ -38,6 +46,7 @@ public class ProducteevControlSet implements TaskEditControlSet { // --- instance variables private final Activity activity; + private final DialogUtilities dialogUtilites; private final View view; private Task myTask; @@ -54,6 +63,8 @@ public class ProducteevControlSet implements TaskEditControlSet { DependencyInjectionService.getInstance().inject(this); this.activity = activity; + this.dialogUtilites = new DialogUtilities(); + view = LayoutInflater.from(activity).inflate(R.layout.producteev_control, parent, true); this.responsibleSelector = (Spinner) activity.findViewById(R.id.producteev_TEA_task_assign); @@ -67,9 +78,65 @@ public class ProducteevControlSet implements TaskEditControlSet { @Override public void onItemSelected(AdapterView spinnerParent, View spinnerView, int position, long id) { - Spinner dashSelector = (Spinner) spinnerParent; + final Spinner dashSelector = (Spinner) spinnerParent; ProducteevDashboard dashboard = (ProducteevDashboard) dashSelector.getSelectedItem(); - refreshResponsibleSpinner(dashboard.getUsers()); + if (dashboard.getId() == ProducteevUtilities.DASHBOARD_CREATE) { + // let the user create a new dashboard + final EditText editor = new EditText(ProducteevControlSet.this.activity); + OnClickListener okListener = new OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + Activity context = ProducteevControlSet.this.activity; + String newDashboardName = editor.getText().toString(); + if (newDashboardName == null || newDashboardName.length() == 0) { + dialog.cancel(); + } else { + // create the real dashboard, select it in the spinner and refresh responsiblespinner + ProgressDialog progressDialog = null; + try { + progressDialog = dialogUtilites.progressDialog(context, + context.getString(R.string.DLG_wait)); + JSONObject newDashJSON = ProducteevSyncProvider.getInvoker().dashboardsCreate(newDashboardName).getJSONObject("dashboard"); + StoreObject local = ProducteevDataService.getInstance().updateDashboards(newDashJSON, true); + if (local != null) { + ProducteevDashboard newDashboard = new ProducteevDashboard(local); + ArrayAdapter adapter = (ArrayAdapter) dashSelector.getAdapter(); + adapter.insert(newDashboard, adapter.getCount()-1); + dashSelector.setSelection(adapter.getCount()-2); + refreshResponsibleSpinner(newDashboard.getUsers()); + dialogUtilites.dismissDialog(context, progressDialog); + } + } catch (Exception e) { + dialogUtilites.dismissDialog(context, progressDialog); + dialogUtilites.okDialog(context, + context.getString(R.string.DLG_error, e.getMessage()), + new OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }); + e.printStackTrace(); + dashSelector.setSelection(0); + } + } + + } + }; + OnClickListener cancelListener = new OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.cancel(); + } + }; + dialogUtilites.viewDialog(ProducteevControlSet.this.activity, + ProducteevControlSet.this.activity.getString(R.string.producteev_create_dashboard_name), + editor, + okListener, + cancelListener); + } else { + refreshResponsibleSpinner(dashboard.getUsers()); + } } @Override @@ -140,8 +207,8 @@ public class ProducteevControlSet implements TaskEditControlSet { ProducteevDashboard ownerDashboard = null; int dashboardSpinnerIndex = -1; - //dashboard to not sync as first spinner-entry - for (int i=0;i dashAdapter = new ArrayAdapter(activity, android.R.layout.simple_spinner_item, dashboards); @@ -157,7 +228,8 @@ public class ProducteevControlSet implements TaskEditControlSet { dashboardSelector.setAdapter(dashAdapter); dashboardSelector.setSelection(dashboardSpinnerIndex+1); - if (ownerDashboard == null || ownerDashboard.getId() == ProducteevUtilities.DASHBOARD_NO_SYNC) { + if (ownerDashboard == null || ownerDashboard.getId() == ProducteevUtilities.DASHBOARD_NO_SYNC + || ownerDashboard.getId() == ProducteevUtilities.DASHBOARD_CREATE) { responsibleSelector.setEnabled(false); responsibleSelector.setAdapter(null); view.findViewById(R.id.producteev_TEA_task_assign_label).setVisibility(View.GONE); diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java index 391e96ef7..f73a39823 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java @@ -18,6 +18,9 @@ public class ProducteevUtilities extends SyncProviderUtilities { public static final ProducteevUtilities INSTANCE = new ProducteevUtilities(); + /** setting for dashboard to getting created */ + public static final int DASHBOARD_CREATE = -2; + /** setting for dashboard to not synchronize */ public static final int DASHBOARD_NO_SYNC = -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 d7d8899bd..1448456b9 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/api/ProducteevInvoker.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/api/ProducteevInvoker.java @@ -389,6 +389,18 @@ public class ProducteevInvoker { "id_colleague", idColleague); } + /** + * 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 * @@ -396,7 +408,7 @@ public class ProducteevInvoker { * @param dashboard array-information about the dashboard, if this ... */ public JSONArray dashboardsAccess(long idDashboard, String dashboard) throws ApiServiceException, IOException { - return getResponse(callAuthenticated("dashboards/access", + return getResponse(callAuthenticated("dashboards/access.json", "token", token, "id_dashboard", idDashboard, "dashboard", dashboard),"dashboard"); diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevDashboard.java b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevDashboard.java index 2deefe8cf..5c763d3c3 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevDashboard.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevDashboard.java @@ -38,7 +38,7 @@ public class ProducteevDashboard { private ArrayList users = null; public ProducteevDashboard (StoreObject dashboardData) { - this(dashboardData.getValue(REMOTE_ID),dashboardData.getValue(NAME),dashboardData.getValue(USERS)); + this(dashboardData.getValue(REMOTE_ID),dashboardData.getValue(NAME),(dashboardData.containsValue(USERS)?dashboardData.getValue(USERS):null)); } /** 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 086da27c6..429873d50 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevDataService.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevDataService.java @@ -243,41 +243,49 @@ public final class ProducteevDataService { readDashboards(); for(int i = 0; i < changedDashboards.length(); i++) { JSONObject remote = changedDashboards.getJSONObject(i).getJSONObject("dashboard"); - long id = remote.getLong("id_dashboard"); - StoreObject local = null; - for(StoreObject dashboard : dashboards) { - if(dashboard.getValue(ProducteevDashboard.REMOTE_ID).equals(id)) { - local = dashboard; - break; - } - } + updateDashboards(remote, false); + } - if(remote.getInt("deleted") != 0) { - if(local != null) - storeObjectDao.delete(local.getId()); - continue; - } + // clear dashboard cache + dashboards = null; + } - if(local == null) - local = new StoreObject(); - local.setValue(StoreObject.TYPE, ProducteevDashboard.TYPE); - local.setValue(ProducteevDashboard.REMOTE_ID, id); - local.setValue(ProducteevDashboard.NAME, 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", ""); - users.append(name.trim()).append(';'); + public StoreObject updateDashboards(JSONObject remote, boolean reinitCache) throws JSONException { + if (reinitCache) + readDashboards(); + long id = remote.getLong("id_dashboard"); + StoreObject local = null; + for(StoreObject dashboard : dashboards) { + if(dashboard.getValue(ProducteevDashboard.REMOTE_ID).equals(id)) { + local = dashboard; + break; } - local.setValue(ProducteevDashboard.USERS, users.toString()); - storeObjectDao.persist(local); } - // clear dashboard cache - dashboards = null; + if(remote.getInt("deleted") != 0) { + if(local != null) + storeObjectDao.delete(local.getId()); + } + + if(local == null) + local = new StoreObject(); + local.setValue(StoreObject.TYPE, ProducteevDashboard.TYPE); + local.setValue(ProducteevDashboard.REMOTE_ID, id); + local.setValue(ProducteevDashboard.NAME, 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", ""); + users.append(name.trim()).append(';'); + } + local.setValue(ProducteevDashboard.USERS, users.toString()); + storeObjectDao.persist(local); + if (reinitCache) + dashboards = null; + return local; } } \ No newline at end of file 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 29dbdcd12..a1558ba1f 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java @@ -255,6 +255,7 @@ public class ProducteevSyncProvider extends SyncProvider Do Not Synchronize + + Add new Workspace... + + + Name for new Workspace + + + new + Default Workspace From 535de14436fb800431cbddae7583f1bb5d0e6459 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Thu, 19 Aug 2010 12:49:20 -0700 Subject: [PATCH 03/10] Update default dashboard preference from setting on server --- .../astrid/producteev/sync/ProducteevSyncProvider.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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 dc0f653a0..7272746ef 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java @@ -86,6 +86,8 @@ public class ProducteevSyncProvider extends SyncProvider Date: Thu, 19 Aug 2010 12:56:19 -0700 Subject: [PATCH 04/10] Fixes to make created user thing work --- .../producteev/ProducteevDetailExposer.java | 6 +++--- astrid/res/drawable/silk_user_orange.png | Bin 0 -> 723 bytes astrid/res/values/strings-producteev.xml | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) create mode 100644 astrid/res/drawable/silk_user_orange.png diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java index aecd45464..545a3f822 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java @@ -67,7 +67,7 @@ public class ProducteevDetailExposer extends BroadcastReceiver implements Detail responsibleId = metadata.getValue(ProducteevTask.RESPONSIBLE_ID); long creatorId = -1; if(metadata.containsNonNullValue(ProducteevTask.CREATOR_ID)) - responsibleId = metadata.getValue(ProducteevTask.CREATOR_ID); + creatorId = metadata.getValue(ProducteevTask.CREATOR_ID); // display dashboard if not "no sync" or "default" StoreObject ownerDashboard = null; @@ -98,9 +98,9 @@ public class ProducteevDetailExposer extends BroadcastReceiver implements Detail // display creator user if not the current one if(creatorId > 0 && ownerDashboard != null && creatorId != Preferences.getLong(ProducteevUtilities.PREF_USER_ID, 0L)) { - String user = getUserFromDashboard(ownerDashboard, responsibleId); + String user = getUserFromDashboard(ownerDashboard, creatorId); if(user != null) - builder.append(" ").append( //$NON-NLS-1$ + builder.append(" ").append( //$NON-NLS-1$ context.getString(R.string.producteev_PDE_task_from, user)). append(TaskAdapter.DETAIL_SEPARATOR); } diff --git a/astrid/res/drawable/silk_user_orange.png b/astrid/res/drawable/silk_user_orange.png new file mode 100644 index 0000000000000000000000000000000000000000..b818127df6d064b71838c377063c2c61517ffa01 GIT binary patch literal 723 zcmV;^0xbQBP);;gl19bUZW9UV z`6Oe&D>N3I2!D7k!S=E!5k8{~b0eJ$-hrpkmhM4q_TKS3xu-U*DrgiQkCtD|&{)Kw z@Y#D|sM?1v(NTuw+G9~;gkF>7r@fcvAL6bMNOH4SHtFf+&$reAQ(9oG0r-#&XpVt; zwjWeGA5_mtP@kGGS{;rD7cyToc?57@T!%c%&QP z>aIXviD1DmFpC6~TPvYA&@c4r2o@DPG2gNsKKT}SnxZi$-wKaxGjqDFCKA(cs$jUD zK=}p3EtktoW$}xSd+TAlO-niit75HYV^|!9{)%KDovB*!3KJ?}M6W0 Name for new Workspace - - new - Default Workspace From 548fb1cf74d71f54d49153255aeff86d749bdd45 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Thu, 19 Aug 2010 12:59:01 -0700 Subject: [PATCH 05/10] If user cancels new dashboard creation, bring 'em back to old selection --- .../com/todoroo/astrid/producteev/ProducteevControlSet.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevControlSet.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevControlSet.java index 86e6de628..29293bc62 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; @@ -59,6 +59,8 @@ public class ProducteevControlSet implements TaskEditControlSet { @Autowired MetadataService metadataService; + private int lastDashboardSelection = 0; + public ProducteevControlSet(final Activity activity, ViewGroup parent) { DependencyInjectionService.getInstance().inject(this); @@ -127,6 +129,7 @@ public class ProducteevControlSet implements TaskEditControlSet { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); + dashboardSelector.setSelection(lastDashboardSelection); } }; dialogUtilites.viewDialog(ProducteevControlSet.this.activity, @@ -136,6 +139,7 @@ public class ProducteevControlSet implements TaskEditControlSet { cancelListener); } else { refreshResponsibleSpinner(dashboard.getUsers()); + lastDashboardSelection = position; } } From 68c87404ab5dd04bfce9636383459f10e15b2d2b Mon Sep 17 00:00:00 2001 From: Tim Su Date: Thu, 19 Aug 2010 13:03:33 -0700 Subject: [PATCH 06/10] Always sync all dashboards, instead of just recently changed ones. Seems like a reasonable thing to do - small amount of data increase, prevents out of sync bugs --- .../todoroo/astrid/producteev/sync/ProducteevSyncProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6aaf73858..550acf9ea 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java @@ -208,7 +208,7 @@ public class ProducteevSyncProvider extends SyncProvider Date: Thu, 19 Aug 2010 13:08:13 -0700 Subject: [PATCH 07/10] we weren't syncing responsible person. Now we are. --- .../astrid/producteev/sync/ProducteevSyncProvider.java | 7 +++++++ 1 file changed, 7 insertions(+) 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 550acf9ea..01477f110 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java @@ -398,6 +398,7 @@ public class ProducteevSyncProvider extends SyncProvider Date: Thu, 19 Aug 2010 13:29:00 -0700 Subject: [PATCH 08/10] Remoted a temporary property on ProducteevLoginActivity, change 'Notes' -> 'Add a Comment' in taskedit with producteev --- astrid/AndroidManifest.xml | 6 +----- astrid/res/layout/task_edit_activity.xml | 4 ++-- astrid/res/values/strings-producteev.xml | 3 +++ .../src/com/todoroo/astrid/activity/TaskEditActivity.java | 3 +++ 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/astrid/AndroidManifest.xml b/astrid/AndroidManifest.xml index 452ff2be2..d1d28d495 100644 --- a/astrid/AndroidManifest.xml +++ b/astrid/AndroidManifest.xml @@ -337,11 +337,7 @@ - - - - + android:theme="@style/Theme" /> diff --git a/astrid/res/layout/task_edit_activity.xml b/astrid/res/layout/task_edit_activity.xml index 5691e1d23..54c4f24f7 100644 --- a/astrid/res/layout/task_edit_activity.xml +++ b/astrid/res/layout/task_edit_activity.xml @@ -81,8 +81,8 @@ android:background="@android:drawable/divider_horizontal_dark" /> - person name) --> from %s + + + Add a Comment diff --git a/astrid/src/com/todoroo/astrid/activity/TaskEditActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskEditActivity.java index f52d5020b..97e17d0e4 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskEditActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskEditActivity.java @@ -58,6 +58,7 @@ import android.widget.LinearLayout; import android.widget.RemoteViews; import android.widget.Spinner; import android.widget.TabHost; +import android.widget.TextView; import android.widget.TimePicker; import android.widget.Toast; import android.widget.ToggleButton; @@ -253,6 +254,8 @@ public final class TaskEditActivity extends TabActivity { AddOn producteevAddon = addOnService.getAddOn(AddOnService.PRODUCTEEV_PACKAGE, "Producteev"); //$NON-NLS-1$ if (addOnService.isInstalled(producteevAddon) && ProducteevUtilities.INSTANCE.isLoggedIn()) { controls.add(new ProducteevControlSet(this, addonsAddons)); + ((TextView)findViewById(R.id.notes)).setHint(R.string.producteev_TEA_notes); + ((TextView)findViewById(R.id.notes_label)).setHint(R.string.producteev_TEA_notes); } } catch (Exception e) { Log.e("astrid-error", "loading-control-set", e); //$NON-NLS-1$ //$NON-NLS-2$ From e98cbacae8ff3bbb64043905c7499ab5ac87052b Mon Sep 17 00:00:00 2001 From: Tim Su Date: Thu, 19 Aug 2010 13:32:59 -0700 Subject: [PATCH 09/10] launching activities from widget resets task --- astrid/src/com/todoroo/astrid/widget/TasksWidget.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/astrid/src/com/todoroo/astrid/widget/TasksWidget.java b/astrid/src/com/todoroo/astrid/widget/TasksWidget.java index 388f10984..77e024963 100644 --- a/astrid/src/com/todoroo/astrid/widget/TasksWidget.java +++ b/astrid/src/com/todoroo/astrid/widget/TasksWidget.java @@ -178,7 +178,7 @@ public class TasksWidget extends AppWidgetProvider { } Intent listIntent = new Intent(context, TaskListActivity.class); - listIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + listIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); if(filter != null) { listIntent.putExtra(TaskListActivity.TOKEN_FILTER, filter); listIntent.setType(filter.sqlQuery); @@ -188,7 +188,7 @@ public class TasksWidget extends AppWidgetProvider { views.setOnClickPendingIntent(R.id.taskbody, pendingIntent); Intent editIntent = new Intent(context, TaskEditActivity.class); - editIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); + editIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); if(filter != null && filter.valuesForNewTasks != null) { String values = AndroidUtilities.contentValuesToSerializedString(filter.valuesForNewTasks); editIntent.putExtra(TaskEditActivity.TOKEN_VALUES, values); From 8bd90f325262dbc89d4b0d9a775d5b9ec52c8206 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Fri, 20 Aug 2010 01:12:59 -0700 Subject: [PATCH 10/10] catch a couple exceptions here and there, be better about varions error possibilities --- .../src/com/todoroo/astrid/activity/TaskEditActivity.java | 2 +- .../src/com/todoroo/astrid/activity/TaskListActivity.java | 5 +++++ astrid/src/com/todoroo/astrid/widget/TasksWidget.java | 7 ++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/astrid/src/com/todoroo/astrid/activity/TaskEditActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskEditActivity.java index 97e17d0e4..0f8d2881d 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskEditActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskEditActivity.java @@ -793,7 +793,7 @@ public final class TaskEditActivity extends TabActivity { Task.URGENCY_TOMORROW); String dayAfterTomorrow = DateUtils.getDayOfWeekString( new Date(DateUtilities.now() + 2 * DateUtilities.ONE_DAY).getDay() + - Calendar.SUNDAY, 0); + Calendar.SUNDAY, DateUtils.FORMAT_ABBREV_ALL); urgencyValues[3] = new UrgencyValue(dayAfterTomorrow, Task.URGENCY_DAY_AFTER); urgencyValues[4] = new UrgencyValue(labels[4], diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java index 2bbba4b56..a574089ca 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java @@ -78,6 +78,7 @@ import com.todoroo.astrid.reminders.ReminderService; import com.todoroo.astrid.reminders.ReminderService.AlarmScheduler; import com.todoroo.astrid.rmilk.MilkPreferences; import com.todoroo.astrid.service.AddOnService; +import com.todoroo.astrid.service.AstridDependencyInjector; import com.todoroo.astrid.service.MetadataService; import com.todoroo.astrid.service.StartupService; import com.todoroo.astrid.service.TaskService; @@ -161,6 +162,10 @@ public class TaskListActivity extends ListActivity implements OnScrollListener, * ======================================================= initialization * ====================================================================== */ + static { + AstridDependencyInjector.initialize(); + } + public TaskListActivity() { DependencyInjectionService.getInstance().inject(this); } diff --git a/astrid/src/com/todoroo/astrid/widget/TasksWidget.java b/astrid/src/com/todoroo/astrid/widget/TasksWidget.java index 77e024963..3f18083ec 100644 --- a/astrid/src/com/todoroo/astrid/widget/TasksWidget.java +++ b/astrid/src/com/todoroo/astrid/widget/TasksWidget.java @@ -51,12 +51,13 @@ public class TasksWidget extends AppWidgetProvider { int[] appWidgetIds) { try { + ContextManager.setContext(context); super.onUpdate(context, appWidgetManager, appWidgetIds); // Start in service to prevent Application Not Responding timeout updateWidgets(context); - } catch (SecurityException e) { - // :( + } catch (Exception e) { + Log.e("astrid-update-widget", "widget update error", e); //$NON-NLS-1$ } } @@ -65,7 +66,7 @@ public class TasksWidget extends AppWidgetProvider { * @param id */ public static void updateWidgets(Context context) { - context.startService(new Intent(ContextManager.getContext(), + context.startService(new Intent(context, TasksWidget.UpdateService.class)); }