From 8c3e0f69bb0137544a5b091a819b4d4d2569c3ba Mon Sep 17 00:00:00 2001 From: Sam Steele Date: Mon, 27 Feb 2012 10:09:49 -0800 Subject: [PATCH] Dont overwrite the contacts schema version in the calendar sync adapter --- app/src/fm/last/android/LastFMApplication.java | 4 ++++ .../fm/last/android/sync/CalendarSyncAdapterService.java | 8 ++++---- .../fm/last/android/sync/ContactsSyncAdapterService.java | 7 ++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/src/fm/last/android/LastFMApplication.java b/app/src/fm/last/android/LastFMApplication.java index 551edd4d..d048a98e 100644 --- a/app/src/fm/last/android/LastFMApplication.java +++ b/app/src/fm/last/android/LastFMApplication.java @@ -390,6 +390,10 @@ public void logout() { editor.remove("scrobbler_npurl"); editor.remove("sync_nag"); editor.remove("sync_nag_cal"); + editor.remove("sync_schema"); + editor.remove("do_full_sync"); + editor.remove("cal_sync_schema"); + editor.remove("cal_do_full_sync"); editor.commit(); session = null; try { diff --git a/app/src/fm/last/android/sync/CalendarSyncAdapterService.java b/app/src/fm/last/android/sync/CalendarSyncAdapterService.java index af9417e7..6d2bbe25 100644 --- a/app/src/fm/last/android/sync/CalendarSyncAdapterService.java +++ b/app/src/fm/last/android/sync/CalendarSyncAdapterService.java @@ -206,10 +206,10 @@ private static void performSync(Context context, Account account, Bundle extras, mContentResolver = context.getContentResolver(); //If our app has requested a full sync, we're going to delete all our local events and start over - boolean is_full_sync = PreferenceManager.getDefaultSharedPreferences(LastFMApplication.getInstance()).getBoolean("do_full_sync", false); + boolean is_full_sync = PreferenceManager.getDefaultSharedPreferences(LastFMApplication.getInstance()).getBoolean("cal_do_full_sync", false); //If our schema is out-of-date, do a fresh sync - if(PreferenceManager.getDefaultSharedPreferences(LastFMApplication.getInstance()).getInt("sync_schema", 0) < syncSchema) + if(PreferenceManager.getDefaultSharedPreferences(LastFMApplication.getInstance()).getInt("cal_sync_schema", 0) < syncSchema) is_full_sync = true; long calendar_id = getCalendar(account); @@ -233,8 +233,8 @@ private static void performSync(Context context, Account account, Bundle extras, c1.close(); Editor editor = PreferenceManager.getDefaultSharedPreferences(LastFMApplication.getInstance()).edit(); - editor.remove("do_full_sync"); - editor.putInt("sync_schema", syncSchema); + editor.remove("cal_do_full_sync"); + editor.putInt("cal_sync_schema", syncSchema); editor.commit(); LastFmServer server = AndroidLastFmServerFactory.getServer(); diff --git a/app/src/fm/last/android/sync/ContactsSyncAdapterService.java b/app/src/fm/last/android/sync/ContactsSyncAdapterService.java index 15ab4c63..78e02d1b 100644 --- a/app/src/fm/last/android/sync/ContactsSyncAdapterService.java +++ b/app/src/fm/last/android/sync/ContactsSyncAdapterService.java @@ -42,6 +42,7 @@ import android.provider.ContactsContract; import android.provider.ContactsContract.RawContacts; import android.provider.ContactsContract.RawContacts.Entity; +import android.util.Log; /** * @author sam @@ -300,6 +301,10 @@ private static void performSync(Context context, Account account, Bundle extras, } } + Log.i("Sync", "DB Schema: " + PreferenceManager.getDefaultSharedPreferences(LastFMApplication.getInstance()).getInt("sync_schema", 0)); + if(is_full_sync) + Log.i("Sync", "Performing full sync"); + Editor editor = PreferenceManager.getDefaultSharedPreferences(LastFMApplication.getInstance()).edit(); editor.remove("do_full_sync"); editor.putInt("sync_schema", syncSchema); @@ -389,7 +394,7 @@ private static void performSync(Context context, Account account, Bundle extras, updateContactName(operationList, entry.raw_id, user.getRealName(), username); } - if(operationList.size() >= 50) { + if(operationList.size() >= 25) { try { mContentResolver.applyBatch(ContactsContract.AUTHORITY, operationList); } catch (Exception e) {