Search in sources :

Example 1 with SyncAccountSwitcher

use of org.chromium.chrome.browser.sync.SyncAccountSwitcher in project AndroidChromium by JackyAndroid.

the class SyncCustomizationFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mProfileSyncService = ProfileSyncService.get();
    assert mProfileSyncService != null;
    mIsBackendInitialized = mProfileSyncService.isBackendInitialized();
    mIsPassphraseRequired = mIsBackendInitialized && mProfileSyncService.isPassphraseRequiredForDecryption();
    getActivity().setTitle(R.string.sign_in_sync);
    View view = super.onCreateView(inflater, container, savedInstanceState);
    addPreferencesFromResource(R.xml.sync_customization_preferences);
    mSyncEverything = (SwitchPreference) findPreference(PREFERENCE_SYNC_EVERYTHING);
    mSyncAutofill = (CheckBoxPreference) findPreference(PREFERENCE_SYNC_AUTOFILL);
    mSyncBookmarks = (CheckBoxPreference) findPreference(PREFERENCE_SYNC_BOOKMARKS);
    mSyncOmnibox = (CheckBoxPreference) findPreference(PREFERENCE_SYNC_OMNIBOX);
    mSyncPasswords = (CheckBoxPreference) findPreference(PREFERENCE_SYNC_PASSWORDS);
    mSyncRecentTabs = (CheckBoxPreference) findPreference(PREFERENCE_SYNC_RECENT_TABS);
    mSyncSettings = (CheckBoxPreference) findPreference(PREFERENCE_SYNC_SETTINGS);
    mPaymentsIntegration = (CheckBoxPreference) findPreference(PREFERENCE_PAYMENTS_INTEGRATION);
    mSyncEncryption = findPreference(PREFERENCE_ENCRYPTION);
    mSyncEncryption.setOnPreferenceClickListener(this);
    mManageSyncData = findPreference(PREFERENCE_SYNC_MANAGE_DATA);
    mManageSyncData.setOnPreferenceClickListener(this);
    mSyncErrorCard = findPreference(PREFERENCE_SYNC_ERROR_CARD);
    mSyncErrorCard.setOnPreferenceClickListener(this);
    mAllTypes = new CheckBoxPreference[] { mSyncAutofill, mSyncBookmarks, mSyncOmnibox, mSyncPasswords, mSyncRecentTabs, mSyncSettings, mPaymentsIntegration };
    mSyncEverything.setOnPreferenceChangeListener(this);
    for (CheckBoxPreference type : mAllTypes) {
        type.setOnPreferenceChangeListener(this);
    }
    mSyncSwitchPreference = (ChromeSwitchPreference) findPreference(PREF_SYNC_SWITCH);
    mSyncSwitchPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            assert canDisableSync();
            if ((boolean) newValue) {
                mProfileSyncService.requestStart();
            } else {
                stopSync();
            }
            // Must be done asynchronously because the switch state isn't updated
            // until after this function exits.
            new Handler().post(new Runnable() {

                @Override
                public void run() {
                    updateSyncStateFromSwitch();
                }
            });
            return true;
        }
    });
    mSyncedAccountPreference = (SyncedAccountPreference) findPreference(PREFERENCE_SYNC_ACCOUNT_LIST);
    mSyncedAccountPreference.setOnPreferenceChangeListener(new SyncAccountSwitcher(getActivity(), mSyncedAccountPreference));
    return view;
}
Also used : SyncAccountSwitcher(org.chromium.chrome.browser.sync.SyncAccountSwitcher) CheckBoxPreference(android.preference.CheckBoxPreference) ChromeSwitchPreference(org.chromium.chrome.browser.preferences.ChromeSwitchPreference) CheckBoxPreference(android.preference.CheckBoxPreference) Preference(android.preference.Preference) SyncedAccountPreference(org.chromium.chrome.browser.preferences.SyncedAccountPreference) SwitchPreference(android.preference.SwitchPreference) Handler(android.os.Handler) OnPreferenceChangeListener(android.preference.Preference.OnPreferenceChangeListener) View(android.view.View)

Aggregations

Handler (android.os.Handler)1 CheckBoxPreference (android.preference.CheckBoxPreference)1 Preference (android.preference.Preference)1 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)1 SwitchPreference (android.preference.SwitchPreference)1 View (android.view.View)1 ChromeSwitchPreference (org.chromium.chrome.browser.preferences.ChromeSwitchPreference)1 SyncedAccountPreference (org.chromium.chrome.browser.preferences.SyncedAccountPreference)1 SyncAccountSwitcher (org.chromium.chrome.browser.sync.SyncAccountSwitcher)1