diff --git a/astrid/AndroidManifest.xml b/astrid/AndroidManifest.xml
index 72c1cb1a1..69f5c00ed 100644
--- a/astrid/AndroidManifest.xml
+++ b/astrid/AndroidManifest.xml
@@ -343,34 +343,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/astrid/plugin-src/com/todoroo/astrid/backup/TasksXmlImporter.java b/astrid/plugin-src/com/todoroo/astrid/backup/TasksXmlImporter.java
index 3409da542..e56407cc5 100644
--- a/astrid/plugin-src/com/todoroo/astrid/backup/TasksXmlImporter.java
+++ b/astrid/plugin-src/com/todoroo/astrid/backup/TasksXmlImporter.java
@@ -38,7 +38,6 @@ import com.todoroo.astrid.legacy.LegacyRepeatInfo.LegacyRepeatInterval;
import com.todoroo.astrid.legacy.LegacyTaskModel;
import com.todoroo.astrid.model.Metadata;
import com.todoroo.astrid.model.Task;
-import com.todoroo.astrid.rmilk.data.MilkTask;
import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.tags.TagService;
@@ -379,10 +378,10 @@ public class TasksXmlImporter {
Metadata metadata = new Metadata();
metadata.setValue(Metadata.TASK, currentTask.getId());
- metadata.setValue(MilkTask.LIST_ID, Long.parseLong(listId));
- metadata.setValue(MilkTask.TASK_SERIES_ID, Long.parseLong(taskSeriesId));
- metadata.setValue(MilkTask.TASK_ID, Long.parseLong(taskId));
- metadata.setValue(MilkTask.REPEATING, syncOnComplete ? 1 : 0);
+ metadata.setValue(Metadata.VALUE1, (listId));
+ metadata.setValue(Metadata.VALUE2, (taskSeriesId));
+ metadata.setValue(Metadata.VALUE3, (taskId));
+ metadata.setValue(Metadata.VALUE4, syncOnComplete ? "1" : "0"); //$NON-NLS-1$ //$NON-NLS-2$
metadataService.save(metadata);
return true;
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevDataService.java b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevDataService.java
index 32a2518df..52fbfd0b5 100644
--- a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevDataService.java
+++ b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevDataService.java
@@ -21,16 +21,15 @@ import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Join;
import com.todoroo.andlib.sql.Query;
import com.todoroo.astrid.dao.MetadataDao;
-import com.todoroo.astrid.dao.StoreObjectDao;
-import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
+import com.todoroo.astrid.dao.StoreObjectDao;
import com.todoroo.astrid.dao.StoreObjectDao.StoreObjectCriteria;
+import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.model.Metadata;
import com.todoroo.astrid.model.StoreObject;
import com.todoroo.astrid.model.Task;
import com.todoroo.astrid.producteev.ProducteevUtilities;
-import com.todoroo.astrid.rmilk.data.MilkNote;
import com.todoroo.astrid.tags.TagService;
public final class ProducteevDataService {
@@ -40,6 +39,8 @@ public final class ProducteevDataService {
/** Utility for joining tasks with metadata */
public static final Join METADATA_JOIN = Join.left(Metadata.TABLE, Task.ID.eq(Metadata.TASK));
+ public static final String MILK_NOTE_KEY = "rmilk-note"; //$NON-NLS-1$
+
// --- singleton
private static ProducteevDataService instance = null;
@@ -166,7 +167,7 @@ public final class ProducteevDataService {
where(Criterion.and(MetadataCriteria.byTask(task.getId()),
Criterion.or(MetadataCriteria.withKey(TagService.KEY),
MetadataCriteria.withKey(ProducteevTask.METADATA_KEY),
- MetadataCriteria.withKey(MilkNote.METADATA_KEY), // to sync rmilk notes
+ MetadataCriteria.withKey(MILK_NOTE_KEY), // to sync rmilk notes
MetadataCriteria.withKey(ProducteevNote.METADATA_KEY)))));
try {
for(metadataCursor.moveToFirst(); !metadataCursor.isAfterLast(); metadataCursor.moveToNext()) {
diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java
index 909f1a57b..7f08f6d80 100644
--- a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java
+++ b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java
@@ -43,7 +43,6 @@ import com.todoroo.astrid.producteev.api.ApiResponseParseException;
import com.todoroo.astrid.producteev.api.ApiServiceException;
import com.todoroo.astrid.producteev.api.ApiUtilities;
import com.todoroo.astrid.producteev.api.ProducteevInvoker;
-import com.todoroo.astrid.rmilk.data.MilkNote;
import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.utility.Preferences;
@@ -437,11 +436,18 @@ public class ProducteevSyncProvider extends SyncProvider producteev note
- if(local.findMetadata(MilkNote.METADATA_KEY) != null && (remote == null ||
+ if(local.findMetadata(ProducteevDataService.MILK_NOTE_KEY) != null && (remote == null ||
(remote.findMetadata(ProducteevNote.METADATA_KEY) == null))) {
for(Metadata item : local.metadata) {
- if(MilkNote.METADATA_KEY.equals(item.getValue(Metadata.KEY))) {
- String message = MilkNote.toTaskDetail(item);
+ if(ProducteevDataService.MILK_NOTE_KEY.equals(item.getValue(Metadata.KEY))) {
+ String title = item.getValue(Metadata.VALUE2);
+ String text = item.getValue(Metadata.VALUE3);
+ String message;
+ if(!TextUtils.isEmpty(title))
+ message = title + "\n" + text;
+ else
+ message = text;
+
JSONObject result = invoker.tasksNoteCreate(idTask, message);
local.metadata.add(ProducteevNote.create(result.getJSONObject("note")));
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/EditOperationExposer.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/EditOperationExposer.java
deleted file mode 100644
index e6d696235..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/EditOperationExposer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * See the file "LICENSE" for the full license governing this code.
- */
-package com.todoroo.astrid.rmilk;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-
-import com.todoroo.astrid.R;
-import com.todoroo.astrid.api.AstridApiConstants;
-import com.todoroo.astrid.api.EditOperation;
-
-/**
- * Exposes {@link EditOperation} for Remember the Milk
- *
- * @author Tim Su
- *
- */
-public class EditOperationExposer extends BroadcastReceiver {
-
- @Override
- public void onReceive(Context context, Intent intent) {
- // if we aren't logged in, don't expose features
- if(!Utilities.isLoggedIn())
- return;
-
- long taskId = intent
- .getLongExtra(AstridApiConstants.EXTRAS_TASK_ID, -1);
- if (taskId == -1)
- return;
-
- EditOperation taskEditOperation;
- Intent editIntent = new Intent(context, MilkEditActivity.class);
- taskEditOperation = new EditOperation(context.getString(
- R.string.rmilk_EOE_button), editIntent);
-
- // transmit
- EditOperation[] operations = new EditOperation[1];
- operations[0] = taskEditOperation;
- Intent broadcastIntent = new Intent(
- AstridApiConstants.BROADCAST_SEND_EDIT_OPERATIONS);
- broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ITEMS, operations);
- context.sendBroadcast(broadcastIntent,
- AstridApiConstants.PERMISSION_READ);
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkBackgroundService.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkBackgroundService.java
deleted file mode 100644
index 33f1a2f2f..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkBackgroundService.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package com.todoroo.astrid.rmilk;
-
-import android.app.AlarmManager;
-import android.app.PendingIntent;
-import android.app.Service;
-import android.content.Context;
-import android.content.Intent;
-import android.os.IBinder;
-import android.util.Log;
-
-import com.timsu.astrid.R;
-import com.todoroo.andlib.service.ContextManager;
-import com.todoroo.andlib.utility.DateUtilities;
-import com.todoroo.astrid.core.PluginServices;
-import com.todoroo.astrid.rmilk.sync.RTMSyncProvider;
-import com.todoroo.astrid.utility.Preferences;
-
-/**
- * SynchronizationService is the service that performs Astrid's background
- * synchronization with online task managers. Starting this service
- * schedules a repeating alarm which handles the synchronization
- *
- * @author Tim Su
- *
- */
-public class MilkBackgroundService extends Service {
-
- /** Minimum time before an auto-sync */
- private static final long AUTO_SYNC_MIN_OFFSET = 5*60*1000L;
-
- /** alarm identifier */
- private static final String SYNC_ACTION = "sync"; //$NON-NLS-1$
-
- // --- BroadcastReceiver abstract methods
-
- /** Receive the alarm - start the synchronize service! */
- @Override
- public void onStart(Intent intent, int startId) {
- try {
- startSynchronization(this);
- } catch (Exception e) {
- PluginServices.getExceptionService().reportError("rtm-bg-sync", e); //$NON-NLS-1$
- }
- }
-
- /** Start the actual synchronization */
- private void startSynchronization(Context context) {
- if(context == null || context.getResources() == null)
- return;
-
- ContextManager.setContext(context);
-
- if(MilkUtilities.isOngoing())
- return;
-
- PluginServices.getTaskService();
- new RTMSyncProvider().synchronize(context);
- }
-
- // --- alarm management
-
- /**
- * Schedules repeating alarm for auto-synchronization
- */
- public static void scheduleService() {
- int syncFrequencySeconds = Preferences.getIntegerFromString(
- R.string.rmilk_MPr_interval_key, -1);
- Context context = ContextManager.getContext();
- if(syncFrequencySeconds <= 0) {
- unscheduleService(context);
- return;
- }
-
- // figure out synchronization frequency
- long interval = 1000L * syncFrequencySeconds;
- long offset = computeNextSyncOffset(interval);
-
- // give a little padding
- offset = Math.max(offset, AUTO_SYNC_MIN_OFFSET);
-
- AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
- PendingIntent pendingIntent = PendingIntent.getService(context, 0,
- createAlarmIntent(context), PendingIntent.FLAG_UPDATE_CURRENT);
-
- Log.i("Astrid", "Autosync set for " + offset / 1000 //$NON-NLS-1$ //$NON-NLS-2$
- + " seconds repeating every " + syncFrequencySeconds); //$NON-NLS-1$
-
- // cancel all existing
- am.cancel(pendingIntent);
-
- // schedule new
- am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + offset,
- interval, pendingIntent);
- }
-
-
- /**
- * Removes repeating alarm for auto-synchronization
- */
- private static void unscheduleService(Context context) {
- AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
- PendingIntent pendingIntent = PendingIntent.getService(context, 0,
- createAlarmIntent(context), PendingIntent.FLAG_UPDATE_CURRENT);
- am.cancel(pendingIntent);
- }
-
- /** Create the alarm intent */
- private static Intent createAlarmIntent(Context context) {
- Intent intent = new Intent(context, MilkBackgroundService.class);
- intent.setAction(SYNC_ACTION);
- return intent;
- }
-
- // --- utility methods
-
-
- private static long computeNextSyncOffset(long interval) {
- // figure out last synchronize time
- long lastSyncDate = MilkUtilities.getLastSyncDate();
-
- // if user never synchronized, give them a full offset period before bg sync
- if(lastSyncDate != 0)
- return Math.max(0, lastSyncDate + interval - DateUtilities.now());
- else
- return interval;
- }
-
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkDetailExposer.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkDetailExposer.java
deleted file mode 100644
index 6f0eebdd4..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkDetailExposer.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * See the file "LICENSE" for the full license governing this code.
- */
-package com.todoroo.astrid.rmilk;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-
-import com.timsu.astrid.R;
-import com.todoroo.andlib.data.TodorooCursor;
-import com.todoroo.astrid.adapter.TaskAdapter;
-import com.todoroo.astrid.api.AstridApiConstants;
-import com.todoroo.astrid.api.DetailExposer;
-import com.todoroo.astrid.model.Metadata;
-import com.todoroo.astrid.rmilk.data.MilkDataService;
-import com.todoroo.astrid.rmilk.data.MilkNote;
-import com.todoroo.astrid.rmilk.data.MilkTask;
-
-/**
- * Exposes Task Details for Remember the Milk:
- * - RTM list
- * - RTM repeat information
- * - RTM notes
- *
- * @author Tim Su
- *
- */
-public class MilkDetailExposer extends BroadcastReceiver implements DetailExposer{
-
- @Override
- public void onReceive(Context context, Intent intent) {
- // if we aren't logged in, don't expose features
- if(!MilkUtilities.isLoggedIn())
- return;
-
- long taskId = intent.getLongExtra(AstridApiConstants.EXTRAS_TASK_ID, -1);
- if(taskId == -1)
- return;
-
- boolean extended = intent.getBooleanExtra(AstridApiConstants.EXTRAS_EXTENDED, false);
- String taskDetail = getTaskDetails(context, taskId, extended);
- if(taskDetail == null)
- return;
-
- Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_DETAILS);
- broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, MilkUtilities.IDENTIFIER);
- broadcastIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
- broadcastIntent.putExtra(AstridApiConstants.EXTRAS_EXTENDED, extended);
- broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, taskDetail);
- context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
- }
-
- @Override
- public String getTaskDetails(Context context, long id, boolean extended) {
- Metadata metadata = MilkDataService.getInstance().getTaskMetadata(id);
- if(metadata == null)
- return null;
-
- StringBuilder builder = new StringBuilder();
-
- if(!extended) {
- long listId = metadata.getValue(MilkTask.LIST_ID);
- String listName = MilkDataService.getInstance().getListName(listId);
- // RTM list is out of date. don't display RTM stuff
- if(listName == null)
- return null;
-
- if(listId > 0 && !"Inbox".equals(listName)) { //$NON-NLS-1$
- builder.append("
").append(listName).append(TaskAdapter.DETAIL_SEPARATOR); //$NON-NLS-1$
- }
-
- int repeat = metadata.getValue(MilkTask.REPEATING);
- if(repeat != 0) {
- builder.append(context.getString(R.string.rmilk_TLA_repeat)).append(TaskAdapter.DETAIL_SEPARATOR);
- }
- } else {
- TodorooCursor notesCursor = MilkDataService.getInstance().getTaskNotesCursor(id);
- try {
- for(notesCursor.moveToFirst(); !notesCursor.isAfterLast(); notesCursor.moveToNext()) {
- metadata.readFromCursor(notesCursor);
- builder.append(MilkNote.toTaskDetail(metadata)).append(TaskAdapter.DETAIL_SEPARATOR);
- }
- } finally {
- notesCursor.close();
- }
- }
-
- if(builder.length() == 0)
- return null;
- String result = builder.toString();
- return result.substring(0, result.length() - TaskAdapter.DETAIL_SEPARATOR.length());
- }
-
- @Override
- public String getPluginIdentifier() {
- return MilkUtilities.IDENTIFIER;
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkEditActivity.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkEditActivity.java
deleted file mode 100644
index 3f132b574..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkEditActivity.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * See the file "LICENSE" for the full license governing this code.
- */
-package com.todoroo.astrid.rmilk;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.Spinner;
-
-import com.todoroo.astrid.R;
-import com.todoroo.astrid.api.AstridApiConstants;
-import com.todoroo.astrid.model.Task;
-import com.todoroo.astrid.rmilk.Utilities.ListContainer;
-import com.todoroo.astrid.rmilk.data.MilkDataService;
-
-/**
- * Displays a dialog box for users to edit their RTM stuff
- *
- * @author Tim Su
- *
- */
-public class MilkEditActivity extends Activity {
-
- long taskId;
- MilkDataService service;
- Task model;
-
- Spinner list;
- EditText repeat;
-
- /** Called when loading up the activity */
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- taskId = getIntent().getLongExtra(AstridApiConstants.EXTRAS_TASK_ID, -1);
- if(taskId == -1)
- return;
-
- setContentView(R.layout.rmilk_edit_activity);
- setTitle(R.string.rmilk_MEA_title);
-
- ((Button)findViewById(R.id.ok)).setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- saveAndQuit();
- }
- });
- ((Button)findViewById(R.id.cancel)).setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- setResult(RESULT_CANCELED);
- finish();
- }
- });
-
- // load all lists
- service = new MilkDataService(this);
- ListContainer[] lists = service.getLists();
-
- list = (Spinner) findViewById(R.id.rmilk_list);
- ArrayAdapter listAdapter = new ArrayAdapter(
- this, android.R.layout.simple_spinner_item,
- lists);
- listAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- list.setAdapter(listAdapter);
-
- // load model
- model = service.readTask(taskId);
- repeat.setText(model.getValue(MilkDataService.REPEAT));
- list.setSelection(0); // TODO
- }
-
- /**
- * Save tags to task and then quit
- */
- protected void saveAndQuit() {
- // model.setValue(DataService.LIST_ID, list.getSelectedItem()); TODO
-
- setResult(RESULT_OK);
- finish();
- }
-
-}
\ No newline at end of file
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkFilterExposer.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkFilterExposer.java
deleted file mode 100644
index 3075acae7..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkFilterExposer.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * See the file "LICENSE" for the full license governing this code.
- */
-package com.todoroo.astrid.rmilk;
-
-import android.content.BroadcastReceiver;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.Intent;
-
-import com.timsu.astrid.R;
-import com.todoroo.andlib.sql.Criterion;
-import com.todoroo.andlib.sql.QueryTemplate;
-import com.todoroo.astrid.api.AstridApiConstants;
-import com.todoroo.astrid.api.Filter;
-import com.todoroo.astrid.api.FilterCategory;
-import com.todoroo.astrid.api.FilterListHeader;
-import com.todoroo.astrid.api.FilterListItem;
-import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
-import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
-import com.todoroo.astrid.model.Metadata;
-import com.todoroo.astrid.rmilk.MilkUtilities.ListContainer;
-import com.todoroo.astrid.rmilk.data.MilkDataService;
-import com.todoroo.astrid.rmilk.data.MilkTask;
-
-/**
- * Exposes filters based on RTM lists
- *
- * @author Tim Su
- *
- */
-public class MilkFilterExposer extends BroadcastReceiver {
-
- private Filter filterFromList(Context context, ListContainer list) {
- String listTitle = list.name;
- String title = context.getString(R.string.rmilk_FEx_list_title, list.name);
- ContentValues values = new ContentValues();
- values.put(Metadata.KEY.name, MilkTask.METADATA_KEY);
- values.put(MilkTask.LIST_ID.name, list.id);
- values.put(MilkTask.TASK_SERIES_ID.name, 0);
- values.put(MilkTask.TASK_ID.name, 0);
- values.put(MilkTask.REPEATING.name, 0);
- Filter filter = new Filter(listTitle, title, new QueryTemplate().join(
- MilkDataService.METADATA_JOIN).where(Criterion.and(
- MetadataCriteria.withKey(MilkTask.METADATA_KEY),
- TaskCriteria.isActive(),
- TaskCriteria.isVisible(),
- MilkTask.LIST_ID.eq(list.id))),
- values);
-
- return filter;
- }
-
- @Override
- public void onReceive(Context context, Intent intent) {
- // if we aren't logged in, don't expose features
- if(!MilkUtilities.isLoggedIn())
- return;
-
- ListContainer[] lists = MilkDataService.getInstance().getListsWithCounts();
-
- // If user does not have any tags, don't show this section at all
- if(lists.length == 0)
- return;
-
- Filter[] listFilters = new Filter[lists.length];
- for(int i = 0; i < lists.length; i++)
- listFilters[i] = filterFromList(context, lists[i]);
-
- FilterListHeader rtmHeader = new FilterListHeader(context.getString(R.string.rmilk_FEx_header));
- FilterCategory rtmLists = new FilterCategory(context.getString(R.string.rmilk_FEx_list),
- listFilters);
-
- // transmit filter list
- FilterListItem[] list = new FilterListItem[2];
- list[0] = rtmHeader;
- list[1] = rtmLists;
- Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_FILTERS);
- broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, MilkUtilities.IDENTIFIER);
- broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, list);
- context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkLoginActivity.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkLoginActivity.java
deleted file mode 100644
index 2e5d350ac..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkLoginActivity.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * ASTRID: Android's Simple Task Recording Dashboard
- *
- * Copyright (c) 2009 Tim Su
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-package com.todoroo.astrid.rmilk;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.os.Handler;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.webkit.WebView;
-import android.webkit.WebViewClient;
-import android.widget.Button;
-
-import com.timsu.astrid.R;
-import com.todoroo.andlib.service.Autowired;
-import com.todoroo.andlib.service.DependencyInjectionService;
-import com.todoroo.andlib.utility.DialogUtilities;
-
-/**
- * This activity displays a WebView that allows users to log in to the
- * synchronization provider requested. A callback method determines whether
- * their login was successful and therefore whether to dismiss the dialog.
- *
- * @author timsu
- *
- */
-public class MilkLoginActivity extends Activity {
-
- @Autowired
- DialogUtilities dialogUtilities;
-
- // --- bundle arguments
-
- /**
- * URL to display
- */
- public static final String URL_TOKEN = "u"; //$NON-NLS-1$
-
- // --- callback
-
- /** Callback interface */
- public interface SyncLoginCallback {
- /**
- * Verifies whether the user's login attempt was successful. Will be
- * called off of the UI thread, use the handler to post messages.
- *
- * @return error string, or null if sync was successful
- */
- public String verifyLogin(Handler handler);
- }
-
- protected static SyncLoginCallback callback = null;
-
- /** Sets callback method */
- public static void setCallback(SyncLoginCallback newCallback) {
- callback = newCallback;
- }
-
- // --- ui initialization
-
- public MilkLoginActivity() {
- super();
- DependencyInjectionService.getInstance().inject(this);
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.rmilk_login_activity);
- setTitle(R.string.rmilk_MPr_header);
-
- String urlParam = getIntent().getStringExtra(URL_TOKEN);
-
- final WebView webView = (WebView)findViewById(R.id.browser);
- Button done = (Button)findViewById(R.id.done);
- Button cancel = (Button)findViewById(R.id.cancel);
-
- webView.setWebViewClient(new WebViewClient() {
- @Override
- public boolean shouldOverrideUrlLoading(WebView view, String url) {
- view.loadUrl(url);
- return true;
- }
- });
- webView.getSettings().setJavaScriptEnabled(true);
- webView.getSettings().setSavePassword(false);
- webView.getSettings().setSupportZoom(true);
- webView.loadUrl(urlParam);
-
- done.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- final Handler handler = new Handler();
-
- if(callback == null) {
- finish();
- return;
- }
-
- new Thread(new Runnable() {
- public void run() {
- final String result = callback.verifyLogin(handler);
- if(result == null) {
- finish();
- } else {
- // display the error
- handler.post(new Runnable() {
- public void run() {
- dialogUtilities.okDialog(MilkLoginActivity.this,
- result, null);
- }
- });
- }
- }
- }).start();
- }
- });
-
- cancel.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- setResult(RESULT_CANCELED);
- finish();
- }
- });
- }
-}
\ No newline at end of file
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkPreferences.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkPreferences.java
deleted file mode 100644
index eb36a57d5..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkPreferences.java
+++ /dev/null
@@ -1,193 +0,0 @@
-package com.todoroo.astrid.rmilk;
-
-import java.util.Date;
-
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.DialogInterface.OnClickListener;
-import android.content.res.Resources;
-import android.graphics.Color;
-import android.os.Bundle;
-import android.preference.Preference;
-import android.preference.Preference.OnPreferenceClickListener;
-import android.view.View;
-import android.view.ViewGroup.OnHierarchyChangeListener;
-
-import com.timsu.astrid.R;
-import com.todoroo.andlib.service.Autowired;
-import com.todoroo.andlib.utility.AndroidUtilities;
-import com.todoroo.andlib.utility.DateUtilities;
-import com.todoroo.andlib.utility.DialogUtilities;
-import com.todoroo.andlib.widget.TodorooPreferences;
-import com.todoroo.astrid.rmilk.sync.RTMSyncProvider;
-
-/**
- * Displays synchronization preferences and an action panel so users can
- * initiate actions from the menu.
- *
- * @author timsu
- *
- */
-public class MilkPreferences extends TodorooPreferences {
-
- @Autowired
- private DialogUtilities dialogUtilities;
-
- private int statusColor = Color.BLACK;
-
- @Override
- public int getPreferenceResource() {
- return R.xml.preferences_rmilk;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getListView().setOnHierarchyChangeListener(new OnHierarchyChangeListener() {
-
- @Override
- public void onChildViewRemoved(View parent, View child) {
- //
- }
-
- @Override
- public void onChildViewAdded(View parent, View child) {
- View view = findViewById(R.id.status);
- if(view != null)
- view.setBackgroundColor(statusColor);
- }
- });
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- MilkBackgroundService.scheduleService();
- }
-
- /**
- *
- * @param resource
- * if null, updates all resources
- */
- @Override
- public void updatePreferences(Preference preference, Object value) {
- final Resources r = getResources();
-
- // interval
- if (r.getString(R.string.rmilk_MPr_interval_key).equals(
- preference.getKey())) {
- int index = AndroidUtilities.indexOf(
- r.getStringArray(R.array.sync_SPr_interval_values),
- (String) value);
- if (index <= 0)
- preference.setSummary(R.string.sync_SPr_interval_desc_disabled);
- else
- preference.setSummary(r.getString(
- R.string.sync_SPr_interval_desc,
- r.getStringArray(R.array.sync_SPr_interval_entries)[index]));
- }
-
- // status
- else if (r.getString(R.string.sync_SPr_status_key).equals(preference.getKey())) {
- boolean loggedIn = MilkUtilities.isLoggedIn();
- String status;
- 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) {
- startService(new Intent(MilkPreferences.this, MilkBackgroundService.class));
- finish();
- return true;
- }
- });
- }
- // sync is occurring
- else if(MilkUtilities.isOngoing()) {
- status = r.getString(R.string.sync_status_ongoing);
- statusColor = Color.rgb(0, 0, 100);
- }
- // last sync was error
- else if(MilkUtilities.getLastAttemptedSyncDate() != 0) {
- status = r.getString(R.string.sync_status_failed,
- DateUtilities.getDateStringWithTime(MilkPreferences.this,
- new Date(MilkUtilities.getLastAttemptedSyncDate())));
- if(MilkUtilities.getLastSyncDate() > 0) {
- subtitle = r.getString(R.string.sync_status_failed_subtitle,
- DateUtilities.getDateStringWithTime(MilkPreferences.this,
- new Date(MilkUtilities.getLastSyncDate())));
- }
- statusColor = Color.rgb(100, 0, 0);
- preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- public boolean onPreferenceClick(Preference p) {
- String error = MilkUtilities.getLastError();
- if(error != null)
- dialogUtilities.okDialog(MilkPreferences.this, error, null);
- return true;
- }
- });
- } else if(MilkUtilities.getLastSyncDate() > 0) {
- status = r.getString(R.string.sync_status_success,
- DateUtilities.getDateStringWithTime(MilkPreferences.this,
- new Date(MilkUtilities.getLastSyncDate())));
- statusColor = Color.rgb(0, 100, 0);
- } else {
- status = r.getString(R.string.sync_status_never);
- statusColor = Color.rgb(0, 0, 100);
- preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- public boolean onPreferenceClick(Preference p) {
- startService(new Intent(MilkPreferences.this, MilkBackgroundService.class));
- finish();
- return true;
- }
- });
- }
- preference.setTitle(status);
- preference.setSummary(subtitle);
-
- 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 = MilkUtilities.isLoggedIn();
- preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- public boolean onPreferenceClick(Preference p) {
- startService(new Intent(MilkPreferences.this, MilkBackgroundService.class));
- finish();
- return true;
- }
- });
- if(!loggedIn)
- preference.setTitle(R.string.sync_SPr_sync_log_in);
- }
-
- // log out button
- else if (r.getString(R.string.sync_SPr_forget_key).equals(preference.getKey())) {
- boolean loggedIn = MilkUtilities.isLoggedIn();
- preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- public boolean onPreferenceClick(Preference p) {
- dialogUtilities.okCancelDialog(MilkPreferences.this,
- r.getString(R.string.sync_forget_confirm), new OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- new RTMSyncProvider().signOut();
- initializePreference(getPreferenceScreen());
- }
- }, null);
- return true;
- }
- });
- if(!loggedIn)
- preference.setEnabled(false);
- }
- }
-
-}
\ No newline at end of file
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkStartupReceiver.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkStartupReceiver.java
deleted file mode 100644
index 3bbcad6c3..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkStartupReceiver.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * See the file "LICENSE" for the full license governing this code.
- */
-package com.todoroo.astrid.rmilk;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-
-import com.todoroo.andlib.service.ContextManager;
-import com.todoroo.astrid.service.AstridDependencyInjector;
-
-public class MilkStartupReceiver extends BroadcastReceiver {
-
- static {
- AstridDependencyInjector.initialize();
- }
-
- @Override
- /** Called when device is restarted */
- public void onReceive(final Context context, Intent intent) {
- ContextManager.setContext(context);
- MilkBackgroundService.scheduleService();
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkUtilities.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkUtilities.java
deleted file mode 100644
index 9f16c5b30..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkUtilities.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/**
- * See the file "LICENSE" for the full license governing this code.
- */
-package com.todoroo.astrid.rmilk;
-
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
-import android.preference.PreferenceManager;
-
-import com.timsu.astrid.R;
-import com.todoroo.andlib.service.ContextManager;
-import com.todoroo.andlib.utility.DateUtilities;
-import com.todoroo.astrid.rmilk.data.MilkList;
-
-/**
- * Constants and preferences for rtm plugin
- *
- * @author Tim Su
- *
- */
-@SuppressWarnings("nls")
-public class MilkUtilities {
-
- // --- constants
-
- /** add-on identifier */
- public static final String IDENTIFIER = "rmilk";
-
- // --- helper classes
-
- /**
- * Helper class for describing RTM lists
- *
- * @author Tim Su
- */
- public static class ListContainer {
- public ListContainer(MilkList list) {
- this(list.getValue(MilkList.ID), list.getValue(MilkList.NAME));
- }
-
- public ListContainer(long id, String name) {
- this.id = id;
- this.name = name;
- this.count = 0;
- }
-
- @Override
- public String toString() {
- return name;
- }
-
- public long id;
- public String name;
- public int count;
- }
-
- // --- Preference Keys
-
- private static final String PREF_TOKEN = "rmilk_token";
-
- private static final String PREF_LAST_SYNC = "rmilk_last_sync";
-
- private static final String PREF_LAST_ATTEMPTED_SYNC = "rmilk_last_attempted";
-
- private static final String PREF_LAST_ERROR = "rmilk_last_error";
-
- private static final String PREF_ONGOING = "rmilk_ongoing";
-
- // --- Preference Utility Methods
-
- /** Get preferences object from the context */
- private static SharedPreferences getPrefs() {
- return PreferenceManager.getDefaultSharedPreferences(ContextManager.getContext());
- }
-
- /**
- * @return true if we have a token for this user, false otherwise
- */
- public static boolean isLoggedIn() {
- return getPrefs().getString(PREF_TOKEN, null) != null;
- }
-
- /** RTM authentication token, or null if doesn't exist */
- public static String getToken() {
- return getPrefs().getString(PREF_TOKEN, null);
- }
-
- /** Sets the RTM authentication token. Set to null to clear. */
- public static void setToken(String setting) {
- Editor editor = getPrefs().edit();
- editor.putString(PREF_TOKEN, setting);
- editor.commit();
- }
-
- /** @return RTM Last Successful Sync Date, or 0 */
- public static long getLastSyncDate() {
- return getPrefs().getLong(PREF_LAST_SYNC, 0);
- }
-
- /** @return RTM Last Attempted Sync Date, or 0 if it was successful */
- public static long getLastAttemptedSyncDate() {
- return getPrefs().getLong(PREF_LAST_ATTEMPTED_SYNC, 0);
- }
-
- /** @return RTM Last Error, or null if no last error */
- public static String getLastError() {
- return getPrefs().getString(PREF_LAST_ERROR, null);
- }
-
- /** @return RTM Last Error, or null if no last error */
- public static boolean isOngoing() {
- return getPrefs().getBoolean(PREF_ONGOING, false);
- }
-
- /** Deletes RTM Last Successful Sync Date */
- public static void clearLastSyncDate() {
- Editor editor = getPrefs().edit();
- editor.remove(PREF_LAST_SYNC);
- editor.commit();
- }
-
- /** Set RTM Last Successful Sync Date */
- public static void setLastError(String error) {
- Editor editor = getPrefs().edit();
- editor.putString(PREF_LAST_ERROR, error);
- editor.commit();
- }
-
- /** Set RTM Ongoing */
- public static void stopOngoing() {
- Editor editor = getPrefs().edit();
- editor.putBoolean(PREF_ONGOING, false);
- editor.commit();
- }
-
- /** Set RTM Last Successful Sync Date */
- public static void recordSuccessfulSync() {
- Editor editor = getPrefs().edit();
- editor.putLong(PREF_LAST_SYNC, DateUtilities.now());
- editor.putLong(PREF_LAST_ATTEMPTED_SYNC, 0);
- editor.commit();
- }
-
- /** Set RTM Last Attempted Sync Date */
- public static void recordSyncStart() {
- Editor editor = getPrefs().edit();
- editor.putLong(PREF_LAST_ATTEMPTED_SYNC, DateUtilities.now());
- editor.putString(PREF_LAST_ERROR, null);
- editor.putBoolean(PREF_ONGOING, true);
- editor.commit();
- }
-
- /**
- * Reads the frequency, in seconds, auto-sync should occur.
- *
- * @return seconds duration, or 0 if not desired
- */
- public static int getSyncAutoSyncFrequency() {
- String value = getPrefs().getString(
- ContextManager.getContext().getString(
- R.string.rmilk_MPr_interval_key), null);
- if (value == null)
- return 0;
- try {
- return Integer.parseInt(value);
- } catch (Exception e) {
- return 0;
- }
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/ApplicationInfo.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/ApplicationInfo.java
deleted file mode 100644
index c7bb56a2d..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/ApplicationInfo.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api;
-
-/**
- * Encapsulates information about an application that is a client of RememberTheMilk. Includes information required by RTM to connect: the API key and
- * the shared secret.
- *
- * @author Will Ross Jun 22, 2007
- */
-public class ApplicationInfo
-{
-
- private final String apiKey;
-
- private final String sharedSecret;
-
- private final String name;
-
- private final String authToken;
-
- public ApplicationInfo(String apiKey, String sharedSecret, String name)
- {
- this(apiKey, sharedSecret, name, null);
- }
-
- public ApplicationInfo(String apiKey, String sharedSecret, String name,
- String authToken)
- {
- super();
- this.apiKey = apiKey;
- this.sharedSecret = sharedSecret;
- this.name = name;
- this.authToken = authToken;
- }
-
- public String getApiKey()
- {
- return apiKey;
- }
-
- public String getSharedSecret()
- {
- return sharedSecret;
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getAuthToken()
- {
- return authToken;
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/Invoker.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/Invoker.java
deleted file mode 100644
index 030976f67..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/Invoker.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
-import android.util.Log;
-
-/**
- * Handles the details of invoking a method on the RTM REST API.
- *
- * @author Will Ross Jun 21, 2007
- */
-@SuppressWarnings("nls")
-public class Invoker {
-
- private static final String SERVICE_UNAVAILABLE_CODE = "105";
-
- private static final String TAG = "rtm-invoker"; //$NON-NLS-1$
-
- private static final DocumentBuilder builder;
- static
- {
- // Done this way because the builder is marked "final"
- DocumentBuilder aBuilder;
- try
- {
- final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(false);
- factory.setValidating(false);
- aBuilder = factory.newDocumentBuilder();
- }
- catch (Exception exception)
- {
- Log.e(TAG, "Unable to construct a document builder", exception);
- aBuilder = null;
- }
- builder = aBuilder;
- }
-
- private static final String ENCODING = "UTF-8"; //$NON-NLS-1$
-
- private static final String API_SIG_PARAM = "api_sig"; //$NON-NLS-1$
-
- private static final long INVOCATION_INTERVAL = 400;
-
- private long lastInvocation;
-
- private final ApplicationInfo applicationInfo;
-
- private final MessageDigest digest;
-
- private final String serviceRelativeUri;
-
- private final HttpClient httpClient;
-
- public Invoker(@SuppressWarnings("unused") String serverHostName,
- @SuppressWarnings("unused") int serverPortNumber,
- String serviceRelativeUri, ApplicationInfo applicationInfo)
- throws ServiceInternalException {
-
- this.serviceRelativeUri = serviceRelativeUri;
-
- httpClient = new DefaultHttpClient();
-
- lastInvocation = System.currentTimeMillis();
- this.applicationInfo = applicationInfo;
-
- try {
- digest = MessageDigest.getInstance("md5"); //$NON-NLS-1$
- } catch (NoSuchAlgorithmException e) {
- throw new ServiceInternalException(
- "Could not create properly the MD5 digest", e);
- }
- }
-
- private StringBuffer computeRequestUri(Param... params)
- throws ServiceInternalException {
- final StringBuffer requestUri = new StringBuffer(serviceRelativeUri);
- if (params.length > 0) {
- requestUri.append("?");
- }
- for (Param param : params) {
- try {
- requestUri.append(param.getName()).append("=").append(
- URLEncoder.encode(param.getValue(), ENCODING)).append(
- "&");
- } catch (Exception exception) {
- final StringBuffer message = new StringBuffer(
- "Cannot encode properly the HTTP GET request URI: cannot execute query");
- Log.e(TAG, message.toString(), exception);
- throw new ServiceInternalException(message.toString());
- }
- }
- requestUri.append(API_SIG_PARAM).append("=").append(calcApiSig(params));
- return requestUri;
- }
-
- /** Call invoke with a false repeat */
- public Element invoke(Param... params) throws ServiceException {
- return invoke(false, params);
- }
-
- public Element invoke(boolean repeat, Param... params)
- throws ServiceException {
- long timeSinceLastInvocation = System.currentTimeMillis() -
- lastInvocation;
- if (timeSinceLastInvocation < INVOCATION_INTERVAL) {
- // In order not to invoke the RTM service too often
- try {
- Thread.sleep(INVOCATION_INTERVAL - timeSinceLastInvocation);
- } catch (InterruptedException e) {
- return null;
- }
- }
-
- // We compute the URI
- final StringBuffer requestUri = computeRequestUri(params);
- HttpResponse response = null;
-
- final HttpGet request = new HttpGet("http://" //$NON-NLS-1$
- + ServiceImpl.SERVER_HOST_NAME + requestUri.toString());
- final String methodUri = request.getRequestLine().getUri();
-
- Element result;
- try {
- Log.i(TAG, "Executing the method:" + methodUri); //$NON-NLS-1$
- response = httpClient.execute(request);
- lastInvocation = System.currentTimeMillis();
-
- final int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != HttpStatus.SC_OK) {
- Log.e(TAG, "Method failed: " + response.getStatusLine()); //$NON-NLS-1$
-
- // Tim: HTTP error. Let's wait a little bit
- if (!repeat) {
- try {
- Thread.sleep(1500);
- } catch (InterruptedException e) {
- // ignore
- }
- return invoke(true, params);
- }
-
- throw new ServiceInternalException("method failed: "
- + response.getStatusLine());
- }
-
- final Document responseDoc = builder.parse(response.getEntity()
- .getContent());
- final Element wrapperElt = responseDoc.getDocumentElement();
- if (!wrapperElt.getNodeName().equals("rsp")) {
- throw new ServiceInternalException(
- "unexpected response returned by RTM service: "
- + wrapperElt.getNodeName());
- } else {
- String stat = wrapperElt.getAttribute("stat");
- if (stat.equals("fail")) {
- Node errElt = wrapperElt.getFirstChild();
- while (errElt != null
- && (errElt.getNodeType() != Node.ELEMENT_NODE || !errElt
- .getNodeName().equals("err"))) {
- errElt = errElt.getNextSibling();
- }
- if (errElt == null) {
- throw new ServiceInternalException(
- "unexpected response returned by RTM service: "
- + wrapperElt.getNodeValue());
- } else {
- if (SERVICE_UNAVAILABLE_CODE.equals(((Element) errElt)
- .getAttribute("code")) && !repeat) {
- try {
- Thread.sleep(1500);
- } catch (InterruptedException e) {
- // ignore
- }
- return invoke(true, params);
- }
-
- throw new ServiceException(Integer
- .parseInt(((Element) errElt)
- .getAttribute("code")),
- ((Element) errElt).getAttribute("msg"));
- }
- } else {
- Node dataElt = wrapperElt.getFirstChild();
- while (dataElt != null
- && (dataElt.getNodeType() != Node.ELEMENT_NODE || dataElt
- .getNodeName().equals("transaction") == true)) {
- try {
- Node nextSibling = dataElt.getNextSibling();
- if (nextSibling == null) {
- break;
- } else {
- dataElt = nextSibling;
- }
- } catch (IndexOutOfBoundsException exception) {
- // Some implementation may throw this exception,
- // instead of returning a null sibling
- break;
- }
- }
- if (dataElt == null) {
- throw new ServiceInternalException(
- "unexpected response returned by RTM service: "
- + wrapperElt.getNodeValue());
- } else {
- result = (Element) dataElt;
- }
- }
- }
- } catch (IOException e) {
- throw new ServiceInternalException("Error making connection: " +
- e.getMessage(), e);
- } catch (SAXException e) {
- // repeat call if possible.
- if(!repeat)
- return invoke(true, params);
- else
- throw new ServiceInternalException("Error parsing response. " +
- "Please try sync again!", e);
- } finally {
- httpClient.getConnectionManager().closeExpiredConnections();
- }
-
- return result;
- }
-
- final String calcApiSig(Param... params) throws ServiceInternalException {
- try {
- digest.reset();
- digest.update(applicationInfo.getSharedSecret().getBytes(ENCODING));
- List sorted = Arrays.asList(params);
- Collections.sort(sorted);
- for (Param param : sorted) {
- digest.update(param.getName().getBytes(ENCODING));
- digest.update(param.getValue().getBytes(ENCODING));
- }
- return convertToHex(digest.digest());
- } catch (UnsupportedEncodingException e) {
- throw new ServiceInternalException(
- "cannot hahdle properly the encoding", e);
- }
- }
-
- private static String convertToHex(byte[] data) {
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < data.length; i++) {
- int halfbyte = (data[i] >>> 4) & 0x0F;
- int two_halfs = 0;
- do {
- if ((0 <= halfbyte) && (halfbyte <= 9))
- buf.append((char) ('0' + halfbyte));
- else
- buf.append((char) ('a' + (halfbyte - 10)));
- halfbyte = data[i] & 0x0F;
- } while (two_halfs++ < 1);
- }
- return buf.toString();
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/Param.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/Param.java
deleted file mode 100644
index a05694dd0..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/Param.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api;
-
-import java.util.Date;
-
-import com.todoroo.astrid.rmilk.api.data.RtmData;
-
-/**
- *
- * @author Will Ross Jun 21, 2007
- */
-@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="EQ_COMPARETO_USE_OBJECT_EQUALS")
-public class Param implements Comparable {
-
- private final String name;
-
- private final String value;
-
- public Param(String name, String value) {
- this.name = name;
- this.value = value;
- }
-
- public Param(String name, Date value) {
- this.name = name;
- this.value = RtmData.formatDate(value);
- }
-
- public String getName() {
- return name;
- }
-
- public String getValue() {
- return value;
- }
-
- public int compareTo(Param p) {
- return name.compareTo(p.getName());
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/Prefs.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/Prefs.java
deleted file mode 100644
index 6b1738365..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/Prefs.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api;
-
-import java.util.prefs.Preferences;
-
-/**
- *
- * @author Will Ross Jun 21, 2007
- */
-public class Prefs {
-
- Preferences preferences;
-
- public enum PrefKey {
- AuthToken
- }
-
- public Prefs() {
- preferences = Preferences.userNodeForPackage(Prefs.class);
- }
-
- public String getAuthToken() {
- return preferences.get(PrefKey.AuthToken.toString(), null);
- }
-
- public void setAuthToken(String authToken) {
- preferences.put(PrefKey.AuthToken.toString(), authToken);
- }
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/ServiceException.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/ServiceException.java
deleted file mode 100644
index 8ba6a6b47..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/ServiceException.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api;
-
-import java.io.IOException;
-
-/**
- *
- * @author Will Ross Jun 21, 2007
- */
-@SuppressWarnings("nls")
-public class ServiceException extends IOException {
-
- private static final long serialVersionUID = -6711156026040643361L;
-
- int responseCode;
-
- String responseMessage;
-
- public ServiceException(int responseCode, String responseMessage) {
- super("Service invocation failed. Code: " + responseCode + "; message: " + responseMessage);
- this.responseCode = responseCode;
- this.responseMessage = responseMessage;
- }
-
- int getResponseCode() {
- return responseCode;
- }
-
- String getResponseMessage() {
- return responseMessage;
- }
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/ServiceImpl.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/ServiceImpl.java
deleted file mode 100644
index 58a212f78..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/ServiceImpl.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import org.w3c.dom.Element;
-
-import com.todoroo.astrid.rmilk.api.data.RtmAuth;
-import com.todoroo.astrid.rmilk.api.data.RtmData;
-import com.todoroo.astrid.rmilk.api.data.RtmFrob;
-import com.todoroo.astrid.rmilk.api.data.RtmList;
-import com.todoroo.astrid.rmilk.api.data.RtmLists;
-import com.todoroo.astrid.rmilk.api.data.RtmLocation;
-import com.todoroo.astrid.rmilk.api.data.RtmTask;
-import com.todoroo.astrid.rmilk.api.data.RtmTaskList;
-import com.todoroo.astrid.rmilk.api.data.RtmTaskNote;
-import com.todoroo.astrid.rmilk.api.data.RtmTaskSeries;
-import com.todoroo.astrid.rmilk.api.data.RtmTasks;
-import com.todoroo.astrid.rmilk.api.data.RtmTimeline;
-import com.todoroo.astrid.rmilk.api.data.RtmTask.Priority;
-
-/**
- * A major part of the RTM API implementation is here.
- *
- * @author Will Ross Jun 21, 2007
- * @author Edouard Mercier, since 2008.04.15
- * @author timsu January 2009
- */
-@SuppressWarnings("nls")
-public class ServiceImpl
-{
-
- public final static String SERVER_HOST_NAME = "api.rememberthemilk.com"; //$NON-NLS-1$
-
- public final static int SERVER_PORT_NUMBER = 80;
-
- public final static String REST_SERVICE_URL_POSTFIX = "/services/rest/"; //$NON-NLS-1$
-
- private final ApplicationInfo applicationInfo;
-
- private final Invoker invoker;
-
- private final Prefs prefs;
-
- private String currentAuthToken;
-
- RtmFrob tempFrob;
-
- public ServiceImpl(ApplicationInfo applicationInfo)
- throws ServiceInternalException
- {
- invoker = new Invoker(SERVER_HOST_NAME, SERVER_PORT_NUMBER, REST_SERVICE_URL_POSTFIX, applicationInfo);
- this.applicationInfo = applicationInfo;
- prefs = new Prefs();
- if (applicationInfo.getAuthToken() != null)
- {
- currentAuthToken = applicationInfo.getAuthToken();
- }
- else
- {
- currentAuthToken = prefs.getAuthToken();
- }
- }
-
- public boolean isServiceAuthorized()
- throws ServiceException
- {
- if (currentAuthToken == null)
- return false;
-
- try
- {
- /* RtmAuth auth = */auth_checkToken(currentAuthToken);
- return true;
- }
- catch (ServiceException e)
- {
- if (e.getResponseCode() != 98)
- {
- throw e;
- }
- else
- {
- // Bad token.
- currentAuthToken = null;
- return false;
- }
- }
- }
-
- public String beginAuthorization(RtmAuth.Perms permissions)
- throws ServiceException
- {
- // Instructions from the "User authentication for desktop applications"
- // section at http://www.rememberthemilk.com/services/api/authentication.rtm
- tempFrob = auth_getFrob();
- return beginAuthorization(tempFrob, permissions);
- }
-
- public String beginAuthorization(RtmFrob frob, RtmAuth.Perms permissions)
- throws ServiceException
- {
- String authBaseUrl = "http://" + SERVER_HOST_NAME + "/services/auth/";
- Param[] params = new Param[] { new Param("api_key", applicationInfo.getApiKey()), new Param("perms", permissions.toString()),
- new Param("frob", frob.getValue()) };
- Param sig = new Param("api_sig", invoker.calcApiSig(params));
- StringBuilder authUrl = new StringBuilder(authBaseUrl);
- authUrl.append("?");
- for (Param param : params)
- {
- authUrl.append(param.getName()).append("=").append(param.getValue()).append("&");
- }
- authUrl.append(sig.getName()).append("=").append(sig.getValue());
- return authUrl.toString();
- }
-
- public String completeAuthorization()
- throws ServiceException
- {
- return completeAuthorization(tempFrob);
- }
-
- public String completeAuthorization(RtmFrob frob)
- throws ServiceException
- {
- currentAuthToken = auth_getToken(frob.getValue());
- prefs.setAuthToken(currentAuthToken);
- return currentAuthToken;
- }
-
- public RtmAuth auth_checkToken(String authToken)
- throws ServiceException
- {
- Element response = invoker.invoke(new Param("method", "rtm.auth.checkToken"), new Param("auth_token", authToken),
- new Param("api_key", applicationInfo.getApiKey()));
- return new RtmAuth(response);
- }
-
- public RtmFrob auth_getFrob()
- throws ServiceException
- {
- return new RtmFrob(invoker.invoke(new Param("method", "rtm.auth.getFrob"), new Param("api_key", applicationInfo.getApiKey())));
- }
-
- public String auth_getToken(String frob)
- throws ServiceException
- {
- Element response = invoker.invoke(new Param("method", "rtm.auth.getToken"), new Param("frob", frob), new Param("api_key", applicationInfo.getApiKey()));
- return new RtmAuth(response).getToken();
- }
-
- public void contacts_add()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void contacts_delete()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void contacts_getList()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void groups_add()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void groups_addContact()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void groups_delete()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void groups_getList()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void groups_removeContact()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public RtmList lists_add(String timelineId, String listName)
- throws ServiceException
- {
- Element response = invoker.invoke(new Param("method", "rtm.lists.add"), new Param("auth_token", currentAuthToken),
- new Param("api_key", applicationInfo.getApiKey()), new Param("name", listName), new Param("timeline", timelineId));
- return new RtmList(response);
- }
-
- public void lists_archive()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void lists_delete(String timelineId, String listId)
- throws ServiceException
- {
- invoker.invoke(new Param("method", "rtm.lists.delete"), new Param("auth_token", currentAuthToken), new Param("api_key", applicationInfo.getApiKey()),
- new Param("timeline", timelineId), new Param("list_id", listId));
- }
-
- public RtmLists lists_getList()
- throws ServiceException
- {
- Element response = invoker.invoke(new Param("method", "rtm.lists.getList"), new Param("auth_token", currentAuthToken),
- new Param("api_key", applicationInfo.getApiKey()));
- return new RtmLists(response);
- }
-
- public RtmList lists_getList(String listName)
- throws ServiceException
- {
- RtmLists fullList = lists_getList();
- for (Entry entry : fullList.getLists().entrySet())
- {
- if (entry.getValue().getName().equals(listName))
- {
- return entry.getValue();
- }
- }
- return null;
- }
-
- public void lists_setDefaultList()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public RtmList lists_setName(String timelineId, String listId, String newName)
- throws ServiceException
- {
- Element response = invoker.invoke(new Param("method", "rtm.lists.setName"), new Param("timeline", timelineId), new Param("list_id", listId),
- new Param("name", newName), new Param("auth_token", currentAuthToken), new Param("api_key", applicationInfo.getApiKey()));
- return new RtmList(response);
- }
-
- public void lists_unarchive()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void reflection_getMethodInfo()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void reflection_getMethods()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void settings_getList()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- /**
- * Adds a task, name, to the list specified by list_id.
- * @param timelineId
- * @param listId can be null to omit this parameter (assumes Inbox)
- * @param name
- * @return
- * @throws ServiceException
- */
- public RtmTaskSeries tasks_add(String timelineId, String listId, String name)
- throws ServiceException
- {
- Element response;
- if(listId != null)
- response = invoker.invoke(new Param("method", "rtm.tasks.add"), new Param("timeline", timelineId), new Param("list_id", listId),
- new Param("name", name), new Param("auth_token", currentAuthToken), new Param("api_key", applicationInfo.getApiKey()));
- else
- response = invoker.invoke(new Param("method", "rtm.tasks.add"), new Param("timeline", timelineId),
- new Param("name", name), new Param("auth_token", currentAuthToken), new Param("api_key", applicationInfo.getApiKey()));
-
- RtmTaskList rtmTaskList = new RtmTaskList(response);
- if (rtmTaskList.getSeries().size() == 1)
- {
- return rtmTaskList.getSeries().get(0);
- }
- else if (rtmTaskList.getSeries().size() > 1)
- {
- throw new ServiceInternalException("Internal error: more that one task (" + rtmTaskList.getSeries().size() + ") has been created");
- }
- throw new ServiceInternalException("Internal error: no task has been created");
- }
-
- public void tasks_addTags()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void tasks_complete(String timelineId, String listId, String taskSeriesId, String taskId)
- throws ServiceException
- {
- invoker.invoke(new Param("method", "rtm.tasks.complete"), new Param("timeline", timelineId), new Param("list_id", listId),
- new Param("taskseries_id", taskSeriesId), new Param("task_id", taskId), new Param("auth_token", currentAuthToken),
- new Param("api_key", applicationInfo.getApiKey()));
- }
-
- public void tasks_delete(String timelineId, String listId, String taskSeriesId, String taskId)
- throws ServiceException
- {
- invoker.invoke(new Param("method", "rtm.tasks.delete"), new Param("timeline", timelineId), new Param("list_id", listId),
- new Param("taskseries_id", taskSeriesId), new Param("task_id", taskId), new Param("auth_token", currentAuthToken),
- new Param("api_key", applicationInfo.getApiKey()));
- }
-
- public RtmTasks tasks_getList(String listId, String filter, Date lastSync)
- throws ServiceException
- {
- Set params = new HashSet();
- params.add(new Param("method", "rtm.tasks.getList"));
- if (listId != null)
- {
- params.add(new Param("list_id", listId));
- }
- if (filter != null)
- {
- params.add(new Param("filter", filter));
- }
- if (lastSync != null)
- {
- params.add(new Param("last_sync", lastSync));
- }
- params.add(new Param("auth_token", currentAuthToken));
- params.add(new Param("api_key", applicationInfo.getApiKey()));
- return new RtmTasks(invoker.invoke(params.toArray(new Param[params.size()])));
- }
-
- public RtmTaskSeries tasks_getTask(String taskName)
- throws ServiceException
- {
- return tasks_getTask(null, taskName);
- }
-
- public RtmTaskSeries tasks_getTask(String taskSeriesId, String taskName)
- throws ServiceException
- {
- Set params = new HashSet();
- params.add(new Param("method", "rtm.tasks.getList"));
- params.add(new Param("auth_token", currentAuthToken));
- params.add(new Param("api_key", applicationInfo.getApiKey()));
- params.add(new Param("filter", "name:\"" + taskName+"\""));
- RtmTasks rtmTasks = new RtmTasks(invoker.invoke(params.toArray(new Param[params.size()])));
- return findTask(taskSeriesId, rtmTasks);
- }
-
- private RtmTaskSeries findTask(String taskId, RtmTasks rtmTasks)
- {
- for (RtmTaskList list : rtmTasks.getLists())
- {
- for (RtmTaskSeries series : list.getSeries())
- {
- if (taskId != null)
- {
- if (series.getId().equals(taskId))
- {
- return series;
- }
- }
- else
- {
- return series;
- }
- }
- }
- return null;
- }
-
- public void tasks_movePriority()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public RtmTaskSeries tasks_moveTo(String timelineId, String fromListId, String toListId, String taskSeriesId, String taskId)
- throws ServiceException
- {
- if(fromListId.equals(toListId))
- return null;
- Element elt = invoker.invoke(new Param("method", "rtm.tasks.moveTo"), new Param("timeline", timelineId), new Param("from_list_id", fromListId),
- new Param("to_list_id", toListId), new Param("taskseries_id", taskSeriesId), new Param("task_id", taskId), new Param("auth_token", currentAuthToken),
- new Param("api_key", applicationInfo.getApiKey()));
- RtmTaskList rtmTaskList = new RtmTaskList(elt);
- return findTask(taskSeriesId, taskId, rtmTaskList);
- }
-
- public void tasks_postpone()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void tasks_removeTags()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void tasks_setDueDate(String timelineId, String listId, String taskSeriesId, String taskId, Date due, boolean hasDueTime)
- throws ServiceException
- {
- final boolean setDueDate = (due != null);
- if (setDueDate == true)
- {
- invoker.invoke(new Param("method", "rtm.tasks.setDueDate"), new Param("timeline", timelineId), new Param("list_id", listId),
- new Param("taskseries_id", taskSeriesId), new Param("task_id", taskId), new Param("due", due), new Param("has_due_time", hasDueTime ? "1" : "0"),
- new Param("auth_token", currentAuthToken), new Param("api_key", applicationInfo.getApiKey()));
- }
- else
- {
- invoker.invoke(new Param("method", "rtm.tasks.setDueDate"), new Param("timeline", timelineId), new Param("list_id", listId),
- new Param("taskseries_id", taskSeriesId), new Param("task_id", taskId), new Param("auth_token", currentAuthToken),
- new Param("api_key", applicationInfo.getApiKey()));
- }
- }
-
- public void tasks_setEstimate(String timelineId, String listId, String taskSeriesId, String taskId, String newEstimate)
- throws ServiceException
- {
- invoker.invoke(new Param("method", "rtm.tasks.setEstimate"), new Param("timeline", timelineId), new Param("list_id", listId),
- new Param("taskseries_id", taskSeriesId), new Param("task_id", taskId), new Param("estimate", newEstimate), new Param("auth_token", currentAuthToken),
- new Param("api_key", applicationInfo.getApiKey()));
- }
-
- public void tasks_setName(String timelineId, String listId, String taskSeriesId, String taskId, String newName)
- throws ServiceException
- {
- invoker.invoke(new Param("method", "rtm.tasks.setName"), new Param("timeline", timelineId), new Param("list_id", listId),
- new Param("taskseries_id", taskSeriesId), new Param("task_id", taskId), new Param("name", newName), new Param("auth_token", currentAuthToken),
- new Param("api_key", applicationInfo.getApiKey()));
- }
-
- private RtmTaskSeries findTask(String taskSeriesId, String taskId, RtmTaskList rtmTaskList)
- {
- for (RtmTaskSeries series : rtmTaskList.getSeries())
- {
- if (series.getId().equals(taskSeriesId) && series.getTask().getId().equals(taskId))
- {
- return series;
- }
- }
- return null;
- }
-
- public void tasks_setPriority(String timelineId, String listId, String taskSeriesId, String taskId, Priority priority)
- throws ServiceException
- {
- invoker.invoke(new Param("method", "rtm.tasks.setPriority"), new Param("timeline", timelineId), new Param("list_id", listId),
- new Param("taskseries_id", taskSeriesId), new Param("task_id", taskId), new Param("priority", RtmTask.convertPriority(priority)),
- new Param("auth_token", currentAuthToken), new Param("api_key", applicationInfo.getApiKey()));
- }
-
- public void tasks_setRecurrence(String timelineId, String listId, String taskSeriesId, String taskId, String repeat)
- throws ServiceException
- {
- invoker.invoke(new Param("method", "rtm.tasks.setRecurrence"), new Param("timeline", timelineId), new Param("list_id", listId),
- new Param("taskseries_id", taskSeriesId), new Param("task_id", taskId), new Param("repeat", repeat),
- new Param("auth_token", currentAuthToken), new Param("api_key", applicationInfo.getApiKey()));
- }
-
- public void tasks_setTags(String timelineId, String listId,
- String taskSeriesId, String taskId, String[] tags) throws ServiceException
- {
- StringBuilder tagString = new StringBuilder();
- if(tags != null) {
- for(int i = 0; i < tags.length; i++) {
- tagString.append(tags[i].replace(" ", "_"));
- if(i < tags.length - 1)
- tagString.append(",");
- }
- }
- invoker.invoke(new Param("method", "rtm.tasks.setTags"), new Param("timeline", timelineId), new Param("list_id", listId),
- new Param("taskseries_id", taskSeriesId), new Param("task_id", taskId), new Param("tags", tagString.toString()), new Param("auth_token", currentAuthToken),
- new Param("api_key", applicationInfo.getApiKey()));
- }
-
- public void tasks_setURL()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void tasks_uncomplete(String timelineId, String listId, String taskSeriesId, String taskId)
- throws ServiceException
- {
- invoker.invoke(new Param("method", "rtm.tasks.uncomplete"), new Param("timeline", timelineId), new Param("list_id", listId),
- new Param("taskseries_id", taskSeriesId), new Param("task_id", taskId), new Param("auth_token", currentAuthToken),
- new Param("api_key", applicationInfo.getApiKey()));
- }
-
- public RtmTaskNote tasks_notes_add(String timelineId, String listId, String taskSeriesId, String taskId, String title, String text)
- throws ServiceException
- {
- Element elt = invoker.invoke(new Param("method", "rtm.tasks.notes.add"), new Param("timeline", timelineId), new Param("list_id", listId),
- new Param("taskseries_id", taskSeriesId), new Param("task_id", taskId), new Param("note_title", title), new Param("note_text", text),
- new Param("auth_token", currentAuthToken), new Param("api_key", applicationInfo.getApiKey()));
- return new RtmTaskNote(elt);
- }
-
- public void tasks_notes_delete(String timelineId, String noteId)
- throws ServiceException
- {
- invoker.invoke(new Param("method", "rtm.tasks.notes.delete"), new Param("timeline", timelineId), new Param("note_id", noteId),
- new Param("auth_token", currentAuthToken), new Param("api_key", applicationInfo.getApiKey()));
- }
-
- public RtmTaskNote tasks_notes_edit(String timelineId, String noteId, String title, String text)
- throws ServiceException
- {
- Element elt = invoker.invoke(new Param("method", "rtm.tasks.notes.edit"), new Param("timeline", timelineId), new Param("note_id", noteId),
- new Param("note_title", title), new Param("note_text", text), new Param("auth_token", currentAuthToken),
- new Param("api_key", applicationInfo.getApiKey()));
- return new RtmTaskNote(elt);
- }
-
- public RtmTaskSeries tasks_setLocation(String timelineId, String listId, String taskSeriesId, String taskId, String locationId)
- throws ServiceException
- {
- Element response = invoker.invoke(new Param("method", "rtm.tasks.setLocation"), new Param("timeline", timelineId), new Param("list_id", listId),
- new Param("taskseries_id", taskSeriesId), new Param("task_id", taskId), new Param("location_id", locationId),
- new Param("auth_token", currentAuthToken), new Param("api_key", applicationInfo.getApiKey()));
- RtmTaskList rtmTaskList = new RtmTaskList(response);
- return findTask(taskSeriesId, taskId, rtmTaskList);
- }
-
- public RtmTaskSeries tasks_setURL(String timelineId, String listId, String taskSeriesId, String taskId, String url)
- throws ServiceException
- {
- Element response = invoker.invoke(new Param("method", "rtm.tasks.setURL"), new Param("timeline", timelineId), new Param("list_id", listId),
- new Param("taskseries_id", taskSeriesId), new Param("task_id", taskId), new Param("url", url), new Param("auth_token", currentAuthToken),
- new Param("api_key", applicationInfo.getApiKey()));
- RtmTaskList rtmTaskList = new RtmTaskList(response);
- return findTask(taskSeriesId, taskId, rtmTaskList);
- }
-
- public void test_echo()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void test_login()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void time_convert()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void time_parse()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public String timelines_create()
- throws ServiceException
- {
- return new RtmTimeline(invoker.invoke(new Param("method", "rtm.timelines.create"), new Param("auth_token", currentAuthToken),
- new Param("api_key", applicationInfo.getApiKey()))).getId();
- }
-
- public void timezones_getList()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public void transactions_undo()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public List locations_getList()
- throws ServiceException
- {
- Element result = invoker.invoke(new Param("method", "rtm.locations.getList"), new Param("auth_token", currentAuthToken),
- new Param("api_key", applicationInfo.getApiKey()));
- List locations = new ArrayList();
- for (Element child : RtmData.children(result, "location"))
- {
- locations.add(new RtmLocation(child));
- }
- return locations;
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/ServiceInternalException.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/ServiceInternalException.java
deleted file mode 100644
index c69eae884..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/ServiceInternalException.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api;
-
-
-/**
- * Introduced in order to get rid of the {@link RuntimeException}, and have only one time of regular exception to cope with, from the API end-user
- * point of view.
- *
- * @author Edouard Mercier
- * @since 2008.04.23
- */
-public class ServiceInternalException
- extends ServiceException
-{
- private static final long serialVersionUID = -423838945284984432L;
-
- private final Exception enclosedException;
-
- public ServiceInternalException(String message)
- {
- this(message, null);
- }
-
- public ServiceInternalException(String message, Exception exception)
- {
- super(-1, message);
- this.enclosedException = exception;
- }
-
- public Exception getEnclosedException()
- {
- return enclosedException;
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmAuth.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmAuth.java
deleted file mode 100644
index b5e8b9a22..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmAuth.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api.data;
-
-import org.w3c.dom.Element;
-
-/**
- *
- * @author Will Ross Jun 21, 2007
- */
-@SuppressWarnings("nls")
-public class RtmAuth extends RtmData {
-
- public enum Perms {
- read, write, delete
- }
-
- private final String token;
-
- private final Perms perms;
-
- private final RtmUser user;
-
- public RtmAuth(String token, Perms perms, RtmUser user) {
- this.token = token;
- this.perms = perms;
- this.user = user;
- }
-
- public RtmAuth(Element elt) {
- if (!elt.getNodeName().equals("auth")) { throw new IllegalArgumentException("Element " + elt.getNodeName() + " does not represent an Auth object."); }
-
- this.token = text(child(elt, "token"));
- this.perms = Enum.valueOf(Perms.class, text(child(elt, "perms")));
- this.user = new RtmUser(child(elt, "user"));
- }
-
- public String getToken() {
- return token;
- }
-
- public Perms getPerms() {
- return perms;
- }
-
- public RtmUser getUser() {
- return user;
- }
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmData.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmData.java
deleted file mode 100644
index 104460e16..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmData.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api.data;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.TimeZone;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- *
- * @author Will Ross Jun 21, 2007
- */
-@SuppressWarnings("nls")
-public abstract class RtmData
-{
-
- private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
-
- public RtmData() {
- //
- }
-
- /**
- * The method is not optimized at most, but circumvents a bug in Android runtime.
- */
- public static Element child(Element elt, String nodeName)
- {
- NodeList childNodes = elt.getChildNodes();
- for (int index = 0; index < childNodes.getLength(); index++)
- {
- Node child = childNodes.item(index);
- if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals(nodeName))
- {
- return (Element) child;
- }
- }
- return null;
- }
-
- /**
- * The method is not optimized at most, but circumvents a bug in Android runtime.
- */
- public static List children(Element elt, String nodeName)
- {
- List result = new ArrayList();
- NodeList childNodes = elt.getChildNodes();
- for (int index = 0; index < childNodes.getLength(); index++)
- {
- Node child = childNodes.item(index);
- if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals(nodeName))
- {
- result.add((Element) child);
- }
- }
- return result;
- }
-
- protected String text(Element elt)
- {
- StringBuilder result = new StringBuilder();
- Node child = elt.getFirstChild();
- while (child != null)
- {
- switch (child.getNodeType())
- {
- case Node.TEXT_NODE:
- case Node.CDATA_SECTION_NODE:
- result.append(child.getNodeValue());
- break;
- default:
- break;
- }
- child = child.getNextSibling();
- }
- return result.toString();
- }
-
- public synchronized static Date parseDate(String s)
- {
- try
- {
- Date d = DATE_FORMAT.parse(s);
- return new Date(d.getTime() + TimeZone.getDefault().getOffset(d.getTime()));
- }
- catch (ParseException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public synchronized static String formatDate(Date d)
- {
- return DATE_FORMAT.format(new Date(d.getTime() - TimeZone.getDefault().getOffset(d.getTime()))) + "Z";
- }
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmFrob.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmFrob.java
deleted file mode 100644
index 29365b364..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmFrob.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api.data;
-
-import org.w3c.dom.Element;
-
-/**
- *
- * @author Will Ross Jun 21, 2007
- */
-public class RtmFrob extends RtmData {
-
- private final String value;
-
- public RtmFrob(String value) {
- this.value = value;
- }
-
- public RtmFrob(Element elt) {
- this.value = text(elt);
- }
-
- public String getValue() {
- return value;
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmList.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmList.java
deleted file mode 100644
index ee128d525..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmList.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api.data;
-
-import org.w3c.dom.Element;
-
-@SuppressWarnings("nls")
-public class RtmList extends RtmData {
-
- private final String id;
- private final boolean smart;
- private final boolean archived;
- private final int position;
- private final String name;
-
- public RtmList(String id, String name, boolean smart, boolean archived, int position) {
- this.id = id;
- this.name = name;
- this.smart = smart;
- this.archived = archived;
- this.position = position;
- }
-
- public RtmList(Element elt) {
- id = elt.getAttribute("id");
- name = elt.getAttribute("name");
- smart = elt.getAttribute("smart").equals("1");
- archived = elt.getAttribute("archived").equals("1");
- position = Integer.parseInt(elt.getAttribute("position"));
- }
-
- public String getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public boolean isSmart() {
- return smart;
- }
-
- public boolean isArchived() {
- return archived;
- }
-
- public int getPosition() {
- return position;
- }
-
- public boolean isInbox() {
- return position == -1;
- }
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmLists.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmLists.java
deleted file mode 100644
index d7fe2254f..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmLists.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api.data;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.w3c.dom.Element;
-
-@SuppressWarnings("nls")
-public class RtmLists extends RtmData {
-
- private final Map lists;
-
- public RtmLists() {
- this.lists = new HashMap();
- }
-
- public RtmLists(Element elt) {
- this.lists = new HashMap();
- for (Element listElt : children(elt, "list")) {
- RtmList list = new RtmList(listElt);
- lists.put(list.getId(), list);
- }
- }
-
- public RtmList getList(String id) {
- return lists.get(id);
- }
-
- public Map getLists() {
- return Collections.unmodifiableMap(lists);
- }
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmLocation.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmLocation.java
deleted file mode 100644
index b54c51766..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmLocation.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api.data;
-
-import org.w3c.dom.Element;
-
-/**
- * Represents a location.
- *
- * @author Edouard Mercier
- * @since 2008.05.22
- */
-@SuppressWarnings("nls")
-public class RtmLocation
- extends RtmData
-{
-
- public final String id;
-
- public final String name;
-
- public final float longitude;
-
- public final float latitude;
-
- public final String address;
-
- public final boolean viewable;
-
- public int zoom;
-
- public RtmLocation(Element element)
- {
- id = element.getAttribute("id");
- name = element.getAttribute("name");
- longitude = Float.parseFloat(element.getAttribute("longitude"));
- latitude = Float.parseFloat(element.getAttribute("latitude"));
- address = element.getAttribute("address");
- zoom = Integer.parseInt(element.getAttribute("zoom"));
- viewable = element.getAttribute("viewable").equals("1") ? true : false;
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTask.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTask.java
deleted file mode 100644
index fe3161cb0..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTask.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api.data;
-
-import java.util.Date;
-
-import org.w3c.dom.Element;
-
-import android.util.Log;
-
-/**
- *
- * @author Will Ross Jun 21, 2007
- */
-@SuppressWarnings("nls")
-public class RtmTask
- extends RtmData
-{
-
- private static final String TAG = "rtm-task";
-
- private final String id;
-
- private final Date due;
-
- private final boolean hasDueTime;
-
- private final Date added;
-
- private final Date completed;
-
- private final Date deleted;
-
- private final Priority priority;
-
- private final int postponed;
-
- private final String estimate;
-
- public enum Priority
- {
- High, Medium, Low, None;
-
- public static Priority values(Integer value) {
- value = Math.max(values().length - 1, value);
- return values()[value];
- }
- }
-
- public static String convertPriority(Priority priority)
- {
- switch (priority)
- {
- case None:
- return new String(new char[] { 'n' });
- case Low:
- return new String(new char[] { '3' });
- case Medium:
- return new String(new char[] { '2' });
- case High:
- return new String(new char[] { '1' });
- default:
- Log.e(TAG, "Unrecognized RTM task priority: '" + priority + "'");
- return new String(new char[] { 'n' });
- }
- }
-
- public RtmTask(String id, Date due, boolean hasDueTime, Date added, Date completed, Date deleted, Priority priority, int postponed, String estimate)
- {
- this.id = id;
- this.due = due;
- this.hasDueTime = hasDueTime;
- this.added = added;
- this.completed = completed;
- this.deleted = deleted;
- this.priority = priority;
- this.postponed = postponed;
- this.estimate = estimate;
- }
-
- public RtmTask(Element elt)
- {
- id = elt.getAttribute("id");
- String dueStr = elt.getAttribute("due");
- due = (dueStr == null || dueStr.length() == 0) ? null : parseDate(dueStr);
- hasDueTime = Integer.parseInt(elt.getAttribute("has_due_time")) != 0;
- String addedStr = elt.getAttribute("added");
- added = (addedStr == null || addedStr.length() == 0) ? null : parseDate(addedStr);
- String completedStr = elt.getAttribute("completed");
- completed = (completedStr == null || completedStr.length() == 0) ? null : parseDate(completedStr);
- String deletedStr = elt.getAttribute("deleted");
- deleted = (deletedStr == null || deletedStr.length() == 0) ? null : parseDate(deletedStr);
- String priorityStr = elt.getAttribute("priority");
- if (priorityStr.length() > 0)
- {
- switch (priorityStr.charAt(0))
- {
- case 'N':
- case 'n':
- priority = Priority.None;
- break;
- case '3':
- priority = Priority.Low;
- break;
- case '2':
- priority = Priority.Medium;
- break;
- case '1':
- priority = Priority.High;
- break;
- default:
- System.err.println("Unrecognized RTM task priority: '" + priorityStr + "'");
- priority = Priority.Medium;
- }
- }
- else
- {
- priority = Priority.None;
- }
- if (elt.hasAttribute("postponed") == true && elt.getAttribute("postponed").length() > 0)
- {
- postponed = Integer.parseInt(elt.getAttribute("postponed"));
- }
- else
- {
- postponed = 0;
- }
- estimate = elt.getAttribute("estimate");
- }
-
- public String getId()
- {
- return id;
- }
-
- public Date getDue()
- {
- return due;
- }
-
- public boolean getHasDueTime()
- {
- return hasDueTime;
- }
-
- public Date getAdded()
- {
- return added;
- }
-
- public Date getCompleted()
- {
- return completed;
- }
-
- public Date getDeleted()
- {
- return deleted;
- }
-
- public Priority getPriority()
- {
- return priority;
- }
-
- public int getPostponed()
- {
- return postponed;
- }
-
- public String getEstimate()
- {
- return estimate;
- }
-
- @Override
- public String toString()
- {
- return "Task<" + id + ">";
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTaskList.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTaskList.java
deleted file mode 100644
index 40bfe43d4..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTaskList.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api.data;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.w3c.dom.Element;
-
-/**
- *
- * @author Will Ross Jun 22, 2007
- */
-@SuppressWarnings("nls")
-public class RtmTaskList extends RtmData {
-
- private final String id;
-
- private final List series;
-
- public RtmTaskList(String id) {
- this.id = id;
- this.series = new ArrayList();
- }
-
- public RtmTaskList(Element elt) {
- id = elt.getAttribute("id");
- series = new ArrayList();
- for (Element seriesElt : children(elt, "taskseries")) {
- series.add(new RtmTaskSeries(this, seriesElt));
- }
-
- if (id == null || id.length() == 0) { throw new RuntimeException("No id found in task list."); }
- }
-
- public String getId() {
- return id;
- }
-
- public List getSeries() {
- return Collections.unmodifiableList(series);
- }
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTaskNote.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTaskNote.java
deleted file mode 100644
index a12a42d40..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTaskNote.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api.data;
-
-import java.util.Date;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.EntityReference;
-import org.w3c.dom.Text;
-
-import android.util.Log;
-
-/**
- * Represents a single task note.
- *
- * @author Edouard Mercier
- * @since 2008.04.22
- */
-@SuppressWarnings("nls")
-public class RtmTaskNote
- extends RtmData
-{
-
- private final String id;
-
- private final Date created;
-
- private final Date modified;
-
- private final String title;
-
- private String text;
-
- public RtmTaskNote(Element element)
- {
- id = element.getAttribute("id");
- created = parseDate(element.getAttribute("created"));
- modified = parseDate(element.getAttribute("modified"));
- title = element.getAttribute("title");
-
- // The note text itself might be split across multiple children of the
- // note element, so get all of the children.
- for (int i=0; i < element.getChildNodes().getLength(); i++) {
- Object innerNote = element.getChildNodes().item(i);
-
- if(innerNote instanceof EntityReference) // this node is empty
- continue;
-
- if(!(innerNote instanceof Text)) {
- Log.w("rtm-note", "Expected text type, got " + innerNote.getClass());
- continue;
- }
-
- Text innerText = (Text) innerNote;
-
- if (text == null)
- text = innerText.getData();
- else
- text = text.concat(innerText.getData());
-
- }
- }
-
- public String getId()
- {
- return id;
- }
-
- public Date getCreated()
- {
- return created;
- }
-
- public Date getModified()
- {
- return modified;
- }
-
- public String getTitle()
- {
- return title;
- }
-
- public String getText()
- {
- return text;
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTaskNotes.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTaskNotes.java
deleted file mode 100644
index 9c3c3870f..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTaskNotes.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api.data;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.w3c.dom.Element;
-
-/**
- * Represents the notes of a task.
- *
- * @author Edouard Mercier
- * @since 2008.04.22
- */
-@SuppressWarnings("nls")
-public class RtmTaskNotes
- extends RtmData
-{
-
- private List notes;
-
- public RtmTaskNotes(Element element)
- {
- notes = new ArrayList();
- for (Element child : children(element, "note"))
- {
- notes.add(new RtmTaskNote(child));
- }
- }
-
- public List getNotes()
- {
- return notes;
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTaskSeries.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTaskSeries.java
deleted file mode 100644
index 1c72c6e69..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTaskSeries.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api.data;
-
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.w3c.dom.Element;
-
-/**
- *
- * @author Will Ross Jun 22, 2007
- */
-@SuppressWarnings("nls")
-public class RtmTaskSeries extends RtmData {
-
- private final RtmTaskList list;
-
- private final String id;
-
- private final Date created;
-
- private final Date modified;
-
- private final String name;
-
- private final String source;
-
- private final RtmTask task;
-
- private final LinkedList tags;
-
- private final RtmTaskNotes notes;
-
- private final String locationId;
-
- private final String url;
-
- private final boolean hasRecurrence;
-
- public RtmTaskSeries(RtmTaskList list, String id, Date created, Date modified, String name,
- String source, RtmTask task) {
- this.list = list;
- this.id = id;
- this.created = created;
- this.modified = modified;
- this.name = name;
- this.source = source;
- this.task = task;
- this.locationId = null;
- notes = null;
- url = null;
- tags = null;
- hasRecurrence = false;
- }
-
- public RtmTaskSeries(RtmTaskList list, Element elt) {
- this.list = list;
- id = elt.getAttribute("id");
- created = parseDate(elt.getAttribute("created"));
- modified = parseDate(elt.getAttribute("modified"));
- name = elt.getAttribute("name");
- source = elt.getAttribute("source");
- List children = children(elt, "task");
- if (children.size() > 1) {
- // assume it's a repeating task - pick the child with nearest
- // but not expired due date
- RtmTask selectedTask = new RtmTask(children.get(0));
- for(Element element : children) {
- RtmTask childTask = new RtmTask(element);
- if(childTask.getCompleted() == null) {
- selectedTask = childTask;
- break;
- }
- }
- task = selectedTask;
- } else {
- task = new RtmTask(child(elt, "task"));
- }
- notes = new RtmTaskNotes(child(elt, "notes"));
- locationId = elt.getAttribute("location_id");
- url = elt.getAttribute("url");
- hasRecurrence = children(elt, "rrule").size() > 0;
-
- Element elementTags = child(elt, "tags");
- if (elementTags.getChildNodes().getLength() > 0) {
- List elementTagList = children(elementTags, "tag");
- tags = new LinkedList();
- for (Element elementTag : elementTagList) {
- String tag = text(elementTag);
- if (tag != null)
- tags.add(tag);
- }
- } else {
- tags = null;
- }
- }
-
- public String getId() {
- return id;
- }
-
- public Date getCreated() {
- return created;
- }
-
- public Date getModified() {
- return modified;
- }
-
- public String getName() {
- return name;
- }
-
- public String getSource() {
- return source;
- }
-
- public RtmTask getTask() {
- return task;
- }
-
- public LinkedList getTags() {
- return tags;
- }
-
- public RtmTaskNotes getNotes() {
- return notes;
- }
-
- public String getLocationId() {
- return locationId;
- }
-
- @Override
- public String toString() {
- return "TaskSeries<" + id + "," + name + ">";
- }
-
- public String getURL() {
- return url;
- }
-
- public boolean hasRecurrence() {
- return hasRecurrence;
- }
-
- public RtmTaskList getList() {
- return list;
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTasks.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTasks.java
deleted file mode 100644
index ee401f471..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTasks.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api.data;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.w3c.dom.Element;
-
-/**
- *
- * @author Will Ross Jun 21, 2007
- */
-@SuppressWarnings("nls")
-public class RtmTasks extends RtmData {
-
- private final List lists;
-
- public RtmTasks() {
- this.lists = new ArrayList();
- }
-
- public RtmTasks(Element elt) {
- this.lists = new ArrayList();
- for (Element listElt : children(elt, "list")) {
- lists.add(new RtmTaskList(listElt));
- }
- }
-
- public List getLists() {
- return Collections.unmodifiableList(lists);
- }
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTimeline.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTimeline.java
deleted file mode 100644
index c9187bfac..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmTimeline.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api.data;
-
-import org.w3c.dom.Element;
-
-public class RtmTimeline extends RtmData {
-
- private final String id;
-
- public RtmTimeline(String id) {
- this.id = id;
- }
-
- public RtmTimeline(Element elt) {
- id = text(elt);
- }
-
- public String getId() {
- return id;
- }
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmUser.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmUser.java
deleted file mode 100644
index 5e71e264c..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/api/data/RtmUser.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2007, MetaDimensional Technologies Inc.
- *
- *
- * This file is part of the RememberTheMilk Java API.
- *
- * The RememberTheMilk Java API is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * The RememberTheMilk Java API is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-package com.todoroo.astrid.rmilk.api.data;
-
-import org.w3c.dom.Element;
-
-/**
- *
- * @author Will Ross Jun 21, 2007
- */
-@SuppressWarnings("nls")
-public class RtmUser extends RtmData {
-
- private final String id;
-
- private final String username;
-
- private final String fullname;
-
- public RtmUser(String id, String username, String fullname) {
- this.id = id;
- this.username = username;
- this.fullname = fullname;
- }
-
- public RtmUser(Element elt) {
- if (!elt.getNodeName().equals("user")) { throw new IllegalArgumentException("Element " + elt.getNodeName() + " does not represent a User object."); }
-
- this.id = elt.getAttribute("id");
- this.username = elt.getAttribute("username");
- this.fullname = elt.getAttribute("fullname");
- }
-
- public String getId() {
- return id;
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getFullname() {
- return fullname;
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkDataService.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkDataService.java
deleted file mode 100644
index 06887c257..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkDataService.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/**
- * See the file "LICENSE" for the full license governing this code.
- */
-package com.todoroo.astrid.rmilk.data;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Random;
-
-import android.content.Context;
-
-import com.todoroo.andlib.data.GenericDao;
-import com.todoroo.andlib.data.Property;
-import com.todoroo.andlib.data.Property.CountProperty;
-import com.todoroo.andlib.data.TodorooCursor;
-import com.todoroo.andlib.service.Autowired;
-import com.todoroo.andlib.service.ContextManager;
-import com.todoroo.andlib.service.DependencyInjectionService;
-import com.todoroo.andlib.sql.Criterion;
-import com.todoroo.andlib.sql.Join;
-import com.todoroo.andlib.sql.Order;
-import com.todoroo.andlib.sql.Query;
-import com.todoroo.andlib.utility.SoftHashMap;
-import com.todoroo.astrid.dao.MetadataDao;
-import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
-import com.todoroo.astrid.dao.TaskDao;
-import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
-import com.todoroo.astrid.model.Metadata;
-import com.todoroo.astrid.model.Task;
-import com.todoroo.astrid.rmilk.MilkUtilities;
-import com.todoroo.astrid.rmilk.MilkUtilities.ListContainer;
-import com.todoroo.astrid.rmilk.api.data.RtmList;
-import com.todoroo.astrid.rmilk.api.data.RtmLists;
-import com.todoroo.astrid.rmilk.sync.RTMTaskContainer;
-import com.todoroo.astrid.tags.TagService;
-
-public final class MilkDataService {
-
- // --- constants
-
- /** Utility for joining tasks with metadata */
- public static final Join METADATA_JOIN = Join.left(Metadata.TABLE, Task.ID.eq(Metadata.TASK));
-
- // --- singleton
-
- private static MilkDataService instance = null;
-
- public static synchronized MilkDataService getInstance() {
- if(instance == null)
- instance = new MilkDataService(ContextManager.getContext());
- return instance;
- }
-
- // --- instance variables
-
- protected final Context context;
-
- private final MilkDatabase milkDatabase = new MilkDatabase();
-
- private final GenericDao milkListDao;
-
- @Autowired
- private TaskDao taskDao;
-
- @Autowired
- private MetadataDao metadataDao;
-
- static final Random random = new Random();
-
- private MilkDataService(Context context) {
- this.context = context;
- DependencyInjectionService.getInstance().inject(this);
- milkListDao = new GenericDao(MilkList.class, milkDatabase);
- milkDatabase.openForReading();
- }
-
- // --- task and metadata methods
-
- /**
- * Clears RTM metadata information. Used when user logs out of RTM
- */
- public void clearMetadata() {
- metadataDao.deleteWhere(Metadata.KEY.eq(MilkTask.METADATA_KEY));
- }
-
- /**
- * Gets tasks that were created since last sync
- * @param properties
- * @return
- */
- public TodorooCursor getLocallyCreated(Property>[] properties) {
- return
- taskDao.query(Query.select(properties).join(MilkDataService.METADATA_JOIN).where(Criterion.and(
- Criterion.not(Task.ID.in(Query.select(Metadata.TASK).from(Metadata.TABLE).
- where(Criterion.and(MetadataCriteria.withKey(MilkTask.METADATA_KEY), MilkTask.TASK_SERIES_ID.gt(0))))),
- TaskCriteria.isActive())).groupBy(Task.ID));
- }
-
- /**
- * Gets tasks that were modified since last sync
- * @param properties
- * @return null if never sync'd
- */
- public TodorooCursor getLocallyUpdated(Property>[] properties) {
- long lastSyncDate = MilkUtilities.getLastSyncDate();
- if(lastSyncDate == 0)
- return taskDao.query(Query.select(Task.ID).where(Criterion.none));
- return
- taskDao.query(Query.select(properties).join(MilkDataService.METADATA_JOIN).
- where(Criterion.and(MetadataCriteria.withKey(MilkTask.METADATA_KEY),
- Task.MODIFICATION_DATE.gt(lastSyncDate))).groupBy(Task.ID));
- }
-
- /**
- * Searches for a local task with same remote id, updates this task's id
- * @param remoteTask
- */
- public void findLocalMatch(RTMTaskContainer remoteTask) {
- if(remoteTask.task.getId() != Task.NO_ID)
- return;
- TodorooCursor cursor = taskDao.query(Query.select(Task.ID).
- join(MilkDataService.METADATA_JOIN).where(Criterion.and(MetadataCriteria.withKey(MilkTask.METADATA_KEY),
- MilkTask.TASK_SERIES_ID.eq(remoteTask.taskSeriesId),
- MilkTask.TASK_ID.eq(remoteTask.taskId))));
- try {
- if(cursor.getCount() == 0)
- return;
- cursor.moveToFirst();
- remoteTask.task.setId(cursor.get(Task.ID));
- } finally {
- cursor.close();
- }
- }
-
- /**
- * Saves a task and its metadata
- * @param task
- */
- public void saveTaskAndMetadata(RTMTaskContainer task) {
- taskDao.save(task.task, true);
-
- metadataDao.deleteWhere(Criterion.and(MetadataCriteria.byTask(task.task.getId()),
- Criterion.or(MetadataCriteria.withKey(MilkTask.METADATA_KEY),
- MetadataCriteria.withKey(MilkNote.METADATA_KEY),
- MetadataCriteria.withKey(TagService.KEY))));
- task.metadata.add(MilkTask.create(task));
- for(Metadata metadata : task.metadata) {
- metadata.setValue(Metadata.TASK, task.task.getId());
- metadataDao.createNew(metadata);
- }
- }
-
- /**
- * Reads a task and its metadata
- * @param task
- * @return
- */
- public RTMTaskContainer readTaskAndMetadata(TodorooCursor taskCursor) {
- Task task = new Task(taskCursor);
-
- // read tags, notes, etc
- ArrayList metadata = new ArrayList();
- TodorooCursor metadataCursor = metadataDao.query(Query.select(Metadata.PROPERTIES).
- where(Criterion.and(MetadataCriteria.byTask(task.getId()),
- Criterion.or(MetadataCriteria.withKey(TagService.KEY),
- MetadataCriteria.withKey(MilkTask.METADATA_KEY),
- MetadataCriteria.withKey(MilkNote.METADATA_KEY)))));
- try {
- for(metadataCursor.moveToFirst(); !metadataCursor.isAfterLast(); metadataCursor.moveToNext()) {
- metadata.add(new Metadata(metadataCursor));
- }
- } finally {
- metadataCursor.close();
- }
-
- return new RTMTaskContainer(task, metadata);
- }
-
- /**
- * Reads metadata out of a task
- * @return null if no metadata found
- */
- public Metadata getTaskMetadata(long taskId) {
- TodorooCursor cursor = metadataDao.query(Query.select(
- MilkTask.LIST_ID, MilkTask.TASK_SERIES_ID, MilkTask.TASK_ID, MilkTask.REPEATING).where(
- MetadataCriteria.byTaskAndwithKey(taskId, MilkTask.METADATA_KEY)));
- try {
- if(cursor.getCount() == 0)
- return null;
- cursor.moveToFirst();
- return new Metadata(cursor);
- } finally {
- cursor.close();
- }
- }
-
- /**
- * Reads task notes out of a task
- */
- public TodorooCursor getTaskNotesCursor(long taskId) {
- TodorooCursor cursor = metadataDao.query(Query.select(Metadata.PROPERTIES).
- where(MetadataCriteria.byTaskAndwithKey(taskId, MilkNote.METADATA_KEY)));
- return cursor;
- }
-
- // --- list methods
-
- private final Map listCache =
- Collections.synchronizedMap(new SoftHashMap());
-
- /**
- * Get list name by list id
- * @param listId
- * @return null if no list by this id exists, otherwise list name
- */
- public String getListName(long listId) {
- if(listCache.containsKey(listId))
- return listCache.get(listId);
-
- TodorooCursor cursor = milkListDao.query(Query.select(
- MilkList.NAME).where(MilkList.ID.eq(listId)));
- try {
- if(cursor.getCount() == 0) {
- listCache.put(listId, null);
- return null;
- }
- cursor.moveToFirst();
- String name = cursor.get(MilkList.NAME);
- listCache.put(listId, name);
- return name;
- } finally {
- cursor.close();
- }
- }
-
- /**
- * Get RTM lists as container objects
- * @return
- */
- public ListContainer[] getListsWithCounts() {
- CountProperty COUNT = new CountProperty();
-
- // read list names
- TodorooCursor listCursor = milkListDao.query(Query.select(MilkList.ID,
- MilkList.NAME).where(MilkList.ARCHIVED.eq(0)).orderBy(Order.asc(MilkList.POSITION)));
- ListContainer[] lists = new ListContainer[listCursor.getCount()];
- HashMap listIdToContainerMap;
- try {
- int length = listCursor.getCount();
- if(length == 0)
- return lists;
- listIdToContainerMap = new HashMap(length);
- MilkList list = new MilkList();
- for(int i = 0; i < length; i++) {
- listCursor.moveToNext();
- list.readFromCursor(listCursor);
- lists[i] = new ListContainer(list);
- listIdToContainerMap.put(list.getId(), lists[i]);
- }
- } finally {
- listCursor.close();
- }
-
- // read all list counts
- TodorooCursor cursor = metadataDao.query(Query.select(MilkTask.LIST_ID, COUNT).
- join(Join.inner(Task.TABLE, Metadata.TASK.eq(Task.ID))).
- where(Criterion.and(TaskCriteria.isVisible(), TaskCriteria.isActive())).
- groupBy(MilkTask.LIST_ID));
- try {
- for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
- ListContainer container = listIdToContainerMap.get(cursor.get(MilkTask.LIST_ID));
- if(container != null) {
- container.count = cursor.get(COUNT);
- }
- }
- return lists;
- } finally {
- cursor.close();
- }
- }
-
- /**
- * Get RTM lists as strings
- * @return
- */
- /*public ListContainer[] getLists() {
- // read all list titles
- milkDatabase.open(context);
- TodorooCursor cursor = milkListDao.fetch(milkDatabase,
- List.PROPERTIES, null, List.ID + " ASC"); //$NON-NLS-1$
- ListContainer[] containers = new ListContainer[cursor.getCount()];
- try {
- List list = new List();
- for(int i = 0; i < containers.length; i++) {
- cursor.moveToNext();
- list.readFromCursor(cursor, List.PROPERTIES);
- ListContainer container = new ListContainer(list);
- containers[i] = container;
- }
- return containers;
- } finally {
- cursor.close();
- milkDatabase.close();
- }
- }*/
-
- /**
- * Clears current cache of RTM lists and re-populates. Returns the inbox
- * list.
- *
- * @param lists
- * @return list with the name "inbox"
- */
- public MilkList setLists(RtmLists lists) {
- milkListDao.deleteWhere(Criterion.all);
- MilkList model = new MilkList();
- MilkList inbox = null;
- for(Map.Entry list : lists.getLists().entrySet()) {
- if(list.getValue().isSmart() || "All Tasks".equals(list.getValue().getName())) //$NON-NLS-1$
- continue;
- model.setValue(MilkList.ID, Long.parseLong(list.getValue().getId()));
- model.setValue(MilkList.NAME, list.getValue().getName());
- model.setValue(MilkList.POSITION, list.getValue().getPosition());
- model.setValue(MilkList.ARCHIVED, list.getValue().isArchived()? 1 : 0);
- milkListDao.createNew(model);
-
- if(list.getValue().isInbox()) {
- inbox = model;
- model = new MilkList();
- }
- }
- return inbox;
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkDatabase.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkDatabase.java
deleted file mode 100644
index 2d077f0fd..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkDatabase.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2009, Todoroo Inc
- * All Rights Reserved
- * http://www.todoroo.com
- */
-package com.todoroo.astrid.rmilk.data;
-
-import com.todoroo.andlib.data.AbstractDatabase;
-import com.todoroo.andlib.data.GenericDao;
-import com.todoroo.andlib.data.Table;
-
-/**
- * Database wrapper
- *
- * @author Tim Su
- *
- */
-@SuppressWarnings("nls")
-public class MilkDatabase extends AbstractDatabase {
-
- // --- constants
-
- /**
- * Database version number. This variable must be updated when database
- * tables are updated, as it determines whether a database needs updating.
- */
- public static final int VERSION = 1;
-
- /**
- * Database name (must be unique)
- */
- private static final String NAME = "milk";
-
- /**
- * List of table/ If you're adding a new table, add it to this list and
- * also make sure that our SQLite helper does the right thing.
- */
- public static final Table[] TABLES = new Table[] {
- MilkList.TABLE,
- };
-
- // --- implementation
-
- private final GenericDao dao = new GenericDao(MilkList.class, this);
-
- @Override
- protected String getName() {
- return NAME;
- }
-
- @Override
- protected int getVersion() {
- return VERSION;
- }
-
- @Override
- public Table[] getTables() {
- return TABLES;
- }
-
- public GenericDao getDao() {
- return dao;
- }
-
- @Override
- protected void onCreateTables() {
- // do nothing
- }
-
- @Override
- protected boolean onUpgrade(int oldVersion, int newVersion) {
- return false;
- }
-
-}
-
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkList.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkList.java
deleted file mode 100644
index aa4f169b8..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkList.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * See the file "LICENSE" for the full license governing this code.
- */
-package com.todoroo.astrid.rmilk.data;
-
-
-import android.content.ContentValues;
-
-import com.todoroo.andlib.data.AbstractModel;
-import com.todoroo.andlib.data.Property;
-import com.todoroo.andlib.data.Table;
-import com.todoroo.andlib.data.TodorooCursor;
-import com.todoroo.andlib.data.Property.IntegerProperty;
-import com.todoroo.andlib.data.Property.LongProperty;
-import com.todoroo.andlib.data.Property.StringProperty;
-import com.todoroo.astrid.model.Task;
-
-/**
- * Data Model which represents a list in RTM
- *
- * @author Tim Su
- *
- */
-@SuppressWarnings("nls")
-public class MilkList extends AbstractModel {
-
- // --- table
-
- public static final Table TABLE = new Table("lists", MilkList.class);
-
- // --- properties
-
- /** ID (corresponds to RTM ID) */
- public static final LongProperty ID = new LongProperty(
- TABLE, ID_PROPERTY_NAME);
-
- /** Name */
- public static final StringProperty NAME = new StringProperty(
- TABLE, "name");
-
- /** Position */
- public static final IntegerProperty POSITION = new IntegerProperty(
- TABLE, "position");
-
- /** Archived (0 or 1) */
- public static final IntegerProperty ARCHIVED = new IntegerProperty(
- TABLE, "archived");
-
- /** List of all properties for this model */
- public static final Property>[] PROPERTIES = generateProperties(MilkList.class);
-
- // --- defaults
-
- /** Default values container */
- private static final ContentValues defaultValues = new ContentValues();
-
- static {
- defaultValues.put(POSITION.name, 0);
- defaultValues.put(ARCHIVED.name, 0);
- }
-
- @Override
- public ContentValues getDefaultValues() {
- return defaultValues;
- }
-
- // --- data access boilerplate
-
- public MilkList() {
- super();
- }
-
- public MilkList(TodorooCursor cursor) {
- this();
- readPropertiesFromCursor(cursor);
- }
-
- public void readFromCursor(TodorooCursor cursor) {
- super.readPropertiesFromCursor(cursor);
- }
-
- @Override
- public long getId() {
- return getIdHelper(ID);
- };
-
- /**
- * @return whether this list is archived. requires {@link ARCHIVED}
- */
- public boolean isArchived() {
- return getValue(ARCHIVED) > 0;
- }
-
- // --- parcelable helpers
-
- private static final Creator CREATOR = new ModelCreator(Task.class);
-
- @Override
- protected Creator extends AbstractModel> getCreator() {
- return CREATOR;
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkNote.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkNote.java
deleted file mode 100644
index 3803d9952..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkNote.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package com.todoroo.astrid.rmilk.data;
-
-import android.text.TextUtils;
-
-import com.todoroo.andlib.data.Property.LongProperty;
-import com.todoroo.andlib.data.Property.StringProperty;
-import com.todoroo.astrid.model.Metadata;
-import com.todoroo.astrid.rmilk.api.data.RtmTaskNote;
-
-/**
- * Metadata entries for a Remember the Milk note. The first RMilk note becomes
- * Astrid's note field, subsequent notes are stored in metadata in this
- * format.
- *
- * @author Tim Su
- *
- */
-public class MilkNote {
-
- /** metadata key */
- public static final String METADATA_KEY = "rmilk-note"; //$NON-NLS-1$
-
- /** note id */
- public static final StringProperty ID = Metadata.VALUE1;
-
- /** note title */
- public static final StringProperty TITLE = Metadata.VALUE2;
-
- /** note text */
- public static final StringProperty TEXT = Metadata.VALUE3;
-
- /** note creation date */
- public static final LongProperty CREATED = new LongProperty(Metadata.TABLE,
- Metadata.VALUE4.name);
-
- public static Metadata create(RtmTaskNote note) {
- Metadata metadata = new Metadata();
- metadata.setValue(Metadata.KEY, METADATA_KEY);
- metadata.setValue(ID, note.getId());
- metadata.setValue(TITLE, note.getTitle());
- metadata.setValue(TEXT, note.getText());
- metadata.setValue(CREATED, note.getCreated().getTime());
- return metadata;
- }
-
- /**
- * Turn a note's title and text into a string
- * @param title
- * @param text
- * @return
- */
- @SuppressWarnings("nls")
- public static String toNoteField(RtmTaskNote note) {
- String title = note.getTitle();
- String text = note.getText();
- if(TextUtils.isEmpty(text) && TextUtils.isEmpty(title))
- return "";
- StringBuilder result = new StringBuilder();
- if(!TextUtils.isEmpty(title)) {
- result.append(title);
- if(!TextUtils.isEmpty(text))
- result.append("\n");
- }
- if(!TextUtils.isEmpty(text)) {
- result.append(text);
- }
- return result.toString();
- }
-
- /**
- * Turn a string into a note's title and text
- * @param value
- * @return
- */
- @SuppressWarnings("nls")
- public static String[] fromNoteField(String value) {
- String[] result = new String[2];
- int firstLineBreak = value.indexOf('\n');
- if(firstLineBreak > -1 && firstLineBreak + 1 < value.length()) {
- result[0] = value.substring(0, firstLineBreak);
- result[1] = value.substring(firstLineBreak + 1, value.length());
- } else {
- result[0] = "";
- result[1] = value;
- }
- return result;
- }
-
- /**
- * Turn a note's title and text into an HTML string for notes
- * @param metadata
- * @return
- */
- @SuppressWarnings("nls")
- public static String toTaskDetail(Metadata metadata) {
- String title = metadata.getValue(TITLE);
- String text = metadata.getValue(TEXT);
-
- String result;
- if(!TextUtils.isEmpty(title))
- result = "" + title + " " + text;
- else
- result = text;
-
- return result;
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkTask.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkTask.java
deleted file mode 100644
index 45cd7af46..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkTask.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.todoroo.astrid.rmilk.data;
-
-import com.todoroo.andlib.data.Property.IntegerProperty;
-import com.todoroo.andlib.data.Property.LongProperty;
-import com.todoroo.astrid.model.Metadata;
-import com.todoroo.astrid.rmilk.sync.RTMTaskContainer;
-
-/**
- * Metadata entries for a Remember The Milk Task
- * @author Tim Su
- *
- */
-public class MilkTask {
-
- /** metadata key */
- public static final String METADATA_KEY = "rmilk"; //$NON-NLS-1$
-
- /** {@link MilkList} id */
- public static final LongProperty LIST_ID = new LongProperty(Metadata.TABLE,
- Metadata.VALUE1.name);
-
- /** RTM Task Series Id */
- public static final LongProperty TASK_SERIES_ID = new LongProperty(Metadata.TABLE,
- Metadata.VALUE2.name);
-
- /** RTM Task Id */
- public static final LongProperty TASK_ID = new LongProperty(Metadata.TABLE,
- Metadata.VALUE3.name);
-
- /** Whether task repeats in RTM (1 or 0) */
- public static final IntegerProperty REPEATING = new IntegerProperty(Metadata.TABLE,
- Metadata.VALUE4.name);
-
- /**
- * Creates a piece of metadata from a remote task
- * @param rtmTaskSeries
- * @return
- */
- public static Metadata create(RTMTaskContainer container) {
- Metadata metadata = new Metadata();
- metadata.setValue(Metadata.KEY, METADATA_KEY);
- metadata.setValue(MilkTask.LIST_ID, container.listId);
- metadata.setValue(MilkTask.TASK_SERIES_ID, container.taskSeriesId);
- metadata.setValue(MilkTask.TASK_ID, container.taskId);
- metadata.setValue(MilkTask.REPEATING, container.repeating ? 1 : 0);
-
- return metadata;
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMSyncProvider.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMSyncProvider.java
deleted file mode 100644
index 296164e0d..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMSyncProvider.java
+++ /dev/null
@@ -1,603 +0,0 @@
-/**
- * See the file "LICENSE" for the full license governing this code.
- */
-package com.todoroo.astrid.rmilk.sync;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-
-import android.app.Activity;
-import android.app.Notification;
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.Resources;
-import android.os.Handler;
-import android.text.TextUtils;
-
-import com.flurry.android.FlurryAgent;
-import com.timsu.astrid.R;
-import com.todoroo.andlib.data.Property;
-import com.todoroo.andlib.data.TodorooCursor;
-import com.todoroo.andlib.service.Autowired;
-import com.todoroo.andlib.service.ContextManager;
-import com.todoroo.andlib.service.DependencyInjectionService;
-import com.todoroo.andlib.service.ExceptionService;
-import com.todoroo.andlib.utility.AndroidUtilities;
-import com.todoroo.andlib.utility.DateUtilities;
-import com.todoroo.andlib.utility.DialogUtilities;
-import com.todoroo.astrid.api.AstridApiConstants;
-import com.todoroo.astrid.api.TaskContainer;
-import com.todoroo.astrid.common.SyncProvider;
-import com.todoroo.astrid.model.Metadata;
-import com.todoroo.astrid.model.Task;
-import com.todoroo.astrid.rmilk.MilkLoginActivity;
-import com.todoroo.astrid.rmilk.MilkLoginActivity.SyncLoginCallback;
-import com.todoroo.astrid.rmilk.MilkPreferences;
-import com.todoroo.astrid.rmilk.MilkUtilities;
-import com.todoroo.astrid.rmilk.api.ApplicationInfo;
-import com.todoroo.astrid.rmilk.api.ServiceImpl;
-import com.todoroo.astrid.rmilk.api.ServiceInternalException;
-import com.todoroo.astrid.rmilk.api.data.RtmAuth.Perms;
-import com.todoroo.astrid.rmilk.api.data.RtmList;
-import com.todoroo.astrid.rmilk.api.data.RtmLists;
-import com.todoroo.astrid.rmilk.api.data.RtmTask;
-import com.todoroo.astrid.rmilk.api.data.RtmTask.Priority;
-import com.todoroo.astrid.rmilk.api.data.RtmTaskList;
-import com.todoroo.astrid.rmilk.api.data.RtmTaskNote;
-import com.todoroo.astrid.rmilk.api.data.RtmTaskSeries;
-import com.todoroo.astrid.rmilk.api.data.RtmTasks;
-import com.todoroo.astrid.rmilk.data.MilkDataService;
-import com.todoroo.astrid.rmilk.data.MilkNote;
-import com.todoroo.astrid.service.AstridDependencyInjector;
-import com.todoroo.astrid.tags.TagService;
-
-public class RTMSyncProvider extends SyncProvider {
-
- private ServiceImpl rtmService = null;
- private String timeline = null;
- private MilkDataService dataService = null;
-
- static {
- AstridDependencyInjector.initialize();
- }
-
- @Autowired
- protected ExceptionService exceptionService;
-
- @Autowired
- protected DialogUtilities dialogUtilities;
-
- public RTMSyncProvider() {
- super();
- DependencyInjectionService.getInstance().inject(this);
- }
-
- // ----------------------------------------------------------------------
- // ------------------------------------------------------- public methods
- // ----------------------------------------------------------------------
-
- /**
- * Sign out of RTM, deleting all synchronization metadata
- */
- public void signOut() {
- MilkUtilities.setToken(null);
- MilkUtilities.clearLastSyncDate();
-
- dataService = MilkDataService.getInstance();
- dataService.clearMetadata();
- }
-
- // ----------------------------------------------------------------------
- // ------------------------------------------------------- authentication
- // ----------------------------------------------------------------------
-
- /**
- * Deal with a synchronization exception. If requested, will show an error
- * to the user (unless synchronization is happening in background)
- *
- * @param context
- * @param tag
- * error tag
- * @param e
- * exception
- * @param showError
- * whether to display a dialog
- */
- @Override
- protected void handleException(String tag, Exception e, boolean showError) {
- MilkUtilities.setLastError(e.toString());
-
- // occurs when application was closed
- if(e instanceof IllegalStateException) {
- exceptionService.reportError(tag + "-caught", e); //$NON-NLS-1$
-
- // occurs when network error
- } else if(e instanceof ServiceInternalException &&
- ((ServiceInternalException)e).getEnclosedException() instanceof
- IOException) {
- Exception enclosedException = ((ServiceInternalException)e).getEnclosedException();
- exceptionService.reportError(tag + "-ioexception", enclosedException); //$NON-NLS-1$
- if(showError) {
- Context context = ContextManager.getContext();
- showError(context, enclosedException,
- context.getString(R.string.rmilk_ioerror));
- }
- } else {
- if(e instanceof ServiceInternalException)
- e = ((ServiceInternalException)e).getEnclosedException();
- exceptionService.reportError(tag + "-unhandled", e); //$NON-NLS-1$
- if(showError) {
- Context context = ContextManager.getContext();
- showError(context, e, null);
- }
- }
- }
-
- @Override
- protected void initiate(Context context) {
- dataService = MilkDataService.getInstance();
-
- // authenticate the user. this will automatically call the next step
- authenticate(context);
- }
-
- /**
- * Perform authentication with RTM. Will open the SyncBrowser if necessary
- */
- @SuppressWarnings("nls")
- private void authenticate(final Context context) {
- final Resources r = context.getResources();
- FlurryAgent.onEvent("rtm-started");
-
- MilkUtilities.recordSyncStart();
-
- try {
- String appName = null;
- String authToken = MilkUtilities.getToken();
- String z = stripslashes(0,"q9883o3384n21snq17501qn38oo1r689", "b");
- String v = stripslashes(16,"19o2n020345219os","a");
-
- // check if we have a token & it works
- if(authToken != null) {
- rtmService = new ServiceImpl(new ApplicationInfo(
- z, v, appName, authToken));
- if(!rtmService.isServiceAuthorized()) // re-do login
- authToken = null;
- }
-
- if(authToken == null) {
- // try completing the authorization if it was partial
- if(rtmService != null) {
- try {
- String token = rtmService.completeAuthorization();
- MilkUtilities.setToken(token);
- performSync();
-
- return;
- } catch (Exception e) {
- // didn't work. do the process again.
- }
- }
-
- // open up a dialog and have the user go to browser
- rtmService = new ServiceImpl(new ApplicationInfo(
- z, v, appName));
- final String url = rtmService.beginAuthorization(Perms.delete);
-
- Intent intent = new Intent(context, MilkLoginActivity.class);
- MilkLoginActivity.setCallback(new SyncLoginCallback() {
- public String verifyLogin(final Handler syncLoginHandler) {
- if(rtmService == null) {
- return null;
- }
-
- try {
- String token = rtmService.completeAuthorization();
- MilkUtilities.setToken(token);
- synchronize(context);
- return null;
- } catch (Exception e) {
- // didn't work
- exceptionService.reportError("rtm-verify-login", e);
- rtmService = null;
- if(e instanceof ServiceInternalException)
- e = ((ServiceInternalException)e).getEnclosedException();
- return r.getString(R.string.rmilk_MLA_error, e.getMessage());
- }
- }
- });
- intent.putExtra(MilkLoginActivity.URL_TOKEN, url);
-
- if(context instanceof Activity)
- ((Activity)context).startActivityForResult(intent, 0);
- else {
- // can't synchronize until user logs in
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(intent);
- MilkUtilities.stopOngoing();
- }
-
- } else {
- performSync();
- }
- } catch (IllegalStateException e) {
- // occurs when application was closed
- } catch (Exception e) {
- handleException("rtm-authenticate", e, true);
- } finally {
- MilkUtilities.stopOngoing();
- }
- }
-
- // ----------------------------------------------------------------------
- // ----------------------------------------------------- synchronization!
- // ----------------------------------------------------------------------
-
- protected void performSync() {
- try {
- // get RTM timeline
- timeline = rtmService.timelines_create();
-
- // load RTM lists
- RtmLists lists = rtmService.lists_getList();
- dataService.setLists(lists);
-
- // read all tasks
- ArrayList remoteChanges = new ArrayList();
- Date lastSyncDate = new Date(MilkUtilities.getLastSyncDate());
- boolean shouldSyncIndividualLists = false;
- String filter = null;
- if(lastSyncDate.getTime() == 0)
- filter = "status:incomplete"; //$NON-NLS-1$ // 1st time sync: get unfinished tasks
-
- // try the quick synchronization
- try {
- Thread.sleep(2000); // throttle
- RtmTasks tasks = rtmService.tasks_getList(null, filter, lastSyncDate);
- addTasksToList(tasks, remoteChanges);
- } catch (Exception e) {
- handleException("rtm-quick-sync", e, false); //$NON-NLS-1$
- remoteChanges.clear();
- shouldSyncIndividualLists = true;
- }
-
- if(shouldSyncIndividualLists) {
- for(RtmList list : lists.getLists().values()) {
- if(list.isSmart())
- continue;
- try {
- Thread.sleep(1500);
- RtmTasks tasks = rtmService.tasks_getList(list.getId(),
- filter, lastSyncDate);
- addTasksToList(tasks, remoteChanges);
- } catch (Exception e) {
- handleException("rtm-indiv-sync", e, true); //$NON-NLS-1$
- continue;
- }
- }
- }
-
- SyncData syncData = populateSyncData(remoteChanges);
- try {
- synchronizeTasks(syncData);
- } finally {
- syncData.localCreated.close();
- syncData.localUpdated.close();
- }
-
- MilkUtilities.recordSuccessfulSync();
- Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH);
- ContextManager.getContext().sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
-
- FlurryAgent.onEvent("rtm-sync-finished"); //$NON-NLS-1$
- } catch (IllegalStateException e) {
- // occurs when application was closed
- } catch (Exception e) {
- handleException("rtm-sync", e, true); //$NON-NLS-1$
- }
- }
-
- // ----------------------------------------------------------------------
- // ------------------------------------------------------------ sync data
- // ----------------------------------------------------------------------
-
- // all synchronized properties
- private static final Property>[] PROPERTIES = new Property>[] {
- Task.ID,
- Task.TITLE,
- Task.IMPORTANCE,
- Task.DUE_DATE,
- Task.CREATION_DATE,
- Task.COMPLETION_DATE,
- Task.DELETION_DATE,
- Task.NOTES,
- };
-
- /**
- * Populate SyncData data structure
- */
- private SyncData populateSyncData(ArrayList remoteTasks) {
- // fetch locally created tasks
- TodorooCursor localCreated = dataService.getLocallyCreated(PROPERTIES);
-
- // fetch locally updated tasks
- TodorooCursor localUpdated = dataService.getLocallyUpdated(PROPERTIES);
-
- return new SyncData(remoteTasks, localCreated, localUpdated);
- }
-
- /**
- * Add the tasks read from RTM to the given list
- */
- private void addTasksToList(RtmTasks tasks, ArrayList list) {
- for (RtmTaskList taskList : tasks.getLists()) {
- for (RtmTaskSeries taskSeries : taskList.getSeries()) {
- RTMTaskContainer remoteTask = parseRemoteTask(taskSeries);
- dataService.findLocalMatch(remoteTask);
- list.add(remoteTask);
- }
- }
- }
-
- // ----------------------------------------------------------------------
- // ------------------------------------------------- create / push / pull
- // ----------------------------------------------------------------------
-
- @Override
- protected void create(RTMTaskContainer task) throws IOException {
- String listId = null;
- if(task.listId > 0)
- listId = Long.toString(task.listId);
- RtmTaskSeries rtmTask = rtmService.tasks_add(timeline, listId,
- task.task.getValue(Task.TITLE));
- RTMTaskContainer newRemoteTask = parseRemoteTask(rtmTask);
- transferIdentifiers(newRemoteTask, task);
- push(task, newRemoteTask);
- }
-
- /**
- * Determine whether this task's property should be transmitted
- * @param task task to consider
- * @param property property to consider
- * @param remoteTask remote task proxy
- * @return
- */
- private boolean shouldTransmit(TaskContainer task, Property> property, TaskContainer remoteTask) {
- if(!task.task.containsValue(property))
- return false;
-
- if(remoteTask == null)
- return true;
- if(!remoteTask.task.containsValue(property))
- return true;
-
- // special cases - match if they're zero or nonzero
- if(property == Task.COMPLETION_DATE ||
- property == Task.DELETION_DATE)
- return !AndroidUtilities.equals((Long)task.task.getValue(property) == 0,
- (Long)remoteTask.task.getValue(property) == 0);
-
- return !AndroidUtilities.equals(task.task.getValue(property),
- remoteTask.task.getValue(property));
- }
-
- /**
- * Send changes for the given Task across the wire. If a remoteTask is
- * supplied, we attempt to intelligently only transmit the values that
- * have changed.
- */
- @Override
- protected void push(RTMTaskContainer local, RTMTaskContainer remote) throws IOException {
- boolean remerge = false;
-
- // fetch remote task for comparison
- if(remote == null)
- remote = pull(local);
-
- String listId = Long.toString(local.listId);
- String taskSeriesId = Long.toString(local.taskSeriesId);
- String taskId = Long.toString(local.taskId);
-
- if(remote != null && !AndroidUtilities.equals(local.listId, remote.listId))
- rtmService.tasks_moveTo(timeline, Long.toString(remote.listId),
- listId, taskSeriesId, taskId);
-
- // either delete or re-create if necessary
- if(shouldTransmit(local, Task.DELETION_DATE, remote)) {
- if(local.task.getValue(Task.DELETION_DATE) > 0)
- rtmService.tasks_delete(timeline, listId, taskSeriesId, taskId);
- else if(remote == null) {
- RtmTaskSeries rtmTask = rtmService.tasks_add(timeline, listId,
- local.task.getValue(Task.TITLE));
- remote = parseRemoteTask(rtmTask);
- transferIdentifiers(remote, local);
- }
- }
-
- if(shouldTransmit(local, Task.TITLE, remote))
- rtmService.tasks_setName(timeline, listId, taskSeriesId,
- taskId, local.task.getValue(Task.TITLE));
- if(shouldTransmit(local, Task.IMPORTANCE, remote))
- rtmService.tasks_setPriority(timeline, listId, taskSeriesId,
- taskId, Priority.values(local.task.getValue(Task.IMPORTANCE)));
- if(shouldTransmit(local, Task.DUE_DATE, remote))
- rtmService.tasks_setDueDate(timeline, listId, taskSeriesId,
- taskId, DateUtilities.unixtimeToDate(local.task.getValue(Task.DUE_DATE)),
- local.task.hasDueTime());
- if(shouldTransmit(local, Task.COMPLETION_DATE, remote)) {
- if(local.task.getValue(Task.COMPLETION_DATE) == 0)
- rtmService.tasks_uncomplete(timeline, listId, taskSeriesId,
- taskId);
- else {
- rtmService.tasks_complete(timeline, listId, taskSeriesId,
- taskId);
- // if repeating, pull and merge
- if(local.repeating)
- remerge = true;
- }
- }
-
- // tags
- HashSet localTags = new HashSet();
- HashSet remoteTags = new HashSet();
- for(Metadata item : local.metadata)
- if(TagService.KEY.equals(item.getValue(Metadata.KEY)))
- localTags.add(item.getValue(TagService.TAG));
- if(remote != null && remote.metadata != null) {
- for(Metadata item : remote.metadata)
- if(TagService.KEY.equals(item.getValue(Metadata.KEY)))
- remoteTags.add(item.getValue(TagService.TAG));
- }
- if(!localTags.equals(remoteTags)) {
- String[] tags = localTags.toArray(new String[localTags.size()]);
- rtmService.tasks_setTags(timeline, listId, taskSeriesId,
- taskId, tags);
- }
-
- // notes
- if(shouldTransmit(local, Task.NOTES, remote)) {
- String[] titleAndText = MilkNote.fromNoteField(local.task.getValue(Task.NOTES));
- List notes = null;
- if(remote != null && remote.remote.getNotes() != null)
- notes = remote.remote.getNotes().getNotes();
- if(notes != null && notes.size() > 0) {
- String remoteNoteId = notes.get(0).getId();
- rtmService.tasks_notes_edit(timeline, remoteNoteId, titleAndText[0],
- titleAndText[1]);
- } else {
- rtmService.tasks_notes_add(timeline, listId, taskSeriesId,
- taskId, titleAndText[0], titleAndText[1]);
- }
- }
-
- if(remerge) {
- remote = pull(local);
- remote.task.setId(local.task.getId());
- write(remote);
- }
- }
-
- /** Create a task container for the given RtmTaskSeries */
- private RTMTaskContainer parseRemoteTask(RtmTaskSeries rtmTaskSeries) {
- Task task = new Task();
- RtmTask rtmTask = rtmTaskSeries.getTask();
- ArrayList metadata = new ArrayList();
-
- task.setValue(Task.TITLE, rtmTaskSeries.getName());
- task.setValue(Task.CREATION_DATE, DateUtilities.dateToUnixtime(rtmTask.getAdded()));
- task.setValue(Task.COMPLETION_DATE, DateUtilities.dateToUnixtime(rtmTask.getCompleted()));
- task.setValue(Task.DELETION_DATE, DateUtilities.dateToUnixtime(rtmTask.getDeleted()));
- if(rtmTask.getDue() != null) {
- task.setValue(Task.DUE_DATE,
- task.createDueDate(rtmTask.getHasDueTime() ? Task.URGENCY_SPECIFIC_DAY_TIME :
- Task.URGENCY_SPECIFIC_DAY, DateUtilities.dateToUnixtime(rtmTask.getDue())));
- } else {
- task.setValue(Task.DUE_DATE, 0L);
- }
- task.setValue(Task.IMPORTANCE, rtmTask.getPriority().ordinal());
-
- if(rtmTaskSeries.getTags() != null) {
- for(String tag : rtmTaskSeries.getTags()) {
- Metadata tagData = new Metadata();
- tagData.setValue(Metadata.KEY, TagService.KEY);
- tagData.setValue(TagService.TAG, tag);
- metadata.add(tagData);
- }
- }
-
- task.setValue(Task.NOTES, ""); //$NON-NLS-1$
- if(rtmTaskSeries.getNotes() != null && rtmTaskSeries.getNotes().getNotes().size() > 0) {
- boolean firstNote = true;
- Collections.reverse(rtmTaskSeries.getNotes().getNotes()); // reverse so oldest is first
- for(RtmTaskNote note : rtmTaskSeries.getNotes().getNotes()) {
- if(firstNote) {
- firstNote = false;
- task.setValue(Task.NOTES, MilkNote.toNoteField(note));
- } else
- metadata.add(MilkNote.create(note));
- }
- }
-
- RTMTaskContainer container = new RTMTaskContainer(task, metadata, rtmTaskSeries);
-
- return container;
- }
-
- @Override
- protected RTMTaskContainer pull(RTMTaskContainer task) throws IOException {
- if(task.taskSeriesId == 0)
- throw new ServiceInternalException("Tried to read an invalid task"); //$NON-NLS-1$
- RtmTaskSeries rtmTask = rtmService.tasks_getTask(Long.toString(task.taskSeriesId),
- task.task.getValue(Task.TITLE));
- if(rtmTask != null)
- return parseRemoteTask(rtmTask);
- return null;
- }
-
- // ----------------------------------------------------------------------
- // --------------------------------------------------------- read / write
- // ----------------------------------------------------------------------
-
- @Override
- protected RTMTaskContainer read(TodorooCursor cursor) throws IOException {
- return dataService.readTaskAndMetadata(cursor);
- }
-
- @Override
- protected void write(RTMTaskContainer task) throws IOException {
- dataService.saveTaskAndMetadata(task);
- }
-
- // ----------------------------------------------------------------------
- // --------------------------------------------------------- misc helpers
- // ----------------------------------------------------------------------
-
- @Override
- protected int matchTask(ArrayList tasks, RTMTaskContainer target) {
- int length = tasks.size();
- for(int i = 0; i < length; i++) {
- RTMTaskContainer task = tasks.get(i);
- if(AndroidUtilities.equals(task.listId, target.listId) &&
- AndroidUtilities.equals(task.taskSeriesId, target.taskSeriesId) &&
- AndroidUtilities.equals(task.taskId, target.taskId))
- return i;
- }
- return -1;
- }
-
- @Override
- protected void updateNotification(Context context, Notification notification) {
- String notificationTitle = context.getString(R.string.rmilk_notification_title);
- Intent intent = new Intent(context, MilkPreferences.class);
- PendingIntent notificationIntent = PendingIntent.getActivity(context, 0,
- intent, 0);
- notification.setLatestEventInfo(context,
- notificationTitle, context.getString(R.string.SyP_progress),
- notificationIntent);
- return ;
- }
-
- @Override
- protected void transferIdentifiers(RTMTaskContainer source,
- RTMTaskContainer destination) {
- destination.listId = source.listId;
- destination.taskSeriesId = source.taskSeriesId;
- destination.taskId = source.taskId;
- }
-
- // ----------------------------------------------------------------------
- // ------------------------------------------------------- helper classes
- // ----------------------------------------------------------------------
-
- private static final String stripslashes(int ____,String __,String ___) {
- int _=__.charAt(____/92);_=_==115?_-1:_;_=((_>=97)&&(_<=123)?
- ((_-83)%27+97):_);return TextUtils.htmlEncode(____==31?___:
- stripslashes(____+1,__.substring(1),___+((char)_)));
- }
-
-}
diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMTaskContainer.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMTaskContainer.java
deleted file mode 100644
index 82e8cfaac..000000000
--- a/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMTaskContainer.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.todoroo.astrid.rmilk.sync;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import com.todoroo.astrid.api.TaskContainer;
-import com.todoroo.astrid.model.Metadata;
-import com.todoroo.astrid.model.Task;
-import com.todoroo.astrid.rmilk.api.data.RtmTaskSeries;
-import com.todoroo.astrid.rmilk.data.MilkTask;
-
-/**
- * RTM Task Container
- *
- * @author Tim Su
- *
- */
-public class RTMTaskContainer extends TaskContainer {
- public long listId, taskSeriesId, taskId;
- public boolean repeating;
- public RtmTaskSeries remote;
-
- public RTMTaskContainer(Task task, ArrayList metadata,
- long listId, long taskSeriesId, long taskId, boolean repeating,
- RtmTaskSeries remote) {
- this.task = task;
- this.metadata = metadata;
- this.listId = listId;
- this.taskSeriesId = taskSeriesId;
- this.taskId = taskId;
- this.repeating = repeating;
- this.remote = remote;
- }
-
- public RTMTaskContainer(Task task, ArrayList metadata,
- RtmTaskSeries rtmTaskSeries) {
- this(task, metadata, Long.parseLong(rtmTaskSeries.getList().getId()),
- Long.parseLong(rtmTaskSeries.getId()), Long.parseLong(rtmTaskSeries.getTask().getId()),
- rtmTaskSeries.hasRecurrence(), rtmTaskSeries);
- }
-
- public RTMTaskContainer(Task task, ArrayList metadata) {
- this(task, metadata, 0, 0, 0, false, null);
- for(Iterator iterator = metadata.iterator(); iterator.hasNext(); ) {
- Metadata item = iterator.next();
- if(MilkTask.METADATA_KEY.equals(item.getValue(Metadata.KEY))) {
- if(item.containsNonNullValue(MilkTask.LIST_ID))
- listId = item.getValue(MilkTask.LIST_ID);
- if(item.containsNonNullValue(MilkTask.TASK_SERIES_ID))
- taskSeriesId = item.getValue(MilkTask.TASK_SERIES_ID);
- if(item.containsNonNullValue(MilkTask.TASK_ID))
- taskId = item.getValue(MilkTask.TASK_ID);
- if(item.containsNonNullValue(MilkTask.REPEATING))
- repeating = item.getValue(MilkTask.REPEATING) == 1;
- iterator.remove();
- break;
- }
- }
- }
-
-
-}
\ No newline at end of file
diff --git a/astrid/res/layout/rmilk_edit_activity.xml b/astrid/res/layout/rmilk_edit_activity.xml
deleted file mode 100644
index d63ec219c..000000000
--- a/astrid/res/layout/rmilk_edit_activity.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/astrid/res/layout/rmilk_login_activity.xml b/astrid/res/layout/rmilk_login_activity.xml
deleted file mode 100644
index c3ff2e3d7..000000000
--- a/astrid/res/layout/rmilk_login_activity.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/astrid/res/values/strings-rmilk.xml b/astrid/res/values/strings-sync.xml
similarity index 57%
rename from astrid/res/values/strings-rmilk.xml
rename to astrid/res/values/strings-sync.xml
index 46be525af..fc42d4c05 100644
--- a/astrid/res/values/strings-rmilk.xml
+++ b/astrid/res/values/strings-sync.xml
@@ -2,48 +2,9 @@
-
-
-
- Remember the Milk Settings
-
-
- RTM Repeating Task
-
-
- Needs synchronization with RTM
-
-
- Remember the Milk
-
-
- Lists
-
-
- RTM List \'%s\'
-
-
-
-
- Remember the Milk
-
-
- RTM List:
-
-
- RTM Repeat Status:
-
-
- i.e. every week, after 14 days
-
-
-
-
- Remember the Milk
-
-
+
Status
@@ -59,7 +20,7 @@
Never Synchronized!
-
+
Options
@@ -105,27 +66,6 @@
- every three days
- every week
-
-
-
-
- Please Log In and Authorize Astrid:
-
-
-
-Sorry, there was an error verifying your login. Please try again.
-\n\n
-Error Message: %s
-
-
-
-
-
- Astrid: Remember the Milk
-
-
- Connection Error! Check your Internet connection,
- or maybe RTM servers (status.rememberthemilk.com), for possible solutions.
diff --git a/astrid/res/xml/preferences_rmilk.xml b/astrid/res/xml/preferences_rmilk.xml
deleted file mode 100644
index 537f4e168..000000000
--- a/astrid/res/xml/preferences_rmilk.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java
index 37863d774..082901abe 100644
--- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java
+++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java
@@ -2,9 +2,9 @@ package com.todoroo.astrid.activity;
import java.util.Date;
import java.util.List;
+import java.util.Map.Entry;
import java.util.Timer;
import java.util.TimerTask;
-import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicReference;
import android.app.AlertDialog;
@@ -25,26 +25,26 @@ import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.ContextMenu;
+import android.view.ContextMenu.ContextMenuInfo;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
-import android.view.Window;
-import android.view.WindowManager;
-import android.view.ContextMenu.ContextMenuInfo;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
+import android.view.Window;
+import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
import android.widget.AbsListView;
+import android.widget.AbsListView.OnScrollListener;
+import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
-import android.widget.Toast;
-import android.widget.AbsListView.OnScrollListener;
-import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.TextView.OnEditorActionListener;
+import android.widget.Toast;
import com.flurry.android.FlurryAgent;
import com.timsu.astrid.R;
@@ -76,7 +76,6 @@ import com.todoroo.astrid.model.Task;
import com.todoroo.astrid.reminders.Notifications;
import com.todoroo.astrid.reminders.ReminderService;
import com.todoroo.astrid.reminders.ReminderService.AlarmScheduler;
-import com.todoroo.astrid.rmilk.MilkPreferences;
import com.todoroo.astrid.service.AddOnService;
import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.service.StartupService;
@@ -245,9 +244,6 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
for(int i = 0; i < length; i++) {
ResolveInfo resolveInfo = resolveInfoList.get(i);
- if(!Constants.SYNC &&
- MilkPreferences.class.getName().equals(resolveInfo.activityInfo.name))
- continue;
if(!addOnService.hasPowerPack() &&
BackupActivity.class.getName().equals(resolveInfo.activityInfo.name))
continue;
diff --git a/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java b/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java
index a36f16fab..8316ae8f1 100644
--- a/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java
+++ b/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java
@@ -18,12 +18,12 @@ import android.text.Html;
import android.text.Html.ImageGetter;
import android.text.util.Linkify;
import android.view.ContextMenu;
+import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
-import android.view.ContextMenu.ContextMenuInfo;
import android.view.View.OnClickListener;
import android.view.View.OnCreateContextMenuListener;
+import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.CheckBox;
@@ -52,7 +52,6 @@ import com.todoroo.astrid.model.Task;
import com.todoroo.astrid.notes.NoteDetailExposer;
import com.todoroo.astrid.producteev.ProducteevDetailExposer;
import com.todoroo.astrid.repeats.RepeatDetailExposer;
-import com.todoroo.astrid.rmilk.MilkDetailExposer;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.tags.TagDetailExposer;
import com.todoroo.astrid.utility.Constants;
@@ -90,7 +89,6 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
new TagDetailExposer(),
new RepeatDetailExposer(),
new NoteDetailExposer(),
- new MilkDetailExposer(),
new ProducteevDetailExposer(),
new AlarmDetailExposer(),
};
diff --git a/astrid/src/com/todoroo/astrid/service/Astrid2To3UpgradeHelper.java b/astrid/src/com/todoroo/astrid/service/Astrid2To3UpgradeHelper.java
index a35875cae..0a764f70c 100644
--- a/astrid/src/com/todoroo/astrid/service/Astrid2To3UpgradeHelper.java
+++ b/astrid/src/com/todoroo/astrid/service/Astrid2To3UpgradeHelper.java
@@ -41,7 +41,6 @@ import com.todoroo.astrid.legacy.LegacyTaskModel;
import com.todoroo.astrid.legacy.TransitionalAlarm;
import com.todoroo.astrid.model.Metadata;
import com.todoroo.astrid.model.Task;
-import com.todoroo.astrid.rmilk.data.MilkTask;
import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.utility.Preferences;
@@ -447,7 +446,7 @@ public class Astrid2To3UpgradeHelper {
return;
Metadata metadata = new Metadata();
- metadata.setValue(Metadata.KEY, MilkTask.METADATA_KEY);
+ metadata.setValue(Metadata.KEY, "rmilk");
for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
long task = cursor.getLong(0);
String id = cursor.getString(1);
@@ -460,10 +459,10 @@ public class Astrid2To3UpgradeHelper {
String listId = strtok.nextToken();
metadata.setValue(Metadata.TASK, task);
- metadata.setValue(MilkTask.LIST_ID, Long.parseLong(listId));
- metadata.setValue(MilkTask.TASK_SERIES_ID, Long.parseLong(taskSeriesId));
- metadata.setValue(MilkTask.TASK_ID, Long.parseLong(taskId));
- metadata.setValue(MilkTask.REPEATING, 0); // not accurate, but not important
+ metadata.setValue(Metadata.VALUE1, (listId));
+ metadata.setValue(Metadata.VALUE2, (taskSeriesId));
+ metadata.setValue(Metadata.VALUE3, (taskId));
+ metadata.setValue(Metadata.VALUE4, "0"); // not accurate, but not important
metadataDao.createNew(metadata);
metadata.clearValue(Metadata.ID);
}
diff --git a/astrid/src/com/todoroo/astrid/service/StartupService.java b/astrid/src/com/todoroo/astrid/service/StartupService.java
index f3531b20f..1949b7cad 100644
--- a/astrid/src/com/todoroo/astrid/service/StartupService.java
+++ b/astrid/src/com/todoroo/astrid/service/StartupService.java
@@ -22,7 +22,6 @@ import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.service.ExceptionService.TodorooUncaughtExceptionHandler;
import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.producteev.ProducteevUtilities;
-import com.todoroo.astrid.rmilk.MilkUtilities;
import com.todoroo.astrid.utility.Constants;
import com.todoroo.astrid.utility.Preferences;
import com.todoroo.astrid.widget.TasksWidget.UpdateService;
@@ -114,7 +113,6 @@ public class StartupService {
Preferences.setPreferenceDefaults();
// if sync ongoing flag was set, clear it
- MilkUtilities.stopOngoing();
ProducteevUtilities.INSTANCE.stopOngoing();
// check for task killers
diff --git a/tests/src/com/todoroo/astrid/upgrade/Astrid2To3UpgradeTests.java b/tests/src/com/todoroo/astrid/upgrade/Astrid2To3UpgradeTests.java
index d0eaf0618..3ffc61fe3 100644
--- a/tests/src/com/todoroo/astrid/upgrade/Astrid2To3UpgradeTests.java
+++ b/tests/src/com/todoroo/astrid/upgrade/Astrid2To3UpgradeTests.java
@@ -11,8 +11,8 @@ import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.TestDependencyInjector;
import com.todoroo.andlib.sql.Query;
import com.todoroo.astrid.dao.MetadataDao;
-import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
+import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.legacy.AlarmDatabase;
import com.todoroo.astrid.legacy.TransitionalAlarm;
@@ -23,14 +23,13 @@ import com.todoroo.astrid.legacy.data.sync.SyncDataController;
import com.todoroo.astrid.legacy.data.sync.SyncMapping;
import com.todoroo.astrid.legacy.data.tag.TagController;
import com.todoroo.astrid.legacy.data.tag.TagIdentifier;
+import com.todoroo.astrid.legacy.data.task.AbstractTaskModel.RepeatInfo;
import com.todoroo.astrid.legacy.data.task.TaskController;
import com.todoroo.astrid.legacy.data.task.TaskIdentifier;
import com.todoroo.astrid.legacy.data.task.TaskModelForEdit;
import com.todoroo.astrid.legacy.data.task.TaskModelForSync;
-import com.todoroo.astrid.legacy.data.task.AbstractTaskModel.RepeatInfo;
import com.todoroo.astrid.model.Metadata;
import com.todoroo.astrid.model.Task;
-import com.todoroo.astrid.rmilk.data.MilkTask;
import com.todoroo.astrid.service.Astrid2To3UpgradeHelper;
import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.tags.TagService.Tag;
@@ -407,13 +406,13 @@ public class Astrid2To3UpgradeTests extends DatabaseTestCase {
database.openForReading();
TodorooCursor cursor = metadataDao.query(Query.select(
- Metadata.PROPERTIES).where(MetadataCriteria.withKey(MilkTask.METADATA_KEY)));
+ Metadata.PROPERTIES).where(MetadataCriteria.withKey("rmilk")));
assertEquals(1, cursor.getCount());
cursor.moveToFirst();
Metadata metadata = new Metadata(cursor);
- assertEquals(123, (long)metadata.getValue(MilkTask.TASK_ID));
- assertEquals(456, (long)metadata.getValue(MilkTask.TASK_SERIES_ID));
- assertEquals(789000, (long)metadata.getValue(MilkTask.LIST_ID));
+ assertEquals("123", metadata.getValue(Metadata.VALUE1));
+ assertEquals("456", metadata.getValue(Metadata.VALUE2));
+ assertEquals("789000", metadata.getValue(Metadata.VALUE3));
cursor.close();
}