blob: 8031005c283f4a82cb0905b0c6d8f407c8d64a41 [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;
Jeff Hamilton462b8e82010-09-23 14:33:43 -050024import android.preference.PreferenceManager;
Ben Murdoch7ed9bd72010-12-13 14:30:33 +000025import android.view.MenuItem;
Bjorn Bringertd69f51d2010-09-13 14:06:41 +010026
Jeff Hamilton462b8e82010-09-23 14:33:43 -050027import java.util.List;
The Android Open Source Project0c908882009-03-03 19:32:16 -080028
Jeff Hamilton462b8e82010-09-23 14:33:43 -050029public class BrowserPreferencesPage extends PreferenceActivity {
The Android Open Source Project0c908882009-03-03 19:32:16 -080030
Jeff Hamilton462b8e82010-09-23 14:33:43 -050031 public static final String CURRENT_PAGE = "currentPage";
Nicolas Roard78a98e42009-05-11 13:34:17 +010032
Ben Murdoch7ed9bd72010-12-13 14:30:33 +000033 @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
Jeff Hamilton462b8e82010-09-23 14:33:43 -050044 /**
45 * Populate the activity with the top-level headers.
Nicolas Roarde46990e2009-06-19 16:27:49 +010046 */
47 @Override
Jeff Hamilton462b8e82010-09-23 14:33:43 -050048 public void onBuildHeaders(List<Header> target) {
49 loadHeadersFromResource(R.xml.preference_headers, target);
50
John Reck35e9dd62011-04-25 09:01:54 -070051 if (BrowserSettings.DEV_BUILD
52 || BrowserSettings.getInstance().isDebugEnabled()) {
Jeff Hamilton462b8e82010-09-23 14:33:43 -050053 Header debug = new Header();
54 debug.title = getText(R.string.pref_development_title);
55 debug.fragment = DebugPreferencesFragment.class.getName();
56 target.add(debug);
57 }
The Android Open Source Project0c908882009-03-03 19:32:16 -080058 }
59
60 @Override
Ben Murdoch7ed9bd72010-12-13 14:30:33 +000061 public boolean onOptionsItemSelected(MenuItem item) {
62 switch (item.getItemId()) {
63 case android.R.id.home:
Dianne Hackbornbf1d10a2011-01-17 12:29:51 -080064 if (getFragmentManager().getBackStackEntryCount() > 0) {
Ben Murdoch7ed9bd72010-12-13 14:30:33 +000065 getFragmentManager().popBackStack();
66 } else {
67 finish();
68 }
69 return true;
70 }
71
72 return false;
73 }
The Android Open Source Project0c908882009-03-03 19:32:16 -080074}