Merge "Add calendar sync checkbox to account settings screen"

This commit is contained in:
Marc Blank 2010-02-04 12:24:52 -08:00 committed by Android (Google) Code Review
commit 8f8179f07e
3 changed files with 22 additions and 1 deletions

View File

@ -545,7 +545,13 @@
<!-- On settings screen, sync contacts check box label --> <!-- On settings screen, sync contacts check box label -->
<string name="account_settings_sync_contacts_enable">Sync contacts</string> <string name="account_settings_sync_contacts_enable">Sync contacts</string>
<!-- On settings screen, sync contacts summary text --> <!-- On settings screen, sync contacts summary text -->
<string name="account_settings_sync_contacts_summary">Also sync contacts from this account</string> <string name="account_settings_sync_contacts_summary">Also sync contacts from this account
</string>
<!-- On settings screen, sync calendar check box label -->
<string name="account_settings_sync_calendar_enable">Sync calendar</string>
<!-- On settings screen, sync calendar summary text -->
<string name="account_settings_sync_calendar_summary">Also sync calendar from this account
</string>
<!-- On Settings screen, setting check box label --> <!-- On Settings screen, setting check box label -->
<string name="account_settings_vibrate_enable">Vibrate</string> <string name="account_settings_vibrate_enable">Vibrate</string>

View File

@ -102,6 +102,12 @@
android:defaultValue="true" android:defaultValue="true"
android:title="@string/account_settings_sync_contacts_enable" android:title="@string/account_settings_sync_contacts_enable"
android:summary="@string/account_settings_sync_contacts_summary" /> android:summary="@string/account_settings_sync_contacts_summary" />
<CheckBoxPreference
android:layout="?android:attr/preferenceLayoutChild"
android:key="account_sync_calendar"
android:defaultValue="true"
android:title="@string/account_settings_sync_calendar_enable"
android:summary="@string/account_settings_sync_calendar_summary" />
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View File

@ -38,6 +38,7 @@ import android.preference.Preference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory; import android.preference.PreferenceCategory;
import android.preference.RingtonePreference; import android.preference.RingtonePreference;
import android.provider.Calendar;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
@ -56,6 +57,7 @@ public class AccountSettings extends PreferenceActivity {
private static final String PREFERENCE_INCOMING = "incoming"; private static final String PREFERENCE_INCOMING = "incoming";
private static final String PREFERENCE_OUTGOING = "outgoing"; private static final String PREFERENCE_OUTGOING = "outgoing";
private static final String PREFERENCE_SYNC_CONTACTS = "account_sync_contacts"; private static final String PREFERENCE_SYNC_CONTACTS = "account_sync_contacts";
private static final String PREFERENCE_SYNC_CALENDAR = "account_sync_calendar";
// NOTE: This string must match the one in res/xml/account_preferences.xml // NOTE: This string must match the one in res/xml/account_preferences.xml
public static final String ACTION_ACCOUNT_MANAGER_ENTRY = public static final String ACTION_ACCOUNT_MANAGER_ENTRY =
@ -79,6 +81,7 @@ public class AccountSettings extends PreferenceActivity {
private CheckBoxPreference mAccountVibrate; private CheckBoxPreference mAccountVibrate;
private RingtonePreference mAccountRingtone; private RingtonePreference mAccountRingtone;
private CheckBoxPreference mSyncContacts; private CheckBoxPreference mSyncContacts;
private CheckBoxPreference mSyncCalendar;
/** /**
* Display (and edit) settings for a specific account * Display (and edit) settings for a specific account
@ -264,15 +267,19 @@ public class AccountSettings extends PreferenceActivity {
} }
mSyncContacts = (CheckBoxPreference) findPreference(PREFERENCE_SYNC_CONTACTS); mSyncContacts = (CheckBoxPreference) findPreference(PREFERENCE_SYNC_CONTACTS);
mSyncCalendar = (CheckBoxPreference) findPreference(PREFERENCE_SYNC_CALENDAR);
if (mAccount.mHostAuthRecv.mProtocol.equals("eas")) { if (mAccount.mHostAuthRecv.mProtocol.equals("eas")) {
android.accounts.Account acct = new android.accounts.Account(mAccount.mEmailAddress, android.accounts.Account acct = new android.accounts.Account(mAccount.mEmailAddress,
Email.EXCHANGE_ACCOUNT_MANAGER_TYPE); Email.EXCHANGE_ACCOUNT_MANAGER_TYPE);
mSyncContacts.setChecked(ContentResolver mSyncContacts.setChecked(ContentResolver
.getSyncAutomatically(acct, ContactsContract.AUTHORITY)); .getSyncAutomatically(acct, ContactsContract.AUTHORITY));
mSyncCalendar.setChecked(ContentResolver
.getSyncAutomatically(acct, Calendar.AUTHORITY));
} else { } else {
PreferenceCategory serverCategory = (PreferenceCategory) findPreference( PreferenceCategory serverCategory = (PreferenceCategory) findPreference(
PREFERENCE_SERVER_CATERGORY); PREFERENCE_SERVER_CATERGORY);
serverCategory.removePreference(mSyncContacts); serverCategory.removePreference(mSyncContacts);
serverCategory.removePreference(mSyncCalendar);
} }
} }
@ -341,6 +348,8 @@ public class AccountSettings extends PreferenceActivity {
Email.EXCHANGE_ACCOUNT_MANAGER_TYPE); Email.EXCHANGE_ACCOUNT_MANAGER_TYPE);
ContentResolver.setSyncAutomatically(acct, ContactsContract.AUTHORITY, ContentResolver.setSyncAutomatically(acct, ContactsContract.AUTHORITY,
mSyncContacts.isChecked()); mSyncContacts.isChecked());
ContentResolver.setSyncAutomatically(acct, Calendar.AUTHORITY,
mSyncCalendar.isChecked());
} }
AccountSettingsUtils.commitSettings(this, mAccount); AccountSettingsUtils.commitSettings(this, mAccount);