blob: e8d6af9a2df2bb7d5cbdf18dea0b2a3319948bbb [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
Bijan Amirzada41242f22014-03-21 12:12:18 -070017package com.android.browser;
The Android Open Source Project0c908882009-03-03 19:32:16 -080018
19import android.content.Context;
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080020import android.preference.DialogPreference;
The Android Open Source Project0c908882009-03-03 19:32:16 -080021import android.util.AttributeSet;
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080022import android.util.Log;
The Android Open Source Project0c908882009-03-03 19:32:16 -080023
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080024class BrowserYesNoPreference extends DialogPreference {
The Android Open Source Project0c908882009-03-03 19:32:16 -080025
26 // This is the constructor called by the inflater
27 public BrowserYesNoPreference(Context context, AttributeSet attrs) {
28 super(context, attrs);
29 }
30
31 @Override
32 protected void onDialogClosed(boolean positiveResult) {
33 super.onDialogClosed(positiveResult);
34
Vivek Sekharb7499802014-04-08 07:48:38 -070035 if (callChangeListener(positiveResult)) {
Vivek Sekhar107f74f2014-05-09 15:51:48 -070036 if (!positiveResult)
37 return;
Axesh R. Ajmera2e241242014-05-19 15:53:38 -070038 setEnabled(false);
John Reck35e9dd62011-04-25 09:01:54 -070039 BrowserSettings settings = BrowserSettings.getInstance();
40 if (PreferenceKeys.PREF_PRIVACY_CLEAR_CACHE.equals(getKey())) {
41 settings.clearCache();
42 settings.clearDatabases();
43 } else if (PreferenceKeys.PREF_PRIVACY_CLEAR_COOKIES.equals(getKey())) {
44 settings.clearCookies();
45 } else if (PreferenceKeys.PREF_PRIVACY_CLEAR_HISTORY.equals(getKey())) {
46 settings.clearHistory();
47 } else if (PreferenceKeys.PREF_PRIVACY_CLEAR_FORM_DATA.equals(getKey())) {
48 settings.clearFormData();
49 } else if (PreferenceKeys.PREF_PRIVACY_CLEAR_PASSWORDS.equals(getKey())) {
50 settings.clearPasswords();
51 } else if (PreferenceKeys.PREF_RESET_DEFAULT_PREFERENCES.equals(
The Android Open Source Project0c908882009-03-03 19:32:16 -080052 getKey())) {
John Reck35e9dd62011-04-25 09:01:54 -070053 settings.resetDefaultPreferences();
The Android Open Source Project0c908882009-03-03 19:32:16 -080054 setEnabled(true);
John Reck35e9dd62011-04-25 09:01:54 -070055 } else if (PreferenceKeys.PREF_PRIVACY_CLEAR_GEOLOCATION_ACCESS.equals(
Steve Blockf344d032009-07-30 10:50:45 +010056 getKey())) {
John Reck35e9dd62011-04-25 09:01:54 -070057 settings.clearLocationAccess();
The Android Open Source Project0c908882009-03-03 19:32:16 -080058 }
59 }
60 }
61}