1
0
mirror of https://github.com/etesync/android synced 2025-01-11 08:10:58 +00:00

Import: Fix address book import.

The import code assumed there can be only one address book, and that
it's the main one. This commit fixes that wrong assumption.
This commit is contained in:
Tom Hacohen 2017-04-26 13:28:27 +01:00
parent e729bcff42
commit 2f95ddbda2
2 changed files with 5 additions and 4 deletions

View File

@ -307,7 +307,7 @@ public class ImportFragment extends DialogFragment {
finishParsingFile(contacts.length); finishParsingFile(contacts.length);
ContentProviderClient provider = getContext().getContentResolver().acquireContentProviderClient(ContactsContract.RawContacts.CONTENT_URI); ContentProviderClient provider = getContext().getContentResolver().acquireContentProviderClient(ContactsContract.RawContacts.CONTENT_URI);
LocalAddressBook localAddressBook = new LocalAddressBook(getContext(), account, provider); LocalAddressBook localAddressBook = LocalAddressBook.findByUid(getContext(), provider, account, info.uid);
for (Contact contact : contacts) { for (Contact contact : contacts) {
try { try {
@ -332,7 +332,7 @@ public class ImportFragment extends DialogFragment {
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
result.e = e; result.e = e;
return result; return result;
} catch (InvalidCalendarException | IOException e) { } catch (InvalidCalendarException | IOException | ContactsStorageException e) {
result.e = e; result.e = e;
return result; return result;
} }

View File

@ -152,8 +152,9 @@ public class LocalContactImportFragment extends Fragment {
private ResultFragment.ImportResult importContacts(LocalAddressBook localAddressBook) { private ResultFragment.ImportResult importContacts(LocalAddressBook localAddressBook) {
ResultFragment.ImportResult result = new ResultFragment.ImportResult(); ResultFragment.ImportResult result = new ResultFragment.ImportResult();
try { try {
LocalAddressBook addressBook = new LocalAddressBook(getContext(), account, LocalAddressBook addressBook = LocalAddressBook.findByUid(getContext(),
getContext().getContentResolver().acquireContentProviderClient(ContactsContract.RawContacts.CONTENT_URI)); getContext().getContentResolver().acquireContentProviderClient(ContactsContract.RawContacts.CONTENT_URI),
account, info.uid);
LocalContact[] localContacts = localAddressBook.getAll(); LocalContact[] localContacts = localAddressBook.getAll();
int total = localContacts.length; int total = localContacts.length;
progressDialog.setMax(total); progressDialog.setMax(total);