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);
}
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));
}
}
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);
}
}
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();
}
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);
}
}
Aggregations