Fix bug #3248308 (On account set up, turn on sync for all apps by default; delay sync until after user selects Finish)

- reuse code by making AccountSyncSettings work in two modes: either use SyncManager or not

Change-Id: I29fc6820aa41ad4689745ed97d38248474033e7e
This commit is contained in:
Fabrice Di Meglio
2010-12-14 19:45:11 -08:00
parent 7553ebea45
commit 31ffa0439d
2 changed files with 71 additions and 47 deletions

View File

@@ -1,11 +1,11 @@
package com.android.settings.accounts;
import android.accounts.Account;
import android.content.ContentResolver;
import android.preference.Preference;
import com.android.settings.R;
import android.app.Activity;
import android.content.ContentResolver;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
@@ -27,6 +27,8 @@ public class AccountSyncSettingsInAddAccount extends AccountSyncSettings
mFinishArea.setVisibility(View.VISIBLE);
mFinishButton = (View) rootView.findViewById(R.id.finish_button);
mFinishButton.setOnClickListener(this);
mUseSyncManagerFeedsState = false;
}
@Override
@@ -37,6 +39,22 @@ public class AccountSyncSettingsInAddAccount extends AccountSyncSettings
}
public void onClick(View v) {
applySyncSettingsToSyncManager();
finish();
}
private void applySyncSettingsToSyncManager() {
for (int i = 0, count = getPreferenceScreen().getPreferenceCount(); i < count; i++) {
Preference pref = getPreferenceScreen().getPreference(i);
if (! (pref instanceof SyncStateCheckBoxPreference)) {
continue;
}
SyncStateCheckBoxPreference syncPref = (SyncStateCheckBoxPreference) pref;
String authority = syncPref.getAuthority();
Account account = syncPref.getAccount();
ContentResolver.setSyncAutomatically(account, authority, syncPref.isChecked());
}
}
}