diff --git a/astrid/src/com/todoroo/astrid/utility/TitleParser.java b/astrid/src/com/todoroo/astrid/utility/TitleParser.java index 556f5916a..b0c6bd0e6 100644 --- a/astrid/src/com/todoroo/astrid/utility/TitleParser.java +++ b/astrid/src/com/todoroo/astrid/utility/TitleParser.java @@ -12,7 +12,7 @@ import com.mdimension.jchronic.AstridChronic; import com.mdimension.jchronic.Chronic; import com.todoroo.astrid.data.Task; - +@SuppressWarnings("nls") public class TitleParser { Task task; ArrayList tags; @@ -61,7 +61,6 @@ public class TitleParser { } //helper method for priorityHelper. converts the string to a Task Importance - @SuppressWarnings("nls") private static int str_to_priority(String priority_str) { if (priority_str!=null) priority_str.toLowerCase().trim(); @@ -86,12 +85,13 @@ public class TitleParser { "(?i)()(\\shigh(est)?|\\slow(est)?|\\stop|\\sleast) ?priority$" }; for (String importanceString:importanceStrings){ - Pattern importancePattern= Pattern.compile(importanceString); + Pattern importancePattern = Pattern.compile(importanceString); while (true){ Matcher m = importancePattern.matcher(inputText); if(m.find()) { task.setValue(Task.IMPORTANCE, str_to_priority(m.group(2).trim())); - inputText = inputText.substring(0, m.start()+1) + inputText.substring(m.end()); + int start = m.start() == 0 ? 0 : m.start() + 1; + inputText = inputText.substring(0, start) + inputText.substring(m.end()); } else break; @@ -118,7 +118,6 @@ public class TitleParser { //Handles setting the task's date. //Day of week (e.g. Monday, Tuesday,..) is overridden by a set date (e.g. October 23 2013). //Vague times (e.g. breakfast, night) are overridden by a set time (9 am, at 10, 17:00) - @SuppressWarnings("nls") private static void dayHelper(Task task ) { String inputText = task.getValue(Task.TITLE); Calendar cal = null; @@ -316,7 +315,6 @@ public class TitleParser { //---------------------DATE-------------------------- //Parses through the text and sets the frequency of the task. - @SuppressWarnings("nls") private static void repeatHelper(Task task) { String inputText = task.getValue(Task.TITLE); HashMap repeatTimes = new HashMap(); diff --git a/tests/src/com/todoroo/astrid/gtasks/GtasksApiTest.java b/tests/src/com/todoroo/astrid/gtasks/GtasksApiTest.java index 7615b4b4d..f13e9b67d 100644 --- a/tests/src/com/todoroo/astrid/gtasks/GtasksApiTest.java +++ b/tests/src/com/todoroo/astrid/gtasks/GtasksApiTest.java @@ -19,7 +19,7 @@ import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.gtasks.api.GtasksApiUtilities; -import com.todoroo.astrid.gtasks.api.GtasksService; +import com.todoroo.astrid.gtasks.api.GtasksInvoker; import com.todoroo.astrid.gtasks.api.MoveListRequest; import com.todoroo.astrid.gtasks.auth.GtasksTokenValidator; import com.todoroo.astrid.test.DatabaseTestCase; @@ -29,7 +29,7 @@ public class GtasksApiTest extends DatabaseTestCase { private static final String DEFAULT_LIST = "@default"; private static final String TEST_ACCOUNT = "sync_tester2@astrid.com"; - private static GtasksService service; + private static GtasksInvoker service; private static boolean initialized = false; private boolean bypassTests = false; @@ -178,7 +178,7 @@ public class GtasksApiTest extends DatabaseTestCase { } private boolean listHasTaskWithTitle(String listId, String title) throws Exception { - com.google.api.services.tasks.model.Tasks newListTasks = service.getAllGtasksFromListId(listId, false, false); + com.google.api.services.tasks.model.Tasks newListTasks = service.getAllGtasksFromListId(listId, false, false, 0); List items = newListTasks.getItems(); if (items != null) { for (Task t : items) { @@ -191,7 +191,7 @@ public class GtasksApiTest extends DatabaseTestCase { } private boolean taskWithTitleExists(String title) throws Exception { - Tasks defaultList = service.getAllGtasksFromListId(DEFAULT_LIST, false, false); + Tasks defaultList = service.getAllGtasksFromListId(DEFAULT_LIST, false, false, 0); List items = defaultList.getItems(); if (items != null) { for (Task t : items) { @@ -270,7 +270,7 @@ public class GtasksApiTest extends DatabaseTestCase { } Preferences.setString(GtasksPreferenceService.PREF_USER_NAME, toUse.name); - AccountManagerFuture accountManagerFuture = manager.manager.getAuthToken(toUse, GtasksService.AUTH_TOKEN_TYPE, true, null, null); + AccountManagerFuture accountManagerFuture = manager.manager.getAuthToken(toUse, GtasksInvoker.AUTH_TOKEN_TYPE, true, null, null); Bundle authTokenBundle = accountManagerFuture.getResult(); if (authTokenBundle.containsKey(AccountManager.KEY_INTENT)) { @@ -282,7 +282,7 @@ public class GtasksApiTest extends DatabaseTestCase { String authToken = authTokenBundle.getString(AccountManager.KEY_AUTHTOKEN); authToken = GtasksTokenValidator.validateAuthToken(getContext(), authToken); - service = new GtasksService(authToken); + service = new GtasksInvoker(authToken); initialized = true; } @@ -306,7 +306,7 @@ public class GtasksApiTest extends DatabaseTestCase { private void clearDefaultList() { try { - Tasks tasks = service.getAllGtasksFromListId(DEFAULT_LIST, false, false); + Tasks tasks = service.getAllGtasksFromListId(DEFAULT_LIST, false, false, 0); List items = tasks.getItems(); if (items != null) { for (Task t : items) { diff --git a/tests/src/com/todoroo/astrid/gtasks/GtasksNewSyncTest.java b/tests/src/com/todoroo/astrid/gtasks/GtasksNewSyncTest.java index 9d3f145e6..4b99f73c9 100644 --- a/tests/src/com/todoroo/astrid/gtasks/GtasksNewSyncTest.java +++ b/tests/src/com/todoroo/astrid/gtasks/GtasksNewSyncTest.java @@ -22,7 +22,7 @@ import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.gtasks.api.GtasksApiUtilities; -import com.todoroo.astrid.gtasks.api.GtasksService; +import com.todoroo.astrid.gtasks.api.GtasksInvoker; import com.todoroo.astrid.gtasks.auth.GtasksTokenValidator; import com.todoroo.astrid.gtasks.sync.GtasksSyncProvider; import com.todoroo.astrid.service.MetadataService; @@ -32,7 +32,7 @@ import com.todoroo.astrid.test.DatabaseTestCase; @SuppressWarnings("nls") public class GtasksNewSyncTest extends DatabaseTestCase { - private static GtasksService gtasksService; + private static GtasksInvoker gtasksService; private GtasksSyncProvider syncProvider; private static boolean initialized = false; private boolean bypassTests = false; @@ -522,13 +522,13 @@ public class GtasksNewSyncTest extends DatabaseTestCase { authToken = GtasksTokenValidator.validateAuthToken(getContext(), authToken); gtasksPreferenceService.setToken(authToken); - gtasksService = new GtasksService(authToken); + gtasksService = new GtasksInvoker(authToken); initialized = true; } private void setupTestList() throws Exception { - Tasks defaultListTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false, false); + Tasks defaultListTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false, false, 0); List items = defaultListTasks.getItems(); if (items != null) { for (com.google.api.services.tasks.model.Task t : items) { diff --git a/tests/src/com/todoroo/astrid/gtasks/GtasksSyncOnSaveTest.java b/tests/src/com/todoroo/astrid/gtasks/GtasksSyncOnSaveTest.java index 24221ff7a..589b76338 100644 --- a/tests/src/com/todoroo/astrid/gtasks/GtasksSyncOnSaveTest.java +++ b/tests/src/com/todoroo/astrid/gtasks/GtasksSyncOnSaveTest.java @@ -12,7 +12,6 @@ import android.os.Bundle; import com.google.api.client.googleapis.extensions.android2.auth.GoogleAccountManager; import com.google.api.services.tasks.model.Tasks; -import com.timsu.astrid.R; import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.utility.AndroidUtilities; @@ -21,20 +20,20 @@ import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.gtasks.api.GtasksApiUtilities; -import com.todoroo.astrid.gtasks.api.GtasksService; +import com.todoroo.astrid.gtasks.api.GtasksInvoker; import com.todoroo.astrid.gtasks.auth.GtasksTokenValidator; -import com.todoroo.astrid.gtasks.sync.GtasksSyncOnSaveService; +import com.todoroo.astrid.gtasks.sync.GtasksSyncService; import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.test.DatabaseTestCase; public class GtasksSyncOnSaveTest extends DatabaseTestCase { @Autowired TaskService taskService; - @Autowired GtasksSyncOnSaveService gtasksSyncOnSaveService; + @Autowired GtasksSyncService gtasksSyncService; @Autowired GtasksMetadataService gtasksMetadataService; @Autowired GtasksPreferenceService gtasksPreferenceService; - private GtasksService gtasksService; + private GtasksInvoker gtasksService; private boolean initialized = false; private boolean bypassTests = false; private static final String TEST_ACCOUNT = "sync_tester2@astrid.com"; @@ -148,7 +147,7 @@ public class GtasksSyncOnSaveTest extends DatabaseTestCase { } private boolean taskWithTitleExists(String title) throws IOException { - Tasks allTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false, false); + Tasks allTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false, false, 0); List items = allTasks.getItems(); if (items != null) { for (com.google.api.services.tasks.model.Task t : items) { @@ -165,9 +164,8 @@ public class GtasksSyncOnSaveTest extends DatabaseTestCase { if (!initialized) { initializeTestService(); - gtasksSyncOnSaveService.initialize(); + gtasksSyncService.initialize(); initialized = true; - Preferences.setBoolean(R.string.gtasks_GPr_sync_on_save_key, true); } setupTestList(); @@ -205,13 +203,13 @@ public class GtasksSyncOnSaveTest extends DatabaseTestCase { authToken = GtasksTokenValidator.validateAuthToken(getContext(), authToken); gtasksPreferenceService.setToken(authToken); - gtasksService = new GtasksService(authToken); + gtasksService = new GtasksInvoker(authToken); initialized = true; } private void setupTestList() throws Exception { - Tasks defaultListTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false, false); + Tasks defaultListTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false, false, 0); List items = defaultListTasks.getItems(); if (items != null) { for (com.google.api.services.tasks.model.Task t : items) { diff --git a/tests/src/com/todoroo/astrid/sync/repeats/RepeatTestsGtasksSync.java b/tests/src/com/todoroo/astrid/sync/repeats/RepeatTestsGtasksSync.java index 0ec9d50c3..d74b4ffa6 100644 --- a/tests/src/com/todoroo/astrid/sync/repeats/RepeatTestsGtasksSync.java +++ b/tests/src/com/todoroo/astrid/sync/repeats/RepeatTestsGtasksSync.java @@ -23,7 +23,7 @@ import com.todoroo.astrid.gtasks.GtasksMetadata; import com.todoroo.astrid.gtasks.GtasksMetadataService; import com.todoroo.astrid.gtasks.GtasksPreferenceService; import com.todoroo.astrid.gtasks.api.GtasksApiUtilities; -import com.todoroo.astrid.gtasks.api.GtasksService; +import com.todoroo.astrid.gtasks.api.GtasksInvoker; import com.todoroo.astrid.gtasks.auth.GtasksTokenValidator; import com.todoroo.astrid.gtasks.sync.GtasksSyncProvider; import com.todoroo.astrid.repeats.NewRepeatTests; @@ -40,7 +40,7 @@ public class RepeatTestsGtasksSync extends NewRepeatTests items = defaultListTasks.getItems(); if (items != null) { for (com.google.api.services.tasks.model.Task t : items) {