The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 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 | |
| 17 | package com.android.settings; |
| 18 | |
Amith Yamasani | 56821db | 2012-06-05 13:20:45 -0700 | [diff] [blame] | 19 | import android.accounts.Account; |
| 20 | import android.accounts.AccountManager; |
| 21 | import android.accounts.OnAccountsUpdateListener; |
Jaewan Kim | a3fe77b | 2013-06-04 21:17:40 +0900 | [diff] [blame] | 22 | import android.content.BroadcastReceiver; |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 23 | import android.content.ComponentName; |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 24 | import android.content.Context; |
Amith Yamasani | 379d9b0 | 2010-09-27 12:03:59 -0700 | [diff] [blame] | 25 | import android.content.Intent; |
Jaewan Kim | a3fe77b | 2013-06-04 21:17:40 +0900 | [diff] [blame] | 26 | import android.content.IntentFilter; |
Dianne Hackborn | caefa9b | 2012-10-10 15:05:42 -0700 | [diff] [blame] | 27 | import android.content.SharedPreferences; |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 28 | import android.content.pm.ActivityInfo; |
| 29 | import android.content.pm.PackageManager; |
| 30 | import android.content.pm.PackageManager.NameNotFoundException; |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 31 | import android.graphics.drawable.Drawable; |
Dianne Hackborn | f4eb85b | 2010-10-29 16:53:04 -0700 | [diff] [blame] | 32 | import android.os.Bundle; |
Jeff Sharkey | 34e964d | 2012-04-21 15:41:48 -0700 | [diff] [blame] | 33 | import android.os.INetworkManagementService; |
| 34 | import android.os.RemoteException; |
| 35 | import android.os.ServiceManager; |
Dianne Hackborn | bb06a42 | 2012-08-16 11:01:57 -0700 | [diff] [blame] | 36 | import android.os.UserHandle; |
Jeff Sharkey | 4420246 | 2012-09-19 13:13:45 -0700 | [diff] [blame] | 37 | import android.os.UserManager; |
Amith Yamasani | a4379d6 | 2011-07-22 10:34:58 -0700 | [diff] [blame] | 38 | import android.preference.Preference; |
Amith Yamasani | 02cf71a | 2010-09-21 15:48:52 -0700 | [diff] [blame] | 39 | import android.preference.PreferenceActivity; |
Amith Yamasani | a4379d6 | 2011-07-22 10:34:58 -0700 | [diff] [blame] | 40 | import android.preference.PreferenceFragment; |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 41 | import android.text.TextUtils; |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 42 | import android.util.Log; |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 43 | import android.view.LayoutInflater; |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 44 | import android.view.View; |
| 45 | import android.view.View.OnClickListener; |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 46 | import android.view.ViewGroup; |
| 47 | import android.widget.ArrayAdapter; |
Amith Yamasani | 9e3a470 | 2011-01-11 09:09:26 -0800 | [diff] [blame] | 48 | import android.widget.Button; |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 49 | import android.widget.ImageView; |
| 50 | import android.widget.ListAdapter; |
| 51 | import android.widget.Switch; |
| 52 | import android.widget.TextView; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 53 | |
Jeff Sharkey | cc0d26b | 2012-11-27 16:42:27 -0800 | [diff] [blame] | 54 | import com.android.internal.util.ArrayUtils; |
Amith Yamasani | a677ee2 | 2013-07-26 13:38:41 -0700 | [diff] [blame] | 55 | import com.android.settings.accessibility.AccessibilitySettings; |
Alan Viverette | 341ff66 | 2013-07-18 17:49:33 -0700 | [diff] [blame] | 56 | import com.android.settings.accessibility.ToggleAccessibilityServicePreferenceFragment; |
Jeff Sharkey | cc0d26b | 2012-11-27 16:42:27 -0800 | [diff] [blame] | 57 | import com.android.settings.accounts.AccountSyncSettings; |
| 58 | import com.android.settings.accounts.AuthenticatorHelper; |
| 59 | import com.android.settings.accounts.ManageAccountsSettings; |
Amith Yamasani | a677ee2 | 2013-07-26 13:38:41 -0700 | [diff] [blame] | 60 | import com.android.settings.applications.AppOpsSummary; |
| 61 | import com.android.settings.applications.ManageApplications; |
Dianne Hackborn | c6d658e | 2013-08-08 12:57:53 -0700 | [diff] [blame] | 62 | import com.android.settings.applications.ProcessStatsUi; |
Jeff Sharkey | cc0d26b | 2012-11-27 16:42:27 -0800 | [diff] [blame] | 63 | import com.android.settings.bluetooth.BluetoothEnabler; |
| 64 | import com.android.settings.bluetooth.BluetoothSettings; |
Amith Yamasani | a677ee2 | 2013-07-26 13:38:41 -0700 | [diff] [blame] | 65 | import com.android.settings.deviceinfo.Memory; |
| 66 | import com.android.settings.deviceinfo.UsbSettings; |
| 67 | import com.android.settings.fuelgauge.PowerUsageSummary; |
| 68 | import com.android.settings.inputmethod.InputMethodAndLanguageSettings; |
| 69 | import com.android.settings.inputmethod.SpellCheckersSettings; |
| 70 | import com.android.settings.inputmethod.UserDictionaryList; |
Amith Yamasani | e990420 | 2013-08-01 10:26:14 -0700 | [diff] [blame] | 71 | import com.android.settings.location.LocationSettings; |
Amith Yamasani | a677ee2 | 2013-07-26 13:38:41 -0700 | [diff] [blame] | 72 | import com.android.settings.nfc.AndroidBeam; |
Martijn Coenen | 53083ab | 2013-08-09 13:37:38 -0700 | [diff] [blame] | 73 | import com.android.settings.nfc.PaymentSettings; |
Svetoslav | 2d53165 | 2013-09-03 21:32:40 -0700 | [diff] [blame^] | 74 | import com.android.settings.print.PrintServiceSettingsFragment; |
| 75 | import com.android.settings.print.PrintSettingsFragment; |
Amith Yamasani | a677ee2 | 2013-07-26 13:38:41 -0700 | [diff] [blame] | 76 | import com.android.settings.tts.TextToSpeechSettings; |
Amith Yamasani | a677ee2 | 2013-07-26 13:38:41 -0700 | [diff] [blame] | 77 | import com.android.settings.users.UserSettings; |
| 78 | import com.android.settings.vpn2.VpnSettings; |
Jeff Sharkey | 0c3634c | 2013-02-20 12:35:16 -0800 | [diff] [blame] | 79 | import com.android.settings.wfd.WifiDisplaySettings; |
Amith Yamasani | a677ee2 | 2013-07-26 13:38:41 -0700 | [diff] [blame] | 80 | import com.android.settings.wifi.AdvancedWifiSettings; |
Jeff Sharkey | cc0d26b | 2012-11-27 16:42:27 -0800 | [diff] [blame] | 81 | import com.android.settings.wifi.WifiEnabler; |
| 82 | import com.android.settings.wifi.WifiSettings; |
| 83 | import com.android.settings.wifi.p2p.WifiP2pSettings; |
| 84 | |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 85 | import java.util.ArrayList; |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 86 | import java.util.Collections; |
| 87 | import java.util.Comparator; |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 88 | import java.util.HashMap; |
Amith Yamasani | 02cf71a | 2010-09-21 15:48:52 -0700 | [diff] [blame] | 89 | import java.util.List; |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 90 | |
| 91 | /** |
| 92 | * Top-level settings activity to handle single pane and double pane UI layout. |
| 93 | */ |
Amith Yamasani | 56821db | 2012-06-05 13:20:45 -0700 | [diff] [blame] | 94 | public class Settings extends PreferenceActivity |
| 95 | implements ButtonBarHandler, OnAccountsUpdateListener { |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 96 | |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 97 | private static final String LOG_TAG = "Settings"; |
Amith Yamasani | ea7b28c | 2012-06-20 13:51:40 -0700 | [diff] [blame] | 98 | |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 99 | private static final String META_DATA_KEY_HEADER_ID = |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 100 | "com.android.settings.TOP_LEVEL_HEADER_ID"; |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 101 | private static final String META_DATA_KEY_FRAGMENT_CLASS = |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 102 | "com.android.settings.FRAGMENT_CLASS"; |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 103 | private static final String META_DATA_KEY_PARENT_TITLE = |
| 104 | "com.android.settings.PARENT_FRAGMENT_TITLE"; |
| 105 | private static final String META_DATA_KEY_PARENT_FRAGMENT_CLASS = |
| 106 | "com.android.settings.PARENT_FRAGMENT_CLASS"; |
| 107 | |
Jeff Sharkey | cc0d26b | 2012-11-27 16:42:27 -0800 | [diff] [blame] | 108 | private static final String EXTRA_UI_OPTIONS = "settings:ui_options"; |
Jeff Sharkey | 9fab0da | 2011-07-09 17:52:31 -0700 | [diff] [blame] | 109 | |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 110 | private static final String SAVE_KEY_CURRENT_HEADER = "com.android.settings.CURRENT_HEADER"; |
| 111 | private static final String SAVE_KEY_PARENT_HEADER = "com.android.settings.PARENT_HEADER"; |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 112 | |
| 113 | private String mFragmentClass; |
| 114 | private int mTopLevelHeaderId; |
Amith Yamasani | 3965ae6 | 2010-11-15 14:45:19 -0800 | [diff] [blame] | 115 | private Header mFirstHeader; |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 116 | private Header mCurrentHeader; |
| 117 | private Header mParentHeader; |
| 118 | private boolean mInLocalHeaderSwitch; |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 119 | |
Amith Yamasani | b810a0d | 2012-03-25 10:12:26 -0700 | [diff] [blame] | 120 | // Show only these settings for restricted users |
| 121 | private int[] SETTINGS_FOR_RESTRICTED = { |
Amith Yamasani | 3263039 | 2012-08-10 19:31:39 -0700 | [diff] [blame] | 122 | R.id.wireless_section, |
Amith Yamasani | b810a0d | 2012-03-25 10:12:26 -0700 | [diff] [blame] | 123 | R.id.wifi_settings, |
| 124 | R.id.bluetooth_settings, |
Jeff Sharkey | 38305fb | 2012-09-14 16:26:51 -0700 | [diff] [blame] | 125 | R.id.data_usage_settings, |
Amith Yamasani | 9627a8e | 2012-09-23 12:54:14 -0700 | [diff] [blame] | 126 | R.id.wireless_settings, |
Amith Yamasani | 3263039 | 2012-08-10 19:31:39 -0700 | [diff] [blame] | 127 | R.id.device_section, |
Amith Yamasani | b810a0d | 2012-03-25 10:12:26 -0700 | [diff] [blame] | 128 | R.id.sound_settings, |
| 129 | R.id.display_settings, |
Jeff Sharkey | 90c8b20 | 2012-08-30 15:20:10 -0700 | [diff] [blame] | 130 | R.id.storage_settings, |
Dianne Hackborn | 271c8b0 | 2012-08-20 17:24:39 -0700 | [diff] [blame] | 131 | R.id.application_settings, |
Dianne Hackborn | 52e56a2 | 2012-09-12 17:02:23 -0700 | [diff] [blame] | 132 | R.id.battery_settings, |
Amith Yamasani | 3263039 | 2012-08-10 19:31:39 -0700 | [diff] [blame] | 133 | R.id.personal_section, |
Amith Yamasani | 9627a8e | 2012-09-23 12:54:14 -0700 | [diff] [blame] | 134 | R.id.location_settings, |
Amith Yamasani | 3deeeb7 | 2012-04-05 14:44:48 -0700 | [diff] [blame] | 135 | R.id.security_settings, |
Amith Yamasani | 9627a8e | 2012-09-23 12:54:14 -0700 | [diff] [blame] | 136 | R.id.language_settings, |
Amith Yamasani | dc6bfa6 | 2012-09-06 18:04:06 -0700 | [diff] [blame] | 137 | R.id.user_settings, |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 138 | R.id.account_settings, |
Amith Yamasani | 3263039 | 2012-08-10 19:31:39 -0700 | [diff] [blame] | 139 | R.id.account_add, |
| 140 | R.id.system_section, |
Amith Yamasani | 9627a8e | 2012-09-23 12:54:14 -0700 | [diff] [blame] | 141 | R.id.date_time_settings, |
Jeff Brown | 9e143f5 | 2012-09-19 20:46:07 -0700 | [diff] [blame] | 142 | R.id.about_settings, |
Svetoslav Ganov | d4c7b49 | 2013-06-11 21:15:11 -0700 | [diff] [blame] | 143 | R.id.accessibility_settings, |
Martijn Coenen | 26515da | 2013-08-01 18:13:33 -0700 | [diff] [blame] | 144 | R.id.print_settings, |
| 145 | R.id.nfc_payment_settings |
Amith Yamasani | b810a0d | 2012-03-25 10:12:26 -0700 | [diff] [blame] | 146 | }; |
| 147 | |
Dianne Hackborn | caefa9b | 2012-10-10 15:05:42 -0700 | [diff] [blame] | 148 | private SharedPreferences mDevelopmentPreferences; |
| 149 | private SharedPreferences.OnSharedPreferenceChangeListener mDevelopmentPreferencesListener; |
| 150 | |
Amith Yamasani | 02cf71a | 2010-09-21 15:48:52 -0700 | [diff] [blame] | 151 | // TODO: Update Call Settings based on airplane mode state. |
Amith Yamasani | b61cf51 | 2010-09-12 08:17:50 -0700 | [diff] [blame] | 152 | |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 153 | protected HashMap<Integer, Integer> mHeaderIndexMap = new HashMap<Integer, Integer>(); |
| 154 | |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 155 | private AuthenticatorHelper mAuthenticatorHelper; |
| 156 | private Header mLastHeader; |
Amith Yamasani | 86708a8 | 2012-06-06 20:23:08 -0700 | [diff] [blame] | 157 | private boolean mListeningToAccountUpdates; |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 158 | |
Jaewan Kim | a3fe77b | 2013-06-04 21:17:40 +0900 | [diff] [blame] | 159 | private boolean mBatteryPresent = true; |
| 160 | private BroadcastReceiver mBatteryInfoReceiver = new BroadcastReceiver() { |
| 161 | |
| 162 | @Override |
| 163 | public void onReceive(Context context, Intent intent) { |
| 164 | String action = intent.getAction(); |
| 165 | if (Intent.ACTION_BATTERY_CHANGED.equals(action)) { |
| 166 | boolean batteryPresent = Utils.isBatteryPresent(intent); |
| 167 | |
| 168 | if (mBatteryPresent != batteryPresent) { |
| 169 | mBatteryPresent = batteryPresent; |
| 170 | invalidateHeaders(); |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | }; |
| 175 | |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 176 | @Override |
| 177 | protected void onCreate(Bundle savedInstanceState) { |
Jeff Sharkey | cc0d26b | 2012-11-27 16:42:27 -0800 | [diff] [blame] | 178 | if (getIntent().hasExtra(EXTRA_UI_OPTIONS)) { |
| 179 | getWindow().setUiOptions(getIntent().getIntExtra(EXTRA_UI_OPTIONS, 0)); |
Jeff Sharkey | 54d0af5 | 2011-08-11 18:26:57 -0700 | [diff] [blame] | 180 | } |
Jeff Sharkey | 9fab0da | 2011-07-09 17:52:31 -0700 | [diff] [blame] | 181 | |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 182 | mAuthenticatorHelper = new AuthenticatorHelper(); |
| 183 | mAuthenticatorHelper.updateAuthDescriptions(this); |
| 184 | mAuthenticatorHelper.onAccountsUpdated(this, null); |
| 185 | |
Dianne Hackborn | caefa9b | 2012-10-10 15:05:42 -0700 | [diff] [blame] | 186 | mDevelopmentPreferences = getSharedPreferences(DevelopmentSettings.PREF_FILE, |
| 187 | Context.MODE_PRIVATE); |
| 188 | |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 189 | getMetaData(); |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 190 | mInLocalHeaderSwitch = true; |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 191 | super.onCreate(savedInstanceState); |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 192 | mInLocalHeaderSwitch = false; |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 193 | |
Gilles Debunne | 3661b62 | 2011-06-27 11:19:16 -0700 | [diff] [blame] | 194 | if (!onIsHidingHeaders() && onIsMultiPane()) { |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 195 | highlightHeader(mTopLevelHeaderId); |
Amith Yamasani | 72aa19d | 2010-12-09 06:07:12 -0800 | [diff] [blame] | 196 | // Force the title so that it doesn't get overridden by a direct launch of |
| 197 | // a specific settings screen. |
| 198 | setTitle(R.string.settings_label); |
| 199 | } |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 200 | |
| 201 | // Retrieve any saved state |
| 202 | if (savedInstanceState != null) { |
| 203 | mCurrentHeader = savedInstanceState.getParcelable(SAVE_KEY_CURRENT_HEADER); |
| 204 | mParentHeader = savedInstanceState.getParcelable(SAVE_KEY_PARENT_HEADER); |
| 205 | } |
| 206 | |
| 207 | // If the current header was saved, switch to it |
| 208 | if (savedInstanceState != null && mCurrentHeader != null) { |
| 209 | //switchToHeaderLocal(mCurrentHeader); |
| 210 | showBreadCrumbs(mCurrentHeader.title, null); |
| 211 | } |
| 212 | |
| 213 | if (mParentHeader != null) { |
| 214 | setParentTitle(mParentHeader.title, null, new OnClickListener() { |
Maggie Benthall | 0c5a401 | 2013-03-14 17:41:27 -0400 | [diff] [blame] | 215 | @Override |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 216 | public void onClick(View v) { |
| 217 | switchToParent(mParentHeader.fragment); |
| 218 | } |
| 219 | }); |
| 220 | } |
Gilles Debunne | dc7101f | 2011-06-27 12:00:49 -0700 | [diff] [blame] | 221 | |
Amith Yamasani | 3d384f4 | 2012-05-11 15:22:04 -0700 | [diff] [blame] | 222 | // Override up navigation for multi-pane, since we handle it in the fragment breadcrumbs |
| 223 | if (onIsMultiPane()) { |
| 224 | getActionBar().setDisplayHomeAsUpEnabled(false); |
| 225 | getActionBar().setHomeButtonEnabled(false); |
| 226 | } |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | @Override |
| 230 | protected void onSaveInstanceState(Bundle outState) { |
| 231 | super.onSaveInstanceState(outState); |
| 232 | |
| 233 | // Save the current fragment, if it is the same as originally launched |
| 234 | if (mCurrentHeader != null) { |
| 235 | outState.putParcelable(SAVE_KEY_CURRENT_HEADER, mCurrentHeader); |
| 236 | } |
| 237 | if (mParentHeader != null) { |
| 238 | outState.putParcelable(SAVE_KEY_PARENT_HEADER, mParentHeader); |
| 239 | } |
| 240 | } |
| 241 | |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 242 | @Override |
| 243 | public void onResume() { |
| 244 | super.onResume(); |
| 245 | |
Dianne Hackborn | caefa9b | 2012-10-10 15:05:42 -0700 | [diff] [blame] | 246 | mDevelopmentPreferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() { |
| 247 | @Override |
| 248 | public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { |
| 249 | invalidateHeaders(); |
| 250 | } |
| 251 | }; |
| 252 | mDevelopmentPreferences.registerOnSharedPreferenceChangeListener( |
| 253 | mDevelopmentPreferencesListener); |
| 254 | |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 255 | ListAdapter listAdapter = getListAdapter(); |
| 256 | if (listAdapter instanceof HeaderAdapter) { |
| 257 | ((HeaderAdapter) listAdapter).resume(); |
| 258 | } |
Amith Yamasani | ea7b28c | 2012-06-20 13:51:40 -0700 | [diff] [blame] | 259 | invalidateHeaders(); |
Jaewan Kim | a3fe77b | 2013-06-04 21:17:40 +0900 | [diff] [blame] | 260 | |
| 261 | registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | @Override |
| 265 | public void onPause() { |
| 266 | super.onPause(); |
| 267 | |
Jaewan Kim | a3fe77b | 2013-06-04 21:17:40 +0900 | [diff] [blame] | 268 | unregisterReceiver(mBatteryInfoReceiver); |
| 269 | |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 270 | ListAdapter listAdapter = getListAdapter(); |
| 271 | if (listAdapter instanceof HeaderAdapter) { |
| 272 | ((HeaderAdapter) listAdapter).pause(); |
Amith Yamasani | 86708a8 | 2012-06-06 20:23:08 -0700 | [diff] [blame] | 273 | } |
Dianne Hackborn | caefa9b | 2012-10-10 15:05:42 -0700 | [diff] [blame] | 274 | |
| 275 | mDevelopmentPreferences.unregisterOnSharedPreferenceChangeListener( |
| 276 | mDevelopmentPreferencesListener); |
| 277 | mDevelopmentPreferencesListener = null; |
Amith Yamasani | 86708a8 | 2012-06-06 20:23:08 -0700 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | @Override |
| 281 | public void onDestroy() { |
| 282 | super.onDestroy(); |
| 283 | if (mListeningToAccountUpdates) { |
Amith Yamasani | 56821db | 2012-06-05 13:20:45 -0700 | [diff] [blame] | 284 | AccountManager.get(this).removeOnAccountsUpdatedListener(this); |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 285 | } |
| 286 | } |
| 287 | |
Amith Yamasani | 56f51a8 | 2013-08-05 10:07:23 -0700 | [diff] [blame] | 288 | @Override |
| 289 | public boolean onIsMultiPane() { |
| 290 | return false; |
| 291 | } |
| 292 | |
Amith Yamasani | a677ee2 | 2013-07-26 13:38:41 -0700 | [diff] [blame] | 293 | private static final String[] ENTRY_FRAGMENTS = { |
| 294 | WirelessSettings.class.getName(), |
| 295 | WifiSettings.class.getName(), |
| 296 | AdvancedWifiSettings.class.getName(), |
| 297 | BluetoothSettings.class.getName(), |
| 298 | TetherSettings.class.getName(), |
| 299 | WifiP2pSettings.class.getName(), |
| 300 | VpnSettings.class.getName(), |
| 301 | DateTimeSettings.class.getName(), |
| 302 | LocalePicker.class.getName(), |
| 303 | InputMethodAndLanguageSettings.class.getName(), |
| 304 | SpellCheckersSettings.class.getName(), |
| 305 | UserDictionaryList.class.getName(), |
| 306 | UserDictionarySettings.class.getName(), |
| 307 | SoundSettings.class.getName(), |
| 308 | DisplaySettings.class.getName(), |
| 309 | DeviceInfoSettings.class.getName(), |
| 310 | ManageApplications.class.getName(), |
Dianne Hackborn | c6d658e | 2013-08-08 12:57:53 -0700 | [diff] [blame] | 311 | ProcessStatsUi.class.getName(), |
Amith Yamasani | a677ee2 | 2013-07-26 13:38:41 -0700 | [diff] [blame] | 312 | NotificationStation.class.getName(), |
| 313 | AppOpsSummary.class.getName(), |
| 314 | LocationSettings.class.getName(), |
| 315 | SecuritySettings.class.getName(), |
| 316 | PrivacySettings.class.getName(), |
| 317 | DeviceAdminSettings.class.getName(), |
| 318 | AccessibilitySettings.class.getName(), |
| 319 | TextToSpeechSettings.class.getName(), |
| 320 | Memory.class.getName(), |
| 321 | DevelopmentSettings.class.getName(), |
| 322 | UsbSettings.class.getName(), |
| 323 | AndroidBeam.class.getName(), |
| 324 | WifiDisplaySettings.class.getName(), |
| 325 | PowerUsageSummary.class.getName(), |
| 326 | AccountSyncSettings.class.getName(), |
| 327 | CryptKeeperSettings.class.getName(), |
| 328 | DataUsageSummary.class.getName(), |
| 329 | DreamSettings.class.getName(), |
| 330 | UserSettings.class.getName(), |
| 331 | NotificationAccessSettings.class.getName(), |
Amith Yamasani | ee226f9 | 2013-08-05 11:02:16 -0700 | [diff] [blame] | 332 | ManageAccountsSettings.class.getName(), |
Svetoslav | 2d53165 | 2013-09-03 21:32:40 -0700 | [diff] [blame^] | 333 | PrintSettingsFragment.class.getName(), |
Martijn Coenen | 53083ab | 2013-08-09 13:37:38 -0700 | [diff] [blame] | 334 | TrustedCredentialsSettings.class.getName(), |
| 335 | PaymentSettings.class.getName() |
Amith Yamasani | a677ee2 | 2013-07-26 13:38:41 -0700 | [diff] [blame] | 336 | }; |
| 337 | |
| 338 | @Override |
| 339 | protected boolean isValidFragment(String fragmentName) { |
| 340 | // Almost all fragments are wrapped in this, |
| 341 | // except for a few that have their own activities. |
| 342 | for (int i = 0; i < ENTRY_FRAGMENTS.length; i++) { |
| 343 | if (ENTRY_FRAGMENTS[i].equals(fragmentName)) return true; |
| 344 | } |
| 345 | return false; |
| 346 | } |
| 347 | |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 348 | private void switchToHeaderLocal(Header header) { |
| 349 | mInLocalHeaderSwitch = true; |
| 350 | switchToHeader(header); |
| 351 | mInLocalHeaderSwitch = false; |
| 352 | } |
| 353 | |
| 354 | @Override |
| 355 | public void switchToHeader(Header header) { |
| 356 | if (!mInLocalHeaderSwitch) { |
| 357 | mCurrentHeader = null; |
| 358 | mParentHeader = null; |
| 359 | } |
| 360 | super.switchToHeader(header); |
| 361 | } |
| 362 | |
| 363 | /** |
| 364 | * Switch to parent fragment and store the grand parent's info |
Jake Hamby | 2748fc2 | 2011-01-12 15:06:28 -0800 | [diff] [blame] | 365 | * @param className name of the activity wrapper for the parent fragment. |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 366 | */ |
| 367 | private void switchToParent(String className) { |
| 368 | final ComponentName cn = new ComponentName(this, className); |
| 369 | try { |
| 370 | final PackageManager pm = getPackageManager(); |
| 371 | final ActivityInfo parentInfo = pm.getActivityInfo(cn, PackageManager.GET_META_DATA); |
| 372 | |
| 373 | if (parentInfo != null && parentInfo.metaData != null) { |
| 374 | String fragmentClass = parentInfo.metaData.getString(META_DATA_KEY_FRAGMENT_CLASS); |
| 375 | CharSequence fragmentTitle = parentInfo.loadLabel(pm); |
| 376 | Header parentHeader = new Header(); |
| 377 | parentHeader.fragment = fragmentClass; |
| 378 | parentHeader.title = fragmentTitle; |
| 379 | mCurrentHeader = parentHeader; |
| 380 | |
| 381 | switchToHeaderLocal(parentHeader); |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 382 | highlightHeader(mTopLevelHeaderId); |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 383 | |
| 384 | mParentHeader = new Header(); |
| 385 | mParentHeader.fragment |
| 386 | = parentInfo.metaData.getString(META_DATA_KEY_PARENT_FRAGMENT_CLASS); |
| 387 | mParentHeader.title = parentInfo.metaData.getString(META_DATA_KEY_PARENT_TITLE); |
| 388 | } |
| 389 | } catch (NameNotFoundException nnfe) { |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 390 | Log.w(LOG_TAG, "Could not find parent activity : " + className); |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 391 | } |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 392 | } |
| 393 | |
Amith Yamasani | 3965ae6 | 2010-11-15 14:45:19 -0800 | [diff] [blame] | 394 | @Override |
| 395 | public void onNewIntent(Intent intent) { |
| 396 | super.onNewIntent(intent); |
| 397 | |
| 398 | // If it is not launched from history, then reset to top-level |
Amith Yamasani | ef61723 | 2012-10-09 16:57:25 -0700 | [diff] [blame] | 399 | if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) { |
| 400 | if (mFirstHeader != null && !onIsHidingHeaders() && onIsMultiPane()) { |
| 401 | switchToHeaderLocal(mFirstHeader); |
| 402 | } |
| 403 | getListView().setSelectionFromTop(0, 0); |
Amith Yamasani | 3965ae6 | 2010-11-15 14:45:19 -0800 | [diff] [blame] | 404 | } |
| 405 | } |
| 406 | |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 407 | private void highlightHeader(int id) { |
| 408 | if (id != 0) { |
| 409 | Integer index = mHeaderIndexMap.get(id); |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 410 | if (index != null) { |
| 411 | getListView().setItemChecked(index, true); |
Amith Yamasani | ef61723 | 2012-10-09 16:57:25 -0700 | [diff] [blame] | 412 | if (isMultiPane()) { |
| 413 | getListView().smoothScrollToPosition(index); |
| 414 | } |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 415 | } |
| 416 | } |
| 417 | } |
| 418 | |
Amith Yamasani | e0e4fc2 | 2010-10-05 11:49:51 -0700 | [diff] [blame] | 419 | @Override |
| 420 | public Intent getIntent() { |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 421 | Intent superIntent = super.getIntent(); |
| 422 | String startingFragment = getStartingFragmentClass(superIntent); |
Gilles Debunne | 3661b62 | 2011-06-27 11:19:16 -0700 | [diff] [blame] | 423 | // This is called from super.onCreate, isMultiPane() is not yet reliable |
| 424 | // Do not use onIsHidingHeaders either, which relies itself on this method |
| 425 | if (startingFragment != null && !onIsMultiPane()) { |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 426 | Intent modIntent = new Intent(superIntent); |
Amith Yamasani | e0e4fc2 | 2010-10-05 11:49:51 -0700 | [diff] [blame] | 427 | modIntent.putExtra(EXTRA_SHOW_FRAGMENT, startingFragment); |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 428 | Bundle args = superIntent.getExtras(); |
Dianne Hackborn | f4eb85b | 2010-10-29 16:53:04 -0700 | [diff] [blame] | 429 | if (args != null) { |
| 430 | args = new Bundle(args); |
| 431 | } else { |
| 432 | args = new Bundle(); |
| 433 | } |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 434 | args.putParcelable("intent", superIntent); |
| 435 | modIntent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, superIntent.getExtras()); |
Amith Yamasani | e0e4fc2 | 2010-10-05 11:49:51 -0700 | [diff] [blame] | 436 | return modIntent; |
| 437 | } |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 438 | return superIntent; |
Amith Yamasani | e0e4fc2 | 2010-10-05 11:49:51 -0700 | [diff] [blame] | 439 | } |
| 440 | |
Amith Yamasani | 02cf71a | 2010-09-21 15:48:52 -0700 | [diff] [blame] | 441 | /** |
Amith Yamasani | 379d9b0 | 2010-09-27 12:03:59 -0700 | [diff] [blame] | 442 | * Checks if the component name in the intent is different from the Settings class and |
| 443 | * returns the class name to load as a fragment. |
| 444 | */ |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 445 | protected String getStartingFragmentClass(Intent intent) { |
| 446 | if (mFragmentClass != null) return mFragmentClass; |
| 447 | |
Dianne Hackborn | f4eb85b | 2010-10-29 16:53:04 -0700 | [diff] [blame] | 448 | String intentClass = intent.getComponent().getClassName(); |
Amith Yamasani | 379d9b0 | 2010-09-27 12:03:59 -0700 | [diff] [blame] | 449 | if (intentClass.equals(getClass().getName())) return null; |
| 450 | |
Dianne Hackborn | ee29379 | 2010-11-01 12:32:33 -0700 | [diff] [blame] | 451 | if ("com.android.settings.ManageApplications".equals(intentClass) |
| 452 | || "com.android.settings.RunningServices".equals(intentClass) |
| 453 | || "com.android.settings.applications.StorageUse".equals(intentClass)) { |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 454 | // Old names of manage apps. |
Dianne Hackborn | f4eb85b | 2010-10-29 16:53:04 -0700 | [diff] [blame] | 455 | intentClass = com.android.settings.applications.ManageApplications.class.getName(); |
| 456 | } |
| 457 | |
Amith Yamasani | 379d9b0 | 2010-09-27 12:03:59 -0700 | [diff] [blame] | 458 | return intentClass; |
| 459 | } |
| 460 | |
| 461 | /** |
| 462 | * Override initial header when an activity-alias is causing Settings to be launched |
| 463 | * for a specific fragment encoded in the android:name parameter. |
| 464 | */ |
| 465 | @Override |
| 466 | public Header onGetInitialHeader() { |
| 467 | String fragmentClass = getStartingFragmentClass(super.getIntent()); |
| 468 | if (fragmentClass != null) { |
| 469 | Header header = new Header(); |
| 470 | header.fragment = fragmentClass; |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 471 | header.title = getTitle(); |
Amith Yamasani | e0e4fc2 | 2010-10-05 11:49:51 -0700 | [diff] [blame] | 472 | header.fragmentArguments = getIntent().getExtras(); |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 473 | mCurrentHeader = header; |
Amith Yamasani | 379d9b0 | 2010-09-27 12:03:59 -0700 | [diff] [blame] | 474 | return header; |
| 475 | } |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 476 | |
Gilles Debunne | b396c9b | 2011-06-22 16:07:29 -0700 | [diff] [blame] | 477 | return mFirstHeader; |
Amith Yamasani | 379d9b0 | 2010-09-27 12:03:59 -0700 | [diff] [blame] | 478 | } |
| 479 | |
Dianne Hackborn | b725818 | 2011-03-15 16:23:55 -0700 | [diff] [blame] | 480 | @Override |
Dianne Hackborn | 48147dc | 2011-03-18 12:29:41 -0700 | [diff] [blame] | 481 | public Intent onBuildStartFragmentIntent(String fragmentName, Bundle args, |
| 482 | int titleRes, int shortTitleRes) { |
| 483 | Intent intent = super.onBuildStartFragmentIntent(fragmentName, args, |
| 484 | titleRes, shortTitleRes); |
Jeff Sharkey | 9fab0da | 2011-07-09 17:52:31 -0700 | [diff] [blame] | 485 | |
Jeff Sharkey | cc0d26b | 2012-11-27 16:42:27 -0800 | [diff] [blame] | 486 | // Some fragments want split ActionBar; these should stay in sync with |
| 487 | // uiOptions for fragments also defined as activities in manifest. |
| 488 | if (WifiSettings.class.getName().equals(fragmentName) || |
| 489 | WifiP2pSettings.class.getName().equals(fragmentName) || |
Jeff Sharkey | 0c3634c | 2013-02-20 12:35:16 -0800 | [diff] [blame] | 490 | WifiDisplaySettings.class.getName().equals(fragmentName) || |
Jeff Sharkey | cc0d26b | 2012-11-27 16:42:27 -0800 | [diff] [blame] | 491 | BluetoothSettings.class.getName().equals(fragmentName) || |
| 492 | DreamSettings.class.getName().equals(fragmentName) || |
Lifu Tang | d5fbbc4 | 2013-08-01 17:23:10 -0700 | [diff] [blame] | 493 | LocationSettings.class.getName().equals(fragmentName) || |
Svetoslav | 2d53165 | 2013-09-03 21:32:40 -0700 | [diff] [blame^] | 494 | ToggleAccessibilityServicePreferenceFragment.class.getName().equals(fragmentName) || |
| 495 | PrintSettingsFragment.class.getName().equals(fragmentName) || |
| 496 | PrintServiceSettingsFragment.class.getName().equals(fragmentName)) { |
Jeff Sharkey | cc0d26b | 2012-11-27 16:42:27 -0800 | [diff] [blame] | 497 | intent.putExtra(EXTRA_UI_OPTIONS, ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW); |
Jeff Sharkey | 9fab0da | 2011-07-09 17:52:31 -0700 | [diff] [blame] | 498 | } |
| 499 | |
Dianne Hackborn | b725818 | 2011-03-15 16:23:55 -0700 | [diff] [blame] | 500 | intent.setClass(this, SubSettings.class); |
| 501 | return intent; |
| 502 | } |
Amith Yamasani | ea7b28c | 2012-06-20 13:51:40 -0700 | [diff] [blame] | 503 | |
Amith Yamasani | 379d9b0 | 2010-09-27 12:03:59 -0700 | [diff] [blame] | 504 | /** |
Amith Yamasani | 02cf71a | 2010-09-21 15:48:52 -0700 | [diff] [blame] | 505 | * Populate the activity with the top-level headers. |
| 506 | */ |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 507 | @Override |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 508 | public void onBuildHeaders(List<Header> headers) { |
| 509 | loadHeadersFromResource(R.xml.settings_headers, headers); |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 510 | updateHeaderList(headers); |
Amith Yamasani | 02cf71a | 2010-09-21 15:48:52 -0700 | [diff] [blame] | 511 | } |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 512 | |
Amith Yamasani | 02cf71a | 2010-09-21 15:48:52 -0700 | [diff] [blame] | 513 | private void updateHeaderList(List<Header> target) { |
Dianne Hackborn | caefa9b | 2012-10-10 15:05:42 -0700 | [diff] [blame] | 514 | final boolean showDev = mDevelopmentPreferences.getBoolean( |
| 515 | DevelopmentSettings.PREF_SHOW, |
| 516 | android.os.Build.TYPE.equals("eng")); |
Amith Yamasani | 02cf71a | 2010-09-21 15:48:52 -0700 | [diff] [blame] | 517 | int i = 0; |
Maggie Benthall | 0c5a401 | 2013-03-14 17:41:27 -0400 | [diff] [blame] | 518 | |
| 519 | final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE); |
Dianne Hackborn | caefa9b | 2012-10-10 15:05:42 -0700 | [diff] [blame] | 520 | mHeaderIndexMap.clear(); |
Amith Yamasani | 02cf71a | 2010-09-21 15:48:52 -0700 | [diff] [blame] | 521 | while (i < target.size()) { |
| 522 | Header header = target.get(i); |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 523 | // Ids are integers, so downcasting |
| 524 | int id = (int) header.id; |
Chris Wren | 2bc32ae | 2012-09-24 14:23:46 -0400 | [diff] [blame] | 525 | if (id == R.id.operator_settings || id == R.id.manufacturer_settings) { |
Amith Yamasani | 02cf71a | 2010-09-21 15:48:52 -0700 | [diff] [blame] | 526 | Utils.updateHeaderToSpecificActivityFromMetaDataOrRemove(this, target, header); |
Gilles Debunne | 2454f49 | 2011-06-21 16:16:06 -0700 | [diff] [blame] | 527 | } else if (id == R.id.wifi_settings) { |
| 528 | // Remove WiFi Settings if WiFi service is not available. |
| 529 | if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) { |
Dianne Hackborn | caefa9b | 2012-10-10 15:05:42 -0700 | [diff] [blame] | 530 | target.remove(i); |
Gilles Debunne | 2454f49 | 2011-06-21 16:16:06 -0700 | [diff] [blame] | 531 | } |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 532 | } else if (id == R.id.bluetooth_settings) { |
| 533 | // Remove Bluetooth Settings if Bluetooth service is not available. |
Gilles Debunne | 2454f49 | 2011-06-21 16:16:06 -0700 | [diff] [blame] | 534 | if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) { |
Dianne Hackborn | caefa9b | 2012-10-10 15:05:42 -0700 | [diff] [blame] | 535 | target.remove(i); |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 536 | } |
Jeff Sharkey | 34e964d | 2012-04-21 15:41:48 -0700 | [diff] [blame] | 537 | } else if (id == R.id.data_usage_settings) { |
| 538 | // Remove data usage when kernel module not enabled |
| 539 | final INetworkManagementService netManager = INetworkManagementService.Stub |
| 540 | .asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE)); |
| 541 | try { |
| 542 | if (!netManager.isBandwidthControlEnabled()) { |
Dianne Hackborn | caefa9b | 2012-10-10 15:05:42 -0700 | [diff] [blame] | 543 | target.remove(i); |
Jeff Sharkey | 34e964d | 2012-04-21 15:41:48 -0700 | [diff] [blame] | 544 | } |
| 545 | } catch (RemoteException e) { |
| 546 | // ignored |
| 547 | } |
Jaewan Kim | a3fe77b | 2013-06-04 21:17:40 +0900 | [diff] [blame] | 548 | } else if (id == R.id.battery_settings) { |
| 549 | // Remove battery settings when battery is not available. (e.g. TV) |
| 550 | |
| 551 | if (!mBatteryPresent) { |
| 552 | target.remove(i); |
| 553 | } |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 554 | } else if (id == R.id.account_settings) { |
| 555 | int headerIndex = i + 1; |
| 556 | i = insertAccountsHeaders(target, headerIndex); |
Amith Yamasani | b810a0d | 2012-03-25 10:12:26 -0700 | [diff] [blame] | 557 | } else if (id == R.id.user_settings) { |
Amith Yamasani | dc6bfa6 | 2012-09-06 18:04:06 -0700 | [diff] [blame] | 558 | if (!UserHandle.MU_ENABLED |
Jeff Sharkey | 4420246 | 2012-09-19 13:13:45 -0700 | [diff] [blame] | 559 | || !UserManager.supportsMultipleUsers() |
Amith Yamasani | b810a0d | 2012-03-25 10:12:26 -0700 | [diff] [blame] | 560 | || Utils.isMonkeyRunning()) { |
Dianne Hackborn | caefa9b | 2012-10-10 15:05:42 -0700 | [diff] [blame] | 561 | target.remove(i); |
| 562 | } |
Martijn Coenen | 26515da | 2013-08-01 18:13:33 -0700 | [diff] [blame] | 563 | } else if (id == R.id.nfc_payment_settings) { |
| 564 | if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC_HCE)) { |
| 565 | target.remove(i); |
| 566 | } |
Dianne Hackborn | caefa9b | 2012-10-10 15:05:42 -0700 | [diff] [blame] | 567 | } else if (id == R.id.development_settings) { |
| 568 | if (!showDev) { |
| 569 | target.remove(i); |
Amith Yamasani | b810a0d | 2012-03-25 10:12:26 -0700 | [diff] [blame] | 570 | } |
Maggie Benthall | 0c5a401 | 2013-03-14 17:41:27 -0400 | [diff] [blame] | 571 | } else if (id == R.id.account_add) { |
| 572 | if (um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) { |
| 573 | target.remove(i); |
| 574 | } |
Amith Yamasani | b810a0d | 2012-03-25 10:12:26 -0700 | [diff] [blame] | 575 | } |
Dianne Hackborn | caefa9b | 2012-10-10 15:05:42 -0700 | [diff] [blame] | 576 | |
Jaewan Kim | bb0e621 | 2013-02-04 15:36:17 +0900 | [diff] [blame] | 577 | if (i < target.size() && target.get(i) == header |
Amith Yamasani | b99f864 | 2012-10-10 21:41:12 -0700 | [diff] [blame] | 578 | && UserHandle.MU_ENABLED && UserHandle.myUserId() != 0 |
Amith Yamasani | b810a0d | 2012-03-25 10:12:26 -0700 | [diff] [blame] | 579 | && !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, id)) { |
Dianne Hackborn | caefa9b | 2012-10-10 15:05:42 -0700 | [diff] [blame] | 580 | target.remove(i); |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 581 | } |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 582 | |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 583 | // Increment if the current one wasn't removed by the Utils code. |
Jaewan Kim | bb0e621 | 2013-02-04 15:36:17 +0900 | [diff] [blame] | 584 | if (i < target.size() && target.get(i) == header) { |
Amith Yamasani | 3965ae6 | 2010-11-15 14:45:19 -0800 | [diff] [blame] | 585 | // Hold on to the first header, when we need to reset to the top-level |
Gilles Debunne | b396c9b | 2011-06-22 16:07:29 -0700 | [diff] [blame] | 586 | if (mFirstHeader == null && |
| 587 | HeaderAdapter.getHeaderType(header) != HeaderAdapter.HEADER_TYPE_CATEGORY) { |
| 588 | mFirstHeader = header; |
| 589 | } |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 590 | mHeaderIndexMap.put(id, i); |
Amith Yamasani | 02cf71a | 2010-09-21 15:48:52 -0700 | [diff] [blame] | 591 | i++; |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 592 | } |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 593 | } |
| 594 | } |
| 595 | |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 596 | private int insertAccountsHeaders(List<Header> target, int headerIndex) { |
| 597 | String[] accountTypes = mAuthenticatorHelper.getEnabledAccountTypes(); |
| 598 | List<Header> accountHeaders = new ArrayList<Header>(accountTypes.length); |
| 599 | for (String accountType : accountTypes) { |
| 600 | CharSequence label = mAuthenticatorHelper.getLabelForType(this, accountType); |
Brian Muramatsu | c28af52 | 2012-06-28 14:25:14 -0700 | [diff] [blame] | 601 | if (label == null) { |
| 602 | continue; |
| 603 | } |
| 604 | |
Amith Yamasani | 3882c2e | 2012-06-07 17:03:20 -0700 | [diff] [blame] | 605 | Account[] accounts = AccountManager.get(this).getAccountsByType(accountType); |
| 606 | boolean skipToAccount = accounts.length == 1 |
| 607 | && !mAuthenticatorHelper.hasAccountPreferences(accountType); |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 608 | Header accHeader = new Header(); |
| 609 | accHeader.title = label; |
| 610 | if (accHeader.extras == null) { |
| 611 | accHeader.extras = new Bundle(); |
| 612 | } |
Amith Yamasani | 3882c2e | 2012-06-07 17:03:20 -0700 | [diff] [blame] | 613 | if (skipToAccount) { |
| 614 | accHeader.breadCrumbTitleRes = R.string.account_sync_settings_title; |
| 615 | accHeader.breadCrumbShortTitleRes = R.string.account_sync_settings_title; |
| 616 | accHeader.fragment = AccountSyncSettings.class.getName(); |
| 617 | accHeader.fragmentArguments = new Bundle(); |
| 618 | // Need this for the icon |
| 619 | accHeader.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType); |
| 620 | accHeader.extras.putParcelable(AccountSyncSettings.ACCOUNT_KEY, accounts[0]); |
| 621 | accHeader.fragmentArguments.putParcelable(AccountSyncSettings.ACCOUNT_KEY, |
| 622 | accounts[0]); |
| 623 | } else { |
| 624 | accHeader.breadCrumbTitle = label; |
| 625 | accHeader.breadCrumbShortTitle = label; |
| 626 | accHeader.fragment = ManageAccountsSettings.class.getName(); |
| 627 | accHeader.fragmentArguments = new Bundle(); |
| 628 | accHeader.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType); |
| 629 | accHeader.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, |
| 630 | accountType); |
| 631 | if (!isMultiPane()) { |
| 632 | accHeader.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_LABEL, |
| 633 | label.toString()); |
| 634 | } |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 635 | } |
| 636 | accountHeaders.add(accHeader); |
| 637 | } |
| 638 | |
| 639 | // Sort by label |
| 640 | Collections.sort(accountHeaders, new Comparator<Header>() { |
| 641 | @Override |
| 642 | public int compare(Header h1, Header h2) { |
| 643 | return h1.title.toString().compareTo(h2.title.toString()); |
| 644 | } |
| 645 | }); |
| 646 | |
| 647 | for (Header header : accountHeaders) { |
| 648 | target.add(headerIndex++, header); |
| 649 | } |
Amith Yamasani | 86708a8 | 2012-06-06 20:23:08 -0700 | [diff] [blame] | 650 | if (!mListeningToAccountUpdates) { |
| 651 | AccountManager.get(this).addOnAccountsUpdatedListener(this, null, true); |
| 652 | mListeningToAccountUpdates = true; |
| 653 | } |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 654 | return headerIndex; |
| 655 | } |
| 656 | |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 657 | private void getMetaData() { |
| 658 | try { |
| 659 | ActivityInfo ai = getPackageManager().getActivityInfo(getComponentName(), |
| 660 | PackageManager.GET_META_DATA); |
| 661 | if (ai == null || ai.metaData == null) return; |
| 662 | mTopLevelHeaderId = ai.metaData.getInt(META_DATA_KEY_HEADER_ID); |
| 663 | mFragmentClass = ai.metaData.getString(META_DATA_KEY_FRAGMENT_CLASS); |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 664 | |
Amith Yamasani | c9fdfa8 | 2010-12-14 14:38:16 -0800 | [diff] [blame] | 665 | // Check if it has a parent specified and create a Header object |
| 666 | final int parentHeaderTitleRes = ai.metaData.getInt(META_DATA_KEY_PARENT_TITLE); |
| 667 | String parentFragmentClass = ai.metaData.getString(META_DATA_KEY_PARENT_FRAGMENT_CLASS); |
| 668 | if (parentFragmentClass != null) { |
| 669 | mParentHeader = new Header(); |
| 670 | mParentHeader.fragment = parentFragmentClass; |
| 671 | if (parentHeaderTitleRes != 0) { |
| 672 | mParentHeader.title = getResources().getString(parentHeaderTitleRes); |
| 673 | } |
| 674 | } |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 675 | } catch (NameNotFoundException nnfe) { |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 676 | // No recovery |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 677 | } |
| 678 | } |
| 679 | |
Amith Yamasani | 9e3a470 | 2011-01-11 09:09:26 -0800 | [diff] [blame] | 680 | @Override |
| 681 | public boolean hasNextButton() { |
| 682 | return super.hasNextButton(); |
| 683 | } |
| 684 | |
| 685 | @Override |
| 686 | public Button getNextButton() { |
| 687 | return super.getNextButton(); |
| 688 | } |
| 689 | |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 690 | private static class HeaderAdapter extends ArrayAdapter<Header> { |
| 691 | static final int HEADER_TYPE_CATEGORY = 0; |
| 692 | static final int HEADER_TYPE_NORMAL = 1; |
| 693 | static final int HEADER_TYPE_SWITCH = 2; |
| 694 | private static final int HEADER_TYPE_COUNT = HEADER_TYPE_SWITCH + 1; |
| 695 | |
| 696 | private final WifiEnabler mWifiEnabler; |
| 697 | private final BluetoothEnabler mBluetoothEnabler; |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 698 | private AuthenticatorHelper mAuthHelper; |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 699 | |
| 700 | private static class HeaderViewHolder { |
| 701 | ImageView icon; |
| 702 | TextView title; |
| 703 | TextView summary; |
| 704 | Switch switch_; |
| 705 | } |
| 706 | |
| 707 | private LayoutInflater mInflater; |
| 708 | |
| 709 | static int getHeaderType(Header header) { |
| 710 | if (header.fragment == null && header.intent == null) { |
| 711 | return HEADER_TYPE_CATEGORY; |
| 712 | } else if (header.id == R.id.wifi_settings || header.id == R.id.bluetooth_settings) { |
| 713 | return HEADER_TYPE_SWITCH; |
| 714 | } else { |
| 715 | return HEADER_TYPE_NORMAL; |
| 716 | } |
| 717 | } |
| 718 | |
| 719 | @Override |
| 720 | public int getItemViewType(int position) { |
| 721 | Header header = getItem(position); |
| 722 | return getHeaderType(header); |
| 723 | } |
| 724 | |
| 725 | @Override |
| 726 | public boolean areAllItemsEnabled() { |
| 727 | return false; // because of categories |
| 728 | } |
| 729 | |
| 730 | @Override |
| 731 | public boolean isEnabled(int position) { |
| 732 | return getItemViewType(position) != HEADER_TYPE_CATEGORY; |
| 733 | } |
| 734 | |
| 735 | @Override |
| 736 | public int getViewTypeCount() { |
| 737 | return HEADER_TYPE_COUNT; |
| 738 | } |
| 739 | |
| 740 | @Override |
| 741 | public boolean hasStableIds() { |
| 742 | return true; |
| 743 | } |
| 744 | |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 745 | public HeaderAdapter(Context context, List<Header> objects, |
| 746 | AuthenticatorHelper authenticatorHelper) { |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 747 | super(context, 0, objects); |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 748 | |
| 749 | mAuthHelper = authenticatorHelper; |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 750 | mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 751 | |
Gilles Debunne | b396c9b | 2011-06-22 16:07:29 -0700 | [diff] [blame] | 752 | // Temp Switches provided as placeholder until the adapter replaces these with actual |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 753 | // Switches inflated from their layouts. Must be done before adapter is set in super |
| 754 | mWifiEnabler = new WifiEnabler(context, new Switch(context)); |
| 755 | mBluetoothEnabler = new BluetoothEnabler(context, new Switch(context)); |
| 756 | } |
| 757 | |
| 758 | @Override |
| 759 | public View getView(int position, View convertView, ViewGroup parent) { |
| 760 | HeaderViewHolder holder; |
| 761 | Header header = getItem(position); |
| 762 | int headerType = getHeaderType(header); |
| 763 | View view = null; |
| 764 | |
| 765 | if (convertView == null) { |
| 766 | holder = new HeaderViewHolder(); |
| 767 | switch (headerType) { |
| 768 | case HEADER_TYPE_CATEGORY: |
Gilles Debunne | b396c9b | 2011-06-22 16:07:29 -0700 | [diff] [blame] | 769 | view = new TextView(getContext(), null, |
| 770 | android.R.attr.listSeparatorTextViewStyle); |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 771 | holder.title = (TextView) view; |
| 772 | break; |
| 773 | |
| 774 | case HEADER_TYPE_SWITCH: |
Gilles Debunne | b396c9b | 2011-06-22 16:07:29 -0700 | [diff] [blame] | 775 | view = mInflater.inflate(R.layout.preference_header_switch_item, parent, |
| 776 | false); |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 777 | holder.icon = (ImageView) view.findViewById(R.id.icon); |
Gilles Debunne | b396c9b | 2011-06-22 16:07:29 -0700 | [diff] [blame] | 778 | holder.title = (TextView) |
| 779 | view.findViewById(com.android.internal.R.id.title); |
| 780 | holder.summary = (TextView) |
| 781 | view.findViewById(com.android.internal.R.id.summary); |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 782 | holder.switch_ = (Switch) view.findViewById(R.id.switchWidget); |
| 783 | break; |
| 784 | |
| 785 | case HEADER_TYPE_NORMAL: |
Gilles Debunne | b396c9b | 2011-06-22 16:07:29 -0700 | [diff] [blame] | 786 | view = mInflater.inflate( |
Amith Yamasani | c8a9317 | 2012-06-08 13:35:47 -0700 | [diff] [blame] | 787 | R.layout.preference_header_item, parent, |
Gilles Debunne | b396c9b | 2011-06-22 16:07:29 -0700 | [diff] [blame] | 788 | false); |
Amith Yamasani | c8a9317 | 2012-06-08 13:35:47 -0700 | [diff] [blame] | 789 | holder.icon = (ImageView) view.findViewById(R.id.icon); |
Gilles Debunne | b396c9b | 2011-06-22 16:07:29 -0700 | [diff] [blame] | 790 | holder.title = (TextView) |
| 791 | view.findViewById(com.android.internal.R.id.title); |
| 792 | holder.summary = (TextView) |
| 793 | view.findViewById(com.android.internal.R.id.summary); |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 794 | break; |
| 795 | } |
| 796 | view.setTag(holder); |
| 797 | } else { |
| 798 | view = convertView; |
| 799 | holder = (HeaderViewHolder) view.getTag(); |
| 800 | } |
| 801 | |
| 802 | // All view fields must be updated every time, because the view may be recycled |
| 803 | switch (headerType) { |
| 804 | case HEADER_TYPE_CATEGORY: |
| 805 | holder.title.setText(header.getTitle(getContext().getResources())); |
| 806 | break; |
| 807 | |
| 808 | case HEADER_TYPE_SWITCH: |
| 809 | // Would need a different treatment if the main menu had more switches |
| 810 | if (header.id == R.id.wifi_settings) { |
| 811 | mWifiEnabler.setSwitch(holder.switch_); |
| 812 | } else { |
| 813 | mBluetoothEnabler.setSwitch(holder.switch_); |
| 814 | } |
| 815 | // No break, fall through on purpose to update common fields |
| 816 | |
| 817 | //$FALL-THROUGH$ |
| 818 | case HEADER_TYPE_NORMAL: |
Amith Yamasani | 3882c2e | 2012-06-07 17:03:20 -0700 | [diff] [blame] | 819 | if (header.extras != null |
| 820 | && header.extras.containsKey(ManageAccountsSettings.KEY_ACCOUNT_TYPE)) { |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 821 | String accType = header.extras.getString( |
| 822 | ManageAccountsSettings.KEY_ACCOUNT_TYPE); |
| 823 | ViewGroup.LayoutParams lp = holder.icon.getLayoutParams(); |
| 824 | lp.width = getContext().getResources().getDimensionPixelSize( |
| 825 | R.dimen.header_icon_width); |
| 826 | lp.height = lp.width; |
| 827 | holder.icon.setLayoutParams(lp); |
| 828 | Drawable icon = mAuthHelper.getDrawableForType(getContext(), accType); |
| 829 | holder.icon.setImageDrawable(icon); |
| 830 | } else { |
| 831 | holder.icon.setImageResource(header.iconRes); |
| 832 | } |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 833 | holder.title.setText(header.getTitle(getContext().getResources())); |
| 834 | CharSequence summary = header.getSummary(getContext().getResources()); |
| 835 | if (!TextUtils.isEmpty(summary)) { |
| 836 | holder.summary.setVisibility(View.VISIBLE); |
| 837 | holder.summary.setText(summary); |
| 838 | } else { |
| 839 | holder.summary.setVisibility(View.GONE); |
| 840 | } |
| 841 | break; |
| 842 | } |
| 843 | |
| 844 | return view; |
| 845 | } |
| 846 | |
| 847 | public void resume() { |
| 848 | mWifiEnabler.resume(); |
| 849 | mBluetoothEnabler.resume(); |
| 850 | } |
Brian Muramatsu | c28af52 | 2012-06-28 14:25:14 -0700 | [diff] [blame] | 851 | |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 852 | public void pause() { |
| 853 | mWifiEnabler.pause(); |
| 854 | mBluetoothEnabler.pause(); |
| 855 | } |
| 856 | } |
| 857 | |
| 858 | @Override |
Amith Yamasani | d1ab828 | 2012-05-18 09:50:08 -0700 | [diff] [blame] | 859 | public void onHeaderClick(Header header, int position) { |
| 860 | boolean revert = false; |
| 861 | if (header.id == R.id.account_add) { |
| 862 | revert = true; |
| 863 | } |
| 864 | |
| 865 | super.onHeaderClick(header, position); |
| 866 | |
| 867 | if (revert && mLastHeader != null) { |
| 868 | highlightHeader((int) mLastHeader.id); |
| 869 | } else { |
| 870 | mLastHeader = header; |
| 871 | } |
| 872 | } |
| 873 | |
| 874 | @Override |
Amith Yamasani | a4379d6 | 2011-07-22 10:34:58 -0700 | [diff] [blame] | 875 | public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) { |
| 876 | // Override the fragment title for Wallpaper settings |
Amith Yamasani | dfb6543 | 2011-11-29 16:38:14 -0800 | [diff] [blame] | 877 | int titleRes = pref.getTitleRes(); |
Amith Yamasani | a4379d6 | 2011-07-22 10:34:58 -0700 | [diff] [blame] | 878 | if (pref.getFragment().equals(WallpaperTypeSettings.class.getName())) { |
Amith Yamasani | dfb6543 | 2011-11-29 16:38:14 -0800 | [diff] [blame] | 879 | titleRes = R.string.wallpaper_settings_fragment_title; |
Amith Yamasani | 8666b9e | 2012-09-27 14:50:13 -0700 | [diff] [blame] | 880 | } else if (pref.getFragment().equals(OwnerInfoSettings.class.getName()) |
| 881 | && UserHandle.myUserId() != UserHandle.USER_OWNER) { |
Amith Yamasani | b017171 | 2013-04-28 22:13:22 -0700 | [diff] [blame] | 882 | if (UserManager.get(this).isLinkedUser()) { |
| 883 | titleRes = R.string.profile_info_settings_title; |
| 884 | } else { |
| 885 | titleRes = R.string.user_info_settings_title; |
| 886 | } |
Amith Yamasani | a4379d6 | 2011-07-22 10:34:58 -0700 | [diff] [blame] | 887 | } |
Jean Chalard | 7dabe45 | 2012-05-10 18:08:07 +0900 | [diff] [blame] | 888 | startPreferencePanel(pref.getFragment(), pref.getExtras(), titleRes, pref.getTitle(), |
| 889 | null, 0); |
Amith Yamasani | a4379d6 | 2011-07-22 10:34:58 -0700 | [diff] [blame] | 890 | return true; |
| 891 | } |
| 892 | |
Maggie Benthall | 0c5a401 | 2013-03-14 17:41:27 -0400 | [diff] [blame] | 893 | @Override |
Amith Yamasani | 3d384f4 | 2012-05-11 15:22:04 -0700 | [diff] [blame] | 894 | public boolean shouldUpRecreateTask(Intent targetIntent) { |
| 895 | return super.shouldUpRecreateTask(new Intent(this, Settings.class)); |
| 896 | } |
| 897 | |
Amith Yamasani | a4379d6 | 2011-07-22 10:34:58 -0700 | [diff] [blame] | 898 | @Override |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 899 | public void setListAdapter(ListAdapter adapter) { |
Amith Yamasani | ea7b28c | 2012-06-20 13:51:40 -0700 | [diff] [blame] | 900 | if (adapter == null) { |
| 901 | super.setListAdapter(null); |
| 902 | } else { |
| 903 | super.setListAdapter(new HeaderAdapter(this, getHeaders(), mAuthenticatorHelper)); |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 904 | } |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 905 | } |
| 906 | |
Amith Yamasani | 56821db | 2012-06-05 13:20:45 -0700 | [diff] [blame] | 907 | @Override |
| 908 | public void onAccountsUpdated(Account[] accounts) { |
Jeff Sharkey | 9ff79c1 | 2012-10-03 16:48:17 -0700 | [diff] [blame] | 909 | // TODO: watch for package upgrades to invalidate cache; see 7206643 |
| 910 | mAuthenticatorHelper.updateAuthDescriptions(this); |
Amith Yamasani | 56821db | 2012-06-05 13:20:45 -0700 | [diff] [blame] | 911 | mAuthenticatorHelper.onAccountsUpdated(this, accounts); |
| 912 | invalidateHeaders(); |
| 913 | } |
| 914 | |
Amith Yamasani | 5203bdf | 2010-11-04 09:59:44 -0700 | [diff] [blame] | 915 | /* |
| 916 | * Settings subclasses for launching independently. |
| 917 | */ |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 918 | public static class BluetoothSettingsActivity extends Settings { /* empty */ } |
| 919 | public static class WirelessSettingsActivity extends Settings { /* empty */ } |
| 920 | public static class TetherSettingsActivity extends Settings { /* empty */ } |
| 921 | public static class VpnSettingsActivity extends Settings { /* empty */ } |
| 922 | public static class DateTimeSettingsActivity extends Settings { /* empty */ } |
| 923 | public static class StorageSettingsActivity extends Settings { /* empty */ } |
| 924 | public static class WifiSettingsActivity extends Settings { /* empty */ } |
repo sync | b98463f | 2011-06-30 10:58:43 -0700 | [diff] [blame] | 925 | public static class WifiP2pSettingsActivity extends Settings { /* empty */ } |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 926 | public static class InputMethodAndLanguageSettingsActivity extends Settings { /* empty */ } |
Jeff Brown | e46c5f3 | 2012-04-05 11:42:18 -0700 | [diff] [blame] | 927 | public static class KeyboardLayoutPickerActivity extends Settings { /* empty */ } |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 928 | public static class InputMethodAndSubtypeEnablerActivity extends Settings { /* empty */ } |
satok | e077d2b | 2011-07-25 09:38:11 +0900 | [diff] [blame] | 929 | public static class SpellCheckersSettingsActivity extends Settings { /* empty */ } |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 930 | public static class LocalePickerActivity extends Settings { /* empty */ } |
| 931 | public static class UserDictionarySettingsActivity extends Settings { /* empty */ } |
| 932 | public static class SoundSettingsActivity extends Settings { /* empty */ } |
| 933 | public static class DisplaySettingsActivity extends Settings { /* empty */ } |
| 934 | public static class DeviceInfoSettingsActivity extends Settings { /* empty */ } |
| 935 | public static class ApplicationSettingsActivity extends Settings { /* empty */ } |
| 936 | public static class ManageApplicationsActivity extends Settings { /* empty */ } |
Dianne Hackborn | a522a8e | 2013-01-15 19:02:05 -0800 | [diff] [blame] | 937 | public static class AppOpsSummaryActivity extends Settings { /* empty */ } |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 938 | public static class StorageUseActivity extends Settings { /* empty */ } |
| 939 | public static class DevelopmentSettingsActivity extends Settings { /* empty */ } |
| 940 | public static class AccessibilitySettingsActivity extends Settings { /* empty */ } |
| 941 | public static class SecuritySettingsActivity extends Settings { /* empty */ } |
Gilles Debunne | a6a8a14 | 2011-06-09 11:56:17 -0700 | [diff] [blame] | 942 | public static class LocationSettingsActivity extends Settings { /* empty */ } |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 943 | public static class PrivacySettingsActivity extends Settings { /* empty */ } |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 944 | public static class RunningServicesActivity extends Settings { /* empty */ } |
| 945 | public static class ManageAccountsSettingsActivity extends Settings { /* empty */ } |
| 946 | public static class PowerUsageSummaryActivity extends Settings { /* empty */ } |
| 947 | public static class AccountSyncSettingsActivity extends Settings { /* empty */ } |
| 948 | public static class AccountSyncSettingsInAddAccountActivity extends Settings { /* empty */ } |
| 949 | public static class CryptKeeperSettingsActivity extends Settings { /* empty */ } |
| 950 | public static class DeviceAdminSettingsActivity extends Settings { /* empty */ } |
| 951 | public static class DataUsageSummaryActivity extends Settings { /* empty */ } |
Gilles Debunne | ab189bd | 2011-07-06 13:10:16 -0700 | [diff] [blame] | 952 | public static class AdvancedWifiSettingsActivity extends Settings { /* empty */ } |
Gilles Debunne | ab189bd | 2011-07-06 13:10:16 -0700 | [diff] [blame] | 953 | public static class TextToSpeechSettingsActivity extends Settings { /* empty */ } |
Jeff Hamilton | 3d670de | 2011-09-21 16:44:36 -0500 | [diff] [blame] | 954 | public static class AndroidBeamSettingsActivity extends Settings { /* empty */ } |
Jeff Brown | 9e143f5 | 2012-09-19 20:46:07 -0700 | [diff] [blame] | 955 | public static class WifiDisplaySettingsActivity extends Settings { /* empty */ } |
Daniel Sandler | 7dee75c | 2012-11-27 22:41:30 -0500 | [diff] [blame] | 956 | public static class DreamSettingsActivity extends Settings { /* empty */ } |
Daniel Sandler | 328e2d2 | 2013-01-17 13:14:02 -0500 | [diff] [blame] | 957 | public static class NotificationStationActivity extends Settings { /* empty */ } |
Amith Yamasani | 233592b | 2013-03-01 17:05:23 -0800 | [diff] [blame] | 958 | public static class UserSettingsActivity extends Settings { /* empty */ } |
Daniel Sandler | 79b9bfe | 2013-04-04 14:30:04 -0400 | [diff] [blame] | 959 | public static class NotificationAccessSettingsActivity extends Settings { /* empty */ } |
Amith Yamasani | a677ee2 | 2013-07-26 13:38:41 -0700 | [diff] [blame] | 960 | public static class UsbSettingsActivity extends Settings { /* empty */ } |
Geoffrey Borggaard | fc6bc20 | 2013-08-09 11:44:42 -0400 | [diff] [blame] | 961 | public static class TrustedCredentialsSettingsActivity extends Settings { /* empty */ } |
Martijn Coenen | 53083ab | 2013-08-09 13:37:38 -0700 | [diff] [blame] | 962 | public static class PaymentSettingsActivity extends Settings { /* empty */ } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 963 | } |