Search in sources :

Example 6 with PrefServiceBridge

use of org.chromium.chrome.browser.preferences.PrefServiceBridge in project AndroidChromium by JackyAndroid.

the class ChromeActivitySessionTracker method updateAcceptLanguages.

/**
     * Update the accept languages after changing Android locale setting. Doing so kills the
     * Activities but it doesn't kill the Application, so this should be called in
     * {@link #onStart} instead of {@link #initialize}.
     */
private void updateAcceptLanguages() {
    PrefServiceBridge instance = PrefServiceBridge.getInstance();
    // ex) en_US, de_DE, zh_CN_#Hans
    String localeString = Locale.getDefault().toString();
    if (hasLocaleChanged(localeString)) {
        instance.resetAcceptLanguages(localeString);
        // Clear cache so that accept-languages change can be applied immediately.
        // TODO(changwan): The underlying BrowsingDataRemover::Remove() is an asynchronous call.
        // So cache-clearing may not be effective if URL rendering can happen before
        // OnBrowsingDataRemoverDone() is called, in which case we may have to reload as well.
        // Check if it can happen.
        instance.clearBrowsingData(null, new int[] { BrowsingDataType.CACHE }, TimePeriod.ALL_TIME);
    }
}
Also used : PrefServiceBridge(org.chromium.chrome.browser.preferences.PrefServiceBridge)

Aggregations

PrefServiceBridge (org.chromium.chrome.browser.preferences.PrefServiceBridge)6 Preference (android.preference.Preference)4 CheckBoxPreference (android.preference.CheckBoxPreference)2 ChromeBaseCheckBoxPreference (org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference)2 SharedPreferences (android.content.SharedPreferences)1 Resources (android.content.res.Resources)1 PreferenceScreen (android.preference.PreferenceScreen)1 ArrayList (java.util.ArrayList)1 ChromeBasePreference (org.chromium.chrome.browser.preferences.ChromeBasePreference)1 ManagedPreferenceDelegate (org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate)1 SyncPreference (org.chromium.chrome.browser.preferences.SyncPreference)1