Add caldav accounts to backup

pull/699/head
Alex Baker 7 years ago
parent 8a95377968
commit fb09501aa4

@ -5,6 +5,7 @@ import static java.util.Collections.emptyList;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import java.util.List; import java.util.List;
import org.tasks.data.Alarm; import org.tasks.data.Alarm;
import org.tasks.data.CaldavAccount;
import org.tasks.data.CaldavCalendar; import org.tasks.data.CaldavCalendar;
import org.tasks.data.CaldavTask; import org.tasks.data.CaldavTask;
import org.tasks.data.Filter; import org.tasks.data.Filter;
@ -22,6 +23,7 @@ class BackupContainer {
final List<TagData> tags; final List<TagData> tags;
final List<Filter> filters; final List<Filter> filters;
final List<GoogleTaskList> googleTaskLists; final List<GoogleTaskList> googleTaskLists;
private final List<CaldavAccount> caldavAccounts;
private final List<CaldavCalendar> caldavCalendars; private final List<CaldavCalendar> caldavCalendars;
BackupContainer( BackupContainer(
@ -29,14 +31,20 @@ class BackupContainer {
List<TagData> tags, List<TagData> tags,
List<Filter> filters, List<Filter> filters,
List<GoogleTaskList> googleTaskLists, List<GoogleTaskList> googleTaskLists,
List<CaldavAccount> caldavAccounts,
List<CaldavCalendar> caldavCalendars) { List<CaldavCalendar> caldavCalendars) {
this.tasks = tasks; this.tasks = tasks;
this.tags = tags; this.tags = tags;
this.filters = filters; this.filters = filters;
this.googleTaskLists = googleTaskLists; this.googleTaskLists = googleTaskLists;
this.caldavAccounts = caldavAccounts;
this.caldavCalendars = caldavCalendars; this.caldavCalendars = caldavCalendars;
} }
public List<CaldavAccount> getCaldavAccounts() {
return caldavAccounts == null ? emptyList() : caldavAccounts;
}
public List<CaldavCalendar> getCaldavCalendars() { public List<CaldavCalendar> getCaldavCalendars() {
return caldavCalendars == null ? emptyList() : caldavCalendars; return caldavCalendars == null ? emptyList() : caldavCalendars;
} }

@ -179,6 +179,7 @@ public class TasksJsonExporter {
tagDataDao.getAll(), tagDataDao.getAll(),
filterDao.getAll(), filterDao.getAll(),
googleTaskListDao.getAll(), googleTaskListDao.getAll(),
caldavDao.getAccounts(),
caldavDao.getCalendars())); caldavDao.getCalendars()));
File file = new File(output); File file = new File(output);

@ -18,6 +18,7 @@ import org.tasks.LocalBroadcastManager;
import org.tasks.R; import org.tasks.R;
import org.tasks.data.Alarm; import org.tasks.data.Alarm;
import org.tasks.data.AlarmDao; import org.tasks.data.AlarmDao;
import org.tasks.data.CaldavAccount;
import org.tasks.data.CaldavCalendar; import org.tasks.data.CaldavCalendar;
import org.tasks.data.CaldavDao; import org.tasks.data.CaldavDao;
import org.tasks.data.CaldavTask; import org.tasks.data.CaldavTask;
@ -141,7 +142,11 @@ public class TasksJsonImporter {
filterDao.insert(filter); filterDao.insert(filter);
} }
} }
// TODO: Add caldav accounts to backup for (CaldavAccount account : backupContainer.getCaldavAccounts()) {
if (caldavDao.getAccountByUuid(account.getUuid()) == null) {
caldavDao.insert(account);
}
}
for (CaldavCalendar calendar : backupContainer.getCaldavCalendars()) { for (CaldavCalendar calendar : backupContainer.getCaldavCalendars()) {
if (caldavDao.getCalendarByUuid(calendar.getUuid()) == null) { if (caldavDao.getCalendarByUuid(calendar.getUuid()) == null) {
caldavDao.insert(calendar); caldavDao.insert(calendar);

@ -13,6 +13,9 @@ public interface CaldavDao {
@Query("SELECT * FROM caldav_calendar WHERE uuid = :uuid LIMIT 1") @Query("SELECT * FROM caldav_calendar WHERE uuid = :uuid LIMIT 1")
CaldavCalendar getCalendarByUuid(String uuid); CaldavCalendar getCalendarByUuid(String uuid);
@Query("SELECT * FROM caldav_account WHERE uuid = :uuid LIMIT 1")
CaldavAccount getAccountByUuid(String uuid);
@Query("SELECT * FROM caldav_account ORDER BY UPPER(name) ASC") @Query("SELECT * FROM caldav_account ORDER BY UPPER(name) ASC")
List<CaldavAccount> getAccounts(); List<CaldavAccount> getAccounts();

Loading…
Cancel
Save