1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
15 */
16
17package com.android.browser.preferences;
18
19import android.content.SharedPreferences;
20import android.os.Bundle;
21import android.preference.ListPreference;
22import android.preference.PreferenceFragment;
23import android.preference.PreferenceScreen;
24
25import com.android.browser.BrowserSettings;
26import com.android.browser.PreferenceKeys;
27import com.android.browser.R;
28
29public class BandwidthPreferencesFragment extends PreferenceFragment {
30
31    static final String TAG = "BandwidthPreferencesFragment";
32
33    @Override
34    public void onCreate(Bundle savedInstanceState) {
35        super.onCreate(savedInstanceState);
36        // Load the XML preferences file
37        addPreferencesFromResource(R.xml.bandwidth_preferences);
38    }
39
40    @Override
41    public void onResume() {
42        super.onResume();
43        PreferenceScreen prefScreen = getPreferenceScreen();
44        SharedPreferences sharedPrefs = prefScreen.getSharedPreferences();
45        if (!sharedPrefs.contains(PreferenceKeys.PREF_DATA_PRELOAD)) {
46            // set default value for preload setting
47            ListPreference preload = (ListPreference) prefScreen.findPreference(
48                    PreferenceKeys.PREF_DATA_PRELOAD);
49            if (preload != null) {
50                preload.setValue(BrowserSettings.getInstance().getDefaultPreloadSetting());
51            }
52        }
53        if (!sharedPrefs.contains(PreferenceKeys.PREF_LINK_PREFETCH)) {
54            // set default value for link prefetch setting
55            ListPreference prefetch = (ListPreference) prefScreen.findPreference(
56                    PreferenceKeys.PREF_LINK_PREFETCH);
57            if (prefetch != null) {
58                prefetch.setValue(BrowserSettings.getInstance().getDefaultLinkPrefetchSetting());
59            }
60        }
61    }
62
63}
64