Change account type

This commit is contained in:
Dominik Schürmann 2014-08-21 11:19:44 +02:00
parent 7adf07a9f9
commit 2930f83b2a
6 changed files with 12 additions and 9 deletions

View File

@ -35,6 +35,9 @@ public final class Constants {
public static final String PACKAGE_NAME = "org.sufficientlysecure.keychain";
public static final String ACCOUNT_NAME = "OpenKeychain";
public static final String ACCOUNT_TYPE = PACKAGE_NAME + ".account";
// as defined in http://tools.ietf.org/html/rfc3156, section 7
public static final String NFC_MIME = "application/pgp-keys";

View File

@ -112,9 +112,9 @@ public class KeychainApplication extends Application {
public static void setupAccountAsNeeded(Context context) {
AccountManager manager = AccountManager.get(context);
Account[] accounts = manager.getAccountsByType(Constants.PACKAGE_NAME);
Account[] accounts = manager.getAccountsByType(Constants.ACCOUNT_TYPE);
if (accounts == null || accounts.length == 0) {
Account account = new Account(context.getString(R.string.app_name), Constants.PACKAGE_NAME);
Account account = new Account(Constants.ACCOUNT_NAME, Constants.ACCOUNT_TYPE);
manager.addAccountExplicitly(account, null, null);
ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);

View File

@ -98,12 +98,12 @@ public class ContactSyncAdapterService extends Service {
}
}
public static void requestSync(Context context) {
public static void requestSync() {
Bundle extras = new Bundle();
// no need to wait for internet connection!
extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
ContentResolver.requestSync(
new Account(context.getString(R.string.app_name), Constants.PACKAGE_NAME),
new Account(Constants.ACCOUNT_NAME, Constants.ACCOUNT_TYPE),
ContactsContract.AUTHORITY,
extras);
}

View File

@ -455,7 +455,7 @@ public class KeychainIntentService extends IntentService
setProgress(R.string.progress_done, 100, 100);
// make sure new data is synced into contacts
ContactSyncAdapterService.requestSync(this);
ContactSyncAdapterService.requestSync();
/* Output */
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, saveResult);
@ -506,7 +506,7 @@ public class KeychainIntentService extends IntentService
providerHelper.consolidateDatabaseStep1(this);
}
// make sure new data is synced into contacts
ContactSyncAdapterService.requestSync(this);
ContactSyncAdapterService.requestSync();
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
} catch (Exception e) {
@ -715,7 +715,7 @@ public class KeychainIntentService extends IntentService
if (success) {
// make sure new data is synced into contacts
ContactSyncAdapterService.requestSync(this);
ContactSyncAdapterService.requestSync();
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY);
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="org.sufficientlysecure.keychain"
android:accountType="org.sufficientlysecure.keychain.account"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" />

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="com.android.contacts"
android:accountType="org.sufficientlysecure.keychain"
android:accountType="org.sufficientlysecure.keychain.account"
android:supportsUploading="false"
android:userVisible="true" />