blob: 5ca1f8bfe1e6660b2ad870de9197b8658de13b0a [file] [log] [blame]
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.settings;
18
19import android.accounts.Account;
20import android.accounts.AccountManager;
21import android.accounts.OnAccountsUpdateListener;
22import android.app.ActionBar;
23import android.app.Activity;
24import android.app.Fragment;
25import android.app.FragmentManager;
26import android.app.FragmentTransaction;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080027import android.content.BroadcastReceiver;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -070028import android.content.ComponentName;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080029import android.content.Context;
30import android.content.Intent;
31import android.content.IntentFilter;
32import android.content.SharedPreferences;
33import android.content.pm.ActivityInfo;
34import android.content.pm.PackageManager;
35import android.content.pm.PackageManager.NameNotFoundException;
36import android.content.pm.ResolveInfo;
37import android.content.res.Configuration;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080038import android.content.res.TypedArray;
39import android.content.res.XmlResourceParser;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080040import android.nfc.NfcAdapter;
41import android.os.Bundle;
42import android.os.Handler;
43import android.os.INetworkManagementService;
44import android.os.Message;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080045import android.os.RemoteException;
46import android.os.ServiceManager;
47import android.os.UserHandle;
48import android.os.UserManager;
49import android.preference.Preference;
50import android.preference.PreferenceFragment;
51import android.preference.PreferenceManager;
52import android.preference.PreferenceScreen;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080053import android.text.TextUtils;
Fabrice Di Meglio59a40552014-05-23 16:46:50 -070054import android.transition.TransitionManager;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080055import android.util.AttributeSet;
56import android.util.Log;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080057import android.util.TypedValue;
58import android.util.Xml;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -070059import android.view.Menu;
60import android.view.MenuInflater;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080061import android.view.MenuItem;
62import android.view.View;
63import android.view.View.OnClickListener;
Fabrice Di Meglio59a40552014-05-23 16:46:50 -070064import android.view.ViewGroup;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080065import android.widget.Button;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -070066import android.widget.SearchView;
John Spurlockc7f8e8c2014-06-04 19:11:22 -040067
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080068import com.android.internal.util.ArrayUtils;
69import com.android.internal.util.XmlUtils;
70import com.android.settings.accessibility.AccessibilitySettings;
71import com.android.settings.accessibility.CaptionPropertiesFragment;
72import com.android.settings.accounts.AccountSyncSettings;
73import com.android.settings.accounts.AuthenticatorHelper;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080074import com.android.settings.accounts.ManageAccountsSettings;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -070075import com.android.settings.applications.InstalledAppDetails;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080076import com.android.settings.applications.ManageApplications;
77import com.android.settings.applications.ProcessStatsUi;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080078import com.android.settings.bluetooth.BluetoothSettings;
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -070079import com.android.settings.dashboard.DashboardCategory;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080080import com.android.settings.dashboard.DashboardSummary;
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -070081import com.android.settings.dashboard.DashboardTile;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -070082import com.android.settings.dashboard.NoHomeDialogFragment;
83import com.android.settings.dashboard.SearchResultsSummary;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080084import com.android.settings.deviceinfo.Memory;
85import com.android.settings.deviceinfo.UsbSettings;
John Spurlockc7f8e8c2014-06-04 19:11:22 -040086import com.android.settings.fuelgauge.BatterySaverSettings;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080087import com.android.settings.fuelgauge.PowerUsageSummary;
Fabrice Di Meglio7a6bfd12014-04-14 19:49:18 -070088import com.android.settings.search.DynamicIndexableContentMonitor;
Fabrice Di Megliofa7dc242014-03-12 19:24:43 -070089import com.android.settings.search.Index;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080090import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
91import com.android.settings.inputmethod.KeyboardLayoutPickerFragment;
92import com.android.settings.inputmethod.SpellCheckersSettings;
93import com.android.settings.inputmethod.UserDictionaryList;
94import com.android.settings.location.LocationSettings;
95import com.android.settings.nfc.AndroidBeam;
96import com.android.settings.nfc.PaymentSettings;
John Spurlockc9afadb2014-04-29 18:07:23 -040097import com.android.settings.notification.ConditionProviderSettings;
John Spurlock4a350512014-04-08 14:08:21 -040098import com.android.settings.notification.NotificationAccessSettings;
99import com.android.settings.notification.NotificationSettings;
100import com.android.settings.notification.NotificationStation;
101import com.android.settings.notification.ZenModeSettings;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800102import com.android.settings.print.PrintJobSettingsFragment;
103import com.android.settings.print.PrintSettingsFragment;
104import com.android.settings.tts.TextToSpeechSettings;
105import com.android.settings.users.UserSettings;
106import com.android.settings.vpn2.VpnSettings;
107import com.android.settings.wfd.WifiDisplaySettings;
Fabrice Di Meglio41937762014-05-13 19:51:59 -0700108import com.android.settings.widget.SwitchBar;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800109import com.android.settings.wifi.AdvancedWifiSettings;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800110import com.android.settings.wifi.WifiSettings;
111import com.android.settings.wifi.p2p.WifiP2pSettings;
John Spurlockc7f8e8c2014-06-04 19:11:22 -0400112
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800113import org.xmlpull.v1.XmlPullParser;
114import org.xmlpull.v1.XmlPullParserException;
115
116import java.io.IOException;
117import java.util.ArrayList;
118import java.util.Collections;
119import java.util.Comparator;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800120import java.util.List;
121
Fabrice Di Meglioe9326d22014-05-13 12:49:14 -0700122import static com.android.settings.dashboard.DashboardTile.TILE_ID_UNDEFINED;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700123
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800124public class SettingsActivity extends Activity
125 implements PreferenceManager.OnPreferenceTreeClickListener,
126 PreferenceFragment.OnPreferenceStartFragmentCallback,
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700127 ButtonBarHandler, OnAccountsUpdateListener, FragmentManager.OnBackStackChangedListener,
128 SearchView.OnQueryTextListener, SearchView.OnCloseListener,
129 MenuItem.OnActionExpandListener {
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800130
131 private static final String LOG_TAG = "Settings";
132
133 // Constants for state save/restore
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700134 private static final String SAVE_KEY_CATEGORIES = ":settings:categories";
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700135 private static final String SAVE_KEY_SEARCH_MENU_EXPANDED = ":settings:search_menu_expanded";
136 private static final String SAVE_KEY_SEARCH_QUERY = ":settings:search_query";
Fabrice Di Megliob731dd02014-04-03 18:40:38 -0700137 private static final String SAVE_KEY_SHOW_HOME_AS_UP = ":settings:show_home_as_up";
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700138 private static final String SAVE_KEY_SHOW_SEARCH = ":settings:show_search";
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800139
140 /**
141 * When starting this activity, the invoking Intent can contain this extra
142 * string to specify which fragment should be initially displayed.
143 * <p/>Starting from Key Lime Pie, when this argument is passed in, the activity
144 * will call isValidFragment() to confirm that the fragment class name is valid for this
145 * activity.
146 */
147 public static final String EXTRA_SHOW_FRAGMENT = ":settings:show_fragment";
148
149 /**
150 * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT},
151 * this extra can also be specified to supply a Bundle of arguments to pass
152 * to that fragment when it is instantiated during the initial creation
153 * of the activity.
154 */
155 public static final String EXTRA_SHOW_FRAGMENT_ARGUMENTS = ":settings:show_fragment_args";
156
157 /**
Fabrice Di Meglioc1457322014-04-04 19:07:50 -0700158 * Fragment "key" argument passed thru {@link #EXTRA_SHOW_FRAGMENT_ARGUMENTS}
159 */
160 public static final String EXTRA_FRAGMENT_ARG_KEY = ":settings:fragment_args_key";
161
Fabrice Di Meglio6f0739a2014-02-03 18:12:25 -0800162 public static final String BACK_STACK_PREFS = ":settings:prefs";
163
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800164 // extras that allow any preference activity to be launched as part of a wizard
165
166 // show Back and Next buttons? takes boolean parameter
167 // Back will then return RESULT_CANCELED and Next RESULT_OK
168 protected static final String EXTRA_PREFS_SHOW_BUTTON_BAR = "extra_prefs_show_button_bar";
169
170 // add a Skip button?
171 private static final String EXTRA_PREFS_SHOW_SKIP = "extra_prefs_show_skip";
172
173 // specify custom text for the Back or Next buttons, or cause a button to not appear
174 // at all by setting it to null
175 protected static final String EXTRA_PREFS_SET_NEXT_TEXT = "extra_prefs_set_next_text";
176 protected static final String EXTRA_PREFS_SET_BACK_TEXT = "extra_prefs_set_back_text";
177
178 /**
179 * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT},
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700180 * those extra can also be specify to supply the title or title res id to be shown for
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800181 * that fragment.
182 */
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700183 public static final String EXTRA_SHOW_FRAGMENT_TITLE = ":settings:show_fragment_title";
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700184 public static final String EXTRA_SHOW_FRAGMENT_TITLE_RESID = ":settings:show_fragment_title_resid";
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800185
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800186 private static final String META_DATA_KEY_FRAGMENT_CLASS =
187 "com.android.settings.FRAGMENT_CLASS";
188
189 private static final String EXTRA_UI_OPTIONS = "settings:ui_options";
190
Fabrice Di Megliod6985df2014-04-03 16:43:26 -0700191 private static final String EMPTY_QUERY = "";
192
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800193 private static boolean sShowNoHomeNotice = false;
194
195 private String mFragmentClass;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800196
Fabrice Di Meglio8eb3f0f2014-02-27 15:51:46 -0800197 private CharSequence mInitialTitle;
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700198 private int mInitialTitleResId;
Fabrice Di Meglio8eb3f0f2014-02-27 15:51:46 -0800199
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800200 // Show only these settings for restricted users
201 private int[] SETTINGS_FOR_RESTRICTED = {
202 R.id.wireless_section,
203 R.id.wifi_settings,
204 R.id.bluetooth_settings,
205 R.id.data_usage_settings,
206 R.id.wireless_settings,
207 R.id.device_section,
John Spurlock4e4cdef2014-05-28 09:43:45 -0400208 R.id.notification_settings,
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800209 R.id.display_settings,
210 R.id.storage_settings,
211 R.id.application_settings,
212 R.id.battery_settings,
213 R.id.personal_section,
214 R.id.location_settings,
215 R.id.security_settings,
216 R.id.language_settings,
217 R.id.user_settings,
218 R.id.account_settings,
219 R.id.account_add,
220 R.id.system_section,
221 R.id.date_time_settings,
222 R.id.about_settings,
223 R.id.accessibility_settings,
224 R.id.print_settings,
225 R.id.nfc_payment_settings,
Fabrice Di Meglio2858b792014-02-18 19:35:08 -0800226 R.id.home_settings,
227 R.id.dashboard
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800228 };
229
230 private static final String[] ENTRY_FRAGMENTS = {
231 WirelessSettings.class.getName(),
232 WifiSettings.class.getName(),
233 AdvancedWifiSettings.class.getName(),
234 BluetoothSettings.class.getName(),
235 TetherSettings.class.getName(),
236 WifiP2pSettings.class.getName(),
237 VpnSettings.class.getName(),
238 DateTimeSettings.class.getName(),
239 LocalePicker.class.getName(),
240 InputMethodAndLanguageSettings.class.getName(),
241 SpellCheckersSettings.class.getName(),
242 UserDictionaryList.class.getName(),
243 UserDictionarySettings.class.getName(),
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800244 DisplaySettings.class.getName(),
245 DeviceInfoSettings.class.getName(),
246 ManageApplications.class.getName(),
247 ProcessStatsUi.class.getName(),
248 NotificationStation.class.getName(),
249 LocationSettings.class.getName(),
250 SecuritySettings.class.getName(),
251 PrivacySettings.class.getName(),
252 DeviceAdminSettings.class.getName(),
253 AccessibilitySettings.class.getName(),
254 CaptionPropertiesFragment.class.getName(),
255 com.android.settings.accessibility.ToggleInversionPreferenceFragment.class.getName(),
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800256 com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment.class.getName(),
257 TextToSpeechSettings.class.getName(),
258 Memory.class.getName(),
259 DevelopmentSettings.class.getName(),
260 UsbSettings.class.getName(),
261 AndroidBeam.class.getName(),
262 WifiDisplaySettings.class.getName(),
263 PowerUsageSummary.class.getName(),
264 AccountSyncSettings.class.getName(),
265 CryptKeeperSettings.class.getName(),
266 DataUsageSummary.class.getName(),
267 DreamSettings.class.getName(),
268 UserSettings.class.getName(),
269 NotificationAccessSettings.class.getName(),
John Spurlockc9afadb2014-04-29 18:07:23 -0400270 ConditionProviderSettings.class.getName(),
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800271 ManageAccountsSettings.class.getName(),
272 PrintSettingsFragment.class.getName(),
273 PrintJobSettingsFragment.class.getName(),
274 TrustedCredentialsSettings.class.getName(),
275 PaymentSettings.class.getName(),
276 KeyboardLayoutPickerFragment.class.getName(),
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700277 ZenModeSettings.class.getName(),
278 NotificationSettings.class.getName(),
279 ChooseLockPassword.ChooseLockPasswordFragment.class.getName(),
280 ChooseLockPattern.ChooseLockPatternFragment.class.getName(),
John Spurlockc7f8e8c2014-06-04 19:11:22 -0400281 InstalledAppDetails.class.getName(),
282 BatterySaverSettings.class.getName(),
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800283 };
284
285 private SharedPreferences mDevelopmentPreferences;
286 private SharedPreferences.OnSharedPreferenceChangeListener mDevelopmentPreferencesListener;
287
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800288 private AuthenticatorHelper mAuthenticatorHelper;
289 private boolean mListeningToAccountUpdates;
290
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800291 private boolean mBatteryPresent = true;
292 private BroadcastReceiver mBatteryInfoReceiver = new BroadcastReceiver() {
293
294 @Override
295 public void onReceive(Context context, Intent intent) {
296 String action = intent.getAction();
297 if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
298 boolean batteryPresent = Utils.isBatteryPresent(intent);
299
300 if (mBatteryPresent != batteryPresent) {
301 mBatteryPresent = batteryPresent;
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700302 invalidateCategories();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800303 }
304 }
305 }
306 };
307
Svetoslav990159a2014-04-14 17:14:59 -0700308 private final DynamicIndexableContentMonitor mDynamicIndexableContentMonitor =
309 new DynamicIndexableContentMonitor();
Svetoslav853e4712014-04-14 10:10:25 -0700310
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700311 private ActionBar mActionBar;
Fabrice Di Meglio41937762014-05-13 19:51:59 -0700312 private SwitchBar mSwitchBar;
313
314 private Button mNextButton;
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700315
Fabrice Di Megliob731dd02014-04-03 18:40:38 -0700316 private boolean mDisplayHomeAsUpEnabled;
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700317 private boolean mDisplaySearch;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700318
Fabrice Di Meglio35062d62014-05-13 14:39:41 -0700319 private boolean mIsShowingDashboard;
320
Fabrice Di Meglio59a40552014-05-23 16:46:50 -0700321 private ViewGroup mContent;
322
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700323 private SearchView mSearchView;
324 private MenuItem mSearchMenuItem;
325 private boolean mSearchMenuItemExpanded = false;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700326 private SearchResultsSummary mSearchResultsFragment;
327 private String mSearchQuery;
328
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700329 // Categories
330 private ArrayList<DashboardCategory> mCategories = new ArrayList<DashboardCategory>();
331 private boolean mNeedToRebuildCategories;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800332
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700333 private static final int MSG_BUILD_CATEGORIES = 1;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800334 private Handler mHandler = new Handler() {
335 @Override
336 public void handleMessage(Message msg) {
337 switch (msg.what) {
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700338 case MSG_BUILD_CATEGORIES: {
Fabrice Di Meglio42c4b0a2014-05-22 10:30:03 -0700339 if(mNeedToRebuildCategories) {
340 buildDashboardCategories(mCategories);
341 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800342 } break;
343 }
344 }
345 };
346
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700347 private boolean mNeedToRevertToInitialFragment = false;
348
Fabrice Di Meglio41937762014-05-13 19:51:59 -0700349 public SwitchBar getSwitchBar() {
350 return mSwitchBar;
351 }
352
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700353 public AuthenticatorHelper getAuthenticatorHelper() {
354 return mAuthenticatorHelper;
355 }
356
357 public List<DashboardCategory> getDashboardCategories() {
Fabrice Di Meglio42c4b0a2014-05-22 10:30:03 -0700358 if (mNeedToRebuildCategories || mCategories.size() == 0) {
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700359 buildDashboardCategories(mCategories);
360 mNeedToRebuildCategories = false;
361 }
362 return mCategories;
363 }
364
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800365 @Override
366 public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) {
367 // Override the fragment title for Wallpaper settings
368 int titleRes = pref.getTitleRes();
369 if (pref.getFragment().equals(WallpaperTypeSettings.class.getName())) {
370 titleRes = R.string.wallpaper_settings_fragment_title;
371 } else if (pref.getFragment().equals(OwnerInfoSettings.class.getName())
372 && UserHandle.myUserId() != UserHandle.USER_OWNER) {
373 if (UserManager.get(this).isLinkedUser()) {
374 titleRes = R.string.profile_info_settings_title;
375 } else {
376 titleRes = R.string.user_info_settings_title;
377 }
378 }
379 startPreferencePanel(pref.getFragment(), pref.getExtras(), titleRes, pref.getTitle(),
380 null, 0);
381 return true;
382 }
383
384 @Override
385 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
386 return false;
387 }
388
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700389 private void invalidateCategories() {
390 if (!mHandler.hasMessages(MSG_BUILD_CATEGORIES)) {
391 mHandler.sendEmptyMessage(MSG_BUILD_CATEGORIES);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800392 }
393 }
394
395 @Override
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800396 public void onConfigurationChanged(Configuration newConfig) {
397 super.onConfigurationChanged(newConfig);
Fabrice Di Meglio6f0739a2014-02-03 18:12:25 -0800398 Index.getInstance(this).update();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800399 }
400
401 @Override
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700402 protected void onStart() {
403 super.onStart();
404
405 if (mNeedToRevertToInitialFragment) {
406 revertToInitialFragment();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800407 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800408 }
409
410 @Override
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700411 public boolean onCreateOptionsMenu(Menu menu) {
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700412 if (!mDisplaySearch) {
413 return false;
414 }
415
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700416 MenuInflater inflater = getMenuInflater();
417 inflater.inflate(R.menu.options_menu, menu);
418
419 // Cache the search query (can be overriden by the OnQueryTextListener)
420 final String query = mSearchQuery;
421
Fabrice Di Meglio95937822014-03-31 19:46:42 -0700422 mSearchMenuItem = menu.findItem(R.id.search);
423 mSearchView = (SearchView) mSearchMenuItem.getActionView();
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700424
Fabrice Di Meglio23ae00c2014-04-21 12:43:20 -0700425 if (mSearchMenuItem == null || mSearchView == null) {
426 return false;
427 }
428
Fabrice Di Meglio8c3b0ce2014-05-12 18:54:32 -0700429 if (mSearchResultsFragment != null) {
430 mSearchResultsFragment.setSearchView(mSearchView);
431 }
432
Fabrice Di Meglio95937822014-03-31 19:46:42 -0700433 mSearchMenuItem.setOnActionExpandListener(this);
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700434 mSearchView.setOnQueryTextListener(this);
435 mSearchView.setOnCloseListener(this);
436
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700437 if (mSearchMenuItemExpanded) {
438 mSearchMenuItem.expandActionView();
439 }
440 mSearchView.setQuery(query, true /* submit */);
441
442 return true;
443 }
444
445 @Override
446 protected void onCreate(Bundle savedState) {
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800447 if (getIntent().hasExtra(EXTRA_UI_OPTIONS)) {
448 getWindow().setUiOptions(getIntent().getIntExtra(EXTRA_UI_OPTIONS, 0));
449 }
Fabrice Di Meglio5ebabfc2014-04-21 09:40:46 -0700450
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800451 mAuthenticatorHelper = new AuthenticatorHelper();
452 mAuthenticatorHelper.updateAuthDescriptions(this);
453 mAuthenticatorHelper.onAccountsUpdated(this, null);
454
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800455 mDevelopmentPreferences = getSharedPreferences(DevelopmentSettings.PREF_FILE,
456 Context.MODE_PRIVATE);
457
458 getMetaData();
459
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700460 super.onCreate(savedState);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800461
462 setContentView(R.layout.settings_main);
463
Fabrice Di Meglio59a40552014-05-23 16:46:50 -0700464 mContent = (ViewGroup) findViewById(R.id.prefs);
465
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800466 getFragmentManager().addOnBackStackChangedListener(this);
467
Fabrice Di Megliob731dd02014-04-03 18:40:38 -0700468 mDisplayHomeAsUpEnabled = true;
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700469 mDisplaySearch = true;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800470
Fabrice Di Meglio5cda21b2014-04-21 10:14:28 -0700471 // Getting Intent properties can only be done after the super.onCreate(...)
472 final String initialFragmentName = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
473
Fabrice Di Meglio35062d62014-05-13 14:39:41 -0700474 mIsShowingDashboard = (initialFragmentName == null);
475
476 if (mIsShowingDashboard) {
Fabrice Di Megliodba577f2014-06-06 16:31:45 -0700477 Index.getInstance(getApplicationContext()).update();
Fabrice Di Meglio5cda21b2014-04-21 10:14:28 -0700478 }
479
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700480 if (savedState != null) {
Fabrice Di Meglio1800a9f2014-04-03 19:31:07 -0700481 // We are restarting from a previous saved state; used that to initialize, instead
482 // of starting fresh.
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700483 mSearchMenuItemExpanded = savedState.getBoolean(SAVE_KEY_SEARCH_MENU_EXPANDED);
484 mSearchQuery = savedState.getString(SAVE_KEY_SEARCH_QUERY);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800485
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700486 setTitleFromIntent(getIntent());
Fabrice Di Meglio5529d292014-02-11 19:52:28 -0800487
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700488 ArrayList<DashboardCategory> categories =
489 savedState.getParcelableArrayList(SAVE_KEY_CATEGORIES);
490 if (categories != null) {
Fabrice Di Meglio5f995722014-05-19 19:51:31 -0700491 mCategories.clear();
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700492 mCategories.addAll(categories);
Fabrice Di Megliob643cbf2014-03-10 12:18:39 -0700493 setTitleFromBackStack();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800494 }
Fabrice Di Megliob731dd02014-04-03 18:40:38 -0700495
496 mDisplayHomeAsUpEnabled = savedState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP);
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700497 mDisplaySearch = savedState.getBoolean(SAVE_KEY_SHOW_SEARCH);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800498 } else {
Fabrice Di Meglio35062d62014-05-13 14:39:41 -0700499 if (!mIsShowingDashboard) {
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700500 final ComponentName cn = getIntent().getComponent();
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700501 // No UP nor Search is shown we are launched thru a Settings "shortcut"
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700502 if (!cn.getClassName().equals(SubSettings.class.getName())) {
Fabrice Di Megliob731dd02014-04-03 18:40:38 -0700503 mDisplayHomeAsUpEnabled = false;
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700504 mDisplaySearch = false;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700505 }
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700506 setTitleFromIntent(getIntent());
Fabrice Di Meglioc1457322014-04-04 19:07:50 -0700507
Fabrice Di Meglio5ebabfc2014-04-21 09:40:46 -0700508 Bundle initialArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700509 switchToFragment(initialFragmentName, initialArguments, true, false,
510 mInitialTitleResId, mInitialTitle, false);
Fabrice Di Meglio10afdb82014-02-11 19:50:56 +0000511 } else {
Fabrice Di Meglioe9326d22014-05-13 12:49:14 -0700512 // No UP if we are displaying the main Dashboard
Fabrice Di Megliob731dd02014-04-03 18:40:38 -0700513 mDisplayHomeAsUpEnabled = false;
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700514 mInitialTitleResId = R.string.dashboard_title;
Fabrice Di Meglio42c4b0a2014-05-22 10:30:03 -0700515 switchToFragment(DashboardSummary.class.getName(), null, false, false,
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700516 mInitialTitleResId, mInitialTitle, false);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800517 }
518 }
519
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700520 mActionBar = getActionBar();
Fabrice Di Megliod8aec082014-05-20 10:49:50 -0700521 if (mActionBar != null) {
522 mActionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled);
523 mActionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled);
524 }
Fabrice Di Meglio41937762014-05-13 19:51:59 -0700525 mSwitchBar = (SwitchBar) findViewById(R.id.switch_bar);
526
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800527 // see if we should show Back/Next buttons
528 Intent intent = getIntent();
529 if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)) {
530
Fabrice Di Megliod2b64f32014-05-20 12:55:15 -0700531 View buttonBar = findViewById(R.id.button_bar);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800532 if (buttonBar != null) {
533 buttonBar.setVisibility(View.VISIBLE);
534
Fabrice Di Megliod2b64f32014-05-20 12:55:15 -0700535 Button backButton = (Button)findViewById(R.id.back_button);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800536 backButton.setOnClickListener(new OnClickListener() {
537 public void onClick(View v) {
538 setResult(RESULT_CANCELED);
539 finish();
540 }
541 });
Fabrice Di Megliod2b64f32014-05-20 12:55:15 -0700542 Button skipButton = (Button)findViewById(R.id.skip_button);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800543 skipButton.setOnClickListener(new OnClickListener() {
544 public void onClick(View v) {
545 setResult(RESULT_OK);
546 finish();
547 }
548 });
Fabrice Di Megliod2b64f32014-05-20 12:55:15 -0700549 mNextButton = (Button)findViewById(R.id.next_button);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800550 mNextButton.setOnClickListener(new OnClickListener() {
551 public void onClick(View v) {
552 setResult(RESULT_OK);
553 finish();
554 }
555 });
556
557 // set our various button parameters
558 if (intent.hasExtra(EXTRA_PREFS_SET_NEXT_TEXT)) {
559 String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_NEXT_TEXT);
560 if (TextUtils.isEmpty(buttonText)) {
561 mNextButton.setVisibility(View.GONE);
562 }
563 else {
564 mNextButton.setText(buttonText);
565 }
566 }
567 if (intent.hasExtra(EXTRA_PREFS_SET_BACK_TEXT)) {
568 String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_BACK_TEXT);
569 if (TextUtils.isEmpty(buttonText)) {
570 backButton.setVisibility(View.GONE);
571 }
572 else {
573 backButton.setText(buttonText);
574 }
575 }
576 if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_SKIP, false)) {
577 skipButton.setVisibility(View.VISIBLE);
578 }
579 }
580 }
Fabrice Di Meglioc95be4f2014-03-07 12:57:38 -0800581 }
582
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700583 private void setTitleFromIntent(Intent intent) {
584 final int initialTitleResId = intent.getIntExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1);
585 if (initialTitleResId > 0) {
586 mInitialTitle = null;
587 mInitialTitleResId = initialTitleResId;
588 setTitle(mInitialTitleResId);
589 } else {
590 mInitialTitleResId = -1;
591 final String initialTitle = intent.getStringExtra(EXTRA_SHOW_FRAGMENT_TITLE);
592 mInitialTitle = (initialTitle != null) ? initialTitle : getTitle();
593 setTitle(mInitialTitle);
594 }
595 }
596
Fabrice Di Meglioc95be4f2014-03-07 12:57:38 -0800597 @Override
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800598 public void onBackStackChanged() {
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700599 setTitleFromBackStack();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800600 }
601
Fabrice Di Megliob643cbf2014-03-10 12:18:39 -0700602 private int setTitleFromBackStack() {
Fabrice Di Meglio8eb3f0f2014-02-27 15:51:46 -0800603 final int count = getFragmentManager().getBackStackEntryCount();
Fabrice Di Megliob643cbf2014-03-10 12:18:39 -0700604
Fabrice Di Meglio8eb3f0f2014-02-27 15:51:46 -0800605 if (count == 0) {
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700606 if (mInitialTitleResId > 0) {
607 setTitle(mInitialTitleResId);
608 } else {
609 setTitle(mInitialTitle);
610 }
Fabrice Di Megliob643cbf2014-03-10 12:18:39 -0700611 return 0;
Fabrice Di Meglio5529d292014-02-11 19:52:28 -0800612 }
Fabrice Di Megliob643cbf2014-03-10 12:18:39 -0700613
Fabrice Di Meglio8eb3f0f2014-02-27 15:51:46 -0800614 FragmentManager.BackStackEntry bse = getFragmentManager().getBackStackEntryAt(count - 1);
615 setTitleFromBackStackEntry(bse);
Fabrice Di Megliob643cbf2014-03-10 12:18:39 -0700616
617 return count;
Fabrice Di Meglio8eb3f0f2014-02-27 15:51:46 -0800618 }
619
620 private void setTitleFromBackStackEntry(FragmentManager.BackStackEntry bse) {
621 final CharSequence title;
622 final int titleRes = bse.getBreadCrumbTitleRes();
623 if (titleRes > 0) {
624 title = getText(titleRes);
625 } else {
626 title = bse.getBreadCrumbTitle();
627 }
628 if (title != null) {
629 setTitle(title);
630 }
Fabrice Di Meglio5529d292014-02-11 19:52:28 -0800631 }
632
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800633 @Override
634 protected void onSaveInstanceState(Bundle outState) {
635 super.onSaveInstanceState(outState);
636
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700637 if (mCategories.size() > 0) {
638 outState.putParcelableArrayList(SAVE_KEY_CATEGORIES, mCategories);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800639 }
Fabrice Di Megliod6985df2014-04-03 16:43:26 -0700640
Fabrice Di Megliob731dd02014-04-03 18:40:38 -0700641 outState.putBoolean(SAVE_KEY_SHOW_HOME_AS_UP, mDisplayHomeAsUpEnabled);
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700642 outState.putBoolean(SAVE_KEY_SHOW_SEARCH, mDisplaySearch);
Fabrice Di Megliob731dd02014-04-03 18:40:38 -0700643
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700644 if (mDisplaySearch) {
645 // The option menus are created if the ActionBar is visible and they are also created
646 // asynchronously. If you launch Settings with an Intent action like
647 // android.intent.action.POWER_USAGE_SUMMARY and at the same time your device is locked
648 // thru a LockScreen, onCreateOptionsMenu() is not yet called and references to the search
649 // menu item and search view are null.
650 boolean isExpanded = (mSearchMenuItem != null) && mSearchMenuItem.isActionViewExpanded();
651 outState.putBoolean(SAVE_KEY_SEARCH_MENU_EXPANDED, isExpanded);
Fabrice Di Megliod6985df2014-04-03 16:43:26 -0700652
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700653 String query = (mSearchView != null) ? mSearchView.getQuery().toString() : EMPTY_QUERY;
654 outState.putString(SAVE_KEY_SEARCH_QUERY, query);
655 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800656 }
657
658 @Override
659 public void onResume() {
660 super.onResume();
661
662 mDevelopmentPreferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
663 @Override
664 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Fabrice Di Megliobb051782014-06-04 17:33:25 -0700665 setNeedToRebuildCategories(true);
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700666 invalidateCategories();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800667 }
668 };
669 mDevelopmentPreferences.registerOnSharedPreferenceChangeListener(
670 mDevelopmentPreferencesListener);
671
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800672 registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
Svetoslav853e4712014-04-14 10:10:25 -0700673
Svetoslav990159a2014-04-14 17:14:59 -0700674 mDynamicIndexableContentMonitor.register(this);
Fabrice Di Meglioa3270762014-04-16 16:54:56 -0700675
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700676 if(mDisplaySearch && !TextUtils.isEmpty(mSearchQuery)) {
Fabrice Di Meglioa3270762014-04-16 16:54:56 -0700677 onQueryTextSubmit(mSearchQuery);
678 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800679 }
680
681 @Override
682 public void onPause() {
683 super.onPause();
684
685 unregisterReceiver(mBatteryInfoReceiver);
686
Svetoslav990159a2014-04-14 17:14:59 -0700687 mDynamicIndexableContentMonitor.unregister();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800688 }
689
690 @Override
691 public void onDestroy() {
692 super.onDestroy();
Fabrice Di Meglio680b0642014-05-20 15:19:29 -0700693
694 mDevelopmentPreferences.unregisterOnSharedPreferenceChangeListener(
695 mDevelopmentPreferencesListener);
696 mDevelopmentPreferencesListener = null;
697
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800698 if (mListeningToAccountUpdates) {
699 AccountManager.get(this).removeOnAccountsUpdatedListener(this);
700 }
701 }
702
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800703 protected boolean isValidFragment(String fragmentName) {
704 // Almost all fragments are wrapped in this,
705 // except for a few that have their own activities.
706 for (int i = 0; i < ENTRY_FRAGMENTS.length; i++) {
707 if (ENTRY_FRAGMENTS[i].equals(fragmentName)) return true;
708 }
709 return false;
710 }
711
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800712 @Override
713 public Intent getIntent() {
714 Intent superIntent = super.getIntent();
715 String startingFragment = getStartingFragmentClass(superIntent);
716 // This is called from super.onCreate, isMultiPane() is not yet reliable
717 // Do not use onIsHidingHeaders either, which relies itself on this method
718 if (startingFragment != null) {
719 Intent modIntent = new Intent(superIntent);
720 modIntent.putExtra(EXTRA_SHOW_FRAGMENT, startingFragment);
721 Bundle args = superIntent.getExtras();
722 if (args != null) {
723 args = new Bundle(args);
724 } else {
725 args = new Bundle();
726 }
727 args.putParcelable("intent", superIntent);
728 modIntent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, superIntent.getExtras());
729 return modIntent;
730 }
731 return superIntent;
732 }
733
734 /**
735 * Checks if the component name in the intent is different from the Settings class and
736 * returns the class name to load as a fragment.
737 */
738 private String getStartingFragmentClass(Intent intent) {
739 if (mFragmentClass != null) return mFragmentClass;
740
741 String intentClass = intent.getComponent().getClassName();
742 if (intentClass.equals(getClass().getName())) return null;
743
744 if ("com.android.settings.ManageApplications".equals(intentClass)
745 || "com.android.settings.RunningServices".equals(intentClass)
746 || "com.android.settings.applications.StorageUse".equals(intentClass)) {
747 // Old names of manage apps.
748 intentClass = com.android.settings.applications.ManageApplications.class.getName();
749 }
750
751 return intentClass;
752 }
753
754 /**
Fabrice Di Meglio10afdb82014-02-11 19:50:56 +0000755 * Start a new fragment containing a preference panel. If the preferences
756 * are being displayed in multi-pane mode, the given fragment class will
757 * be instantiated and placed in the appropriate pane. If running in
758 * single-pane mode, a new activity will be launched in which to show the
759 * fragment.
760 *
761 * @param fragmentClass Full name of the class implementing the fragment.
762 * @param args Any desired arguments to supply to the fragment.
763 * @param titleRes Optional resource identifier of the title of this
764 * fragment.
765 * @param titleText Optional text of the title of this fragment.
766 * @param resultTo Optional fragment that result data should be sent to.
767 * If non-null, resultTo.onActivityResult() will be called when this
768 * preference panel is done. The launched panel must use
769 * {@link #finishPreferencePanel(Fragment, int, Intent)} when done.
770 * @param resultRequestCode If resultTo is non-null, this is the caller's
771 * request code to be received with the resut.
772 */
773 public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes,
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700774 CharSequence titleText, Fragment resultTo, int resultRequestCode) {
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700775 String title = null;
776 if (titleRes < 0) {
777 if (titleText != null) {
778 title = titleText.toString();
779 } else {
780 // There not much we can do in that case
781 title = "";
782 }
Fabrice Di Meglio911fb2a2014-04-04 17:55:57 -0700783 }
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700784 Utils.startWithFragment(this, fragmentClass, args, resultTo, resultRequestCode,
785 titleRes, title);
Fabrice Di Meglio10afdb82014-02-11 19:50:56 +0000786 }
787
788 /**
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800789 * Called by a preference panel fragment to finish itself.
790 *
791 * @param caller The fragment that is asking to be finished.
792 * @param resultCode Optional result code to send back to the original
793 * launching fragment.
794 * @param resultData Optional result data to send back to the original
795 * launching fragment.
796 */
797 public void finishPreferencePanel(Fragment caller, int resultCode, Intent resultData) {
798 setResult(resultCode, resultData);
799 }
800
801 /**
Fabrice Di Meglio10afdb82014-02-11 19:50:56 +0000802 * Start a new fragment.
803 *
804 * @param fragment The fragment to start
805 * @param push If true, the current fragment will be pushed onto the back stack. If false,
806 * the current fragment will be replaced.
807 */
808 public void startPreferenceFragment(Fragment fragment, boolean push) {
809 FragmentTransaction transaction = getFragmentManager().beginTransaction();
810 transaction.replace(R.id.prefs, fragment);
811 if (push) {
812 transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
813 transaction.addToBackStack(BACK_STACK_PREFS);
814 } else {
815 transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
816 }
817 transaction.commitAllowingStateLoss();
818 }
819
820 /**
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700821 * Switch to a specific Fragment with taking care of validation, Title and BackStack
822 */
823 private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate,
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700824 boolean addToBackStack, int titleResId, CharSequence title, boolean withTransition) {
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700825 if (validate && !isValidFragment(fragmentName)) {
826 throw new IllegalArgumentException("Invalid fragment for this activity: "
827 + fragmentName);
828 }
829 Fragment f = Fragment.instantiate(this, fragmentName, args);
830 FragmentTransaction transaction = getFragmentManager().beginTransaction();
831 transaction.replace(R.id.prefs, f);
832 if (withTransition) {
Fabrice Di Meglio59a40552014-05-23 16:46:50 -0700833 TransitionManager.beginDelayedTransition(mContent);
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700834 }
835 if (addToBackStack) {
836 transaction.addToBackStack(SettingsActivity.BACK_STACK_PREFS);
837 }
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700838 if (titleResId > 0) {
839 transaction.setBreadCrumbTitle(titleResId);
840 } else if (title != null) {
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700841 transaction.setBreadCrumbTitle(title);
842 }
843 transaction.commitAllowingStateLoss();
Fabrice Di Meglio59a40552014-05-23 16:46:50 -0700844 getFragmentManager().executePendingTransactions();
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700845 return f;
846 }
847
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700848 public void setNeedToRebuildCategories(boolean need) {
849 mNeedToRebuildCategories = need;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700850 }
851
852 /**
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700853 * Called when the activity needs its list of categories/tiles built.
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -0700854 *
855 * @param categories The list in which to place the tiles categories.
856 */
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700857 private void buildDashboardCategories(List<DashboardCategory> categories) {
Fabrice Di Meglio5f995722014-05-19 19:51:31 -0700858 categories.clear();
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -0700859 loadCategoriesFromResource(R.xml.dashboard_categories, categories);
860 updateTilesList(categories);
861 }
862
863 /**
864 * Parse the given XML file as a categories description, adding each
865 * parsed categories and tiles into the target list.
866 *
867 * @param resid The XML resource to load and parse.
868 * @param target The list in which the parsed categories and tiles should be placed.
869 */
870 private void loadCategoriesFromResource(int resid, List<DashboardCategory> target) {
871 XmlResourceParser parser = null;
872 try {
873 parser = getResources().getXml(resid);
874 AttributeSet attrs = Xml.asAttributeSet(parser);
875
876 int type;
877 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
878 && type != XmlPullParser.START_TAG) {
879 // Parse next until start tag is found
880 }
881
882 String nodeName = parser.getName();
883 if (!"dashboard-categories".equals(nodeName)) {
884 throw new RuntimeException(
885 "XML document must start with <preference-categories> tag; found"
886 + nodeName + " at " + parser.getPositionDescription());
887 }
888
889 Bundle curBundle = null;
890
891 final int outerDepth = parser.getDepth();
892 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
893 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
894 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
895 continue;
896 }
897
898 nodeName = parser.getName();
899 if ("dashboard-category".equals(nodeName)) {
900 DashboardCategory category = new DashboardCategory();
901
902 TypedArray sa = obtainStyledAttributes(
903 attrs, com.android.internal.R.styleable.PreferenceHeader);
904 category.id = sa.getResourceId(
905 com.android.internal.R.styleable.PreferenceHeader_id,
906 (int)DashboardCategory.CAT_ID_UNDEFINED);
907
908 TypedValue tv = sa.peekValue(
909 com.android.internal.R.styleable.PreferenceHeader_title);
910 if (tv != null && tv.type == TypedValue.TYPE_STRING) {
911 if (tv.resourceId != 0) {
912 category.titleRes = tv.resourceId;
913 } else {
914 category.title = tv.string;
915 }
916 }
917 sa.recycle();
918
919 final int innerDepth = parser.getDepth();
920 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
921 && (type != XmlPullParser.END_TAG || parser.getDepth() > innerDepth)) {
922 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
923 continue;
924 }
925
926 String innerNodeName = parser.getName();
927 if (innerNodeName.equals("dashboard-tile")) {
928 DashboardTile tile = new DashboardTile();
929
930 sa = obtainStyledAttributes(
931 attrs, com.android.internal.R.styleable.PreferenceHeader);
932 tile.id = sa.getResourceId(
933 com.android.internal.R.styleable.PreferenceHeader_id,
Fabrice Di Meglioe9326d22014-05-13 12:49:14 -0700934 (int)TILE_ID_UNDEFINED);
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -0700935 tv = sa.peekValue(
936 com.android.internal.R.styleable.PreferenceHeader_title);
937 if (tv != null && tv.type == TypedValue.TYPE_STRING) {
938 if (tv.resourceId != 0) {
939 tile.titleRes = tv.resourceId;
940 } else {
941 tile.title = tv.string;
942 }
943 }
944 tv = sa.peekValue(
945 com.android.internal.R.styleable.PreferenceHeader_summary);
946 if (tv != null && tv.type == TypedValue.TYPE_STRING) {
947 if (tv.resourceId != 0) {
948 tile.summaryRes = tv.resourceId;
949 } else {
950 tile.summary = tv.string;
951 }
952 }
953 tile.iconRes = sa.getResourceId(
954 com.android.internal.R.styleable.PreferenceHeader_icon, 0);
955 tile.fragment = sa.getString(
956 com.android.internal.R.styleable.PreferenceHeader_fragment);
957 sa.recycle();
958
959 if (curBundle == null) {
960 curBundle = new Bundle();
961 }
962
963 final int innerDepth2 = parser.getDepth();
964 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
965 && (type != XmlPullParser.END_TAG || parser.getDepth() > innerDepth2)) {
966 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
967 continue;
968 }
969
970 String innerNodeName2 = parser.getName();
971 if (innerNodeName2.equals("extra")) {
972 getResources().parseBundleExtra("extra", attrs, curBundle);
973 XmlUtils.skipCurrentTag(parser);
974
975 } else if (innerNodeName2.equals("intent")) {
976 tile.intent = Intent.parseIntent(getResources(), parser, attrs);
977
978 } else {
979 XmlUtils.skipCurrentTag(parser);
980 }
981 }
982
983 if (curBundle.size() > 0) {
984 tile.fragmentArguments = curBundle;
985 curBundle = null;
986 }
987
988 category.addTile(tile);
989
990 } else {
991 XmlUtils.skipCurrentTag(parser);
992 }
993 }
994
995 target.add(category);
996 } else {
997 XmlUtils.skipCurrentTag(parser);
998 }
999 }
1000
1001 } catch (XmlPullParserException e) {
1002 throw new RuntimeException("Error parsing categories", e);
1003 } catch (IOException e) {
1004 throw new RuntimeException("Error parsing categories", e);
1005 } finally {
1006 if (parser != null) parser.close();
1007 }
1008 }
1009
1010 private void updateTilesList(List<DashboardCategory> target) {
1011 final boolean showDev = mDevelopmentPreferences.getBoolean(
1012 DevelopmentSettings.PREF_SHOW,
1013 android.os.Build.TYPE.equals("eng"));
1014
1015 final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
1016
1017 final int size = target.size();
1018 for (int i = 0; i < size; i++) {
1019
1020 DashboardCategory category = target.get(i);
1021
1022 // Ids are integers, so downcasting is ok
1023 int id = (int) category.id;
1024 if (id == R.id.account_settings) {
1025 insertAccountsTiles(category);
1026 continue;
1027 }
1028 int n = category.getTilesCount() - 1;
1029 while (n >= 0) {
1030
1031 DashboardTile tile = category.getTile(n);
1032
1033 id = (int) tile.id;
1034 if (id == R.id.operator_settings || id == R.id.manufacturer_settings) {
1035 Utils.updateTileToSpecificActivityFromMetaDataOrRemove(this, category, tile);
1036 } else if (id == R.id.wifi_settings) {
1037 // Remove WiFi Settings if WiFi service is not available.
1038 if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) {
1039 category.removeTile(n);
1040 }
1041 } else if (id == R.id.bluetooth_settings) {
1042 // Remove Bluetooth Settings if Bluetooth service is not available.
1043 if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
1044 category.removeTile(n);
1045 }
1046 } else if (id == R.id.data_usage_settings) {
1047 // Remove data usage when kernel module not enabled
1048 final INetworkManagementService netManager = INetworkManagementService.Stub
1049 .asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
1050 try {
1051 if (!netManager.isBandwidthControlEnabled()) {
1052 category.removeTile(n);
1053 }
1054 } catch (RemoteException e) {
1055 // ignored
1056 }
1057 } else if (id == R.id.battery_settings) {
1058 // Remove battery settings when battery is not available. (e.g. TV)
1059
1060 if (!mBatteryPresent) {
1061 category.removeTile(n);
1062 }
1063 } else if (id == R.id.home_settings) {
1064 if (!updateHomeSettingTiles(tile)) {
1065 category.removeTile(n);
1066 }
1067 } else if (id == R.id.user_settings) {
Amith Yamasani4093e402014-06-06 14:31:37 -07001068 boolean hasMultipleUsers =
1069 ((UserManager) getSystemService(Context.USER_SERVICE))
1070 .getUserCount() > 1;
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -07001071 if (!UserHandle.MU_ENABLED
Amith Yamasani4093e402014-06-06 14:31:37 -07001072 || (!UserManager.supportsMultipleUsers()
1073 && !hasMultipleUsers)
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -07001074 || Utils.isMonkeyRunning()) {
1075 category.removeTile(n);
1076 }
1077 } else if (id == R.id.nfc_payment_settings) {
1078 if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) {
1079 category.removeTile(n);
1080 } else {
1081 // Only show if NFC is on and we have the HCE feature
1082 NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this);
1083 if (!adapter.isEnabled() || !getPackageManager().hasSystemFeature(
1084 PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
1085 category.removeTile(n);
1086 }
1087 }
Fabrice Di Meglio488cae32014-05-13 11:26:34 -07001088 } else if (id == R.id.print_settings) {
1089 boolean hasPrintingSupport = getPackageManager().hasSystemFeature(
1090 PackageManager.FEATURE_PRINTING);
1091 if (!hasPrintingSupport) {
1092 category.removeTile(n);
1093 }
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -07001094 } else if (id == R.id.development_settings) {
Julia Reynolds6c088cb2014-05-08 09:29:41 -04001095 if (!showDev || um.hasUserRestriction(
1096 UserManager.DISALLOW_DEBUGGING_FEATURES)) {
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -07001097 category.removeTile(n);
1098 }
1099 } else if (id == R.id.account_add) {
1100 if (um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) {
1101 category.removeTile(n);
1102 }
1103 }
1104
1105 if (UserHandle.MU_ENABLED && UserHandle.myUserId() != 0
Amith Yamasania97089d2014-04-30 10:58:09 -07001106 && !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, id)
1107 && n < category.getTilesCount()) {
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -07001108 category.removeTile(n);
1109 }
1110
1111 n--;
1112 }
1113 }
1114 }
1115
1116 private boolean updateHomeSettingTiles(DashboardTile tile) {
1117 // Once we decide to show Home settings, keep showing it forever
1118 SharedPreferences sp = getSharedPreferences(HomeSettings.HOME_PREFS, Context.MODE_PRIVATE);
1119 if (sp.getBoolean(HomeSettings.HOME_PREFS_DO_SHOW, false)) {
1120 return true;
1121 }
1122
1123 try {
1124 final ArrayList<ResolveInfo> homeApps = new ArrayList<ResolveInfo>();
1125 getPackageManager().getHomeActivities(homeApps);
1126 if (homeApps.size() < 2) {
1127 // When there's only one available home app, omit this settings
1128 // category entirely at the top level UI. If the user just
1129 // uninstalled the penultimate home app candidiate, we also
1130 // now tell them about why they aren't seeing 'Home' in the list.
1131 if (sShowNoHomeNotice) {
1132 sShowNoHomeNotice = false;
1133 NoHomeDialogFragment.show(this);
1134 }
1135 return false;
1136 } else {
1137 // Okay, we're allowing the Home settings category. Tell it, when
1138 // invoked via this front door, that we'll need to be told about the
1139 // case when the user uninstalls all but one home app.
1140 if (tile.fragmentArguments == null) {
1141 tile.fragmentArguments = new Bundle();
1142 }
1143 tile.fragmentArguments.putBoolean(HomeSettings.HOME_SHOW_NOTICE, true);
1144 }
1145 } catch (Exception e) {
1146 // Can't look up the home activity; bail on configuring the icon
1147 Log.w(LOG_TAG, "Problem looking up home activity!", e);
1148 }
1149
1150 sp.edit().putBoolean(HomeSettings.HOME_PREFS_DO_SHOW, true).apply();
1151 return true;
1152 }
1153
1154 private void insertAccountsTiles(DashboardCategory target) {
1155 String[] accountTypes = mAuthenticatorHelper.getEnabledAccountTypes();
1156 List<DashboardTile> dashboardTiles = new ArrayList<DashboardTile>(accountTypes.length);
1157 for (String accountType : accountTypes) {
1158 CharSequence label = mAuthenticatorHelper.getLabelForType(this, accountType);
1159 if (label == null) {
1160 continue;
1161 }
1162
1163 Account[] accounts = AccountManager.get(this).getAccountsByType(accountType);
1164 boolean skipToAccount = accounts.length == 1
1165 && !mAuthenticatorHelper.hasAccountPreferences(accountType);
1166 DashboardTile accountTile = new DashboardTile();
1167 accountTile.title = label;
1168 if (accountTile.extras == null) {
1169 accountTile.extras = new Bundle();
1170 }
1171 if (skipToAccount) {
1172 accountTile.fragment = AccountSyncSettings.class.getName();
1173 accountTile.fragmentArguments = new Bundle();
1174 // Need this for the icon
1175 accountTile.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType);
1176 accountTile.extras.putParcelable(AccountSyncSettings.ACCOUNT_KEY, accounts[0]);
1177 accountTile.fragmentArguments.putParcelable(AccountSyncSettings.ACCOUNT_KEY,
1178 accounts[0]);
1179 } else {
1180 accountTile.fragment = ManageAccountsSettings.class.getName();
1181 accountTile.fragmentArguments = new Bundle();
1182 accountTile.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType);
1183 accountTile.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE,
1184 accountType);
1185 accountTile.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_LABEL,
1186 label.toString());
1187 }
1188 dashboardTiles.add(accountTile);
1189 mAuthenticatorHelper.preloadDrawableForType(this, accountType);
1190 }
1191
1192 // Sort by label
1193 Collections.sort(dashboardTiles, new Comparator<DashboardTile>() {
1194 @Override
1195 public int compare(DashboardTile t1, DashboardTile t2) {
1196 return t1.title.toString().compareTo(t2.title.toString());
1197 }
1198 });
1199 int index = 0;
1200 for (DashboardTile tile : dashboardTiles) {
1201 target.addTile(index, tile);
1202 index++;
1203 }
1204 if (!mListeningToAccountUpdates) {
1205 AccountManager.get(this).addOnAccountsUpdatedListener(this, null, true);
1206 mListeningToAccountUpdates = true;
1207 }
1208 }
1209
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001210 private void getMetaData() {
1211 try {
1212 ActivityInfo ai = getPackageManager().getActivityInfo(getComponentName(),
1213 PackageManager.GET_META_DATA);
1214 if (ai == null || ai.metaData == null) return;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001215 mFragmentClass = ai.metaData.getString(META_DATA_KEY_FRAGMENT_CLASS);
1216 } catch (NameNotFoundException nnfe) {
1217 // No recovery
1218 Log.d(LOG_TAG, "Cannot get Metadata for: " + getComponentName().toString());
1219 }
1220 }
1221
1222 // give subclasses access to the Next button
1223 public boolean hasNextButton() {
1224 return mNextButton != null;
1225 }
1226
1227 public Button getNextButton() {
1228 return mNextButton;
1229 }
1230
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001231 @Override
1232 public boolean shouldUpRecreateTask(Intent targetIntent) {
1233 return super.shouldUpRecreateTask(new Intent(this, SettingsActivity.class));
1234 }
1235
1236 @Override
1237 public void onAccountsUpdated(Account[] accounts) {
1238 // TODO: watch for package upgrades to invalidate cache; see 7206643
1239 mAuthenticatorHelper.updateAuthDescriptions(this);
1240 mAuthenticatorHelper.onAccountsUpdated(this, accounts);
Fabrice Di Meglio769630c2014-04-24 14:48:48 -07001241 invalidateCategories();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001242 }
1243
1244 public static void requestHomeNotice() {
1245 sShowNoHomeNotice = true;
1246 }
1247
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001248 @Override
1249 public boolean onQueryTextSubmit(String query) {
1250 switchToSearchResultsFragmentIfNeeded();
1251 mSearchQuery = query;
1252 return mSearchResultsFragment.onQueryTextSubmit(query);
1253 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001254
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001255 @Override
1256 public boolean onQueryTextChange(String newText) {
1257 mSearchQuery = newText;
Fabrice Di Meglio7e4855e2014-05-23 16:03:43 -07001258 if (mSearchResultsFragment == null) {
Fabrice Di Meglioa3270762014-04-16 16:54:56 -07001259 return false;
1260 }
1261 return mSearchResultsFragment.onQueryTextChange(newText);
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001262 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001263
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001264 @Override
1265 public boolean onClose() {
1266 return false;
1267 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001268
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001269 @Override
1270 public boolean onMenuItemActionExpand(MenuItem item) {
1271 if (item.getItemId() == mSearchMenuItem.getItemId()) {
Fabrice Di Megliobb16fd82014-04-04 14:48:05 -07001272 switchToSearchResultsFragmentIfNeeded();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001273 }
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001274 return true;
1275 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001276
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001277 @Override
1278 public boolean onMenuItemActionCollapse(MenuItem item) {
1279 if (item.getItemId() == mSearchMenuItem.getItemId()) {
Fabrice Di Megliobb16fd82014-04-04 14:48:05 -07001280 if (mSearchMenuItemExpanded) {
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001281 revertToInitialFragment();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001282 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001283 }
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001284 return true;
1285 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001286
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001287 private void switchToSearchResultsFragmentIfNeeded() {
Fabrice Di Megliobb16fd82014-04-04 14:48:05 -07001288 if (mSearchResultsFragment != null) {
1289 return;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001290 }
Fabrice Di Megliobb16fd82014-04-04 14:48:05 -07001291 Fragment current = getFragmentManager().findFragmentById(R.id.prefs);
1292 if (current != null && current instanceof SearchResultsSummary) {
1293 mSearchResultsFragment = (SearchResultsSummary) current;
1294 } else {
Fabrice Di Megliobb16fd82014-04-04 14:48:05 -07001295 mSearchResultsFragment = (SearchResultsSummary) switchToFragment(
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -07001296 SearchResultsSummary.class.getName(), null, false, true,
1297 R.string.search_results_title, null, true);
Fabrice Di Megliobb16fd82014-04-04 14:48:05 -07001298 }
Fabrice Di Megliod297a582014-04-22 17:23:23 -07001299 mSearchResultsFragment.setSearchView(mSearchView);
Fabrice Di Megliobb16fd82014-04-04 14:48:05 -07001300 mSearchMenuItemExpanded = true;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001301 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001302
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001303 public void needToRevertToInitialFragment() {
1304 mNeedToRevertToInitialFragment = true;
1305 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001306
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001307 private void revertToInitialFragment() {
1308 mNeedToRevertToInitialFragment = false;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001309 mSearchResultsFragment = null;
Fabrice Di Megliobb16fd82014-04-04 14:48:05 -07001310 mSearchMenuItemExpanded = false;
1311 getFragmentManager().popBackStackImmediate(SettingsActivity.BACK_STACK_PREFS,
1312 FragmentManager.POP_BACK_STACK_INCLUSIVE);
Fabrice Di Meglio23ae00c2014-04-21 12:43:20 -07001313 if (mSearchMenuItem != null) {
1314 mSearchMenuItem.collapseActionView();
1315 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001316 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001317}