blob: 83020112562566a991b6326aed9dafd820eb2690 [file] [log] [blame]
The Android Open Source Project0c908882009-03-03 19:32:16 -08001/*
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
Jeff Hamilton462b8e82010-09-23 14:33:43 -050019import com.android.browser.preferences.DebugPreferencesFragment;
20
Ben Murdoch7ed9bd72010-12-13 14:30:33 +000021import android.app.ActionBar;
22import android.os.Bundle;
The Android Open Source Project0c908882009-03-03 19:32:16 -080023import android.preference.PreferenceActivity;
Ben Murdoch7ed9bd72010-12-13 14:30:33 +000024import android.view.MenuItem;
Bjorn Bringertd69f51d2010-09-13 14:06:41 +010025
Jeff Hamilton462b8e82010-09-23 14:33:43 -050026import java.util.List;
The Android Open Source Project0c908882009-03-03 19:32:16 -080027
Jeff Hamilton462b8e82010-09-23 14:33:43 -050028public class BrowserPreferencesPage extends PreferenceActivity {
The Android Open Source Project0c908882009-03-03 19:32:16 -080029
Jeff Hamilton462b8e82010-09-23 14:33:43 -050030 public static final String CURRENT_PAGE = "currentPage";
Nicolas Roard78a98e42009-05-11 13:34:17 +010031
Ben Murdoch7ed9bd72010-12-13 14:30:33 +000032 @Override
33 public void onCreate(Bundle icicle) {
34 super.onCreate(icicle);
35
36 ActionBar actionBar = getActionBar();
37 if (actionBar != null) {
38 actionBar.setDisplayOptions(
39 ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP);
40 }
41 }
42
Jeff Hamilton462b8e82010-09-23 14:33:43 -050043 /**
44 * Populate the activity with the top-level headers.
Nicolas Roarde46990e2009-06-19 16:27:49 +010045 */
46 @Override
Jeff Hamilton462b8e82010-09-23 14:33:43 -050047 public void onBuildHeaders(List<Header> target) {
48 loadHeadersFromResource(R.xml.preference_headers, target);
49
John Reckf48314f2011-04-27 17:52:17 -070050 if (BrowserSettings.getInstance().isDebugEnabled()) {
Jeff Hamilton462b8e82010-09-23 14:33:43 -050051 Header debug = new Header();
52 debug.title = getText(R.string.pref_development_title);
53 debug.fragment = DebugPreferencesFragment.class.getName();
54 target.add(debug);
55 }
The Android Open Source Project0c908882009-03-03 19:32:16 -080056 }
57
58 @Override
Ben Murdoch7ed9bd72010-12-13 14:30:33 +000059 public boolean onOptionsItemSelected(MenuItem item) {
60 switch (item.getItemId()) {
61 case android.R.id.home:
Dianne Hackbornbf1d10a2011-01-17 12:29:51 -080062 if (getFragmentManager().getBackStackEntryCount() > 0) {
Ben Murdoch7ed9bd72010-12-13 14:30:33 +000063 getFragmentManager().popBackStack();
64 } else {
65 finish();
66 }
67 return true;
68 }
69
70 return false;
71 }
The Android Open Source Project0c908882009-03-03 19:32:16 -080072}