diff options
author | Mathew Inwood <mathewi@google.com> | 2011-10-04 14:52:52 +0100 |
---|---|---|
committer | Mathew Inwood <mathewi@google.com> | 2011-10-05 11:40:28 +0100 |
commit | 825fba7eb4dae7911f84d8a48a662c4cd6a4db1f (patch) | |
tree | 4e674c98d27261e783ec11010f66888754ee9c41 | |
parent | 5e65609a9f4e1eda54167ec911206365ff7fde6c (diff) | |
download | packages_apps_Browser-825fba7eb4dae7911f84d8a48a662c4cd6a4db1f.zip packages_apps_Browser-825fba7eb4dae7911f84d8a48a662c4cd6a4db1f.tar.gz packages_apps_Browser-825fba7eb4dae7911f84d8a48a662c4cd6a4db1f.tar.bz2 |
Allow default preload setting to be configured via Gservices.
We now load the default value from a secure setting. To over-ride it, set
Gservices key secure:browser_default_preload_setting to the appropriate
value.
The Gservices default value will only be used if the user has never opened
the 'Bandwidth management' tab in the browswer settings. Once that tab has
been opened, even if the user did not change the setting, the value will be
persisted in the browser and the default will be ignored.
Bug: 5346028
Change-Id: If3b14485dc8bc46e7ed72c49eb5cf3c474893fe3
-rw-r--r-- | res/xml/bandwidth_preferences.xml | 1 | ||||
-rw-r--r-- | src/com/android/browser/BrowserSettings.java | 13 | ||||
-rw-r--r-- | src/com/android/browser/preferences/BandwidthPreferencesFragment.java | 19 |
3 files changed, 27 insertions, 6 deletions
diff --git a/res/xml/bandwidth_preferences.xml b/res/xml/bandwidth_preferences.xml index f294026..bb1688e 100644 --- a/res/xml/bandwidth_preferences.xml +++ b/res/xml/bandwidth_preferences.xml @@ -20,7 +20,6 @@ android:key="preload_when" android:title="@string/pref_data_preload_title" android:summary="@string/pref_data_preload_summary" - android:defaultValue="@string/pref_data_preload_default_value" android:entries="@array/pref_data_preload_choices" android:entryValues="@array/pref_data_preload_values" android:dialogTitle="@string/pref_data_preload_dialogtitle" /> diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java index b9eec9c..cfb8dd4 100644 --- a/src/com/android/browser/BrowserSettings.java +++ b/src/com/android/browser/BrowserSettings.java @@ -25,6 +25,7 @@ import android.os.Build; import android.os.Message; import android.preference.PreferenceManager; import android.provider.Browser; +import android.provider.Settings; import android.util.DisplayMetrics; import android.webkit.CookieManager; import android.webkit.GeolocationPermissions; @@ -802,8 +803,16 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, return context.getResources().getString(R.string.pref_data_preload_value_always); } - private String getDefaultPreloadSetting() { - return mContext.getResources().getString(R.string.pref_data_preload_default_value); + private static final String DEAULT_PRELOAD_SECURE_SETTING_KEY = + "browser_default_preload_setting"; + + public String getDefaultPreloadSetting() { + String preload = Settings.Secure.getString(mContext.getContentResolver(), + DEAULT_PRELOAD_SECURE_SETTING_KEY); + if (preload == null) { + preload = mContext.getResources().getString(R.string.pref_data_preload_default_value); + } + return preload; } public String getPreloadEnabled() { diff --git a/src/com/android/browser/preferences/BandwidthPreferencesFragment.java b/src/com/android/browser/preferences/BandwidthPreferencesFragment.java index 18b9fa4..2c147cc 100644 --- a/src/com/android/browser/preferences/BandwidthPreferencesFragment.java +++ b/src/com/android/browser/preferences/BandwidthPreferencesFragment.java @@ -16,12 +16,11 @@ package com.android.browser.preferences; -import android.content.res.Resources; import android.os.Bundle; -import android.preference.Preference; +import android.preference.ListPreference; import android.preference.PreferenceFragment; -import android.util.Log; +import com.android.browser.BrowserSettings; import com.android.browser.PreferenceKeys; import com.android.browser.R; @@ -36,4 +35,18 @@ public class BandwidthPreferencesFragment extends PreferenceFragment { addPreferencesFromResource(R.xml.bandwidth_preferences); } + @Override + public void onResume() { + super.onResume(); + if (!getPreferenceScreen().getSharedPreferences() + .contains(PreferenceKeys.PREF_DATA_PRELOAD)) { + // set default value for preload setting + ListPreference preload = (ListPreference) getPreferenceScreen().findPreference( + PreferenceKeys.PREF_DATA_PRELOAD); + if (preload != null) { + preload.setValue(BrowserSettings.getInstance().getDefaultPreloadSetting()); + } + } + } + } |