Home | History | Annotate | Download | only in preferences
      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 
     17 package com.android.browser.preferences;
     18 
     19 import android.content.SharedPreferences;
     20 import android.os.Bundle;
     21 import android.preference.ListPreference;
     22 import android.preference.PreferenceFragment;
     23 import android.preference.PreferenceScreen;
     24 
     25 import com.android.browser.BrowserSettings;
     26 import com.android.browser.PreferenceKeys;
     27 import com.android.browser.R;
     28 
     29 public 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