1/*
2 * Copyright (C) 2010 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 com.android.browser.PreferenceKeys;
20import com.android.browser.R;
21
22import android.app.Activity;
23import android.content.Intent;
24import android.os.Bundle;
25import android.preference.Preference;
26import android.preference.PreferenceFragment;
27
28public class PrivacySecurityPreferencesFragment extends PreferenceFragment
29        implements Preference.OnPreferenceChangeListener {
30
31    @Override
32    public void onCreate(Bundle savedInstanceState) {
33        super.onCreate(savedInstanceState);
34
35        // Load the preferences from an XML resource
36        addPreferencesFromResource(R.xml.privacy_security_preferences);
37
38        Preference e = findPreference(PreferenceKeys.PREF_PRIVACY_CLEAR_HISTORY);
39        e.setOnPreferenceChangeListener(this);
40    }
41
42    @Override
43    public void onResume() {
44        super.onResume();
45    }
46
47    @Override
48    public boolean onPreferenceChange(Preference pref, Object objValue) {
49        if (pref.getKey().equals(PreferenceKeys.PREF_PRIVACY_CLEAR_HISTORY)
50                && ((Boolean) objValue).booleanValue() == true) {
51            // Need to tell the browser to remove the parent/child relationship
52            // between tabs
53            getActivity().setResult(Activity.RESULT_OK, (new Intent()).putExtra(Intent.EXTRA_TEXT,
54                    pref.getKey()));
55            return true;
56        }
57
58        return false;
59    }
60
61}
62