diff --git a/astrid/AndroidManifest.xml b/astrid/AndroidManifest.xml index 14f52fdd3..ad27b7629 100644 --- a/astrid/AndroidManifest.xml +++ b/astrid/AndroidManifest.xml @@ -84,10 +84,10 @@ - @@ -313,6 +313,7 @@ diff --git a/astrid/default.properties b/astrid/default.properties index dab739e94..c5d5335ee 100644 --- a/astrid/default.properties +++ b/astrid/default.properties @@ -10,5 +10,5 @@ # Indicates whether an apk should be generated for each density. split.density=false # Project target. -target=Motorola, Inc.:MILESTONE:7 +target=android-8 apk-configurations= diff --git a/astrid/plugin-src/com/todoroo/astrid/backup/BackupService.java b/astrid/plugin-src/com/todoroo/astrid/backup/BackupService.java index ca863e271..205b8936d 100644 --- a/astrid/plugin-src/com/todoroo/astrid/backup/BackupService.java +++ b/astrid/plugin-src/com/todoroo/astrid/backup/BackupService.java @@ -15,6 +15,7 @@ import android.util.Log; import com.timsu.astrid.R; import com.todoroo.andlib.service.ContextManager; +import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.utility.Preferences; /** @@ -44,9 +45,11 @@ public class BackupService extends Service { @Override public void onStart(Intent intent, int startId) { - if (intent.getAction().equals(BACKUP_ACTION)) { + try { ContextManager.setContext(this); startBackup(this); + } catch (Exception e) { + PluginServices.getExceptionService().reportError("backup-bg-sync", e); //$NON-NLS-1$ } } diff --git a/astrid/plugin-src/com/todoroo/astrid/common/SyncProviderPreferences.java b/astrid/plugin-src/com/todoroo/astrid/common/SyncProviderPreferences.java index f5095963a..0c90c8499 100644 --- a/astrid/plugin-src/com/todoroo/astrid/common/SyncProviderPreferences.java +++ b/astrid/plugin-src/com/todoroo/astrid/common/SyncProviderPreferences.java @@ -91,18 +91,18 @@ abstract public class SyncProviderPreferences extends TodorooPreferences { if (r.getString(getUtilities().getSyncIntervalKey()).equals( preference.getKey())) { int index = AndroidUtilities.indexOf( - r.getStringArray(R.array.rmilk_MPr_interval_values), + r.getStringArray(R.array.sync_SPr_interval_values), (String) value); if (index <= 0) preference.setSummary(R.string.sync_SPr_interval_desc_disabled); else preference.setSummary(r.getString( R.string.sync_SPr_interval_desc, - r.getStringArray(R.array.rmilk_MPr_interval_entries)[index])); + r.getStringArray(R.array.sync_SPr_interval_entries)[index])); } // status - else if (r.getString(R.string.rmilk_MPr_status_key).equals(preference.getKey())) { + else if (r.getString(R.string.sync_SPr_status_key).equals(preference.getKey())) { boolean loggedIn = getUtilities().isLoggedIn(); String status; String subtitle = ""; //$NON-NLS-1$ @@ -168,7 +168,7 @@ abstract public class SyncProviderPreferences extends TodorooPreferences { } // sync button - else if (r.getString(R.string.rmilk_MPr_sync_key).equals(preference.getKey())) { + else if (r.getString(R.string.sync_SPr_sync_key).equals(preference.getKey())) { boolean loggedIn = getUtilities().isLoggedIn(); preference.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference p) { @@ -182,12 +182,12 @@ abstract public class SyncProviderPreferences extends TodorooPreferences { } // log out button - else if (r.getString(R.string.rmilk_MPr_forget_key).equals(preference.getKey())) { + else if (r.getString(R.string.sync_SPr_forget_key).equals(preference.getKey())) { boolean loggedIn = getUtilities().isLoggedIn(); preference.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference p) { dialogUtilities.okCancelDialog(SyncProviderPreferences.this, - r.getString(R.string.rmilk_forget_confirm), new OnClickListener() { + r.getString(R.string.sync_forget_confirm), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { diff --git a/astrid/plugin-src/com/todoroo/astrid/gcal/GCalControlSet.java b/astrid/plugin-src/com/todoroo/astrid/gcal/GCalControlSet.java index 8b295c729..70f4380bb 100644 --- a/astrid/plugin-src/com/todoroo/astrid/gcal/GCalControlSet.java +++ b/astrid/plugin-src/com/todoroo/astrid/gcal/GCalControlSet.java @@ -10,15 +10,15 @@ import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; -import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.view.View.OnClickListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; -import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.Spinner; import android.widget.Toast; +import android.widget.CompoundButton.OnCheckedChangeListener; import com.flurry.android.FlurryAgent; import com.timsu.astrid.R; @@ -93,7 +93,7 @@ public class GCalControlSet implements TaskEditControlSet { Intent intent = new Intent(Intent.ACTION_EDIT, calendarUri); try { - if(cursor.getCount() == 0) { + if(cursor == null || cursor.getCount() == 0) { // event no longer exists, recreate it calendarUri = null; writeToModel(myTask); @@ -106,7 +106,8 @@ public class GCalControlSet implements TaskEditControlSet { Log.e("gcal-error", "Error opening calendar", e); //$NON-NLS-1$ //$NON-NLS-2$ Toast.makeText(activity, R.string.gcal_TEA_error, Toast.LENGTH_LONG); } finally { - cursor.close(); + if(cursor != null) + cursor.close(); } activity.startActivity(intent); diff --git a/astrid/plugin-src/com/todoroo/astrid/locale/LocaleEditAlerts.java b/astrid/plugin-src/com/todoroo/astrid/locale/LocaleEditAlerts.java index e3b2870c7..3a203723f 100644 --- a/astrid/plugin-src/com/todoroo/astrid/locale/LocaleEditAlerts.java +++ b/astrid/plugin-src/com/todoroo/astrid/locale/LocaleEditAlerts.java @@ -186,6 +186,9 @@ public final class LocaleEditAlerts extends ExpandableListActivity { .setPositiveButton(android.R.string.ok, AddOnActivity.createAddOnClicker(LocaleEditAlerts.this, true)) .show(); + FlurryAgent.onEvent("locale-edit-alerts-no-plugin"); //$NON-NLS-1$ + } else { + FlurryAgent.onEvent("locale-edit-alerts"); //$NON-NLS-1$ } } diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevBackgroundService.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevBackgroundService.java index 05bea95cd..667d425d2 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevBackgroundService.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevBackgroundService.java @@ -11,6 +11,7 @@ import android.util.Log; import com.timsu.astrid.R; import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.utility.DateUtilities; +import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.producteev.sync.ProducteevSyncProvider; import com.todoroo.astrid.utility.Preferences; @@ -35,8 +36,11 @@ public class ProducteevBackgroundService extends Service { /** Receive the alarm - start the synchronize service! */ @Override public void onStart(Intent intent, int startId) { - if(intent != null && SYNC_ACTION.equals(intent.getAction())) + try { startSynchronization(this); + } catch (Exception e) { + PluginServices.getExceptionService().reportError("pdv-bg-sync", e); //$NON-NLS-1$ + } } /** Start the actual synchronization */ @@ -49,6 +53,7 @@ public class ProducteevBackgroundService extends Service { if(ProducteevUtilities.INSTANCE.isOngoing()) return; + PluginServices.getTaskService(); new ProducteevSyncProvider().synchronize(context); } diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevFilterExposer.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevFilterExposer.java index ea5fd583b..6b442e407 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevFilterExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevFilterExposer.java @@ -3,10 +3,14 @@ */ package com.todoroo.astrid.producteev; +import java.util.TreeMap; +import java.util.Map.Entry; + import android.content.BroadcastReceiver; import android.content.ContentValues; import android.content.Context; import android.content.Intent; +import android.util.Pair; import com.timsu.astrid.R; import com.todoroo.andlib.sql.Criterion; @@ -32,10 +36,8 @@ import com.todoroo.astrid.producteev.sync.ProducteevTask; */ public class ProducteevFilterExposer extends BroadcastReceiver { - @SuppressWarnings("nls") private Filter filterFromList(Context context, ProducteevDashboard dashboard) { - String dashboardTitle = context.getString(R.string.producteev_FEx_dashboard_item). - replace("$N", dashboard.getName()); + String dashboardTitle = dashboard.getName(); String title = context.getString(R.string.producteev_FEx_dashboard_title, dashboard.getName()); ContentValues values = new ContentValues(); values.put(Metadata.KEY.name, ProducteevTask.METADATA_KEY); @@ -54,6 +56,25 @@ public class ProducteevFilterExposer extends BroadcastReceiver { return filter; } + private Filter filterFromUser(Context context, String user, Pair ids) { + String title = context.getString(R.string.producteev_FEx_responsible_title, user); + ContentValues values = new ContentValues(); + values.put(Metadata.KEY.name, ProducteevTask.METADATA_KEY); + values.put(ProducteevTask.DASHBOARD_ID.name, ids.first); + values.put(ProducteevTask.ID.name, 0); + values.put(ProducteevTask.CREATOR_ID.name, 0); + values.put(ProducteevTask.RESPONSIBLE_ID.name, ids.second); + Filter filter = new Filter(user, title, new QueryTemplate().join( + ProducteevDataService.METADATA_JOIN).where(Criterion.and( + MetadataCriteria.withKey(ProducteevTask.METADATA_KEY), + TaskCriteria.isActive(), + TaskCriteria.isVisible(), + ProducteevTask.RESPONSIBLE_ID.eq(ids.second))), + values); + + return filter; + } + @Override public void onReceive(Context context, Intent intent) { // if we aren't logged in, don't expose features @@ -62,26 +83,60 @@ public class ProducteevFilterExposer extends BroadcastReceiver { StoreObject[] dashboards = ProducteevDataService.getInstance().getDashboards(); - // If user does not have any tags, don't show this section at all + // If user does not have any dashboards, don't show this section at all if(dashboards.length == 0) return; + FilterListHeader producteevHeader = new FilterListHeader(context.getString(R.string.producteev_FEx_header)); + + // load dashboards Filter[] dashboardFilters = new Filter[dashboards.length]; for(int i = 0; i < dashboards.length; i++) dashboardFilters[i] = filterFromList(context, new ProducteevDashboard(dashboards[i])); - - FilterListHeader producteevHeader = new FilterListHeader(context.getString(R.string.producteev_FEx_header)); FilterCategory producteevDashboards = new FilterCategory(context.getString(R.string.producteev_FEx_dashboard), dashboardFilters); + // load responsible people + TreeMap> people = loadResponsiblePeople(dashboards); + Filter[] peopleFilters = new Filter[people.size()]; + int index = 0; + for(Entry> person : people.entrySet()) + peopleFilters[index++] = filterFromUser(context, person.getKey(), person.getValue()); + FilterCategory producteevUsers = new FilterCategory(context.getString(R.string.producteev_FEx_responsible), + peopleFilters); + // transmit filter list - FilterListItem[] list = new FilterListItem[2]; + FilterListItem[] list = new FilterListItem[3]; list[0] = producteevHeader; list[1] = producteevDashboards; + list[2] = producteevUsers; Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_FILTERS); broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, ProducteevUtilities.IDENTIFIER); broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, list); context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ); } + /** + * @param dashboards + * @return people in a map of name => pair(dashboard id, user id) + */ + @SuppressWarnings("nls") + private TreeMap> loadResponsiblePeople( + StoreObject[] dashboards) { + TreeMap> results = new TreeMap>(); + for(StoreObject dashboard : dashboards) { + String users = dashboard.getValue(ProducteevDashboard.USERS); + String[] entries = users.split(";"); + for(String entry : entries) { + String[] data = entry.split(","); + if(data.length != 2) + continue; + results.put(data[1], new Pair( + dashboard.getValue(ProducteevDashboard.REMOTE_ID), data[0])); // name, id + } + } + + return results; + } + } 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 3c11c4afc..5461247ee 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java @@ -163,8 +163,8 @@ public class ProducteevSyncProvider extends SyncProvider @@ -11,74 +10,76 @@ import org.json.JSONObject; @SuppressWarnings("nls") public class ProducteevUser { - private final long id; - - private final String email; + private final long id; - private final String firstname; + private final String email; - private final String lastname; + private final String firstname; - public ProducteevUser(long id, String email, String firstname, String lastname) { - this.id = id; - this.email = email; - this.firstname = firstname; - this.lastname = lastname; - } + private final String lastname; - public ProducteevUser(JSONObject elt) throws JSONException { - this.id = elt.getLong("id"); - this.email = elt.getString("email"); - this.firstname = elt.getString("firstname"); - this.lastname = elt.getString("lastname"); - } + public ProducteevUser(long id, String email, String firstname, + String lastname) { + this.id = id; + this.email = email; + this.firstname = firstname; + this.lastname = lastname; + } - /** - * @return the email - */ -public String getEmail() { - return email; -} + public ProducteevUser(JSONObject elt) throws JSONException { + this.id = elt.getLong("id"); + this.email = elt.getString("email"); + this.firstname = elt.getString("firstname"); + this.lastname = elt.getString("lastname"); + } -/** - * @return the firstname - */ -public String getFirstname() { - return firstname; -} + /** + * @return the email + */ + public String getEmail() { + return email; + } -/** - * @return the lastname - */ -public String getLastname() { - return lastname; -} + /** + * @return the firstname + */ + public String getFirstname() { + return firstname; + } -/** - * @return the id - */ -public long getId() { - return id; - } + /** + * @return the lastname + */ + public String getLastname() { + return lastname; + } -@Override -public String toString() { - String displayString = ""; - boolean hasFirstname = false; - boolean hasLastname = false; - if (firstname != null && firstname.length() > 0) { - displayString += firstname; - hasFirstname = true; + /** + * @return the id + */ + public long getId() { + return id; } - if (lastname != null && lastname.length() > 0) - hasLastname = true; - if (hasFirstname && hasLastname) - displayString += " "; - if (hasLastname) - displayString += lastname; - if (!hasFirstname && !hasLastname && email != null && email.length() > 0) - displayString += email; - return displayString; -} + @Override + public String toString() { + String displayString = ""; + boolean hasFirstname = false; + boolean hasLastname = false; + if (firstname != null && firstname.length() > 0) { + displayString += firstname; + hasFirstname = true; + } + if (lastname != null && lastname.length() > 0) + hasLastname = true; + if (hasFirstname && hasLastname) + displayString += " "; + if (hasLastname) + displayString += lastname; + + if (!hasFirstname && !hasLastname && email != null + && email.length() > 0) + displayString += email; + return displayString; + } } diff --git a/astrid/plugin-src/com/todoroo/astrid/repeats/RepeatTaskCompleteListener.java b/astrid/plugin-src/com/todoroo/astrid/repeats/RepeatTaskCompleteListener.java index f1934471e..4742a493a 100644 --- a/astrid/plugin-src/com/todoroo/astrid/repeats/RepeatTaskCompleteListener.java +++ b/astrid/plugin-src/com/todoroo/astrid/repeats/RepeatTaskCompleteListener.java @@ -124,10 +124,14 @@ public class RepeatTaskCompleteListener extends BroadcastReceiver { if(nextDate instanceof DateTimeValueImpl) { DateTimeValueImpl newDateTime = (DateTimeValueImpl)nextDate; + Date date = new Date(Date.UTC(newDateTime.year() - 1900, newDateTime.month() - 1, + newDateTime.day(), newDateTime.hour(), + newDateTime.minute(), newDateTime.second())); + // time may be inaccurate due to DST, force time to be same + date.setHours(repeatFromDate.getHours()); + date.setMinutes(repeatFromDate.getMinutes()); newDueDate = task.createDueDate(Task.URGENCY_SPECIFIC_DAY_TIME, - Date.UTC(newDateTime.year() - 1900, newDateTime.month() - 1, - newDateTime.day(), newDateTime.hour(), - newDateTime.minute(), newDateTime.second())); + date.getTime()); } else { newDueDate = task.createDueDate(Task.URGENCY_SPECIFIC_DAY, new Date(nextDate.year() - 1900, nextDate.month() - 1, diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkBackgroundService.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkBackgroundService.java index 50144084a..33f1a2f2f 100644 --- a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkBackgroundService.java +++ b/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkBackgroundService.java @@ -11,6 +11,7 @@ import android.util.Log; import com.timsu.astrid.R; import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.utility.DateUtilities; +import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.rmilk.sync.RTMSyncProvider; import com.todoroo.astrid.utility.Preferences; @@ -35,8 +36,11 @@ public class MilkBackgroundService extends Service { /** Receive the alarm - start the synchronize service! */ @Override public void onStart(Intent intent, int startId) { - if(SYNC_ACTION.equals(intent.getAction())) + try { startSynchronization(this); + } catch (Exception e) { + PluginServices.getExceptionService().reportError("rtm-bg-sync", e); //$NON-NLS-1$ + } } /** Start the actual synchronization */ @@ -49,6 +53,7 @@ public class MilkBackgroundService extends Service { if(MilkUtilities.isOngoing()) return; + PluginServices.getTaskService(); new RTMSyncProvider().synchronize(context); } diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkPreferences.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkPreferences.java index 6e78b5301..865e59b78 100644 --- a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkPreferences.java +++ b/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkPreferences.java @@ -3,8 +3,8 @@ package com.todoroo.astrid.rmilk; import java.util.Date; import android.content.DialogInterface; -import android.content.DialogInterface.OnClickListener; import android.content.Intent; +import android.content.DialogInterface.OnClickListener; import android.content.res.Resources; import android.graphics.Color; import android.os.Bundle; @@ -78,18 +78,18 @@ public class MilkPreferences extends TodorooPreferences { if (r.getString(R.string.rmilk_MPr_interval_key).equals( preference.getKey())) { int index = AndroidUtilities.indexOf( - r.getStringArray(R.array.rmilk_MPr_interval_values), + r.getStringArray(R.array.sync_SPr_interval_values), (String) value); if (index <= 0) preference.setSummary(R.string.sync_SPr_interval_desc_disabled); else preference.setSummary(r.getString( R.string.sync_SPr_interval_desc, - r.getStringArray(R.array.rmilk_MPr_interval_entries)[index])); + r.getStringArray(R.array.sync_SPr_interval_entries)[index])); } // status - else if (r.getString(R.string.rmilk_MPr_status_key).equals(preference.getKey())) { + else if (r.getString(R.string.sync_SPr_status_key).equals(preference.getKey())) { boolean loggedIn = MilkUtilities.isLoggedIn(); String status; String subtitle = ""; //$NON-NLS-1$ @@ -155,7 +155,7 @@ public class MilkPreferences extends TodorooPreferences { } // sync button - else if (r.getString(R.string.rmilk_MPr_sync_key).equals(preference.getKey())) { + else if (r.getString(R.string.sync_SPr_sync_key).equals(preference.getKey())) { boolean loggedIn = MilkUtilities.isLoggedIn(); preference.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference p) { @@ -169,12 +169,12 @@ public class MilkPreferences extends TodorooPreferences { } // log out button - else if (r.getString(R.string.rmilk_MPr_forget_key).equals(preference.getKey())) { + else if (r.getString(R.string.sync_SPr_forget_key).equals(preference.getKey())) { boolean loggedIn = MilkUtilities.isLoggedIn(); preference.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference p) { dialogUtilities.okCancelDialog(MilkPreferences.this, - r.getString(R.string.rmilk_forget_confirm), new OnClickListener() { + r.getString(R.string.sync_forget_confirm), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMSyncProvider.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMSyncProvider.java index 489e019dc..777fae37b 100644 --- a/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMSyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMSyncProvider.java @@ -36,21 +36,21 @@ import com.todoroo.astrid.common.SyncProvider; import com.todoroo.astrid.model.Metadata; import com.todoroo.astrid.model.Task; import com.todoroo.astrid.rmilk.MilkLoginActivity; -import com.todoroo.astrid.rmilk.MilkLoginActivity.SyncLoginCallback; import com.todoroo.astrid.rmilk.MilkPreferences; import com.todoroo.astrid.rmilk.MilkUtilities; +import com.todoroo.astrid.rmilk.MilkLoginActivity.SyncLoginCallback; import com.todoroo.astrid.rmilk.api.ApplicationInfo; import com.todoroo.astrid.rmilk.api.ServiceImpl; import com.todoroo.astrid.rmilk.api.ServiceInternalException; -import com.todoroo.astrid.rmilk.api.data.RtmAuth.Perms; import com.todoroo.astrid.rmilk.api.data.RtmList; import com.todoroo.astrid.rmilk.api.data.RtmLists; import com.todoroo.astrid.rmilk.api.data.RtmTask; -import com.todoroo.astrid.rmilk.api.data.RtmTask.Priority; import com.todoroo.astrid.rmilk.api.data.RtmTaskList; import com.todoroo.astrid.rmilk.api.data.RtmTaskNote; import com.todoroo.astrid.rmilk.api.data.RtmTaskSeries; import com.todoroo.astrid.rmilk.api.data.RtmTasks; +import com.todoroo.astrid.rmilk.api.data.RtmAuth.Perms; +import com.todoroo.astrid.rmilk.api.data.RtmTask.Priority; import com.todoroo.astrid.rmilk.data.MilkDataService; import com.todoroo.astrid.rmilk.data.MilkNote; import com.todoroo.astrid.service.AstridDependencyInjector; @@ -212,10 +212,14 @@ public class RTMSyncProvider extends SyncProvider { } }); intent.putExtra(MilkLoginActivity.URL_TOKEN, url); + if(context instanceof Activity) ((Activity)context).startActivityForResult(intent, 0); - else - context.startActivity(intent); + else { + // can't synchronize until user logs in + MilkUtilities.setToken(null); + MilkUtilities.stopOngoing(); + } } else { performSync(); diff --git a/astrid/plugin-src/com/todoroo/astrid/tags/TagsControlSet.java b/astrid/plugin-src/com/todoroo/astrid/tags/TagsControlSet.java index 1c0bb5ec9..4154e6e83 100644 --- a/astrid/plugin-src/com/todoroo/astrid/tags/TagsControlSet.java +++ b/astrid/plugin-src/com/todoroo/astrid/tags/TagsControlSet.java @@ -86,7 +86,7 @@ public final class TagsControlSet implements TaskEditControlSet { if(loadedTags.length <= i || !loadedTags[i].equals(tag)) identical = false; } - if(identical && tags.size() != loadedTags.length) + if(loadedTags == null || tags.size() != loadedTags.length) identical = false; if(!identical) { diff --git a/astrid/res/layout/task_adapter_row.xml b/astrid/res/layout/task_adapter_row.xml index de54bce1c..40c201cac 100644 --- a/astrid/res/layout/task_adapter_row.xml +++ b/astrid/res/layout/task_adapter_row.xml @@ -19,7 +19,7 @@ diff --git a/astrid/res/layout/task_list_activity.xml b/astrid/res/layout/task_list_activity.xml index d3f6edc47..8dc5c3531 100644 --- a/astrid/res/layout/task_list_activity.xml +++ b/astrid/res/layout/task_list_activity.xml @@ -27,12 +27,13 @@ diff --git a/astrid/res/layout/task_list_activity_api3.xml b/astrid/res/layout/task_list_activity_api3.xml index f952be010..94adb83ca 100644 --- a/astrid/res/layout/task_list_activity_api3.xml +++ b/astrid/res/layout/task_list_activity_api3.xml @@ -10,7 +10,7 @@ @@ -22,19 +22,18 @@ android:layout_weight="1" android:src="@drawable/tango_filters" android:scaleType="center" - android:paddingTop="8dip" android:paddingLeft="5dip" android:paddingRight="5dip"/> diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml index 89a23d4cf..332190f37 100644 --- a/astrid/res/values/keys.xml +++ b/astrid/res/values/keys.xml @@ -178,10 +178,10 @@ p_def_hide - + - - + + 0 900 1800 @@ -195,14 +195,16 @@ - rmilk_status + sync_status - sync_bgwifi + sync_bgwifi - rmilk_sync + sync_sync - rmilk_forget + sync_forget + + sync_freq diff --git a/astrid/res/values/strings-producteev.xml b/astrid/res/values/strings-producteev.xml index ef9d1b684..6b368884e 100644 --- a/astrid/res/values/strings-producteev.xml +++ b/astrid/res/values/strings-producteev.xml @@ -4,23 +4,20 @@ - - W: %s - - - R: %s - Producteev - Producteev Workspaces + Workspaces + + + %s - - $N + + Assigned To - Workspace \'%s\' + Assigned To \'%s\' diff --git a/astrid/res/values/strings-rmilk.xml b/astrid/res/values/strings-rmilk.xml index 5ea47d3b3..1724c50fb 100644 --- a/astrid/res/values/strings-rmilk.xml +++ b/astrid/res/values/strings-rmilk.xml @@ -47,7 +47,7 @@ - Status + Status Not Logged In! @@ -73,24 +73,41 @@ Currently set to: %s - Wifi Only Setting + Wifi Only Setting - Background synchronization only happens when on Wifi + Background synchronization only happens when on Wifi - Background synchronization will always occur + Background synchronization will always occur - Actions + Actions - Synchronize Now! + Synchronize Now! - Log In & Synchronize! + Log In & Synchronize! - Log Out + Log Out - Clears all synchronization data + Clears all synchronization data + + + Log out / clear synchronization data? + + + + disable + every fifteen minutes + every thirty minutes + every hour + every three hours + every six hours + every twelve hours + every day + every three days + every week + @@ -109,27 +126,9 @@ Error Message: %s Astrid: Remember the Milk - - Log out / clear synchronization data? - Connection Error! Check your Internet connection, or maybe RTM servers (status.rememberthemilk.com), for possible solutions. - - - - disable - every fifteen minutes - every thirty minutes - every hour - every three hours - every six hours - every twelve hours - every day - every three days - every week - - - + diff --git a/astrid/res/values/styles.xml b/astrid/res/values/styles.xml index b6a87e59e..5f7b9fb81 100644 --- a/astrid/res/values/styles.xml +++ b/astrid/res/values/styles.xml @@ -25,7 +25,7 @@ diff --git a/astrid/res/xml/preferences_producteev.xml b/astrid/res/xml/preferences_producteev.xml index 7f41c5b19..7c7627ce7 100644 --- a/astrid/res/xml/preferences_producteev.xml +++ b/astrid/res/xml/preferences_producteev.xml @@ -7,7 +7,7 @@ @@ -19,7 +19,7 @@ diff --git a/astrid/res/xml/preferences_rmilk.xml b/astrid/res/xml/preferences_rmilk.xml index 8640087bc..537f4e168 100644 --- a/astrid/res/xml/preferences_rmilk.xml +++ b/astrid/res/xml/preferences_rmilk.xml @@ -7,7 +7,7 @@ @@ -19,7 +19,7 @@ @@ -28,11 +28,11 @@ android:title="@string/sync_SPr_group_actions"> diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java index 888b20a26..37863d774 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java @@ -191,6 +191,12 @@ public class TaskListActivity extends ListActivity implements OnScrollListener, database.openForWriting(); setUpUiComponents(); + onNewIntent(getIntent()); + } + + @Override + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); setUpTaskList(); if(Constants.DEBUG) setTitle("[D] " + filter.title); //$NON-NLS-1$ @@ -264,7 +270,6 @@ public class TaskListActivity extends ListActivity implements OnScrollListener, Intent intent = new Intent(TaskListActivity.this, FilterListActivity.class); startActivity(intent); - finish(); } }); @@ -495,6 +500,7 @@ public class TaskListActivity extends ListActivity implements OnScrollListener, super.onActivityResult(requestCode, resultCode, data); if(resultCode != RESULT_CANCELED) { + taskAdapter.flushCaches(); loadTaskListContent(true); taskService.cleanup(); } @@ -870,7 +876,6 @@ public class TaskListActivity extends ListActivity implements OnScrollListener, Intent intent = new Intent(TaskListActivity.this, FilterListActivity.class); startActivity(intent); - finish(); } } diff --git a/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java b/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java index 1455605f2..a36f16fab 100644 --- a/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java +++ b/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java @@ -18,12 +18,12 @@ import android.text.Html; import android.text.Html.ImageGetter; import android.text.util.Linkify; import android.view.ContextMenu; -import android.view.ContextMenu.ContextMenuInfo; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; +import android.view.ContextMenu.ContextMenuInfo; import android.view.View.OnClickListener; import android.view.View.OnCreateContextMenuListener; -import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.widget.Button; import android.widget.CheckBox; @@ -42,6 +42,7 @@ import com.todoroo.andlib.service.ExceptionService; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.SoftHashMap; import com.todoroo.astrid.activity.TaskEditActivity; +import com.todoroo.astrid.activity.TaskListActivity; import com.todoroo.astrid.alarms.AlarmDetailExposer; import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.DetailExposer; @@ -557,7 +558,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable { public void onClick(View arg0) { Intent intent = new Intent(activity, TaskEditActivity.class); intent.putExtra(TaskEditActivity.TOKEN_ID, taskId); - activity.startActivity(intent); + activity.startActivityForResult(intent, TaskListActivity.ACTIVITY_EDIT_TASK); } }); editButton.setLayoutParams(params); @@ -786,7 +787,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable { * @return list if there was already one */ protected synchronized Collection initialize(long taskId) { - if(cache.containsKey(taskId)) + if(cache.containsKey(taskId) && cache.get(taskId) != null) return get(taskId); cache.put(taskId, new HashMap()); return null; diff --git a/astrid/src/com/todoroo/astrid/dao/TaskDao.java b/astrid/src/com/todoroo/astrid/dao/TaskDao.java index bbe18991d..debbf747a 100644 --- a/astrid/src/com/todoroo/astrid/dao/TaskDao.java +++ b/astrid/src/com/todoroo/astrid/dao/TaskDao.java @@ -154,8 +154,10 @@ public class TaskDao extends GenericDao { boolean saveSuccessful; ContentValues values = task.getSetValues(); - if(values == null || values.size() == 0) - return false; + if(values == null || values.size() == 0) { + if(task.getDatabaseValues() != null) + return false; + } if (task.getId() == Task.NO_ID) { saveSuccessful = createNew(task); diff --git a/astrid/src/com/todoroo/astrid/widget/TasksWidget.java b/astrid/src/com/todoroo/astrid/widget/TasksWidget.java index f74ae2dc7..576f1fb65 100644 --- a/astrid/src/com/todoroo/astrid/widget/TasksWidget.java +++ b/astrid/src/com/todoroo/astrid/widget/TasksWidget.java @@ -175,6 +175,7 @@ public class TasksWidget extends AppWidgetProvider { } Intent listIntent = new Intent(context, TaskListActivity.class); + listIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); if(filter != null) { listIntent.putExtra(TaskListActivity.TOKEN_FILTER, filter); listIntent.setType(filter.sqlQuery); @@ -184,6 +185,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); if(filter != null && filter.valuesForNewTasks != null) { String values = AndroidUtilities.contentValuesToSerializedString(filter.valuesForNewTasks); editIntent.putExtra(TaskEditActivity.TOKEN_VALUES, values); diff --git a/astrid/src/com/todoroo/astrid/widget/WidgetConfigActivity.java b/astrid/src/com/todoroo/astrid/widget/WidgetConfigActivity.java index 9fce15efb..6f2284796 100644 --- a/astrid/src/com/todoroo/astrid/widget/WidgetConfigActivity.java +++ b/astrid/src/com/todoroo/astrid/widget/WidgetConfigActivity.java @@ -9,12 +9,14 @@ import android.view.View; import android.widget.Button; import android.widget.ExpandableListView; +import com.flurry.android.FlurryAgent; import com.timsu.astrid.R; import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.astrid.adapter.FilterAdapter; import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.FilterCategory; import com.todoroo.astrid.api.FilterListItem; +import com.todoroo.astrid.utility.Constants; import com.todoroo.astrid.utility.Preferences; public class WidgetConfigActivity extends ExpandableListActivity { @@ -56,6 +58,8 @@ public class WidgetConfigActivity extends ExpandableListActivity { Button button = (Button)findViewById(R.id.ok); button.setOnClickListener(mOnClickListener); + + FlurryAgent.onEvent("widget-config"); //$NON-NLS-1$ } View.OnClickListener mOnClickListener = new View.OnClickListener() { @@ -115,6 +119,18 @@ public class WidgetConfigActivity extends ExpandableListActivity { adapter.unregisterRecevier(); } + @Override + protected void onStart() { + super.onStart(); + FlurryAgent.onStartSession(this, Constants.FLURRY_KEY); + } + + @Override + protected void onStop() { + super.onStop(); + FlurryAgent.onEndSession(this); + } + private void saveConfiguration(FilterListItem filterListItem) { String sql = null, contentValuesString = null, title = null;