diff --git a/api/res/values/keys.xml b/api/res/values/keys.xml
index ed660ae6b..1cb65b7e4 100644
--- a/api/res/values/keys.xml
+++ b/api/res/values/keys.xml
@@ -29,5 +29,7 @@
sync_sync
sync_forget
+
+ sync_options
diff --git a/api/res/values/strings.xml b/api/res/values/strings.xml
index 178a739e7..a98de36e0 100644
--- a/api/res/values/strings.xml
+++ b/api/res/values/strings.xml
@@ -155,8 +155,10 @@
Status
+
+ Status: %s
- Not Logged In!
+ Not Logged In
Sync Ongoing...
@@ -191,7 +193,7 @@
Actions
- Synchronize Now!
+ Synchronize Now
Log In & Synchronize!
diff --git a/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java b/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java
index 5e9bbb6aa..9cad00c1c 100644
--- a/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java
+++ b/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java
@@ -4,11 +4,13 @@ import java.util.Date;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
+import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
+import android.preference.PreferenceCategory;
import android.view.View;
import android.view.ViewGroup.OnHierarchyChangeListener;
@@ -30,6 +32,8 @@ abstract public class SyncProviderPreferences extends TodorooPreferenceActivity
// --- interface
+ public static final int RESULT_CODE_SYNCHRONIZE = 2;
+
/**
* @return your preference resource
*/
@@ -52,6 +56,8 @@ abstract public class SyncProviderPreferences extends TodorooPreferenceActivity
abstract public SyncProviderUtilities getUtilities();
+ protected static final int REQUEST_LOGIN = 0;
+
// --- implementation
private int statusColor = Color.BLACK;
@@ -106,18 +112,12 @@ abstract public class SyncProviderPreferences extends TodorooPreferenceActivity
else if (r.getString(R.string.sync_SPr_status_key).equals(preference.getKey())) {
boolean loggedIn = getUtilities().isLoggedIn();
String status;
- String subtitle = ""; //$NON-NLS-1$
+ //String subtitle = ""; //$NON-NLS-1$
// ! logged in - display message, click -> sync
if(!loggedIn) {
status = r.getString(R.string.sync_status_loggedout);
- statusColor = Color.RED;
- preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- public boolean onPreferenceClick(Preference p) {
- startSync();
- return true;
- }
- });
+ statusColor = Color.rgb(19, 132, 165);
}
// sync is occurring
else if(getUtilities().isOngoing()) {
@@ -134,9 +134,9 @@ abstract public class SyncProviderPreferences extends TodorooPreferenceActivity
statusColor = Color.rgb(100, 0, 0);
if(getUtilities().getLastSyncDate() > 0) {
- subtitle = r.getString(R.string.sync_status_failed_subtitle,
- DateUtilities.getDateStringWithTime(SyncProviderPreferences.this,
- new Date(getUtilities().getLastSyncDate())));
+// subtitle = r.getString(R.string.sync_status_failed_subtitle,
+// DateUtilities.getDateStringWithTime(SyncProviderPreferences.this,
+// new Date(getUtilities().getLastSyncDate())));
}
} else {
long lastSyncDate = getUtilities().getLastSyncDate();
@@ -146,14 +146,6 @@ abstract public class SyncProviderPreferences extends TodorooPreferenceActivity
status = r.getString(R.string.sync_status_errors, dateString);
statusColor = Color.rgb(100, 100, 0);
}
- preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- public boolean onPreferenceClick(Preference p) {
- String error = getUtilities().getLastError();
- if(error != null)
- DialogUtilities.okDialog(SyncProviderPreferences.this, error, null);
- return true;
- }
- });
}
else if(getUtilities().getLastSyncDate() > 0) {
status = r.getString(R.string.sync_status_success,
@@ -163,38 +155,21 @@ abstract public class SyncProviderPreferences extends TodorooPreferenceActivity
} else {
status = r.getString(R.string.sync_status_never);
statusColor = Color.rgb(0, 0, 100);
- preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- public boolean onPreferenceClick(Preference p) {
- startSync();
- return true;
- }
- });
}
- preference.setTitle(status);
- preference.setSummary(subtitle);
+ preference.setTitle(R.string.sync_SPr_sync);
+ preference.setSummary(r.getString(R.string.sync_SPr_status_subtitle, status));
- View view = findViewById(R.id.status);
- if(view != null)
- view.setBackgroundColor(statusColor);
- }
-
- // sync button
- 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) {
startSync();
return true;
}
});
- if(!loggedIn) {
- preference.setTitle(R.string.sync_SPr_sync_log_in);
- preference.setSummary("");
- }
- else
- preference.setSummary(r.getString(R.string.sync_SPr_logged_in_prefix) + " " + getUtilities().getLoggedInUserName());
- }
+ View view = findViewById(R.id.status);
+ if(view != null)
+ view.setBackgroundColor(statusColor);
+ }
// log out button
else if (r.getString(R.string.sync_SPr_forget_key).equals(preference.getKey())) {
boolean loggedIn = getUtilities().isLoggedIn();
@@ -212,8 +187,21 @@ abstract public class SyncProviderPreferences extends TodorooPreferenceActivity
return true;
}
});
- if(!loggedIn)
- preference.setEnabled(false);
+ if(!loggedIn) {
+ PreferenceCategory category = (PreferenceCategory) findPreference(r.getString(R.string.sync_SPr_key_options));
+ category.removePreference(preference);
+ }
+
+ }
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == REQUEST_LOGIN && resultCode == RESULT_OK) {
+ setResult(RESULT_CODE_SYNCHRONIZE);
+ finish();
+ } else {
+ super.onActivityResult(requestCode, resultCode, data);
}
}
diff --git a/astrid/AndroidManifest.xml b/astrid/AndroidManifest.xml
index 87b1dfda7..99c49c09d 100644
--- a/astrid/AndroidManifest.xml
+++ b/astrid/AndroidManifest.xml
@@ -1,8 +1,8 @@
+ android:versionName="4.0.2"
+ android:versionCode="253">
diff --git a/astrid/build.xml b/astrid/build.xml
index 704c26c0f..d4269f494 100644
--- a/astrid/build.xml
+++ b/astrid/build.xml
@@ -127,6 +127,10 @@
match="TASK_RABBIT_URL = .*"
replace="TASK_RABBIT_URL = "${apikey.taskrabbit.url}";" />
+
+
diff --git a/astrid/common-src/com/mdimension/jchronic/AstridChronic.java b/astrid/common-src/com/mdimension/jchronic/AstridChronic.java
index 137d4da71..1232f9786 100644
--- a/astrid/common-src/com/mdimension/jchronic/AstridChronic.java
+++ b/astrid/common-src/com/mdimension/jchronic/AstridChronic.java
@@ -17,7 +17,7 @@ import com.mdimension.jchronic.utils.Token;
@SuppressWarnings("nls")
public class AstridChronic {
-public static final String VERSION = "0.2.3";
+ public static final String VERSION = "0.2.3";
private AstridChronic() {
// DO NOTHING
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmCameraModule.java b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmCameraModule.java
index 33633dc5c..069c0e6a7 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmCameraModule.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmCameraModule.java
@@ -8,6 +8,7 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -74,12 +75,17 @@ public class ActFmCameraModule {
public static void showPictureLauncher(final Fragment fragment, final ClearImageCallback clearImageOption) {
ArrayList options = new ArrayList();
- options.add(fragment.getString(R.string.actfm_picture_camera));
+
+ final Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
+ PackageManager pm = fragment.getActivity().getPackageManager();
+ if(pm.queryIntentActivities(cameraIntent, 0).size() > 0)
+ options.add(fragment.getString(R.string.actfm_picture_camera));
+
options.add(fragment.getString(R.string.actfm_picture_gallery));
- if (clearImageOption != null) {
+ if (clearImageOption != null)
options.add(fragment.getString(R.string.actfm_picture_clear));
- }
+
ArrayAdapter adapter = new ArrayAdapter(fragment.getActivity(),
android.R.layout.simple_spinner_dropdown_item, options.toArray(new String[options.size()]));
@@ -89,11 +95,9 @@ public class ActFmCameraModule {
public void onClick(DialogInterface d, int which) {
if(which == 0) {
lastTempFile = getTempFile(fragment.getActivity());
- Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- if (lastTempFile != null) {
- intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(lastTempFile));
- }
- fragment.startActivityForResult(intent, REQUEST_CODE_CAMERA);
+ if (lastTempFile != null)
+ cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(lastTempFile));
+ fragment.startActivityForResult(cameraIntent, REQUEST_CODE_CAMERA);
} else if (which == 1) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmLoginActivity.java b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmLoginActivity.java
index 80e4637e3..1e590fed0 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmLoginActivity.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmLoginActivity.java
@@ -76,14 +76,12 @@ import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.sync.ActFmInvoker;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.activity.Eula;
-import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.gtasks.auth.ModernAuthManager;
import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.service.StatisticsConstants;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.SyncV2Service;
import com.todoroo.astrid.service.TaskService;
-import com.todoroo.astrid.sync.SyncResultCallbackAdapter;
/**
* This activity allows users to sign in or log in to Astrid.com
@@ -109,7 +107,6 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
private Facebook facebook;
private AsyncFacebookRunner facebookRunner;
private TextView errors;
- protected boolean noSync = false;
public static final String SHOW_TOAST = "show_toast"; //$NON-NLS-1$
@@ -122,8 +119,6 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
AstridDependencyInjector.initialize();
}
- public static final String EXTRA_DO_NOT_SYNC = "nosync"; //$NON-NLS-1$
-
protected int getContentViewResource() {
return R.layout.actfm_login_activity;
}
@@ -151,8 +146,6 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
rand = new Random(DateUtilities.now());
- noSync = getIntent().getBooleanExtra(EXTRA_DO_NOT_SYNC, false);
-
initializeUI();
getWindow().setFormat(PixelFormat.RGBA_8888);
@@ -538,20 +531,6 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
setResult(RESULT_OK);
finish();
- if (!noSync) {
- new Thread() {
- @Override
- public void run() {
- syncService.synchronizeActiveTasks(false, new SyncResultCallbackAdapter() {
- @Override
- public void finished() {
- ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH));
- }
- });
- }
- }.start();
- }
-
try {
C2DMReceiver.register();
} catch (Exception e) {
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java
index 63460c1cc..c357e2556 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java
@@ -6,13 +6,10 @@ import android.preference.Preference;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
-import com.todoroo.andlib.service.ContextManager;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.actfm.sync.ActFmSyncV2Provider;
-import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.sync.SyncProviderPreferences;
import com.todoroo.astrid.sync.SyncProviderUtilities;
-import com.todoroo.astrid.sync.SyncResultCallbackAdapter;
/**
* Displays synchronization preferences and an action panel so users can
@@ -34,14 +31,9 @@ public class ActFmPreferences extends SyncProviderPreferences {
public void startSync() {
if (!actFmPreferenceService.isLoggedIn()) {
Intent intent = new Intent(this, ActFmLoginActivity.class);
- startActivityForResult(intent, 0);
+ startActivityForResult(intent, REQUEST_LOGIN);
} else {
- new ActFmSyncV2Provider().synchronizeActiveTasks(true, new SyncResultCallbackAdapter() {
- @Override
- public void finished() {
- ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH));
- }
- });
+ setResult(RESULT_CODE_SYNCHRONIZE);
finish();
}
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java b/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java
index 570aeccf6..48318fc3b 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java
@@ -110,6 +110,8 @@ public class EditPeopleControlSet extends PopupControlSet {
private AssignedToUser taskRabbitUser = null;
+ private boolean loadedUI = false;
+
private final List listeners = new LinkedList();
public interface AssignedChangedListener {
@@ -223,23 +225,30 @@ public class EditPeopleControlSet extends PopupControlSet {
final String tag = metadata.getValue(TagService.TAG);
TagData tagData = tagDataService.getTag(tag, TagData.MEMBER_COUNT, TagData.MEMBERS, TagData.USER);
if(tagData != null && tagData.getValue(TagData.MEMBER_COUNT) > 0) {
- addMembersFromTagData(tagData, tag, sharedPeople, collaborators);
+ try {
+ addMembersFromTagData(tagData, tag, sharedPeople, collaborators);
+ } catch (JSONException e) {
+ exceptionService.reportError("json-reading-data", e);
+ }
} else {
nonSharedTags.add((Metadata) metadata.clone());
}
}
if (includeTag != null && tags.getCount() == 0) {
- addMembersFromTagData(includeTag, null, sharedPeople, collaborators);
+ try {
+ addMembersFromTagData(includeTag, null, sharedPeople, collaborators);
+ } catch (JSONException e) {
+ exceptionService.reportError("json-reading-data", e);
+ }
}
if(collaborators.size() > 0)
buildCollaborators(collaborators);
buildAssignedToSpinner(task, sharedPeople);
- } catch (JSONException e) {
- exceptionService.reportError("json-reading-data", e);
} finally {
tags.close();
+ loadedUI = true;
}
}
}).start();
@@ -269,7 +278,7 @@ public class EditPeopleControlSet extends PopupControlSet {
}
@SuppressWarnings("nls")
- private void buildCollaborators(final ArrayList sharedPeople) throws JSONException {
+ private void buildCollaborators(final ArrayList sharedPeople) {
activity.runOnUiThread(new Runnable() {
@Override
@@ -318,94 +327,98 @@ public class EditPeopleControlSet extends PopupControlSet {
}
@SuppressWarnings("nls")
- private void buildAssignedToSpinner(Task t, ArrayList sharedPeople) throws JSONException {
+ private void buildAssignedToSpinner(Task t, ArrayList sharedPeople) {
HashSet userIds = new HashSet();
HashSet emails = new HashSet();
HashMap names = new HashMap();
- if(t.getValue(Task.USER_ID) > 0) {
- JSONObject user = new JSONObject(t.getValue(Task.USER));
- sharedPeople.add(0, user);
- }
+ int assignedIndex = 0;
+ try {
+ if(t.getValue(Task.USER_ID) > 0) {
+ JSONObject user = new JSONObject(t.getValue(Task.USER));
+ sharedPeople.add(0, user);
+ }
- JSONObject myself = new JSONObject();
- myself.put("id", Task.USER_ID_SELF);
- sharedPeople.add(0, myself);
+ JSONObject myself = new JSONObject();
+ myself.put("id", Task.USER_ID_SELF);
+ sharedPeople.add(0, myself);
- boolean hasTags = t.getTransitory("tags") != null &&
- ((HashSet)t.getTransitory("tags")).size() > 0;
- if (actFmPreferenceService.isLoggedIn() && hasTags) {
- JSONObject unassigned = new JSONObject();
- unassigned.put("id", Task.USER_ID_UNASSIGNED);
- sharedPeople.add(1, unassigned);
- }
+ boolean hasTags = t.getTransitory("tags") != null &&
+ ((HashSet)t.getTransitory("tags")).size() > 0;
+ if (actFmPreferenceService.isLoggedIn() && hasTags) {
+ JSONObject unassigned = new JSONObject();
+ unassigned.put("id", Task.USER_ID_UNASSIGNED);
+ sharedPeople.add(1, unassigned);
+ }
- // de-duplicate by user id and/or email
- listValues.clear();
- for(int i = 0; i < sharedPeople.size(); i++) {
- JSONObject person = sharedPeople.get(i);
- if(person == null)
- continue;
- long id = person.optLong("id", -2);
- if(id == ActFmPreferenceService.userId() || (id >= -1 && userIds.contains(id)))
- continue;
- userIds.add(id);
-
- String email = person.optString("email");
- if(!TextUtils.isEmpty(email) && emails.contains(email))
- continue;
- emails.add(email);
-
- String name = person.optString("name");
- if(id == 0)
- name = activity.getString(R.string.actfm_EPA_assign_me);
- if (id == -1)
- name = activity.getString(R.string.actfm_EPA_unassigned);
-
- AssignedToUser atu = new AssignedToUser(name, person);
- listValues.add(atu);
- if(names.containsKey(name)) {
- AssignedToUser user = names.get(name);
- if(user != null && user.user.has("email")) {
- user.label += " (" + user.user.optString("email") + ")";
- names.put(name, null);
- }
- if(!TextUtils.isEmpty("email"))
- atu.label += " (" + email + ")";
- } else if(TextUtils.isEmpty(name)) {
- if(!TextUtils.isEmpty("email"))
- atu.label = email;
- else
- listValues.remove(atu);
- } else
- names.put(name, atu);
- }
+ // de-duplicate by user id and/or email
+ listValues.clear();
+ for(int i = 0; i < sharedPeople.size(); i++) {
+ JSONObject person = sharedPeople.get(i);
+ if(person == null)
+ continue;
+ long id = person.optLong("id", -2);
+ if(id == ActFmPreferenceService.userId() || (id >= -1 && userIds.contains(id)))
+ continue;
+ userIds.add(id);
- String assignedStr = t.getValue(Task.USER);
- int assignedIndex = 0;
- if (!TextUtils.isEmpty(assignedStr)) {
- JSONObject assigned = new JSONObject(assignedStr);
- long assignedId = assigned.optLong("id", -2);
- String assignedEmail = assigned.optString("email");
- for (int i = 0; i < listValues.size(); i++) {
- JSONObject user = listValues.get(i).user;
- if (user != null) {
- if (user.optLong("id") == assignedId ||
- (user.optString("email").equals(assignedEmail) &&
- !(TextUtils.isEmpty(assignedEmail))))
- assignedIndex = i;
+ String email = person.optString("email");
+ if(!TextUtils.isEmpty(email) && emails.contains(email))
+ continue;
+ emails.add(email);
+
+ String name = person.optString("name");
+ if(id == 0)
+ name = activity.getString(R.string.actfm_EPA_assign_me);
+ if (id == -1)
+ name = activity.getString(R.string.actfm_EPA_unassigned);
+
+ AssignedToUser atu = new AssignedToUser(name, person);
+ listValues.add(atu);
+ if(names.containsKey(name)) {
+ AssignedToUser user = names.get(name);
+ if(user != null && user.user.has("email")) {
+ user.label += " (" + user.user.optString("email") + ")";
+ names.put(name, null);
+ }
+ if(!TextUtils.isEmpty("email"))
+ atu.label += " (" + email + ")";
+ } else if(TextUtils.isEmpty(name)) {
+ if(!TextUtils.isEmpty("email"))
+ atu.label = email;
+ else
+ listValues.remove(atu);
+ } else
+ names.put(name, atu);
+ }
+
+ String assignedStr = t.getValue(Task.USER);
+ if (!TextUtils.isEmpty(assignedStr)) {
+ JSONObject assigned = new JSONObject(assignedStr);
+ long assignedId = assigned.optLong("id", -2);
+ String assignedEmail = assigned.optString("email");
+ for (int i = 0; i < listValues.size(); i++) {
+ JSONObject user = listValues.get(i).user;
+ if (user != null) {
+ if (user.optLong("id") == assignedId ||
+ (user.optString("email").equals(assignedEmail) &&
+ !(TextUtils.isEmpty(assignedEmail))))
+ assignedIndex = i;
+ }
}
}
- }
- for (AssignedChangedListener l : listeners) {
- if (l.shouldShowTaskRabbit()) {
- taskRabbitUser = new AssignedToUser(activity.getString(R.string.actfm_EPA_task_rabbit), new JSONObject().put("default_picture", R.drawable.task_rabbit_image));
- listValues.add(taskRabbitUser);
- if(l.didPostToTaskRabbit()){
- assignedIndex = listValues.size()-1;
+ for (AssignedChangedListener l : listeners) {
+ if (l.shouldShowTaskRabbit()) {
+ taskRabbitUser = new AssignedToUser(activity.getString(R.string.actfm_EPA_task_rabbit), new JSONObject().put("default_picture", R.drawable.task_rabbit_image));
+ listValues.add(taskRabbitUser);
+ if(l.didPostToTaskRabbit()){
+ assignedIndex = listValues.size()-1;
+ }
}
}
+ } catch (JSONException e) {
+ exceptionService.reportError("json-reading-data", e);
}
selected = assignedIndex;
@@ -543,6 +556,10 @@ public class EditPeopleControlSet extends PopupControlSet {
// Nothing, we don't lazy load this control set yet
}
+ public boolean hasLoadedUI() {
+ return loadedUI;
+ }
+
/**
* Save sharing settings
* @param toast toast to show after saving is finished
@@ -562,6 +579,8 @@ public class EditPeopleControlSet extends PopupControlSet {
userJson = PeopleContainer.createUserJson(assignedCustom);
assignedView = assignedCustom;
} else {
+ if (!loadedUI || assignedList.getCheckedItemPosition() == ListView.INVALID_POSITION)
+ return true;
AssignedToUser item = (AssignedToUser) assignedList.getAdapter().getItem(assignedList.getCheckedItemPosition());
if (item != null) {
if (item.equals(taskRabbitUser)) { //don't want to ever set the user as the task rabbit user
diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksPreferences.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksPreferences.java
index 79d8be4cd..c0ddece42 100644
--- a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksPreferences.java
+++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksPreferences.java
@@ -5,14 +5,11 @@ import android.os.Bundle;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
-import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
-import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.gtasks.auth.GtasksLoginActivity;
import com.todoroo.astrid.gtasks.sync.GtasksSyncV2Provider;
import com.todoroo.astrid.sync.SyncProviderPreferences;
import com.todoroo.astrid.sync.SyncProviderUtilities;
-import com.todoroo.astrid.sync.SyncResultCallbackAdapter;
/**
* Displays synchronization preferences and an action panel so users can
@@ -44,14 +41,9 @@ public class GtasksPreferences extends SyncProviderPreferences {
public void startSync() {
if (!gtasksPreferenceService.isLoggedIn()) {
Intent intent = new Intent(this, GtasksLoginActivity.class);
- startActivityForResult(intent, 0);
+ startActivityForResult(intent, REQUEST_LOGIN);
} else {
- new GtasksSyncV2Provider().synchronizeActiveTasks(true, new SyncResultCallbackAdapter() {
- @Override
- public void finished() {
- ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH));
- }
- });
+ setResult(RESULT_CODE_SYNCHRONIZE);
finish();
}
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.java
index c532d9c3f..815912e41 100644
--- a/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.java
+++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.java
@@ -47,13 +47,11 @@ import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.andlib.utility.Preferences;
-import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.gtasks.api.GtasksInvoker;
import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.SyncV2Service;
-import com.todoroo.astrid.sync.SyncResultCallbackAdapter;
/**
* This activity allows users to sign in or log in to Google Tasks
@@ -172,24 +170,6 @@ public class GtasksLoginActivity extends ListActivity {
private void onAuthTokenSuccess() {
gtasksPreferenceService.setToken(authToken);
Preferences.setString(GtasksPreferenceService.PREF_USER_NAME, accountName);
- synchronize();
- }
-
- /**
- * Perform synchronization
- */
- protected void synchronize() {
- new Thread() {
- @Override
- public void run() {
- syncService.synchronizeActiveTasks(false, new SyncResultCallbackAdapter() {
- @Override
- public void finished() {
- ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH));
- }
- });
- }
- }.start();
setResult(RESULT_OK);
finish();
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedListUpdater.java b/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedListUpdater.java
index 06ebd0516..29f18bd57 100644
--- a/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedListUpdater.java
+++ b/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedListUpdater.java
@@ -268,10 +268,13 @@ abstract public class OrderedListUpdater {
parent.children.add(currentNode.get());
} else { // in a different tree
Node node = currentNode.get().parent;
- for(int i = indent; i < previousIndentValue; i++)
+ for(int i = indent; i < previousIndentValue; i++) {
node = node.parent;
- if(node == null)
- node = root;
+ if(node == null) {
+ node = root;
+ break;
+ }
+ }
currentNode.set(new Node(taskId, node));
node.children.add(currentNode.get());
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/taskrabbit/TaskRabbitActivity.java b/astrid/plugin-src/com/todoroo/astrid/taskrabbit/TaskRabbitActivity.java
index 84dd4061c..5796816ce 100644
--- a/astrid/plugin-src/com/todoroo/astrid/taskrabbit/TaskRabbitActivity.java
+++ b/astrid/plugin-src/com/todoroo/astrid/taskrabbit/TaskRabbitActivity.java
@@ -158,6 +158,8 @@ public class TaskRabbitActivity extends FragmentActivity {
private TaskRabbitTaskContainer taskRabbitTask;
+ private boolean showingNoGPSAlertMessage = false;
+
public TaskRabbitActivity() {
DependencyInjectionService.getInstance().inject(this);
}
@@ -217,7 +219,8 @@ public class TaskRabbitActivity extends FragmentActivity {
didReportStatistics = true;
}
populateFields();
- showIntroDialog();
+ if (!showingNoGPSAlertMessage)
+ showIntroDialog();
}
@Override
@@ -689,7 +692,7 @@ public class TaskRabbitActivity extends FragmentActivity {
Intent intent = new Intent(this,
OAuthLoginActivity.class);
try {
- String url = TASK_RABBIT_URL + "/api/authorize?client_id=" + TASK_RABBIT_CLIENT_ID; //$NON-NLS-1$
+ String url = String.format(TASK_RABBIT_URL + "/api/authorize?client_id=%s&client_application=%s", TASK_RABBIT_CLIENT_ID, TASK_RABBIT_CLIENT_APPLICATION_ID); //$NON-NLS-1$
intent.putExtra(OAuthLoginActivity.URL_TOKEN, url);
this.startActivityForResult(intent, REQUEST_CODE_TASK_RABBIT_OAUTH);
StatisticsService.reportEvent(StatisticsConstants.TASK_RABBIT_LOGIN);
@@ -697,11 +700,13 @@ public class TaskRabbitActivity extends FragmentActivity {
e.printStackTrace();
}
}
+
private void loadLocation() {
if (locationManager == null) {
locationManager = new TaskRabbitLocationManager(this);
- if ( !locationManager.isLocationUpdatesEnabled()) {
+ if (!locationManager.isLocationUpdatesEnabled()) {
buildAlertMessageNoGps();
+ showingNoGPSAlertMessage = true;
}
}
currentLocation = locationManager.getLastKnownLocation();
@@ -730,11 +735,14 @@ public class TaskRabbitActivity extends FragmentActivity {
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, final int id) {
startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), REQUEST_CODE_ENABLE_GPS);
+ showingNoGPSAlertMessage = false;
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, final int id) {
dialog.cancel();
+ showingNoGPSAlertMessage = false;
+ showIntroDialog();
}
});
final AlertDialog alert = builder.create();
@@ -777,7 +785,7 @@ public class TaskRabbitActivity extends FragmentActivity {
result = result.substring(result.indexOf(key)+key.length());
Preferences.setString(TASK_RABBIT_TOKEN, result);
- String url = String.format("%s?oauth_token=%s&client_application=",taskRabbitURL("account"), Preferences.getStringValue(TASK_RABBIT_TOKEN), TASK_RABBIT_CLIENT_APPLICATION_ID);
+ String url = String.format("%s?oauth_token=%s&client_application=%s",taskRabbitURL("account"), Preferences.getStringValue(TASK_RABBIT_TOKEN), TASK_RABBIT_CLIENT_APPLICATION_ID);
String response = restClient.get(url);
saveUserInfo(response);//;
@@ -789,7 +797,6 @@ public class TaskRabbitActivity extends FragmentActivity {
}
}
else if (requestCode == REQUEST_CODE_ENABLE_GPS) {
-
loadLocation();
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/taskrabbit/TaskRabbitControlSet.java b/astrid/plugin-src/com/todoroo/astrid/taskrabbit/TaskRabbitControlSet.java
index 4ad251aeb..23f2115d3 100644
--- a/astrid/plugin-src/com/todoroo/astrid/taskrabbit/TaskRabbitControlSet.java
+++ b/astrid/plugin-src/com/todoroo/astrid/taskrabbit/TaskRabbitControlSet.java
@@ -207,20 +207,22 @@ public class TaskRabbitControlSet extends TaskEditControlSet implements Assigned
*/
public void updateDisplay(JSONObject json) {
- String stateKey = fragment.getActivity().getString(R.string.tr_attr_state_label);
- if (json != null && json.has(stateKey)) {
- String status = json.optString(stateKey);
- TextView statusText = (TextView) getDisplayView().findViewById(R.id.display_row_edit);
- statusText.setText(status);
- getDisplayView().setVisibility(View.VISIBLE);
- }
- else if (taskRabbitTask != null && taskRabbitTask.getLocalTaskData() != null) {
- TextView statusText = (TextView) getDisplayView().findViewById(R.id.display_row_edit);
- statusText.setText(fragment.getActivity().getString(R.string.tr_status_draft));
- getDisplayView().setVisibility(View.VISIBLE);
- }
- else {
- getDisplayView().setVisibility(View.GONE);
+ if (fragment.getActivity() != null) {
+ String stateKey = fragment.getActivity().getString(R.string.tr_attr_state_label);
+ if (json != null && json.has(stateKey)) {
+ String status = json.optString(stateKey);
+ TextView statusText = (TextView) getDisplayView().findViewById(R.id.display_row_edit);
+ statusText.setText(status);
+ getDisplayView().setVisibility(View.VISIBLE);
+ }
+ else if (taskRabbitTask != null && taskRabbitTask.getLocalTaskData() != null) {
+ TextView statusText = (TextView) getDisplayView().findViewById(R.id.display_row_edit);
+ statusText.setText(fragment.getActivity().getString(R.string.tr_status_draft));
+ getDisplayView().setVisibility(View.VISIBLE);
+ }
+ else {
+ getDisplayView().setVisibility(View.GONE);
+ }
}
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/taskrabbit/TaskRabbitMapActivity.java b/astrid/plugin-src/com/todoroo/astrid/taskrabbit/TaskRabbitMapActivity.java
index 78249b2d0..e33ec4cfe 100644
--- a/astrid/plugin-src/com/todoroo/astrid/taskrabbit/TaskRabbitMapActivity.java
+++ b/astrid/plugin-src/com/todoroo/astrid/taskrabbit/TaskRabbitMapActivity.java
@@ -19,8 +19,10 @@ import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.View;
+import android.view.ViewGroup.LayoutParams;
import android.widget.EditText;
import android.widget.ImageButton;
+import android.widget.LinearLayout;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
@@ -43,6 +45,9 @@ public class TaskRabbitMapActivity extends MapActivity implements LocationListen
private static final int LOCATION_SEARCH_SUCCESS = 1;
private static final int LOCATION_SEARCH_FAIL = -1;
+ // Production value
+ private static final String MAPS_API_KEY = "0J-miH1uUbgVV5xsNNmvSIzb4DIENVCMERxB7gw"; //$NON-NLS-1$
+
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
@@ -50,9 +55,14 @@ public class TaskRabbitMapActivity extends MapActivity implements LocationListen
super.onCreate(savedInstanceState);
setContentView(R.layout.task_rabbit_map_activity);
- mapView = (MapView) findViewById(R.id.map_view);
+ mapView = new MapView(this, MAPS_API_KEY);
+ mapView.setClickable(true);
mapView.setBuiltInZoomControls(true);
+ LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 12.0f);
+
+ ((LinearLayout) findViewById(R.id.task_rabbit_map_parent)).addView(mapView, 0, lp);
+
locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
currentLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
diff --git a/astrid/res/layout/task_rabbit_map_activity.xml b/astrid/res/layout/task_rabbit_map_activity.xml
index 20f594d06..25b6ab45d 100644
--- a/astrid/res/layout/task_rabbit_map_activity.xml
+++ b/astrid/res/layout/task_rabbit_map_activity.xml
@@ -1,18 +1,11 @@
-
-
Error posting task
Please try again
Close
- GPS needs to be enabled in order to add location based tasks. Do you want to enable it?
+ Wireless Network Location Provider needs to be enabled in order to add location based tasks. Do you want to enable it?
Yes
No
diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml
index ce9a2d7d4..158996ea0 100644
--- a/astrid/res/values/keys.xml
+++ b/astrid/res/values/keys.xml
@@ -300,6 +300,8 @@
sync_sync
sync_forget
+
+ sync_options
actfmHttps
diff --git a/astrid/res/values/strings-core.xml b/astrid/res/values/strings-core.xml
index 6ba10a21d..49988970d 100644
--- a/astrid/res/values/strings-core.xml
+++ b/astrid/res/values/strings-core.xml
@@ -512,8 +512,8 @@
Auto-load Ideas Tab
- Web searches for Ideas tab will be performed when task is edited
- Web searches for Ideas tab will be performed when tab is clicked
+ Web searches for Ideas tab will be performed when tab is clicked
+ Web searches for Ideas tab will be performed only when manually requested
Color Theme
diff --git a/astrid/res/xml/preferences_actfm.xml b/astrid/res/xml/preferences_actfm.xml
index cdd238280..de8364955 100644
--- a/astrid/res/xml/preferences_actfm.xml
+++ b/astrid/res/xml/preferences_actfm.xml
@@ -14,6 +14,7 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/astrid/res/xml/preferences_producteev.xml b/astrid/res/xml/preferences_producteev.xml
index eac379611..de5150d24 100644
--- a/astrid/res/xml/preferences_producteev.xml
+++ b/astrid/res/xml/preferences_producteev.xml
@@ -14,6 +14,7 @@
-
-
-
-
-
intentComponent = Class.forName(intent.getComponent().getClassName());
+ if (SyncProviderPreferences.class.equals(intentComponent.getSuperclass())) {
+ preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference pref) {
+ startActivityForResult(intent, REQUEST_CODE_SYNC);
+ return true;
+ }
+ });
+ } else {
+ preference.setIntent(intent);
+ }
+ } catch (ClassNotFoundException e) {
+ preference.setIntent(intent);
+ }
String category = MetadataHelper.resolveActivityCategoryName(resolveInfo, pm);
@@ -359,6 +377,11 @@ public class EditPreferences extends TodorooPreferenceActivity {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == REQUEST_CODE_SYNC && resultCode == SyncProviderPreferences.RESULT_CODE_SYNCHRONIZE) {
+ setResult(SyncProviderPreferences.RESULT_CODE_SYNCHRONIZE);
+ finish();
+ return;
+ }
try {
VoiceOutputService.getVoiceOutputInstance().handleActivityResult(requestCode, resultCode, data);
} catch (VerifyError e) {
diff --git a/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java
index ce0680d6b..33bfc6024 100755
--- a/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java
+++ b/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java
@@ -772,6 +772,10 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
model = null;
remoteId = 0;
populateFields(intent);
+ if (webServices != null) {
+ webServices.setTask(model);
+ webServices.reset();
+ }
}
/** Populate UI component values from the model */
@@ -859,7 +863,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
public boolean onKeyDown(int keyCode) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
- if (title.getText().length() == 0)
+ if (title.getText().length() == 0 || !peopleControlSet.hasLoadedUI())
discardButtonClick();
else
saveButtonClick();
diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java
index b2fcf7a7e..40de3bcb8 100644
--- a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java
+++ b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java
@@ -89,6 +89,7 @@ import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.service.UpgradeService;
import com.todoroo.astrid.subtasks.SubtasksListFragment;
+import com.todoroo.astrid.sync.SyncProviderPreferences;
import com.todoroo.astrid.ui.QuickAddBar;
import com.todoroo.astrid.utility.AstridPreferences;
import com.todoroo.astrid.utility.Constants;
@@ -678,10 +679,13 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
if(quickAddBar.onActivityResult(requestCode, resultCode, data))
return;
- if (requestCode == ACTIVITY_SETTINGS
- && resultCode == EditPreferences.RESULT_CODE_THEME_CHANGED) {
- getActivity().finish();
- getActivity().startActivity(getActivity().getIntent());
+ if (requestCode == ACTIVITY_SETTINGS) {
+ if (resultCode == EditPreferences.RESULT_CODE_THEME_CHANGED) {
+ getActivity().finish();
+ getActivity().startActivity(getActivity().getIntent());
+ } else if (resultCode == SyncProviderPreferences.RESULT_CODE_SYNCHRONIZE) {
+ Preferences.setLong(SyncActionHelper.PREF_LAST_AUTO_SYNC, 0); // Forces autosync to occur after login
+ }
}
super.onActivityResult(requestCode, resultCode, data);
@@ -799,7 +803,7 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
setListAdapter(taskAdapter);
getListView().setOnScrollListener(this);
registerForContextMenu(getListView());
- syncActionHelper = new SyncActionHelper(getActivity());
+ syncActionHelper = new SyncActionHelper(getActivity(), this);
loadTaskListContent(true);
}
diff --git a/astrid/src/com/todoroo/astrid/helper/SyncActionHelper.java b/astrid/src/com/todoroo/astrid/helper/SyncActionHelper.java
index 8641db909..c73950519 100644
--- a/astrid/src/com/todoroo/astrid/helper/SyncActionHelper.java
+++ b/astrid/src/com/todoroo/astrid/helper/SyncActionHelper.java
@@ -18,6 +18,7 @@ import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
+import android.support.v4.app.Fragment;
import android.widget.ArrayAdapter;
import android.widget.Toast;
@@ -28,6 +29,7 @@ import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences;
+import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.SyncAction;
@@ -48,7 +50,7 @@ import com.todoroo.astrid.sync.SyncV2Provider;
*/
public class SyncActionHelper {
- private static final String PREF_LAST_AUTO_SYNC = "taskListLastAutoSync"; //$NON-NLS-1$
+ public static final String PREF_LAST_AUTO_SYNC = "taskListLastAutoSync"; //$NON-NLS-1$
private final LinkedHashSet syncActions = new LinkedHashSet();
@@ -56,6 +58,8 @@ public class SyncActionHelper {
private final Activity activity;
+ private final Fragment fragment;
+
protected SyncActionReceiver syncActionReceiver = new SyncActionReceiver();
@Autowired SyncV2Service syncService;
@@ -63,10 +67,11 @@ public class SyncActionHelper {
// --- boilerplate
- public SyncActionHelper(Activity activity) {
+ public SyncActionHelper(Activity activity, Fragment fragment) {
DependencyInjectionService.getInstance().inject(this);
this.activity = activity;
+ this.fragment = fragment;
syncResultCallback = new ProgressBarSyncResultCallback(activity,
R.id.progressBar, new Runnable() {
@Override
@@ -201,7 +206,7 @@ public class SyncActionHelper {
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface click, int which) {
- activity.startActivity(actions[which]);
+ fragment.startActivityForResult(actions[which], TaskListFragment.ACTIVITY_SETTINGS);
}
};
diff --git a/astrid/src/com/todoroo/astrid/service/SyncV2Service.java b/astrid/src/com/todoroo/astrid/service/SyncV2Service.java
index 2b8af7a16..d96b6cc8e 100644
--- a/astrid/src/com/todoroo/astrid/service/SyncV2Service.java
+++ b/astrid/src/com/todoroo/astrid/service/SyncV2Service.java
@@ -42,6 +42,13 @@ public class SyncV2Service {
return Collections.unmodifiableList(actives);
}
+ public boolean hasActiveProvider() {
+ for (SyncV2Provider provider : providers) {
+ if (provider.isActive()) return true;
+ }
+ return false;
+ }
+
/**
* Initiate synchronization of active tasks
*
diff --git a/astrid/src/com/todoroo/astrid/service/UpgradeService.java b/astrid/src/com/todoroo/astrid/service/UpgradeService.java
index 19457c64e..56127dac9 100644
--- a/astrid/src/com/todoroo/astrid/service/UpgradeService.java
+++ b/astrid/src/com/todoroo/astrid/service/UpgradeService.java
@@ -40,6 +40,7 @@ import com.todoroo.astrid.utility.AstridPreferences;
public final class UpgradeService {
+ public static final int V4_0_2 = 253;
public static final int V4_0_1 = 252;
public static final int V4_0_0 = 251;
public static final int V3_9_2_3 = 210;
@@ -176,6 +177,16 @@ public final class UpgradeService {
Preferences.clear(AstridPreferences.P_UPGRADE_FROM);
StringBuilder changeLog = new StringBuilder();
+ if (from >= V4_0_0 && from < V4_0_2) {
+ newVersionString(changeLog, "4.0.2 (2/29/12)", new String[] {
+ "Removed GPS permission--no longer needed",
+ "Fixes for some subtasks issues",
+ "No longer need to run the Crittercism service in the background",
+ "Fixed a crash that could occur when cloning tasks",
+ "Fixed a bug that prevented certain comments from syncing correctly",
+ });
+ }
+
if (from >= V4_0_0 && from < V4_0_1) {
newVersionString(changeLog, "4.0.1 (2/23/12)", new String[] {
"Fixed a database issue affecting Android 2.1 users",
diff --git a/astrid/src/com/todoroo/astrid/ui/CalendarView.java b/astrid/src/com/todoroo/astrid/ui/CalendarView.java
index ce89a2591..190e0f0c5 100644
--- a/astrid/src/com/todoroo/astrid/ui/CalendarView.java
+++ b/astrid/src/com/todoroo/astrid/ui/CalendarView.java
@@ -315,7 +315,7 @@ public class CalendarView extends View {
// Day heading -- End
// Calendar -- Start
- calendar.setTime(getCoercedDate(calendar.getTime(), calendarDate));
+ calendar.setTime(getCoercedDate(new Date(), calendarDate)); // Reset the calendar to either today or the specified date
if (currentHighlightDay == -1) {
currentHighlightDay = calendarDate.getTime() == 0 ? 0 : calendar.get(Calendar.DATE);
diff --git a/astrid/src/com/todoroo/astrid/ui/WebServicesView.java b/astrid/src/com/todoroo/astrid/ui/WebServicesView.java
index 18f514651..0ae7e798e 100644
--- a/astrid/src/com/todoroo/astrid/ui/WebServicesView.java
+++ b/astrid/src/com/todoroo/astrid/ui/WebServicesView.java
@@ -1,7 +1,5 @@
package com.todoroo.astrid.ui;
-import com.todoroo.astrid.helper.AsyncImageView;
-
import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
@@ -45,6 +43,7 @@ import com.todoroo.andlib.service.RestClient;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.helper.AmazonRequestsHelper;
+import com.todoroo.astrid.helper.AsyncImageView;
import com.todoroo.astrid.producteev.api.StringEscapeUtils;
import com.todoroo.astrid.service.StatisticsConstants;
import com.todoroo.astrid.service.StatisticsService;
@@ -78,19 +77,21 @@ public class WebServicesView extends LinearLayout {
public WebServicesView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+ initialize();
}
public WebServicesView(Context context, AttributeSet attrs) {
super(context, attrs);
+ initialize();
}
public WebServicesView(Context context) {
super(context);
+ initialize();
}
public void setTask(Task task) {
this.task = task;
- initialize();
}
public int[] getScrollableViews() {
@@ -127,6 +128,15 @@ public class WebServicesView extends LinearLayout {
}
}
+ public void reset() {
+ if (!Preferences.getBoolean(R.string.p_autoIdea, true)) {
+ removeAllViews();
+ initialize();
+ } else {
+ refresh();
+ }
+ }
+
public void onPageSelected(Runnable runnable) {
if(!pageLoaded && Preferences.getBoolean(R.string.p_autoIdea, true))
refresh();
diff --git a/tests-sync/.classpath b/tests-sync/.classpath
index bf2584e47..235ca48e1 100644
--- a/tests-sync/.classpath
+++ b/tests-sync/.classpath
@@ -5,8 +5,5 @@
-
-
-
diff --git a/tests-sync/project.properties b/tests-sync/project.properties
index 816c46ffb..730e911f2 100644
--- a/tests-sync/project.properties
+++ b/tests-sync/project.properties
@@ -9,5 +9,3 @@
# Project target.
target=android-14
-android.library.reference.1=../api
-android.library.reference.2=../facebook/facebook
diff --git a/tests-sync/src/com/todoroo/astrid/gtasks/GtasksNewSyncTest.java b/tests-sync/src/com/todoroo/astrid/gtasks/GtasksNewSyncTest.java
index 4b99f73c9..684176fdc 100644
--- a/tests-sync/src/com/todoroo/astrid/gtasks/GtasksNewSyncTest.java
+++ b/tests-sync/src/com/todoroo/astrid/gtasks/GtasksNewSyncTest.java
@@ -24,16 +24,16 @@ import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.api.GtasksApiUtilities;
import com.todoroo.astrid.gtasks.api.GtasksInvoker;
import com.todoroo.astrid.gtasks.auth.GtasksTokenValidator;
-import com.todoroo.astrid.gtasks.sync.GtasksSyncProvider;
+import com.todoroo.astrid.gtasks.sync.GtasksSyncV2Provider;
import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.service.TaskService;
+import com.todoroo.astrid.sync.SyncResultCallbackAdapter;
import com.todoroo.astrid.test.DatabaseTestCase;
@SuppressWarnings("nls")
public class GtasksNewSyncTest extends DatabaseTestCase {
private static GtasksInvoker gtasksService;
- private GtasksSyncProvider syncProvider;
private static boolean initialized = false;
private boolean bypassTests = false;
@@ -473,8 +473,21 @@ public class GtasksNewSyncTest extends DatabaseTestCase {
//Perform a synchronization
private void whenInvokeSync() {
- syncProvider.synchronize(getContext());
- gtasksService = syncProvider.getGtasksService(); //This is to prevent token mismatch; the sync provider invalidates the old one
+ new GtasksSyncV2Provider().synchronizeActiveTasks(true, new SyncResultCallbackAdapter() {
+ @Override
+ public void finished() {
+ synchronized(GtasksNewSyncTest.this) {
+ GtasksNewSyncTest.this.notify();
+ }
+ }
+ });
+ try {
+ synchronized(this) {
+ wait();
+ }
+ } catch (InterruptedException e) {
+ fail("Interrupted while waiting for sync to finish");
+ }
}
@Override
@@ -486,8 +499,6 @@ public class GtasksNewSyncTest extends DatabaseTestCase {
}
setupTestList();
-
- syncProvider = new GtasksSyncProvider();
}
private void initializeTestService() throws Exception {
diff --git a/tests-sync/src/com/todoroo/astrid/gtasks/GtasksSyncOnSaveTest.java b/tests-sync/src/com/todoroo/astrid/gtasks/GtasksSyncOnSaveTest.java
index 589b76338..5ef2e7f45 100644
--- a/tests-sync/src/com/todoroo/astrid/gtasks/GtasksSyncOnSaveTest.java
+++ b/tests-sync/src/com/todoroo/astrid/gtasks/GtasksSyncOnSaveTest.java
@@ -33,7 +33,7 @@ public class GtasksSyncOnSaveTest extends DatabaseTestCase {
@Autowired GtasksMetadataService gtasksMetadataService;
@Autowired GtasksPreferenceService gtasksPreferenceService;
- private GtasksInvoker gtasksService;
+ private static GtasksInvoker gtasksService;
private boolean initialized = false;
private boolean bypassTests = false;
private static final String TEST_ACCOUNT = "sync_tester2@astrid.com";
diff --git a/tests-sync/src/com/todoroo/astrid/gtasks/GtasksSyncTest.java b/tests-sync/src/com/todoroo/astrid/gtasks/GtasksSyncTest.java
deleted file mode 100644
index 2e3efc46d..000000000
--- a/tests-sync/src/com/todoroo/astrid/gtasks/GtasksSyncTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*package com.todoroo.astrid.gtasks;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.todoroo.andlib.service.Autowired;
-import com.todoroo.andlib.utility.DateUtilities;
-import com.todoroo.andlib.utility.Preferences;
-import com.todoroo.astrid.data.Task;
-import com.todoroo.astrid.gtasks.sync.GtasksSyncProvider;
-import com.todoroo.astrid.service.TaskService;
-import com.todoroo.astrid.test.DatabaseTestCase;
-
-
-public class GtasksSyncTest extends DatabaseTestCase {
-
- private static final String TEST_USERNAME = "astridtasktest@gmail.com";
- private static final String TEST_PASSWORD = "tasktest0000";
-
- private static boolean initialized = false;
- private static GoogleTaskService testService;
- private static GoogleTaskListInfo taskList;
-
- @Autowired TaskService taskService;
- @Autowired GtasksPreferenceService gtasksPreferenceService;
-
- // --- tests
-
- // !!! This test is disabled until it works :(
-
- public void DISABLED_testBasicTaskCreation() throws Exception {
- Task task = givenTask("wasabi");
-
- whenSynchronizing();
-
- thenAssertTaskExistsRemotely(task);
- }
-
- public void DISABLED_testTaskWithDueDate() throws Exception {
- Task task = givenTask("wasabi");
- task.setValue(Task.DUE_DATE, task.createDueDate(Task.URGENCY_SPECIFIC_DAY,
- DateUtilities.now()));
-
- whenSynchronizing();
-
- GoogleTaskTask remote = thenAssertTaskExistsRemotely(task);
- assertTrue(remote.getTask_date() > DateUtilities.now() - DateUtilities.ONE_DAY);
- assertEquals(task.getValue(Task.DUE_DATE), refetchLocal(task).getValue(Task.DUE_DATE));
- }
-
- public void DISABLED_testTaskWithDueTime() throws Exception {
- Task task = givenTask("wasabi");
- task.setValue(Task.DUE_DATE, task.createDueDate(Task.URGENCY_SPECIFIC_DAY_TIME,
- DateUtilities.now()));
-
- whenSynchronizing();
-
- GoogleTaskTask remote = thenAssertTaskExistsRemotely(task);
- assertTrue(remote.getTask_date() > DateUtilities.now() - DateUtilities.ONE_DAY);
- assertEquals(task.getValue(Task.DUE_DATE), refetchLocal(task).getValue(Task.DUE_DATE));
- }
-
- // --- helpers
-
- private Task refetchLocal(Task task) {
- return taskService.fetchById(task.getId(), Task.PROPERTIES);
- }
-
- private GoogleTaskTask thenAssertTaskExistsRemotely(Task task) throws Exception {
- List tasks = testService.getTasks(taskList.getId());
- for(GoogleTaskTask remote : tasks) {
- if(remote.getName().equals(task.getValue(Task.TITLE)))
- return remote;
- }
- fail("Task didn't exist remotely: " + task);
- return null;
- }
-
- private void whenSynchronizing() {
- new GtasksSyncProvider().synchronize(getContext());
- }
-
- private Task givenTask(String title) {
- Task task = new Task();
- task.setValue(Task.TITLE, title + System.currentTimeMillis());
- taskService.save(task);
- return task;
- }
-
- // --- setup stuff
-
- // set up task list and clean it out
- protected void DISABLED_setUp() throws Exception {
- super.setUp();
-
- if(!initialized)
- initializeTestService();
-
- ArrayList actions = new ArrayList();
- ListActions l = new ListActions();
- for(GoogleTaskTask task : testService.getTasks(taskList.getId())) {
- actions.add(l.modifyTask(task.getId()).deleted(true).done());
- }
-
- testService.executeListActions(taskList.getId(), actions.toArray(new ListAction[actions.size()]));
- }
-
- public void initializeTestService() throws Exception {
- GoogleConnectionManager gcm = new GoogleConnectionManager(TEST_USERNAME, TEST_PASSWORD);
- testService = new GoogleTaskService(gcm);
- GoogleTaskView taskView = testService.getTaskView();
- GoogleTaskListInfo[] lists = taskView.getAllLists();
- outer: {
- for(GoogleTaskListInfo list : lists) {
- if("AstridUnitTests".equals(list.getName())) {
- taskList = list;
- break outer;
- }
- }
- fail("could not find the main list");
- }
- initialized = true;
-
- Preferences.setString(GtasksPreferenceService.PREF_DEFAULT_LIST, taskList.getId());
- Preferences.setString(GtasksPreferenceService.PREF_USER_NAME, TEST_USERNAME);
- Preferences.setString(GtasksPreferenceService.PREF_PASSWORD, TEST_PASSWORD);
- gtasksPreferenceService.setToken(gcm.getToken());
- }
-
-
-
-}//*/
diff --git a/tests-sync/src/com/todoroo/astrid/sync/repeats/AbstractSyncRepeatTests.java b/tests-sync/src/com/todoroo/astrid/sync/repeats/AbstractSyncRepeatTests.java
index 70862198d..4280b6270 100644
--- a/tests-sync/src/com/todoroo/astrid/sync/repeats/AbstractSyncRepeatTests.java
+++ b/tests-sync/src/com/todoroo/astrid/sync/repeats/AbstractSyncRepeatTests.java
@@ -21,6 +21,7 @@ import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.dao.MetadataDao;
import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
+import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.repeats.RepeatTaskCompleteListener;
import com.todoroo.astrid.test.DatabaseTestCase;
@@ -38,11 +39,11 @@ abstract public class AbstractSyncRepeatTests extends DatabaseTest
protected void setUp() throws Exception {
super.setUp();
Preferences.setStringFromInteger(R.string.p_default_urgency_key, 0);
- RepeatTaskCompleteListener.setSkipActFmCheck(true);
}
private void saveAndTriggerRepeatListener(Task task) {
- Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
+ task.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
+ task.putTransitory(SyncFlags.GTASKS_SUPPRESS_SYNC, true);
if(task.isSaved())
taskDao.saveExisting(task);
else
diff --git a/tests-sync/src/com/todoroo/astrid/sync/repeats/RepeatTestsActFmSync.java b/tests-sync/src/com/todoroo/astrid/sync/repeats/RepeatTestsActFmSync.java
index aa2f1d9b3..9f0c4499d 100644
--- a/tests-sync/src/com/todoroo/astrid/sync/repeats/RepeatTestsActFmSync.java
+++ b/tests-sync/src/com/todoroo/astrid/sync/repeats/RepeatTestsActFmSync.java
@@ -18,13 +18,13 @@ import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.sync.ActFmDataService;
import com.todoroo.astrid.actfm.sync.ActFmInvoker;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
-import com.todoroo.astrid.actfm.sync.ActFmSyncProvider;
import com.todoroo.astrid.actfm.sync.ActFmSyncService;
+import com.todoroo.astrid.actfm.sync.ActFmSyncV2Provider;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task;
-import com.todoroo.astrid.repeats.RepeatTaskCompleteListener;
import com.todoroo.astrid.service.MetadataService;
+import com.todoroo.astrid.sync.SyncResultCallbackAdapter;
public class RepeatTestsActFmSync extends AbstractSyncRepeatTests {
@@ -42,7 +42,6 @@ public class RepeatTestsActFmSync extends AbstractSyncRepeatTests {
protected void setUp() throws Exception {
super.setUp();
Preferences.setStringFromInteger(R.string.p_default_urgency_key, 0);
- RepeatTaskCompleteListener.setSkipActFmCheck(false);
if (!initialized) {
initializeTestService();
@@ -53,7 +52,7 @@ public class RepeatTestsActFmSync extends AbstractSyncRepeatTests {
private void initializeTestService() throws Exception {
invoker = new ActFmInvoker();
- authenticate(TEST_ACCOUNT, null, ActFmInvoker.PROVIDER_PASSWORD, TEST_PASSWORD);
+ authenticate(TEST_ACCOUNT, null, null, ActFmInvoker.PROVIDER_PASSWORD, TEST_PASSWORD);
initialized = true;
}
@@ -70,9 +69,9 @@ public class RepeatTestsActFmSync extends AbstractSyncRepeatTests {
}
}
- private void authenticate(String email, String name, String provider, String secret) {
+ private void authenticate(String email, String firstName, String lastName, String provider, String secret) {
try {
- JSONObject result = invoker.authenticate(email, name, provider, secret);
+ JSONObject result = invoker.authenticate(email, firstName, lastName, provider, secret);
String token = invoker.getToken();
postAuthenticate(result, token);
} catch (IOException e) {
@@ -96,7 +95,21 @@ public class RepeatTestsActFmSync extends AbstractSyncRepeatTests {
@Override
protected void waitAndSync() {
AndroidUtilities.sleepDeep(3000L);
- new ActFmSyncProvider().synchronize(null);
+ new ActFmSyncV2Provider().synchronizeActiveTasks(true, new SyncResultCallbackAdapter() {
+ @Override
+ public void finished() {
+ synchronized(RepeatTestsActFmSync.this) {
+ RepeatTestsActFmSync.this.notify();
+ }
+ }
+ });
+ try {
+ synchronized(this) {
+ wait();
+ }
+ } catch (InterruptedException e) {
+ fail("Interrupted while waiting for sync to finish");
+ }
AndroidUtilities.sleepDeep(3000L);
}
diff --git a/tests-sync/src/com/todoroo/astrid/sync/repeats/RepeatTestsGtasksSync.java b/tests-sync/src/com/todoroo/astrid/sync/repeats/RepeatTestsGtasksSync.java
index 0ce53d716..b4f873f3f 100644
--- a/tests-sync/src/com/todoroo/astrid/sync/repeats/RepeatTestsGtasksSync.java
+++ b/tests-sync/src/com/todoroo/astrid/sync/repeats/RepeatTestsGtasksSync.java
@@ -25,9 +25,9 @@ import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.gtasks.api.GtasksApiUtilities;
import com.todoroo.astrid.gtasks.api.GtasksInvoker;
import com.todoroo.astrid.gtasks.auth.GtasksTokenValidator;
-import com.todoroo.astrid.gtasks.sync.GtasksSyncProvider;
-import com.todoroo.astrid.repeats.RepeatTaskCompleteListener;
+import com.todoroo.astrid.gtasks.sync.GtasksSyncV2Provider;
import com.todoroo.astrid.service.MetadataService;
+import com.todoroo.astrid.sync.SyncResultCallbackAdapter;
public class RepeatTestsGtasksSync extends AbstractSyncRepeatTests {
@@ -45,7 +45,6 @@ public class RepeatTestsGtasksSync extends AbstractSyncRepeatTests
+
+
+