Created
May 12, 2010 12:20
-
-
Save loganj/398514 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/main/AndroidManifest.xml b/main/AndroidManifest.xml | |
index 963fb7a..a955b06 100644 | |
--- a/main/AndroidManifest.xml | |
+++ b/main/AndroidManifest.xml | |
@@ -23,6 +23,16 @@ | |
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" /> | |
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" /> | |
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" /> | |
+ <uses-permission | |
+ android:name="android.permission.WRITE_CONTACTS" /> | |
+ <uses-permission | |
+ android:name="android.permission.READ_SYNC_STATS" /> | |
+ <uses-permission | |
+ android:name="android.permission.READ_CONTACTS" /> | |
+ <uses-permission | |
+ android:name="android.permission.USE_CREDENTIALS" /> | |
+ <uses-permission | |
+ android:name="android.permission.WRITE_SETTINGS" /> | |
<uses-sdk | |
android:minSdkVersion="3" | |
android:targetSdkVersion="5" /> | |
@@ -400,5 +410,13 @@ | |
android:resource="@xml/authenticator" /> | |
</service> | |
+ <service android:name=".ContactsSyncService" android:exported="true"> | |
+ <intent-filter> | |
+ <action android:name="android.content.SyncAdapter" /> | |
+ </intent-filter> | |
+ <meta-data android:name="android.content.SyncAdapter" android:resource="@xml/sync_contacts" /> | |
+ <meta-data android:name="android.provider.CONTACTS_STRUCTURE" android:resource="@xml/contacts" /> | |
+ </service> | |
+ | |
</application> | |
</manifest> | |
diff --git a/main/res/xml/contacts.xml b/main/res/xml/contacts.xml | |
new file mode 100644 | |
index 0000000..6ebe490 | |
--- /dev/null | |
+++ b/main/res/xml/contacts.xml | |
@@ -0,0 +1,8 @@ | |
+<ContactsSource xmlns:android="http://schemas.android.com/apk/res/android"> | |
+ <ContactsDataKind | |
+ android:icon="@drawable/icon" | |
+ android:mimeType="vnd.android.cursor.item/com.joelapenna.foursquared.profile" | |
+ android:summaryColumn="data2" | |
+ android:detailColumn="data3" | |
+ android:detailSocialSummary="true" /> | |
+</ContactsSource> | |
\ No newline at end of file | |
diff --git a/main/res/xml/sync_contacts.xml b/main/res/xml/sync_contacts.xml | |
new file mode 100644 | |
index 0000000..a33a32f | |
--- /dev/null | |
+++ b/main/res/xml/sync_contacts.xml | |
@@ -0,0 +1,5 @@ | |
+<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android" | |
+ android:contentAuthority="com.android.contacts" | |
+ android:accountType="org.joelapenna.foursquared.account" | |
+ android:supportsUploading="false" | |
+/> | |
\ No newline at end of file | |
diff --git a/main/src/com/joelapenna/foursquared/ContactsSyncAdapter.java b/main/src/com/joelapenna/foursquared/ContactsSyncAdapter.java | |
new file mode 100644 | |
index 0000000..a4b26ae | |
--- /dev/null | |
+++ b/main/src/com/joelapenna/foursquared/ContactsSyncAdapter.java | |
@@ -0,0 +1,28 @@ | |
+package com.joelapenna.foursquared; | |
+ | |
+import com.joelapenna.foursquare.Foursquare; | |
+import com.joelapenna.foursquared.location.LocationUtils; | |
+ | |
+import android.accounts.Account; | |
+import android.accounts.AccountManager; | |
+import android.content.AbstractThreadedSyncAdapter; | |
+import android.content.ContentProviderClient; | |
+import android.content.Context; | |
+import android.content.SyncResult; | |
+import android.os.Bundle; | |
+ | |
+public class ContactsSyncAdapter extends AbstractThreadedSyncAdapter { | |
+ | |
+ final private AccountManager mAccountManager; | |
+ | |
+ public ContactsSyncAdapter(Context context, boolean autoInitialize) { | |
+ super(context, autoInitialize); | |
+ mAccountManager = AccountManager.get(context); | |
+ } | |
+ | |
+ @Override | |
+ public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, | |
+ SyncResult syncResult) { | |
+ } | |
+ | |
+} | |
diff --git a/main/src/com/joelapenna/foursquared/ContactsSyncService.java b/main/src/com/joelapenna/foursquared/ContactsSyncService.java | |
new file mode 100644 | |
index 0000000..d340283 | |
--- /dev/null | |
+++ b/main/src/com/joelapenna/foursquared/ContactsSyncService.java | |
@@ -0,0 +1,28 @@ | |
+package com.joelapenna.foursquared; | |
+ | |
+import android.app.Service; | |
+import android.content.Intent; | |
+import android.os.IBinder; | |
+ | |
+public class ContactsSyncService extends Service { | |
+ | |
+ private static final Object sSyncAdapterLock = new Object(); | |
+ private static ContactsSyncAdapter sSyncAdapter = null; | |
+ | |
+ | |
+ @Override | |
+ public void onCreate() { | |
+ synchronized(sSyncAdapterLock) { | |
+ if (sSyncAdapter == null) { | |
+ sSyncAdapter = new ContactsSyncAdapter(getApplicationContext(), true); | |
+ } | |
+ } | |
+ } | |
+ | |
+ | |
+ @Override | |
+ public IBinder onBind(Intent intent) { | |
+ return sSyncAdapter.getSyncAdapterBinder(); | |
+ } | |
+ | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment