1
0
mirror of https://github.com/etesync/android synced 2024-11-16 04:49:06 +00:00

Change LocalAddressBook to look like LocalCalendar (accept journalentity)

This commit is contained in:
Tom Hacohen 2017-04-21 19:39:08 +01:00
parent 48a77530a8
commit 19b955f981

View File

@ -32,6 +32,7 @@ import android.support.v4.os.OperationCanceledException;
import com.etesync.syncadapter.App;
import com.etesync.syncadapter.model.CollectionInfo;
import com.etesync.syncadapter.model.JournalEntity;
import com.etesync.syncadapter.utils.Base64;
import java.io.ByteArrayOutputStream;
@ -83,7 +84,8 @@ public class LocalAddressBook extends AndroidAddressBook implements LocalCollect
return result.toArray(new LocalAddressBook[result.size()]);
}
public static LocalAddressBook create(@NonNull Context context, @NonNull ContentProviderClient provider, @NonNull Account mainAccount, @NonNull CollectionInfo info) throws ContactsStorageException {
public static LocalAddressBook create(@NonNull Context context, @NonNull ContentProviderClient provider, @NonNull Account mainAccount, @NonNull JournalEntity journalEntity) throws ContactsStorageException {
CollectionInfo info = journalEntity.getInfo();
AccountManager accountManager = AccountManager.get(context);
Account account = new Account(accountName(mainAccount, info), App.getAddressBookAccountType());
@ -99,7 +101,8 @@ public class LocalAddressBook extends AndroidAddressBook implements LocalCollect
return addressBook;
}
public void update(@NonNull CollectionInfo info) throws AuthenticatorException, OperationCanceledException, IOException, ContactsStorageException, android.accounts.OperationCanceledException {
public void update(@NonNull JournalEntity journalEntity) throws AuthenticatorException, OperationCanceledException, IOException, ContactsStorageException, android.accounts.OperationCanceledException {
CollectionInfo info = journalEntity.getInfo();
final String newAccountName = accountName(getMainAccount(), info);
if (!account.name.equals(newAccountName) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
final AccountManager accountManager = AccountManager.get(context);