From 2930f83b2a49735a840f2adad4a4c3cb83ac07e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 21 Aug 2014 11:19:44 +0200 Subject: [PATCH] Change account type --- .../java/org/sufficientlysecure/keychain/Constants.java | 3 +++ .../sufficientlysecure/keychain/KeychainApplication.java | 4 ++-- .../keychain/service/ContactSyncAdapterService.java | 4 ++-- .../keychain/service/KeychainIntentService.java | 6 +++--- OpenKeychain/src/main/res/xml/account_desc.xml | 2 +- OpenKeychain/src/main/res/xml/sync_adapter_desc.xml | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java index 78b66464b..9f84da815 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java @@ -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"; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java index ca9af8a9d..964342c60 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java @@ -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); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java index 909c3031c..fbe914b78 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java @@ -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); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 246804383..021e6bc07 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -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); } diff --git a/OpenKeychain/src/main/res/xml/account_desc.xml b/OpenKeychain/src/main/res/xml/account_desc.xml index 41ce8fe48..d29395202 100644 --- a/OpenKeychain/src/main/res/xml/account_desc.xml +++ b/OpenKeychain/src/main/res/xml/account_desc.xml @@ -1,5 +1,5 @@ diff --git a/OpenKeychain/src/main/res/xml/sync_adapter_desc.xml b/OpenKeychain/src/main/res/xml/sync_adapter_desc.xml index bbfd41842..d05dc6918 100644 --- a/OpenKeychain/src/main/res/xml/sync_adapter_desc.xml +++ b/OpenKeychain/src/main/res/xml/sync_adapter_desc.xml @@ -1,6 +1,6 @@ \ No newline at end of file