BrowserPreferencesPage.java revision bf1d10af39eb23d68db69a8eda9e12e62f1a9682
1/* 2 * Copyright (C) 2008 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; 18 19import com.android.browser.preferences.DebugPreferencesFragment; 20 21import android.app.ActionBar; 22import android.os.Bundle; 23import android.preference.PreferenceActivity; 24import android.preference.PreferenceManager; 25import android.view.MenuItem; 26 27import java.util.List; 28 29public class BrowserPreferencesPage extends PreferenceActivity { 30 31 public static final String CURRENT_PAGE = "currentPage"; 32 33 @Override 34 public void onCreate(Bundle icicle) { 35 super.onCreate(icicle); 36 37 ActionBar actionBar = getActionBar(); 38 if (actionBar != null) { 39 actionBar.setDisplayOptions( 40 ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP); 41 } 42 } 43 44 /** 45 * Populate the activity with the top-level headers. 46 */ 47 @Override 48 public void onBuildHeaders(List<Header> target) { 49 loadHeadersFromResource(R.xml.preference_headers, target); 50 51 if (BrowserSettings.DEV_BUILD || BrowserSettings.getInstance().showDebugSettings()) { 52 Header debug = new Header(); 53 debug.title = getText(R.string.pref_development_title); 54 debug.fragment = DebugPreferencesFragment.class.getName(); 55 target.add(debug); 56 } 57 } 58 59 @Override 60 protected void onPause() { 61 super.onPause(); 62 63 // sync the shared preferences back to BrowserSettings 64 BrowserSettings.getInstance().syncSharedPreferences( 65 getApplicationContext(), 66 PreferenceManager.getDefaultSharedPreferences(this)); 67 } 68 69 @Override 70 public boolean onOptionsItemSelected(MenuItem item) { 71 switch (item.getItemId()) { 72 case android.R.id.home: 73 if (getFragmentManager().getBackStackEntryCount() > 0) { 74 getFragmentManager().popBackStack(); 75 } else { 76 finish(); 77 } 78 return true; 79 } 80 81 return false; 82 } 83} 84