Skip to content

Commit

Permalink
Dont overwrite the contacts schema version in the calendar sync adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Steele committed Feb 27, 2012
1 parent 7657e5b commit 8c3e0f6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/src/fm/last/android/LastFMApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions app/src/fm/last/android/sync/CalendarSyncAdapterService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down
7 changes: 6 additions & 1 deletion app/src/fm/last/android/sync/ContactsSyncAdapterService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 8c3e0f6

Please sign in to comment.