mirror of
https://github.com/etesync/android
synced 2025-03-22 10:25:44 +00:00
Start bringing the task list up to date.
This commit is contained in:
parent
90bd1c8b7a
commit
e9b09453f8
@ -47,8 +47,6 @@ public class LocalCalendar extends AndroidCalendar implements LocalCollection {
|
||||
|
||||
public static final int defaultColor = 0xFF8bc34a; // light green 500
|
||||
|
||||
public static final String COLUMN_CTAG = Calendars.CAL_SYNC1;
|
||||
|
||||
static String[] BASE_INFO_COLUMNS = new String[] {
|
||||
Events._ID,
|
||||
Events._SYNC_ID,
|
||||
|
@ -13,6 +13,7 @@ import android.content.ContentValues;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.CalendarContract.Events;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.etesync.syncadapter.App;
|
||||
import com.etesync.syncadapter.Constants;
|
||||
@ -21,10 +22,12 @@ import net.fortuna.ical4j.model.property.ProdId;
|
||||
|
||||
import org.dmfs.provider.tasks.TaskContract.Tasks;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import at.bitfire.ical4android.AndroidTask;
|
||||
import at.bitfire.ical4android.AndroidTaskFactory;
|
||||
@ -65,13 +68,17 @@ public class LocalTask extends AndroidTask implements LocalResource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContent() throws IOException, ContactsStorageException {
|
||||
return null;
|
||||
}
|
||||
public String getContent() throws IOException, CalendarStorageException {
|
||||
App.log.log(Level.FINE, "Preparing upload of task " + getFileName(), getTask());
|
||||
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
getTask().write(os);
|
||||
|
||||
return os.toString(); }
|
||||
|
||||
@Override
|
||||
public boolean isLocalOnly() {
|
||||
return false;
|
||||
return TextUtils.isEmpty(getETag());
|
||||
}
|
||||
|
||||
/* process LocalTask-specific fields */
|
||||
@ -102,7 +109,7 @@ public class LocalTask extends AndroidTask implements LocalResource {
|
||||
public void prepareForUpload() throws CalendarStorageException {
|
||||
try {
|
||||
final String uid = UUID.randomUUID().toString();
|
||||
final String newFileName = uid + ".ics";
|
||||
final String newFileName = uid;
|
||||
|
||||
ContentValues values = new ContentValues(2);
|
||||
values.put(Tasks._SYNC_ID, newFileName);
|
||||
|
@ -20,6 +20,8 @@ import android.os.RemoteException;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.etesync.syncadapter.model.CollectionInfo;
|
||||
import com.etesync.syncadapter.model.JournalEntity;
|
||||
import com.etesync.syncadapter.model.JournalModel;
|
||||
|
||||
import org.dmfs.provider.tasks.TaskContract.TaskLists;
|
||||
import org.dmfs.provider.tasks.TaskContract.Tasks;
|
||||
@ -36,8 +38,6 @@ public class LocalTaskList extends AndroidTaskList implements LocalCollection {
|
||||
|
||||
public static final int defaultColor = 0xFFC3EA6E; // "DAVdroid green"
|
||||
|
||||
public static final String COLUMN_CTAG = TaskLists.SYNC_VERSION;
|
||||
|
||||
static String[] BASE_INFO_COLUMNS = new String[] {
|
||||
Tasks._ID,
|
||||
Tasks._SYNC_ID,
|
||||
@ -55,19 +55,20 @@ public class LocalTaskList extends AndroidTaskList implements LocalCollection {
|
||||
super(account, provider, LocalTask.Factory.INSTANCE, id);
|
||||
}
|
||||
|
||||
public static Uri create(Account account, TaskProvider provider, CollectionInfo info) throws CalendarStorageException {
|
||||
ContentValues values = valuesFromCollectionInfo(info, true);
|
||||
public static Uri create(Account account, TaskProvider provider, JournalEntity journalEntity) throws CalendarStorageException {
|
||||
ContentValues values = valuesFromCollectionInfo(journalEntity, true);
|
||||
values.put(TaskLists.OWNER, account.name);
|
||||
values.put(TaskLists.SYNC_ENABLED, 1);
|
||||
values.put(TaskLists.VISIBLE, 1);
|
||||
return create(account, provider, values);
|
||||
}
|
||||
|
||||
public void update(CollectionInfo info, boolean updateColor) throws CalendarStorageException {
|
||||
update(valuesFromCollectionInfo(info, updateColor));
|
||||
public void update(JournalEntity journalEntity, boolean updateColor) throws CalendarStorageException {
|
||||
update(valuesFromCollectionInfo(journalEntity, updateColor));
|
||||
}
|
||||
|
||||
private static ContentValues valuesFromCollectionInfo(CollectionInfo info, boolean withColor) {
|
||||
private static ContentValues valuesFromCollectionInfo(JournalEntity journalEntity, boolean withColor) {
|
||||
CollectionInfo info = journalEntity.getInfo();
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(TaskLists._SYNC_ID, info.uid);
|
||||
values.put(TaskLists.LIST_NAME, info.displayName);
|
||||
@ -151,17 +152,4 @@ public class LocalTaskList extends AndroidTaskList implements LocalCollection {
|
||||
return new LocalTaskList[size];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// HELPERS
|
||||
|
||||
public static void onRenameAccount(@NonNull ContentResolver resolver, @NonNull String oldName, @NonNull String newName) throws RemoteException {
|
||||
@Cleanup("release") ContentProviderClient client = resolver.acquireContentProviderClient(TaskProvider.ProviderName.OpenTasks.authority);
|
||||
if (client != null) {
|
||||
ContentValues values = new ContentValues(1);
|
||||
values.put(Tasks.ACCOUNT_NAME, newName);
|
||||
client.update(Tasks.getContentUri(TaskProvider.ProviderName.OpenTasks.authority), values, Tasks.ACCOUNT_NAME + "=?", new String[]{oldName});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user