summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/xml/bandwidth_preferences.xml1
-rw-r--r--src/com/android/browser/BrowserSettings.java13
-rw-r--r--src/com/android/browser/preferences/BandwidthPreferencesFragment.java19
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());
+ }
+ }
+ }
+
}