Merge remote-tracking branch 'upstream/master' into 120221_sb_swipe_between_lists

Conflicts:
	astrid/src/com/todoroo/astrid/activity/AstridActivity.java
	astrid/src/com/todoroo/astrid/activity/TaskListFragment.java

Merge upstream/master
pull/14/head
Sam Bosley 13 years ago
commit 054b8b4f4f

@ -29,5 +29,7 @@
<string name="sync_SPr_sync_key">sync_sync</string>
<!-- Preference Key (do not translate) -->
<string name="sync_SPr_forget_key">sync_forget</string>
<!-- Preference Key (do not translate) -->
<string name="sync_SPr_key_options">sync_options</string>
</resources>

@ -155,8 +155,10 @@
<!-- Status Group Label -->
<string name="sync_SPr_group_status">Status</string>
<!-- Sync status subtitle, %s-> status message -->
<string name="sync_SPr_status_subtitle">Status: %s</string>
<!-- Sync Status: log in -->
<string name="sync_status_loggedout">Not Logged In!</string>
<string name="sync_status_loggedout">Not Logged In</string>
<!-- Status: ongoing -->
<string name="sync_status_ongoing">Sync Ongoing...</string>
<!-- Sync Status: success status (%s -> last sync date). Keep it short!-->
@ -191,7 +193,7 @@
<string name="sync_SPr_group_actions">Actions</string>
<!-- Synchronize Now Button -->
<string name="sync_SPr_sync">Synchronize Now!</string>
<string name="sync_SPr_sync">Synchronize Now</string>
<!-- Synchronize Now Button if not logged in-->
<string name="sync_SPr_sync_log_in">Log In &amp; Synchronize!</string>

@ -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);
}
}

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.timsu.astrid"
android:versionName="4.0.1"
android:versionCode="252">
android:versionName="4.0.2"
android:versionCode="253">
<!-- widgets, alarms, and services will break if Astrid is installed on SD card -->
<!-- android:installLocation="internalOnly"> -->

@ -127,6 +127,10 @@
match="TASK_RABBIT_URL = .*"
replace="TASK_RABBIT_URL = &quot;${apikey.taskrabbit.url}&quot;;" />
<replaceregexp file="${source.dir}/com/todoroo/astrid/taskrabbit/TaskRabbitMapActivity.java"
match="MAPS_API_KEY = .*"
replace="MAPS_API_KEY = &quot;${apikey.maps}&quot;;" />
<replaceregexp file="${source.dir}/com/todoroo/astrid/gtasks/api/GtasksInvoker.java"
match="API_KEY = .*"
replace="API_KEY = &quot;${apikey.gtasks}&quot;;" />

@ -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

