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