diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2011-01-06 13:46:43 -0800 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2011-01-07 17:47:59 -0800 |
commit | ce9f77bb558434b9daa40304d3eb8a7201865ac8 (patch) | |
tree | c40075301684b8c2c686f55640e65bc95d59b7b6 /src/com/android/settings/accounts | |
parent | b1a234ef46dffa625acc37dac3d612a52149ba2d (diff) | |
download | packages_apps_Settings-ce9f77bb558434b9daa40304d3eb8a7201865ac8.zip packages_apps_Settings-ce9f77bb558434b9daa40304d3eb8a7201865ac8.tar.gz packages_apps_Settings-ce9f77bb558434b9daa40304d3eb8a7201865ac8.tar.bz2 |
Fix for bug #3325868 (add accounts should not use the settings activity as part of its flow)
- suppress non needed AccountSyncSettingsInAddAccount class
Change-Id: I27ba9ea2d45a5e2c9ec1d2ed6033f6d68e100a3f
Diffstat (limited to 'src/com/android/settings/accounts')
-rw-r--r-- | src/com/android/settings/accounts/AccountSyncSettings.java | 92 | ||||
-rw-r--r-- | src/com/android/settings/accounts/AccountSyncSettingsInAddAccount.java | 60 |
2 files changed, 43 insertions, 109 deletions
diff --git a/src/com/android/settings/accounts/AccountSyncSettings.java b/src/com/android/settings/accounts/AccountSyncSettings.java index b782ed8..298f1b6 100644 --- a/src/com/android/settings/accounts/AccountSyncSettings.java +++ b/src/com/android/settings/accounts/AccountSyncSettings.java @@ -81,8 +81,6 @@ public class AccountSyncSettings extends AccountPreferenceBase { private ArrayList<SyncStateCheckBoxPreference> mCheckBoxes = new ArrayList<SyncStateCheckBoxPreference>(); private ArrayList<String> mInvisibleAdapters = Lists.newArrayList(); - // Tell if we will use the current SyncManager data or just the User input - protected boolean mUseSyncManagerFeedsState = true; @Override public Dialog onCreateDialog(final int id) { @@ -264,7 +262,7 @@ public class AccountSyncSettings extends AccountPreferenceBase { @Override public boolean onPreferenceTreeClick(PreferenceScreen preferences, Preference preference) { - if (preference instanceof SyncStateCheckBoxPreference && mUseSyncManagerFeedsState) { + if (preference instanceof SyncStateCheckBoxPreference) { SyncStateCheckBoxPreference syncPref = (SyncStateCheckBoxPreference) preference; String authority = syncPref.getAuthority(); Account account = syncPref.getAccount(); @@ -345,10 +343,10 @@ public class AccountSyncSettings extends AccountPreferenceBase { @Override protected void onSyncStateUpdated() { if (!isResumed()) return; - setFeedsState(mUseSyncManagerFeedsState); + setFeedsState(); } - private void setFeedsState(boolean useSyncManager) { + private void setFeedsState() { // iterate over all the preferences, setting the state properly for each Date date = new Date(); List<SyncInfo> currentSyncs = ContentResolver.getCurrentSyncs(); @@ -367,53 +365,49 @@ public class AccountSyncSettings extends AccountPreferenceBase { String authority = syncPref.getAuthority(); Account account = syncPref.getAccount(); - if (useSyncManager) { - SyncStatusInfo status = ContentResolver.getSyncStatus(account, authority); - boolean syncEnabled = ContentResolver.getSyncAutomatically(account, authority); - boolean authorityIsPending = status == null ? false : status.pending; - boolean initialSync = status == null ? false : status.initialize; - - boolean activelySyncing = isSyncing(currentSyncs, account, authority); - boolean lastSyncFailed = status != null - && status.lastFailureTime != 0 - && status.getLastFailureMesgAsInt(0) - != ContentResolver.SYNC_ERROR_SYNC_ALREADY_IN_PROGRESS; - if (!syncEnabled) lastSyncFailed = false; - if (lastSyncFailed && !activelySyncing && !authorityIsPending) { - syncIsFailing = true; - } - if (Log.isLoggable(TAG, Log.VERBOSE)) { - Log.d(TAG, "Update sync status: " + account + " " + authority + - " active = " + activelySyncing + " pend =" + authorityIsPending); - } + SyncStatusInfo status = ContentResolver.getSyncStatus(account, authority); + boolean syncEnabled = ContentResolver.getSyncAutomatically(account, authority); + boolean authorityIsPending = status == null ? false : status.pending; + boolean initialSync = status == null ? false : status.initialize; + + boolean activelySyncing = isSyncing(currentSyncs, account, authority); + boolean lastSyncFailed = status != null + && status.lastFailureTime != 0 + && status.getLastFailureMesgAsInt(0) + != ContentResolver.SYNC_ERROR_SYNC_ALREADY_IN_PROGRESS; + if (!syncEnabled) lastSyncFailed = false; + if (lastSyncFailed && !activelySyncing && !authorityIsPending) { + syncIsFailing = true; + } + if (Log.isLoggable(TAG, Log.VERBOSE)) { + Log.d(TAG, "Update sync status: " + account + " " + authority + + " active = " + activelySyncing + " pend =" + authorityIsPending); + } - final long successEndTime = (status == null) ? 0 : status.lastSuccessTime; - if (successEndTime != 0) { - date.setTime(successEndTime); - final String timeString = mDateFormat.format(date) + " " - + mTimeFormat.format(date); - syncPref.setSummary(timeString); - } else { - syncPref.setSummary(""); - } - int syncState = ContentResolver.getIsSyncable(account, authority); - - syncPref.setActive(activelySyncing && (syncState >= 0) && - !initialSync); - syncPref.setPending(authorityIsPending && (syncState >= 0) && - !initialSync); - - syncPref.setFailed(lastSyncFailed); - ConnectivityManager connManager = - (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); - final boolean masterSyncAutomatically = ContentResolver.getMasterSyncAutomatically(); - final boolean backgroundDataEnabled = connManager.getBackgroundDataSetting(); - final boolean oneTimeSyncMode = !masterSyncAutomatically || !backgroundDataEnabled; - syncPref.setOneTimeSyncMode(oneTimeSyncMode); - syncPref.setChecked(oneTimeSyncMode || syncEnabled); + final long successEndTime = (status == null) ? 0 : status.lastSuccessTime; + if (successEndTime != 0) { + date.setTime(successEndTime); + final String timeString = mDateFormat.format(date) + " " + + mTimeFormat.format(date); + syncPref.setSummary(timeString); } else { - syncPref.setChecked(true); + syncPref.setSummary(""); } + int syncState = ContentResolver.getIsSyncable(account, authority); + + syncPref.setActive(activelySyncing && (syncState >= 0) && + !initialSync); + syncPref.setPending(authorityIsPending && (syncState >= 0) && + !initialSync); + + syncPref.setFailed(lastSyncFailed); + ConnectivityManager connManager = + (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); + final boolean masterSyncAutomatically = ContentResolver.getMasterSyncAutomatically(); + final boolean backgroundDataEnabled = connManager.getBackgroundDataSetting(); + final boolean oneTimeSyncMode = !masterSyncAutomatically || !backgroundDataEnabled; + syncPref.setOneTimeSyncMode(oneTimeSyncMode); + syncPref.setChecked(oneTimeSyncMode || syncEnabled); } mErrorInfoView.setVisibility(syncIsFailing ? View.VISIBLE : View.GONE); getActivity().invalidateOptionsMenu(); diff --git a/src/com/android/settings/accounts/AccountSyncSettingsInAddAccount.java b/src/com/android/settings/accounts/AccountSyncSettingsInAddAccount.java deleted file mode 100644 index 5b3af83..0000000 --- a/src/com/android/settings/accounts/AccountSyncSettingsInAddAccount.java +++ /dev/null @@ -1,60 +0,0 @@ - -package com.android.settings.accounts; - -import android.accounts.Account; -import android.content.ContentResolver; -import android.preference.Preference; -import com.android.settings.R; - -import android.view.Menu; -import android.view.View; -import android.view.View.OnClickListener; - -/** - * This is AccountSyncSettings with 'remove account' button always gone and - * a wizard-like button bar to complete the activity. - */ -public class AccountSyncSettingsInAddAccount extends AccountSyncSettings - implements OnClickListener { - private View mFinishArea; - private View mFinishButton; - - @Override - protected void initializeUi(final View rootView) { - super.initializeUi(rootView); - - mFinishArea = (View) rootView.findViewById(R.id.finish_button_area); - mFinishArea.setVisibility(View.VISIBLE); - mFinishButton = (View) rootView.findViewById(R.id.finish_button); - mFinishButton.setOnClickListener(this); - - mUseSyncManagerFeedsState = false; - } - - @Override - public void onPrepareOptionsMenu(Menu menu) { - super.onPrepareOptionsMenu(menu); - // Remove the "remove account" menu item - menu.findItem(MENU_REMOVE_ACCOUNT_ID).setVisible(false); - } - - 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()); - } - } -} |