Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/sync/ui/SyncCustomizationFragment.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/sync/ui/SyncCustomizationFragment.java b/chrome/android/java/src/org/chromium/chrome/browser/sync/ui/SyncCustomizationFragment.java |
| index 394fae03fc677eac8ba62089715f3c2c9561d288..4c43d3223e0af8f2513dcd8b2623e78268269149 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/sync/ui/SyncCustomizationFragment.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/sync/ui/SyncCustomizationFragment.java |
| @@ -7,8 +7,8 @@ package org.chromium.chrome.browser.sync.ui; |
| import android.app.DialogFragment; |
| import android.app.FragmentManager; |
| import android.app.FragmentTransaction; |
| +import android.content.Context; |
| import android.content.Intent; |
| -import android.graphics.Color; |
| import android.net.Uri; |
| import android.os.Bundle; |
| import android.os.Handler; |
| @@ -28,11 +28,11 @@ import android.view.ViewGroup; |
| import org.chromium.base.VisibleForTesting; |
| import org.chromium.base.metrics.RecordHistogram; |
| import org.chromium.chrome.R; |
| - |
| import org.chromium.chrome.browser.autofill.PersonalDataManager; |
| import org.chromium.chrome.browser.childaccounts.ChildAccountService; |
| import org.chromium.chrome.browser.invalidation.InvalidationController; |
| import org.chromium.chrome.browser.preferences.ChromeSwitchPreference; |
| +import org.chromium.chrome.browser.preferences.SyncedAccountPreference; |
| import org.chromium.chrome.browser.sync.ProfileSyncService; |
| import org.chromium.sync.AndroidSyncSettings; |
| import org.chromium.sync.ModelType; |
| @@ -57,7 +57,6 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| public static final String FRAGMENT_CUSTOM_PASSPHRASE = "custom_password"; |
| @VisibleForTesting |
| public static final String FRAGMENT_PASSPHRASE_TYPE = "password_type"; |
| - |
| @VisibleForTesting |
| public static final String PREFERENCE_SYNC_EVERYTHING = "sync_everything"; |
| @VisibleForTesting |
| @@ -79,12 +78,14 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| @VisibleForTesting |
| public static final String PREF_SYNC_SWITCH = "sync_switch"; |
| @VisibleForTesting |
| + public static final String PREFERENCE_SYNC_IMPORT_DATA = "sync_import_data"; |
|
newt (away)
2016/02/16 23:05:01
still unused
May
2016/02/17 13:24:31
Done.
|
| + @VisibleForTesting |
| public static final String PREFERENCE_SYNC_MANAGE_DATA = "sync_manage_data"; |
| + @VisibleForTesting |
| + public static final String PREFERENCE_SYNC_ACCOUNT_LIST = "sync_account_list"; |
| public static final String ARGUMENT_ACCOUNT = "account"; |
| - private static final int ERROR_COLOR = Color.RED; |
| - |
| private ChromeSwitchPreference mSyncSwitchPreference; |
| private boolean mIsBackendInitialized; |
| private boolean mIsPassphraseRequired; |
| @@ -96,7 +97,6 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| PREFERENCE_SYNC_BOOKMARKS, |
| PREFERENCE_SYNC_OMNIBOX, |
| PREFERENCE_SYNC_PASSWORDS, |
| - PREFERENCE_SYNC_RECENT_TABS, |
| PREFERENCE_SYNC_SETTINGS, |
| PREFERENCE_PAYMENTS_INTEGRATION |
| }; |
| @@ -114,7 +114,6 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| private Preference mSyncEncryption; |
| private Preference mManageSyncData; |
| private CheckBoxPreference[] mAllTypes; |
| - private boolean mCheckboxesInitialized; |
| private ProfileSyncService mProfileSyncService; |
| @@ -145,9 +144,9 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| mManageSyncData = findPreference(PREFERENCE_SYNC_MANAGE_DATA); |
| mManageSyncData.setOnPreferenceClickListener(this); |
| - mAllTypes = new CheckBoxPreference[]{ |
| - mSyncAutofill, mSyncBookmarks, mSyncOmnibox, mSyncPasswords, |
| - mSyncRecentTabs, mSyncSettings, mPaymentsIntegration |
| + mAllTypes = new CheckBoxPreference[] { |
| + mSyncAutofill, mSyncBookmarks, mSyncOmnibox, mSyncPasswords, |
| + mSyncRecentTabs, mSyncSettings, mPaymentsIntegration |
| }; |
| mSyncEverything.setOnPreferenceChangeListener(this); |
| @@ -285,6 +284,12 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| updateSyncStateFromSwitch(); |
| } |
| + private void updateSyncAccountsListState() { |
| + SyncedAccountPreference accountList = |
| + (SyncedAccountPreference) findPreference(PREFERENCE_SYNC_ACCOUNT_LIST); |
| + accountList.setEnabled(mSyncSwitchPreference.isChecked()); |
| + } |
| + |
| /** |
| * Update the state of settings using the switch state to determine if sync is enabled. |
| */ |
| @@ -292,6 +297,7 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| updateSyncEverythingState(); |
| updateDataTypeState(); |
| updateEncryptionState(); |
| + updateSyncAccountsListState(); |
| } |
| /** |
| @@ -320,16 +326,18 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| } |
| if (mProfileSyncService.isPassphraseRequiredForDecryption() && isAdded()) { |
| mSyncEncryption.setSummary( |
| - errorSummary(getString(R.string.sync_need_passphrase))); |
| + errorSummary(getString(R.string.sync_need_passphrase), getActivity())); |
| } |
| } |
| /** |
| * Applies a span to the given string to give it an error color. |
| */ |
| - private static Spannable errorSummary(String string) { |
| + private static Spannable errorSummary(String string, Context context) { |
| SpannableString summary = new SpannableString(string); |
| - summary.setSpan(new ForegroundColorSpan(ERROR_COLOR), 0, summary.length(), 0); |
| + summary.setSpan(new ForegroundColorSpan( |
| + context.getResources().getColor(R.color.input_underline_error_color, null)), |
| + 0, summary.length(), 0); |
| return summary; |
| } |
| @@ -339,8 +347,7 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| boolean syncEverything = mSyncEverything.isChecked(); |
| mProfileSyncService.setPreferredDataTypes(syncEverything, getSelectedModelTypes()); |
| // Update the invalidation listener with the set of types we are enabling. |
| - InvalidationController invController = |
| - InvalidationController.get(getActivity()); |
| + InvalidationController invController = InvalidationController.get(getActivity()); |
| invController.ensureStartedAndUpdateRegisteredTypes(); |
| } |
| @@ -475,7 +482,7 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| public boolean onPreferenceClick(Preference preference) { |
| if (!isResumed()) { |
| // This event could come in after onPause if the user clicks back and the preference at |
| - // roughly the same time. See http://b/5983282 |
| + // roughly the same time. See http://b/5983282 |
| return false; |
| } |
| if (preference == mSyncEncryption && mProfileSyncService.isBackendInitialized()) { |
| @@ -579,6 +586,7 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| /** |
| * Disables Sync if all data types have been disabled. |
| + * |
| * @return true if Sync has been disabled, false otherwise. |
| */ |
| private boolean maybeDisableSync() { |