mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-23 15:38:50 -05:00
Merge pull request #1155 from adithyaphilip/development
Removed JellyBean restriction on Contact Sync
This commit is contained in:
commit
53d7c1f533
@ -118,24 +118,21 @@ public class KeychainApplication extends Application {
|
||||
* @param context
|
||||
*/
|
||||
public static void setupAccountAsNeeded(Context context) {
|
||||
// only enabled for Jelly Bean because we need some newer methods in our sync adapter
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
try {
|
||||
AccountManager manager = AccountManager.get(context);
|
||||
Account[] accounts = manager.getAccountsByType(Constants.ACCOUNT_TYPE);
|
||||
if (accounts == null || accounts.length == 0) {
|
||||
Account account = new Account(Constants.ACCOUNT_NAME, Constants.ACCOUNT_TYPE);
|
||||
if (manager.addAccountExplicitly(account, null, null)) {
|
||||
ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
|
||||
ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
|
||||
} else {
|
||||
Log.e(Constants.TAG, "Adding account failed!");
|
||||
}
|
||||
try {
|
||||
AccountManager manager = AccountManager.get(context);
|
||||
Account[] accounts = manager.getAccountsByType(Constants.ACCOUNT_TYPE);
|
||||
if (accounts == null || accounts.length == 0) {
|
||||
Account account = new Account(Constants.ACCOUNT_NAME, Constants.ACCOUNT_TYPE);
|
||||
if (manager.addAccountExplicitly(account, null, null)) {
|
||||
ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
|
||||
ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
|
||||
} else {
|
||||
Log.e(Constants.TAG, "Adding account failed!");
|
||||
}
|
||||
} catch (SecurityException e) {
|
||||
Log.e(Constants.TAG, "SecurityException when adding the account", e);
|
||||
Toast.makeText(context, R.string.reinstall_openkeychain, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} catch (SecurityException e) {
|
||||
Log.e(Constants.TAG, "SecurityException when adding the account", e);
|
||||
Toast.makeText(context, R.string.reinstall_openkeychain, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user