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

Create an AndroidCompat class to wrap around Android oddities.

As part of it, move removeAccount to that class.
This commit is contained in:
Tom Hacohen 2017-04-26 12:00:01 +01:00
parent de6a124bf2
commit c81ba0cddb
2 changed files with 18 additions and 6 deletions

View File

@ -33,6 +33,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.AndroidCompat;
import com.etesync.syncadapter.utils.Base64;
import java.io.ByteArrayOutputStream;
@ -143,12 +144,7 @@ public class LocalAddressBook extends AndroidAddressBook implements LocalCollect
public void delete() {
AccountManager accountManager = AccountManager.get(context);
if (Build.VERSION.SDK_INT >=
Build.VERSION_CODES.LOLLIPOP_MR1) {
accountManager.removeAccountExplicitly(account);
} else {
accountManager.removeAccount(account, null, null);
}
AndroidCompat.removeAccount(accountManager, account);
}
public LocalAddressBook(Context context, Account account, ContentProviderClient provider) {

View File

@ -0,0 +1,16 @@
package com.etesync.syncadapter.utils;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.os.Build;
public class AndroidCompat {
public static void removeAccount (AccountManager accountManager, Account account) {
if (Build.VERSION.SDK_INT >=
Build.VERSION_CODES.LOLLIPOP_MR1) {
accountManager.removeAccountExplicitly(account);
} else {
accountManager.removeAccount(account, null, null);
}
}
}