Search in sources :

Example 6 with ProfileSyncService

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

the class SyncPreference method getSyncStatusSummary.

/**
     * Return a short summary of the current sync status.
     */
static String getSyncStatusSummary(Context context) {
    if (!ChromeSigninController.get(context).isSignedIn())
        return "";
    ProfileSyncService profileSyncService = ProfileSyncService.get();
    Resources res = context.getResources();
    if (ChildAccountService.isChildAccount()) {
        return res.getString(R.string.kids_account);
    }
    if (!AndroidSyncSettings.isMasterSyncEnabled(context)) {
        return res.getString(R.string.sync_android_master_sync_disabled);
    }
    if (profileSyncService == null) {
        return res.getString(R.string.sync_is_disabled);
    }
    if (profileSyncService.getAuthError() != GoogleServiceAuthError.State.NONE) {
        return res.getString(profileSyncService.getAuthError().getMessage());
    }
    if (profileSyncService.getProtocolErrorClientAction() == ProtocolErrorClientAction.UPGRADE_CLIENT) {
        return res.getString(R.string.sync_error_upgrade_client, BuildInfo.getPackageLabel(context));
    }
    if (profileSyncService.hasUnrecoverableError()) {
        return res.getString(R.string.sync_error_generic);
    }
    boolean syncEnabled = AndroidSyncSettings.isSyncEnabled(context);
    if (syncEnabled) {
        if (!profileSyncService.isSyncActive()) {
            return res.getString(R.string.sync_setup_progress);
        }
        if (profileSyncService.isPassphraseRequiredForDecryption()) {
            return res.getString(R.string.sync_need_passphrase);
        }
        Account account = ChromeSigninController.get(context).getSignedInUser();
        return String.format(context.getString(R.string.account_management_sync_summary), account.name);
    }
    return context.getString(R.string.sync_is_disabled);
}
Also used : ProfileSyncService(org.chromium.chrome.browser.sync.ProfileSyncService) Account(android.accounts.Account) Resources(android.content.res.Resources)

Example 7 with ProfileSyncService

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

the class MainPreferences method updatePreferences.

private void updatePreferences() {
    if (getPreferenceScreen() != null)
        getPreferenceScreen().removeAll();
    addPreferencesFromResource(R.xml.main_preferences);
    addBlimpPreferences();
    if (TemplateUrlService.getInstance().isLoaded()) {
        updateSummary();
    } else {
        TemplateUrlService.getInstance().registerLoadListener(this);
        TemplateUrlService.getInstance().load();
        ChromeBasePreference searchEnginePref = (ChromeBasePreference) findPreference(PREF_SEARCH_ENGINE);
        searchEnginePref.setEnabled(false);
    }
    ChromeBasePreference autofillPref = (ChromeBasePreference) findPreference(PREF_AUTOFILL_SETTINGS);
    setOnOffSummary(autofillPref, PersonalDataManager.isAutofillEnabled());
    autofillPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
    ChromeBasePreference passwordsPref = (ChromeBasePreference) findPreference(PREF_SAVED_PASSWORDS);
    ProfileSyncService syncService = ProfileSyncService.get();
    if (AndroidSyncSettings.isSyncEnabled(getActivity().getApplicationContext()) && syncService.isBackendInitialized() && !syncService.isUsingSecondaryPassphrase() && ChromeFeatureList.isEnabled(VIEW_PASSWORDS)) {
        passwordsPref.setKey(PREF_MANAGE_ACCOUNT_LINK);
        passwordsPref.setTitle(R.string.redirect_to_passwords_text);
        passwordsPref.setSummary(R.string.redirect_to_passwords_link);
        passwordsPref.setOnPreferenceClickListener(this);
        passwordsPref.setManagedPreferenceDelegate(null);
    } else {
        if (PasswordUIView.shouldUseSmartLockBranding()) {
            passwordsPref.setTitle(getResources().getString(R.string.prefs_smart_lock_for_passwords));
        } else {
            passwordsPref.setTitle(getResources().getString(R.string.prefs_saved_passwords));
        }
        passwordsPref.setFragment(SavePasswordsPreferences.class.getCanonicalName());
        setOnOffSummary(passwordsPref, PrefServiceBridge.getInstance().isRememberPasswordsEnabled());
        passwordsPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
    }
    Preference homepagePref = findPreference(PREF_HOMEPAGE);
    if (HomepageManager.shouldShowHomepageSetting()) {
        setOnOffSummary(homepagePref, HomepageManager.getInstance(getActivity()).getPrefHomepageEnabled());
    } else {
        getPreferenceScreen().removePreference(homepagePref);
    }
    ChromeBasePreference dataReduction = (ChromeBasePreference) findPreference(PREF_DATA_REDUCTION);
    if (DataReductionProxySettings.getInstance().isDataReductionProxyAllowed()) {
        dataReduction.setSummary(DataReductionPreferences.generateSummary(getResources()));
        dataReduction.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
    } else {
        getPreferenceScreen().removePreference(dataReduction);
    }
    if (!SigninManager.get(getActivity()).isSigninSupported()) {
        getPreferenceScreen().removePreference(findPreference(PREF_SIGN_IN));
    }
}
Also used : ProfileSyncService(org.chromium.chrome.browser.sync.ProfileSyncService) Preference(android.preference.Preference) SavePasswordsPreferences(org.chromium.chrome.browser.preferences.password.SavePasswordsPreferences)

Example 8 with ProfileSyncService

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

the class AccountManagementFragment method onDestroy.

@Override
public void onDestroy() {
    super.onDestroy();
    // Allow sync to begin syncing if it hasn't yet.
    ProfileSyncService syncService = ProfileSyncService.get();
    if (syncService != null) {
        syncService.setSetupInProgress(false);
    }
}
Also used : ProfileSyncService(org.chromium.chrome.browser.sync.ProfileSyncService)

Example 9 with ProfileSyncService

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

the class AccountManagementFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    SigninManager.get(getActivity()).addSignInStateObserver(this);
    ProfileDownloader.addObserver(this);
    ProfileSyncService syncService = ProfileSyncService.get();
    if (syncService != null) {
        syncService.addSyncStateChangedListener(this);
    }
    update();
}
Also used : ProfileSyncService(org.chromium.chrome.browser.sync.ProfileSyncService)

Example 10 with ProfileSyncService

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

the class AccountManagementFragment method onPause.

@Override
public void onPause() {
    super.onPause();
    SigninManager.get(getActivity()).removeSignInStateObserver(this);
    ProfileDownloader.removeObserver(this);
    ProfileSyncService syncService = ProfileSyncService.get();
    if (syncService != null) {
        syncService.removeSyncStateChangedListener(this);
    }
}
Also used : ProfileSyncService(org.chromium.chrome.browser.sync.ProfileSyncService)

Aggregations

ProfileSyncService (org.chromium.chrome.browser.sync.ProfileSyncService)12 SigninManager (org.chromium.chrome.browser.signin.SigninManager)2 Account (android.accounts.Account)1 Intent (android.content.Intent)1 Resources (android.content.res.Resources)1 Preference (android.preference.Preference)1 SpannableString (android.text.SpannableString)1 HashSet (java.util.HashSet)1 SavePasswordsPreferences (org.chromium.chrome.browser.preferences.password.SavePasswordsPreferences)1 SyncController (org.chromium.chrome.browser.sync.SyncController)1 Tab (org.chromium.chrome.browser.tab.Tab)1 PassphraseType (org.chromium.components.sync.PassphraseType)1