@ -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<String> options = new ArrayList<String>();
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<String> adapter = new ArrayAdapter<String>(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/*");

@ -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) {

@ -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();
}
}

@ -110,6 +110,8 @@ public class EditPeopleControlSet extends PopupControlSet {
private AssignedToUser taskRabbitUser = null;
private boolean loadedUI = false;
private final List<AssignedChangedListener> listeners = new LinkedList<AssignedChangedListener>();
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<JSONObject> sharedPeople) throws JSONException {
private void buildCollaborators(final ArrayList<JSONObject> sharedPeople) {
activity.runOnUiThread(new Runnable() {
@Override
@ -318,94 +327,98 @@ public class EditPeopleControlSet extends PopupControlSet {
}
@SuppressWarnings("nls")
private void buildAssignedToSpinner(Task t, ArrayList<JSONObject> sharedPeople) throws JSONException {
private void buildAssignedToSpinner(Task t, ArrayList<JSONObject> sharedPeople) {
HashSet<Long> userIds = new HashSet<Long>();
HashSet<String> emails = new HashSet<String>();
HashMap<String, AssignedToUser> names = new HashMap<String, AssignedToUser>();
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<String>)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<String>)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

@ -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();
}
}

@ -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();
}

@ -268,10 +268,13 @@ abstract public class OrderedListUpdater<LIST> {
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());
}

@ -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();
}

@ -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);
}
}
}

@ -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);

@ -1,18 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/task_rabbit_map_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
style="@style/Content_EditScroll" >
<com.google.android.maps.MapView
android:id="@+id/map_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="12"
android:apiKey="0J-miH1uUbgW2wG77C9qZiqvpBW8FEnoRnn7qBw"
android:clickable="true" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"

@ -407,7 +407,7 @@
<string name="tr_alert_title_fail">Error posting task</string>
<string name="tr_alert_message_fail">Please try again</string>
<string name="tr_alert_button_close">Close</string>
<string name="tr_alert_gps_title">GPS needs to be enabled in order to add location based tasks. Do you want to enable it?</string>
<string name="tr_alert_gps_title">Wireless Network Location Provider needs to be enabled in order to add location based tasks. Do you want to enable it?</string>
<string name="tr_alert_gps_yes">Yes</string>
<string name="tr_alert_gps_no">No</string>

@ -300,6 +300,8 @@
<string name="sync_SPr_sync_key">sync_sync</string>
<!-- Preference Key (do not translate) -->
<string name="sync_SPr_forget_key">sync_forget</string>
<!-- Preference Key (do not translate) -->
<string name="sync_SPr_key_options">sync_options</string>
<!-- ===========================================================ACTFM == -->
<string name="actfm_https_key">actfmHttps</string>

@ -512,8 +512,8 @@
<!-- Preferences: Auto-load Ideas Tab -->
<string name="EPr_ideaAuto_title">Auto-load Ideas Tab</string>
<string name="EPr_ideaAuto_desc_enabled">Web searches for Ideas tab will be performed when task is edited</string>
<string name="EPr_ideaAuto_desc_disabled">Web searches for Ideas tab will be performed when tab is clicked</string>
<string name="EPr_ideaAuto_desc_enabled">Web searches for Ideas tab will be performed when tab is clicked</string>
<string name="EPr_ideaAuto_desc_disabled">Web searches for Ideas tab will be performed only when manually requested</string>
<!-- Preference: Theme -->
<string name="EPr_theme_title">Color Theme</string>

@ -14,6 +14,7 @@
</PreferenceCategory>
<PreferenceCategory
android:key="@string/sync_SPr_key_options"
android:title="@string/sync_SPr_group_options">
<com.todoroo.astrid.ui.MultilineListPreference
@ -21,19 +22,11 @@
android:entries="@array/sync_SPr_interval_entries"
android:entryValues="@array/sync_SPr_interval_values"
android:title="@string/sync_SPr_interval_title" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:key="@string/actfm_https_key"
android:title="@string/actfm_https_title"
android:defaultValue="false"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/sync_SPr_group_actions">
<com.todoroo.astrid.ui.MultilinePreference
android:key="@string/sync_SPr_sync_key"
android:title="@string/sync_SPr_sync" />
<com.todoroo.astrid.ui.MultilinePreference
android:key="@string/sync_SPr_forget_key"

@ -14,6 +14,7 @@
</PreferenceCategory>
<PreferenceCategory
android:key="@string/sync_SPr_key_options"
android:title="@string/sync_SPr_group_options">
<com.todoroo.astrid.ui.MultilineListPreference
@ -21,22 +22,12 @@
android:entries="@array/sync_SPr_interval_entries"
android:entryValues="@array/sync_SPr_interval_values"
android:title="@string/sync_SPr_interval_title" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/sync_SPr_group_actions">
<com.todoroo.astrid.ui.MultilinePreference
android:key="@string/sync_SPr_sync_key"
android:title="@string/sync_SPr_sync"
android:summary=""/>
<com.todoroo.astrid.ui.MultilinePreference
android:key="@string/sync_SPr_forget_key"
android:title="@string/sync_SPr_forget"
android:summary="@string/sync_SPr_forget_description" />
</PreferenceCategory>
</PreferenceScreen>

@ -14,6 +14,7 @@
</PreferenceCategory>
<PreferenceCategory
android:key="@string/sync_SPr_key_options"
android:title="@string/sync_SPr_group_options">
<com.todoroo.astrid.ui.MultilineListPreference
@ -25,14 +26,6 @@
<com.todoroo.astrid.ui.MultilineListPreference
android:key="@string/producteev_PPr_defaultdash_key"
android:title="@string/producteev_PPr_defaultdash_title" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/sync_SPr_group_actions">
<com.todoroo.astrid.ui.MultilinePreference
android:key="@string/sync_SPr_sync_key"
android:title="@string/sync_SPr_sync" />
<com.todoroo.astrid.ui.MultilinePreference
android:key="@string/sync_SPr_forget_key"

@ -161,7 +161,11 @@ public class AstridActivity extends FragmentActivity
if(item instanceof Filter) {
Filter filter = (Filter)item;
Bundle extras = configureIntentAndExtrasWithFilter(intent, filter);
if (fragmentLayout == LAYOUT_TRIPLE && getTaskEditFragment() != null) {
onBackPressed(); // remove the task edit fragment when switching between lists
}
setupTasklistFragmentWithFilter(filter, extras);
// no animation for dualpane-layout

@ -49,6 +49,7 @@ import com.todoroo.astrid.service.StartupService;
import com.todoroo.astrid.service.StatisticsConstants;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.sync.SyncProviderPreferences;
import com.todoroo.astrid.ui.ContactListAdapter;
import com.todoroo.astrid.utility.Constants;
import com.todoroo.astrid.utility.Flags;
@ -67,6 +68,8 @@ public class EditPreferences extends TodorooPreferenceActivity {
private static final int APPEARANCE_PREFERENCE = 3;
private static final int POWER_PACK_PREFERENCE = 4;
private static final int REQUEST_CODE_SYNC = 0;
public static final int RESULT_CODE_THEME_CHANGED = 1;
// --- instance variables
@ -186,7 +189,7 @@ public class EditPreferences extends TodorooPreferenceActivity {
// that have a settings action
for(int i = 0; i < length; i++) {
ResolveInfo resolveInfo = resolveInfoList.get(i);
Intent intent = new Intent(AstridApiConstants.ACTION_SETTINGS);
final Intent intent = new Intent(AstridApiConstants.ACTION_SETTINGS);
intent.setClassName(resolveInfo.activityInfo.packageName,
resolveInfo.activityInfo.name);
@ -196,7 +199,22 @@ public class EditPreferences extends TodorooPreferenceActivity {
Preference preference = new Preference(this);
preference.setTitle(resolveInfo.activityInfo.loadLabel(pm));
preference.setIntent(intent);
try {
Class<?> 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) {

@ -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();

@ -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);
}

@ -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<SyncAction> syncActions = new LinkedHashSet<SyncAction>();
@ -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);
}
};

@ -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
*

@ -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",

@ -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);

@ -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();

@ -5,8 +5,5 @@
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry combineaccessrules="false" kind="src" path="/astrid"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry combineaccessrules="false" kind="src" path="/astridApi"/>
<classpathentry combineaccessrules="false" kind="src" path="/facebook"/>
<classpathentry combineaccessrules="false" kind="src" path="/GreenDroid"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

@ -9,5 +9,3 @@
# Project target.
target=android-14
android.library.reference.1=../api
android.library.reference.2=../facebook/facebook

@ -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 {

@ -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";

@ -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<GoogleTaskTask> 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<ListAction> actions = new ArrayList<ListAction>();
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());
}
}//*/

@ -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<REMOTE_MODEL> 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

@ -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<Task> {
@ -42,7 +42,6 @@ public class RepeatTestsActFmSync extends AbstractSyncRepeatTests<Task> {
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<Task> {
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<Task> {
}
}
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<Task> {
@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);
}

@ -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<com.google.api.services.tasks.model.Task> {
@ -45,7 +45,6 @@ public class RepeatTestsGtasksSync extends AbstractSyncRepeatTests<com.google.ap
protected void setUp() throws Exception {
super.setUp();
Preferences.setStringFromInteger(R.string.p_default_urgency_key, 0);
RepeatTaskCompleteListener.setSkipActFmCheck(true);
if (!initialized) {
initializeTestService();
@ -57,7 +56,21 @@ public class RepeatTestsGtasksSync extends AbstractSyncRepeatTests<com.google.ap
@Override
protected void waitAndSync() {
AndroidUtilities.sleepDeep(3000L);
new GtasksSyncProvider().synchronize(null);
new GtasksSyncV2Provider().synchronizeActiveTasks(true, new SyncResultCallbackAdapter() {
@Override
public void finished() {
synchronized(RepeatTestsGtasksSync.this) {
RepeatTestsGtasksSync.this.notify();
}
}
});
try {
synchronized(this) {
wait();
}
} catch (InterruptedException e) {
fail("Interrupted while waiting for sync to finish");
}
AndroidUtilities.sleepDeep(3000L);
}

@ -75,6 +75,9 @@
<arg value="-e" />
<arg value="coverageFile" />
<arg value="${emma.dump.file}" />
<arg value="-e" />
<arg value="delay_msec" />
<arg value="15" />
</extra-instrument-args>
</run-tests-helper>

Loading…
Cancel
Save