Strip CR from google task descriptions

Tasks created in OneTask for Windows were only sending a CR
pull/795/head
Alex Baker 6 years ago
parent 74cf0fc378
commit acc0dda646

@ -0,0 +1,26 @@
package com.todoroo.astrid.gtasks.sync;
import static com.todoroo.astrid.gtasks.sync.GtasksTaskContainer.stripCarriageReturns;
import static org.junit.Assert.assertEquals;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class GtasksTaskContainerTest {
@Test
public void replaceCRLF() {
assertEquals("aaa\nbbb", stripCarriageReturns("aaa\r\nbbb"));
}
@Test
public void replaceCR() {
assertEquals("aaa\nbbb", stripCarriageReturns("aaa\rbbb"));
}
@Test
public void dontReplaceLF() {
assertEquals("aaa\nbbb", stripCarriageReturns("aaa\nbbb"));
}
}

@ -38,7 +38,7 @@ public class GtasksTaskContainer {
long dueDate = GtasksApiUtilities.gtasksDueTimeToUnixTime(remoteTask.getDue());
mergeDates(Task.createDueDate(Task.URGENCY_SPECIFIC_DAY, dueDate), task);
task.setNotes(remoteTask.getNotes());
task.setNotes(stripCarriageReturns(remoteTask.getNotes()));
gtaskMetadata.setRemoteId(remoteTask.getId());
gtaskMetadata.setListId(listId);
@ -54,4 +54,8 @@ public class GtasksTaskContainer {
public void prepareForSaving() {
metadata.add(gtaskMetadata);
}
static String stripCarriageReturns(String original) {
return original.replaceAll("\\r\\n?", "\n");
}
}

Loading…
Cancel
Save