Add account only on jelly bean and above

This commit is contained in:
Dominik Schürmann 2014-08-21 11:36:47 +02:00
parent 0c1e65bc8b
commit 3c46c3c2df
2 changed files with 15 additions and 8 deletions

View File

@ -25,6 +25,7 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Environment;
import android.provider.ContactsContract;
@ -111,6 +112,8 @@ public class KeychainApplication extends Application {
}
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) {
AccountManager manager = AccountManager.get(context);
Account[] accounts = manager.getAccountsByType(Constants.ACCOUNT_TYPE);
if (accounts == null || accounts.length == 0) {
@ -122,6 +125,7 @@ public class KeychainApplication extends Application {
}
}
}
}
static void brandGlowEffect(Context context, int brandColor) {
// terrible hack to brand the edge overscroll glow effect

View File

@ -19,6 +19,7 @@ package org.sufficientlysecure.keychain.helper;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.annotation.TargetApi;
import android.content.ContentProviderOperation;
import android.content.ContentResolver;
import android.content.ContentUris;
@ -252,6 +253,7 @@ public class ContactHelper {
return new ArrayList<String>(names);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static Uri dataUriFromContactUri(Context context, Uri contactUri) {
Cursor contactMasterKey = context.getContentResolver().query(contactUri,
new String[]{ContactsContract.Data.DATA2}, null, null, null, null);
@ -367,6 +369,7 @@ public class ContactHelper {
*
* @return raw contact id or -1 if not found
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private static int findRawContactId(ContentResolver resolver, String fingerprint) {
int rawContactId = -1;
Cursor raw = resolver.query(ContactsContract.RawContacts.CONTENT_URI, ID_PROJECTION,