blob: c5204d78145d792ca1f73325f38b02d487a90eb8 [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 Meglio263bcc82014-01-17 19:17:58 -080066
Fabrice Di Megliod25314d2014-03-21 19:24:43 -070067import android.widget.SearchView;
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;
86import com.android.settings.fuelgauge.PowerUsageSummary;
Fabrice Di Meglio7a6bfd12014-04-14 19:49:18 -070087import com.android.settings.search.DynamicIndexableContentMonitor;
Fabrice Di Megliofa7dc242014-03-12 19:24:43 -070088import com.android.settings.search.Index;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080089import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
90import com.android.settings.inputmethod.KeyboardLayoutPickerFragment;
91import com.android.settings.inputmethod.SpellCheckersSettings;
92import com.android.settings.inputmethod.UserDictionaryList;
93import com.android.settings.location.LocationSettings;
94import com.android.settings.nfc.AndroidBeam;
95import com.android.settings.nfc.PaymentSettings;
John Spurlockc9afadb2014-04-29 18:07:23 -040096import com.android.settings.notification.ConditionProviderSettings;
John Spurlock4a350512014-04-08 14:08:21 -040097import com.android.settings.notification.NotificationAccessSettings;
98import com.android.settings.notification.NotificationSettings;
99import com.android.settings.notification.NotificationStation;
100import com.android.settings.notification.ZenModeSettings;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800101import com.android.settings.print.PrintJobSettingsFragment;
102import com.android.settings.print.PrintSettingsFragment;
103import com.android.settings.tts.TextToSpeechSettings;
104import com.android.settings.users.UserSettings;
105import com.android.settings.vpn2.VpnSettings;
106import com.android.settings.wfd.WifiDisplaySettings;
Fabrice Di Meglio41937762014-05-13 19:51:59 -0700107import com.android.settings.widget.SwitchBar;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800108import com.android.settings.wifi.AdvancedWifiSettings;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800109import com.android.settings.wifi.WifiSettings;
110import com.android.settings.wifi.p2p.WifiP2pSettings;
111import org.xmlpull.v1.XmlPullParser;
112import org.xmlpull.v1.XmlPullParserException;
113
114import java.io.IOException;
115import java.util.ArrayList;
116import java.util.Collections;
117import java.util.Comparator;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800118import java.util.List;
119
Fabrice Di Meglioe9326d22014-05-13 12:49:14 -0700120import static com.android.settings.dashboard.DashboardTile.TILE_ID_UNDEFINED;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700121
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800122public class SettingsActivity extends Activity
123 implements PreferenceManager.OnPreferenceTreeClickListener,
124 PreferenceFragment.OnPreferenceStartFragmentCallback,
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700125 ButtonBarHandler, OnAccountsUpdateListener, FragmentManager.OnBackStackChangedListener,
126 SearchView.OnQueryTextListener, SearchView.OnCloseListener,
127 MenuItem.OnActionExpandListener {
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800128
129 private static final String LOG_TAG = "Settings";
130
131 // Constants for state save/restore
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700132 private static final String SAVE_KEY_CATEGORIES = ":settings:categories";
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700133 private static final String SAVE_KEY_SEARCH_MENU_EXPANDED = ":settings:search_menu_expanded";
134 private static final String SAVE_KEY_SEARCH_QUERY = ":settings:search_query";
Fabrice Di Megliob731dd02014-04-03 18:40:38 -0700135 private static final String SAVE_KEY_SHOW_HOME_AS_UP = ":settings:show_home_as_up";
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700136 private static final String SAVE_KEY_SHOW_SEARCH = ":settings:show_search";
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800137
138 /**
139 * When starting this activity, the invoking Intent can contain this extra
140 * string to specify which fragment should be initially displayed.
141 * <p/>Starting from Key Lime Pie, when this argument is passed in, the activity
142 * will call isValidFragment() to confirm that the fragment class name is valid for this
143 * activity.
144 */
145 public static final String EXTRA_SHOW_FRAGMENT = ":settings:show_fragment";
146
147 /**
148 * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT},
149 * this extra can also be specified to supply a Bundle of arguments to pass
150 * to that fragment when it is instantiated during the initial creation
151 * of the activity.
152 */
153 public static final String EXTRA_SHOW_FRAGMENT_ARGUMENTS = ":settings:show_fragment_args";
154
155 /**
Fabrice Di Meglioc1457322014-04-04 19:07:50 -0700156 * Fragment "key" argument passed thru {@link #EXTRA_SHOW_FRAGMENT_ARGUMENTS}
157 */
158 public static final String EXTRA_FRAGMENT_ARG_KEY = ":settings:fragment_args_key";
159
Fabrice Di Meglio6f0739a2014-02-03 18:12:25 -0800160 public static final String BACK_STACK_PREFS = ":settings:prefs";
161
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800162 // extras that allow any preference activity to be launched as part of a wizard
163
164 // show Back and Next buttons? takes boolean parameter
165 // Back will then return RESULT_CANCELED and Next RESULT_OK
166 protected static final String EXTRA_PREFS_SHOW_BUTTON_BAR = "extra_prefs_show_button_bar";
167
168 // add a Skip button?
169 private static final String EXTRA_PREFS_SHOW_SKIP = "extra_prefs_show_skip";
170
171 // specify custom text for the Back or Next buttons, or cause a button to not appear
172 // at all by setting it to null
173 protected static final String EXTRA_PREFS_SET_NEXT_TEXT = "extra_prefs_set_next_text";
174 protected static final String EXTRA_PREFS_SET_BACK_TEXT = "extra_prefs_set_back_text";
175
176 /**
177 * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT},
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700178 * 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 -0800179 * that fragment.
180 */
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700181 public static final String EXTRA_SHOW_FRAGMENT_TITLE = ":settings:show_fragment_title";
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700182 public static final String EXTRA_SHOW_FRAGMENT_TITLE_RESID = ":settings:show_fragment_title_resid";
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800183
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800184 private static final String META_DATA_KEY_FRAGMENT_CLASS =
185 "com.android.settings.FRAGMENT_CLASS";
186
187 private static final String EXTRA_UI_OPTIONS = "settings:ui_options";
188
Fabrice Di Megliod6985df2014-04-03 16:43:26 -0700189 private static final String EMPTY_QUERY = "";
190
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800191 private static boolean sShowNoHomeNotice = false;
192
193 private String mFragmentClass;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800194
Fabrice Di Meglio8eb3f0f2014-02-27 15:51:46 -0800195 private CharSequence mInitialTitle;
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700196 private int mInitialTitleResId;
Fabrice Di Meglio8eb3f0f2014-02-27 15:51:46 -0800197
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800198 // Show only these settings for restricted users
199 private int[] SETTINGS_FOR_RESTRICTED = {
200 R.id.wireless_section,
201 R.id.wifi_settings,
202 R.id.bluetooth_settings,
203 R.id.data_usage_settings,
204 R.id.wireless_settings,
205 R.id.device_section,
John Spurlock4e4cdef2014-05-28 09:43:45 -0400206 R.id.notification_settings,
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800207 R.id.display_settings,
208 R.id.storage_settings,
209 R.id.application_settings,
210 R.id.battery_settings,
211 R.id.personal_section,
212 R.id.location_settings,
213 R.id.security_settings,
214 R.id.language_settings,
215 R.id.user_settings,
216 R.id.account_settings,
217 R.id.account_add,
218 R.id.system_section,
219 R.id.date_time_settings,
220 R.id.about_settings,
221 R.id.accessibility_settings,
222 R.id.print_settings,
223 R.id.nfc_payment_settings,
Fabrice Di Meglio2858b792014-02-18 19:35:08 -0800224 R.id.home_settings,
225 R.id.dashboard
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800226 };
227
228 private static final String[] ENTRY_FRAGMENTS = {
229 WirelessSettings.class.getName(),
230 WifiSettings.class.getName(),
231 AdvancedWifiSettings.class.getName(),
232 BluetoothSettings.class.getName(),
233 TetherSettings.class.getName(),
234 WifiP2pSettings.class.getName(),
235 VpnSettings.class.getName(),
236 DateTimeSettings.class.getName(),
237 LocalePicker.class.getName(),
238 InputMethodAndLanguageSettings.class.getName(),
239 SpellCheckersSettings.class.getName(),
240 UserDictionaryList.class.getName(),
241 UserDictionarySettings.class.getName(),
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800242 DisplaySettings.class.getName(),
243 DeviceInfoSettings.class.getName(),
244 ManageApplications.class.getName(),
245 ProcessStatsUi.class.getName(),
246 NotificationStation.class.getName(),
247 LocationSettings.class.getName(),
248 SecuritySettings.class.getName(),
249 PrivacySettings.class.getName(),
250 DeviceAdminSettings.class.getName(),
251 AccessibilitySettings.class.getName(),
252 CaptionPropertiesFragment.class.getName(),
253 com.android.settings.accessibility.ToggleInversionPreferenceFragment.class.getName(),
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800254 com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment.class.getName(),
255 TextToSpeechSettings.class.getName(),
256 Memory.class.getName(),
257 DevelopmentSettings.class.getName(),
258 UsbSettings.class.getName(),
259 AndroidBeam.class.getName(),
260 WifiDisplaySettings.class.getName(),
261 PowerUsageSummary.class.getName(),
262 AccountSyncSettings.class.getName(),
263 CryptKeeperSettings.class.getName(),
264 DataUsageSummary.class.getName(),
265 DreamSettings.class.getName(),
266 UserSettings.class.getName(),
267 NotificationAccessSettings.class.getName(),
John Spurlockc9afadb2014-04-29 18:07:23 -0400268 ConditionProviderSettings.class.getName(),
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800269 ManageAccountsSettings.class.getName(),
270 PrintSettingsFragment.class.getName(),
271 PrintJobSettingsFragment.class.getName(),
272 TrustedCredentialsSettings.class.getName(),
273 PaymentSettings.class.getName(),
274 KeyboardLayoutPickerFragment.class.getName(),
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700275 ZenModeSettings.class.getName(),
276 NotificationSettings.class.getName(),
277 ChooseLockPassword.ChooseLockPasswordFragment.class.getName(),
278 ChooseLockPattern.ChooseLockPatternFragment.class.getName(),
279 InstalledAppDetails.class.getName()
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800280 };
281
282 private SharedPreferences mDevelopmentPreferences;
283 private SharedPreferences.OnSharedPreferenceChangeListener mDevelopmentPreferencesListener;
284
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800285 private AuthenticatorHelper mAuthenticatorHelper;
286 private boolean mListeningToAccountUpdates;
287
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800288 private boolean mBatteryPresent = true;
289 private BroadcastReceiver mBatteryInfoReceiver = new BroadcastReceiver() {
290
291 @Override
292 public void onReceive(Context context, Intent intent) {
293 String action = intent.getAction();
294 if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
295 boolean batteryPresent = Utils.isBatteryPresent(intent);
296
297 if (mBatteryPresent != batteryPresent) {
298 mBatteryPresent = batteryPresent;
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700299 invalidateCategories();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800300 }
301 }
302 }
303 };
304
Svetoslav990159a2014-04-14 17:14:59 -0700305 private final DynamicIndexableContentMonitor mDynamicIndexableContentMonitor =
306 new DynamicIndexableContentMonitor();
Svetoslav853e4712014-04-14 10:10:25 -0700307
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700308 private ActionBar mActionBar;
Fabrice Di Meglio41937762014-05-13 19:51:59 -0700309 private SwitchBar mSwitchBar;
310
311 private Button mNextButton;
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700312
Fabrice Di Megliob731dd02014-04-03 18:40:38 -0700313 private boolean mDisplayHomeAsUpEnabled;
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700314 private boolean mDisplaySearch;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700315
Fabrice Di Meglio35062d62014-05-13 14:39:41 -0700316 private boolean mIsShowingDashboard;
317
Fabrice Di Meglio59a40552014-05-23 16:46:50 -0700318 private ViewGroup mContent;
319
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700320 private SearchView mSearchView;
321 private MenuItem mSearchMenuItem;
322 private boolean mSearchMenuItemExpanded = false;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700323 private SearchResultsSummary mSearchResultsFragment;
324 private String mSearchQuery;
325
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700326 // Categories
327 private ArrayList<DashboardCategory> mCategories = new ArrayList<DashboardCategory>();
328 private boolean mNeedToRebuildCategories;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800329
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700330 private static final int MSG_BUILD_CATEGORIES = 1;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800331 private Handler mHandler = new Handler() {
332 @Override
333 public void handleMessage(Message msg) {
334 switch (msg.what) {
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700335 case MSG_BUILD_CATEGORIES: {
Fabrice Di Meglio42c4b0a2014-05-22 10:30:03 -0700336 if(mNeedToRebuildCategories) {
337 buildDashboardCategories(mCategories);
338 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800339 } break;
340 }
341 }
342 };
343
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700344 private boolean mNeedToRevertToInitialFragment = false;
345
Fabrice Di Meglio41937762014-05-13 19:51:59 -0700346 public SwitchBar getSwitchBar() {
347 return mSwitchBar;
348 }
349
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700350 public AuthenticatorHelper getAuthenticatorHelper() {
351 return mAuthenticatorHelper;
352 }
353
354 public List<DashboardCategory> getDashboardCategories() {
Fabrice Di Meglio42c4b0a2014-05-22 10:30:03 -0700355 if (mNeedToRebuildCategories || mCategories.size() == 0) {
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700356 buildDashboardCategories(mCategories);
357 mNeedToRebuildCategories = false;
358 }
359 return mCategories;
360 }
361
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800362 @Override
363 public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) {
364 // Override the fragment title for Wallpaper settings
365 int titleRes = pref.getTitleRes();
366 if (pref.getFragment().equals(WallpaperTypeSettings.class.getName())) {
367 titleRes = R.string.wallpaper_settings_fragment_title;
368 } else if (pref.getFragment().equals(OwnerInfoSettings.class.getName())
369 && UserHandle.myUserId() != UserHandle.USER_OWNER) {
370 if (UserManager.get(this).isLinkedUser()) {
371 titleRes = R.string.profile_info_settings_title;
372 } else {
373 titleRes = R.string.user_info_settings_title;
374 }
375 }
376 startPreferencePanel(pref.getFragment(), pref.getExtras(), titleRes, pref.getTitle(),
377 null, 0);
378 return true;
379 }
380
381 @Override
382 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
383 return false;
384 }
385
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700386 private void invalidateCategories() {
387 if (!mHandler.hasMessages(MSG_BUILD_CATEGORIES)) {
388 mHandler.sendEmptyMessage(MSG_BUILD_CATEGORIES);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800389 }
390 }
391
392 @Override
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800393 public void onConfigurationChanged(Configuration newConfig) {
394 super.onConfigurationChanged(newConfig);
Fabrice Di Meglio6f0739a2014-02-03 18:12:25 -0800395 Index.getInstance(this).update();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800396 }
397
398 @Override
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700399 protected void onStart() {
400 super.onStart();
401
402 if (mNeedToRevertToInitialFragment) {
403 revertToInitialFragment();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800404 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800405 }
406
407 @Override
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700408 public boolean onCreateOptionsMenu(Menu menu) {
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700409 if (!mDisplaySearch) {
410 return false;
411 }
412
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700413 MenuInflater inflater = getMenuInflater();
414 inflater.inflate(R.menu.options_menu, menu);
415
416 // Cache the search query (can be overriden by the OnQueryTextListener)
417 final String query = mSearchQuery;
418
Fabrice Di Meglio95937822014-03-31 19:46:42 -0700419 mSearchMenuItem = menu.findItem(R.id.search);
420 mSearchView = (SearchView) mSearchMenuItem.getActionView();
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700421
Fabrice Di Meglio23ae00c2014-04-21 12:43:20 -0700422 if (mSearchMenuItem == null || mSearchView == null) {
423 return false;
424 }
425
Fabrice Di Meglio8c3b0ce2014-05-12 18:54:32 -0700426 if (mSearchResultsFragment != null) {
427 mSearchResultsFragment.setSearchView(mSearchView);
428 }
429
Fabrice Di Meglio95937822014-03-31 19:46:42 -0700430 mSearchMenuItem.setOnActionExpandListener(this);
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700431 mSearchView.setOnQueryTextListener(this);
432 mSearchView.setOnCloseListener(this);
433
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700434 if (mSearchMenuItemExpanded) {
435 mSearchMenuItem.expandActionView();
436 }
437 mSearchView.setQuery(query, true /* submit */);
438
439 return true;
440 }
441
442 @Override
443 protected void onCreate(Bundle savedState) {
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800444 if (getIntent().hasExtra(EXTRA_UI_OPTIONS)) {
445 getWindow().setUiOptions(getIntent().getIntExtra(EXTRA_UI_OPTIONS, 0));
446 }
Fabrice Di Meglio5ebabfc2014-04-21 09:40:46 -0700447
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800448 mAuthenticatorHelper = new AuthenticatorHelper();
449 mAuthenticatorHelper.updateAuthDescriptions(this);
450 mAuthenticatorHelper.onAccountsUpdated(this, null);
451
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800452 mDevelopmentPreferences = getSharedPreferences(DevelopmentSettings.PREF_FILE,
453 Context.MODE_PRIVATE);
454
455 getMetaData();
456
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700457 super.onCreate(savedState);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800458
Fabrice Di Meglioda8baba2014-06-10 17:12:51 -0700459 // Getting Intent properties can only be done after the super.onCreate(...)
460 final String initialFragmentName = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
461
462 mIsShowingDashboard = (initialFragmentName == null);
463
464 final ComponentName cn = getIntent().getComponent();
465 final boolean isShortcut = !cn.getClassName().equals(SubSettings.class.getName());
466
467 // If this is a subsettings (but not a Shortcut) then apply the correct theme for
468 // the ActionBar content inset
469 if (!mIsShowingDashboard && !isShortcut) {
470 setTheme(R.style.Theme_SubSettings);
471 }
472
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800473 setContentView(R.layout.settings_main);
474
Fabrice Di Meglio59a40552014-05-23 16:46:50 -0700475 mContent = (ViewGroup) findViewById(R.id.prefs);
476
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800477 getFragmentManager().addOnBackStackChangedListener(this);
478
Fabrice Di Megliob731dd02014-04-03 18:40:38 -0700479 mDisplayHomeAsUpEnabled = true;
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700480 mDisplaySearch = true;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800481
Fabrice Di Meglio35062d62014-05-13 14:39:41 -0700482 if (mIsShowingDashboard) {
Fabrice Di Megliodba577f2014-06-06 16:31:45 -0700483 Index.getInstance(getApplicationContext()).update();
Fabrice Di Meglio5cda21b2014-04-21 10:14:28 -0700484 }
485
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700486 if (savedState != null) {
Fabrice Di Meglio1800a9f2014-04-03 19:31:07 -0700487 // We are restarting from a previous saved state; used that to initialize, instead
488 // of starting fresh.
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700489 mSearchMenuItemExpanded = savedState.getBoolean(SAVE_KEY_SEARCH_MENU_EXPANDED);
490 mSearchQuery = savedState.getString(SAVE_KEY_SEARCH_QUERY);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800491
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700492 setTitleFromIntent(getIntent());
Fabrice Di Meglio5529d292014-02-11 19:52:28 -0800493
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700494 ArrayList<DashboardCategory> categories =
495 savedState.getParcelableArrayList(SAVE_KEY_CATEGORIES);
496 if (categories != null) {
Fabrice Di Meglio5f995722014-05-19 19:51:31 -0700497 mCategories.clear();
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700498 mCategories.addAll(categories);
Fabrice Di Megliob643cbf2014-03-10 12:18:39 -0700499 setTitleFromBackStack();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800500 }
Fabrice Di Megliob731dd02014-04-03 18:40:38 -0700501
502 mDisplayHomeAsUpEnabled = savedState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP);
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700503 mDisplaySearch = savedState.getBoolean(SAVE_KEY_SHOW_SEARCH);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800504 } else {
Fabrice Di Meglio35062d62014-05-13 14:39:41 -0700505 if (!mIsShowingDashboard) {
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700506 // No UP nor Search is shown we are launched thru a Settings "shortcut"
Fabrice Di Meglioda8baba2014-06-10 17:12:51 -0700507 if (isShortcut) {
Fabrice Di Megliob731dd02014-04-03 18:40:38 -0700508 mDisplayHomeAsUpEnabled = false;
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700509 mDisplaySearch = false;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700510 }
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700511 setTitleFromIntent(getIntent());
Fabrice Di Meglioc1457322014-04-04 19:07:50 -0700512
Fabrice Di Meglio5ebabfc2014-04-21 09:40:46 -0700513 Bundle initialArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700514 switchToFragment(initialFragmentName, initialArguments, true, false,
515 mInitialTitleResId, mInitialTitle, false);
Fabrice Di Meglio10afdb82014-02-11 19:50:56 +0000516 } else {
Fabrice Di Meglioe9326d22014-05-13 12:49:14 -0700517 // No UP if we are displaying the main Dashboard
Fabrice Di Megliob731dd02014-04-03 18:40:38 -0700518 mDisplayHomeAsUpEnabled = false;
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700519 mInitialTitleResId = R.string.dashboard_title;
Fabrice Di Meglio42c4b0a2014-05-22 10:30:03 -0700520 switchToFragment(DashboardSummary.class.getName(), null, false, false,
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700521 mInitialTitleResId, mInitialTitle, false);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800522 }
523 }
524
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700525 mActionBar = getActionBar();
Fabrice Di Megliod8aec082014-05-20 10:49:50 -0700526 if (mActionBar != null) {
527 mActionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled);
528 mActionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled);
529 }
Fabrice Di Meglio41937762014-05-13 19:51:59 -0700530 mSwitchBar = (SwitchBar) findViewById(R.id.switch_bar);
531
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800532 // see if we should show Back/Next buttons
533 Intent intent = getIntent();
534 if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)) {
535
Fabrice Di Megliod2b64f32014-05-20 12:55:15 -0700536 View buttonBar = findViewById(R.id.button_bar);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800537 if (buttonBar != null) {
538 buttonBar.setVisibility(View.VISIBLE);
539
Fabrice Di Megliod2b64f32014-05-20 12:55:15 -0700540 Button backButton = (Button)findViewById(R.id.back_button);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800541 backButton.setOnClickListener(new OnClickListener() {
542 public void onClick(View v) {
543 setResult(RESULT_CANCELED);
544 finish();
545 }
546 });
Fabrice Di Megliod2b64f32014-05-20 12:55:15 -0700547 Button skipButton = (Button)findViewById(R.id.skip_button);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800548 skipButton.setOnClickListener(new OnClickListener() {
549 public void onClick(View v) {
550 setResult(RESULT_OK);
551 finish();
552 }
553 });
Fabrice Di Megliod2b64f32014-05-20 12:55:15 -0700554 mNextButton = (Button)findViewById(R.id.next_button);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800555 mNextButton.setOnClickListener(new OnClickListener() {
556 public void onClick(View v) {
557 setResult(RESULT_OK);
558 finish();
559 }
560 });
561
562 // set our various button parameters
563 if (intent.hasExtra(EXTRA_PREFS_SET_NEXT_TEXT)) {
564 String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_NEXT_TEXT);
565 if (TextUtils.isEmpty(buttonText)) {
566 mNextButton.setVisibility(View.GONE);
567 }
568 else {
569 mNextButton.setText(buttonText);
570 }
571 }
572 if (intent.hasExtra(EXTRA_PREFS_SET_BACK_TEXT)) {
573 String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_BACK_TEXT);
574 if (TextUtils.isEmpty(buttonText)) {
575 backButton.setVisibility(View.GONE);
576 }
577 else {
578 backButton.setText(buttonText);
579 }
580 }
581 if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_SKIP, false)) {
582 skipButton.setVisibility(View.VISIBLE);
583 }
584 }
585 }
Fabrice Di Meglioc95be4f2014-03-07 12:57:38 -0800586 }
587
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700588 private void setTitleFromIntent(Intent intent) {
589 final int initialTitleResId = intent.getIntExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1);
590 if (initialTitleResId > 0) {
591 mInitialTitle = null;
592 mInitialTitleResId = initialTitleResId;
593 setTitle(mInitialTitleResId);
594 } else {
595 mInitialTitleResId = -1;
596 final String initialTitle = intent.getStringExtra(EXTRA_SHOW_FRAGMENT_TITLE);
597 mInitialTitle = (initialTitle != null) ? initialTitle : getTitle();
598 setTitle(mInitialTitle);
599 }
600 }
601
Fabrice Di Meglioc95be4f2014-03-07 12:57:38 -0800602 @Override
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800603 public void onBackStackChanged() {
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700604 setTitleFromBackStack();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800605 }
606
Fabrice Di Megliob643cbf2014-03-10 12:18:39 -0700607 private int setTitleFromBackStack() {
Fabrice Di Meglio8eb3f0f2014-02-27 15:51:46 -0800608 final int count = getFragmentManager().getBackStackEntryCount();
Fabrice Di Megliob643cbf2014-03-10 12:18:39 -0700609
Fabrice Di Meglio8eb3f0f2014-02-27 15:51:46 -0800610 if (count == 0) {
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700611 if (mInitialTitleResId > 0) {
612 setTitle(mInitialTitleResId);
613 } else {
614 setTitle(mInitialTitle);
615 }
Fabrice Di Megliob643cbf2014-03-10 12:18:39 -0700616 return 0;
Fabrice Di Meglio5529d292014-02-11 19:52:28 -0800617 }
Fabrice Di Megliob643cbf2014-03-10 12:18:39 -0700618
Fabrice Di Meglio8eb3f0f2014-02-27 15:51:46 -0800619 FragmentManager.BackStackEntry bse = getFragmentManager().getBackStackEntryAt(count - 1);
620 setTitleFromBackStackEntry(bse);
Fabrice Di Megliob643cbf2014-03-10 12:18:39 -0700621
622 return count;
Fabrice Di Meglio8eb3f0f2014-02-27 15:51:46 -0800623 }
624
625 private void setTitleFromBackStackEntry(FragmentManager.BackStackEntry bse) {
626 final CharSequence title;
627 final int titleRes = bse.getBreadCrumbTitleRes();
628 if (titleRes > 0) {
629 title = getText(titleRes);
630 } else {
631 title = bse.getBreadCrumbTitle();
632 }
633 if (title != null) {
634 setTitle(title);
635 }
Fabrice Di Meglio5529d292014-02-11 19:52:28 -0800636 }
637
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800638 @Override
639 protected void onSaveInstanceState(Bundle outState) {
640 super.onSaveInstanceState(outState);
641
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700642 if (mCategories.size() > 0) {
643 outState.putParcelableArrayList(SAVE_KEY_CATEGORIES, mCategories);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800644 }
Fabrice Di Megliod6985df2014-04-03 16:43:26 -0700645
Fabrice Di Megliob731dd02014-04-03 18:40:38 -0700646 outState.putBoolean(SAVE_KEY_SHOW_HOME_AS_UP, mDisplayHomeAsUpEnabled);
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700647 outState.putBoolean(SAVE_KEY_SHOW_SEARCH, mDisplaySearch);
Fabrice Di Megliob731dd02014-04-03 18:40:38 -0700648
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700649 if (mDisplaySearch) {
650 // The option menus are created if the ActionBar is visible and they are also created
651 // asynchronously. If you launch Settings with an Intent action like
652 // android.intent.action.POWER_USAGE_SUMMARY and at the same time your device is locked
653 // thru a LockScreen, onCreateOptionsMenu() is not yet called and references to the search
654 // menu item and search view are null.
655 boolean isExpanded = (mSearchMenuItem != null) && mSearchMenuItem.isActionViewExpanded();
656 outState.putBoolean(SAVE_KEY_SEARCH_MENU_EXPANDED, isExpanded);
Fabrice Di Megliod6985df2014-04-03 16:43:26 -0700657
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700658 String query = (mSearchView != null) ? mSearchView.getQuery().toString() : EMPTY_QUERY;
659 outState.putString(SAVE_KEY_SEARCH_QUERY, query);
660 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800661 }
662
663 @Override
664 public void onResume() {
665 super.onResume();
666
667 mDevelopmentPreferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
668 @Override
669 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Fabrice Di Megliobb051782014-06-04 17:33:25 -0700670 setNeedToRebuildCategories(true);
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700671 invalidateCategories();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800672 }
673 };
674 mDevelopmentPreferences.registerOnSharedPreferenceChangeListener(
675 mDevelopmentPreferencesListener);
676
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800677 registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
Svetoslav853e4712014-04-14 10:10:25 -0700678
Svetoslav990159a2014-04-14 17:14:59 -0700679 mDynamicIndexableContentMonitor.register(this);
Fabrice Di Meglioa3270762014-04-16 16:54:56 -0700680
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700681 if(mDisplaySearch && !TextUtils.isEmpty(mSearchQuery)) {
Fabrice Di Meglioa3270762014-04-16 16:54:56 -0700682 onQueryTextSubmit(mSearchQuery);
683 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800684 }
685
686 @Override
687 public void onPause() {
688 super.onPause();
689
690 unregisterReceiver(mBatteryInfoReceiver);
691
Svetoslav990159a2014-04-14 17:14:59 -0700692 mDynamicIndexableContentMonitor.unregister();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800693 }
694
695 @Override
696 public void onDestroy() {
697 super.onDestroy();
Fabrice Di Meglio680b0642014-05-20 15:19:29 -0700698
699 mDevelopmentPreferences.unregisterOnSharedPreferenceChangeListener(
700 mDevelopmentPreferencesListener);
701 mDevelopmentPreferencesListener = null;
702
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800703 if (mListeningToAccountUpdates) {
704 AccountManager.get(this).removeOnAccountsUpdatedListener(this);
705 }
706 }
707
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800708 protected boolean isValidFragment(String fragmentName) {
709 // Almost all fragments are wrapped in this,
710 // except for a few that have their own activities.
711 for (int i = 0; i < ENTRY_FRAGMENTS.length; i++) {
712 if (ENTRY_FRAGMENTS[i].equals(fragmentName)) return true;
713 }
714 return false;
715 }
716
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800717 @Override
718 public Intent getIntent() {
719 Intent superIntent = super.getIntent();
720 String startingFragment = getStartingFragmentClass(superIntent);
721 // This is called from super.onCreate, isMultiPane() is not yet reliable
722 // Do not use onIsHidingHeaders either, which relies itself on this method
723 if (startingFragment != null) {
724 Intent modIntent = new Intent(superIntent);
725 modIntent.putExtra(EXTRA_SHOW_FRAGMENT, startingFragment);
726 Bundle args = superIntent.getExtras();
727 if (args != null) {
728 args = new Bundle(args);
729 } else {
730 args = new Bundle();
731 }
732 args.putParcelable("intent", superIntent);
733 modIntent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, superIntent.getExtras());
734 return modIntent;
735 }
736 return superIntent;
737 }
738
739 /**
740 * Checks if the component name in the intent is different from the Settings class and
741 * returns the class name to load as a fragment.
742 */
743 private String getStartingFragmentClass(Intent intent) {
744 if (mFragmentClass != null) return mFragmentClass;
745
746 String intentClass = intent.getComponent().getClassName();
747 if (intentClass.equals(getClass().getName())) return null;
748
749 if ("com.android.settings.ManageApplications".equals(intentClass)
750 || "com.android.settings.RunningServices".equals(intentClass)
751 || "com.android.settings.applications.StorageUse".equals(intentClass)) {
752 // Old names of manage apps.
753 intentClass = com.android.settings.applications.ManageApplications.class.getName();
754 }
755
756 return intentClass;
757 }
758
759 /**
Fabrice Di Meglio10afdb82014-02-11 19:50:56 +0000760 * Start a new fragment containing a preference panel. If the preferences
761 * are being displayed in multi-pane mode, the given fragment class will
762 * be instantiated and placed in the appropriate pane. If running in
763 * single-pane mode, a new activity will be launched in which to show the
764 * fragment.
765 *
766 * @param fragmentClass Full name of the class implementing the fragment.
767 * @param args Any desired arguments to supply to the fragment.
768 * @param titleRes Optional resource identifier of the title of this
769 * fragment.
770 * @param titleText Optional text of the title of this fragment.
771 * @param resultTo Optional fragment that result data should be sent to.
772 * If non-null, resultTo.onActivityResult() will be called when this
773 * preference panel is done. The launched panel must use
774 * {@link #finishPreferencePanel(Fragment, int, Intent)} when done.
775 * @param resultRequestCode If resultTo is non-null, this is the caller's
776 * request code to be received with the resut.
777 */
778 public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes,
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700779 CharSequence titleText, Fragment resultTo, int resultRequestCode) {
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700780 String title = null;
781 if (titleRes < 0) {
782 if (titleText != null) {
783 title = titleText.toString();
784 } else {
785 // There not much we can do in that case
786 title = "";
787 }
Fabrice Di Meglio911fb2a2014-04-04 17:55:57 -0700788 }
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700789 Utils.startWithFragment(this, fragmentClass, args, resultTo, resultRequestCode,
790 titleRes, title);
Fabrice Di Meglio10afdb82014-02-11 19:50:56 +0000791 }
792
793 /**
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800794 * Called by a preference panel fragment to finish itself.
795 *
796 * @param caller The fragment that is asking to be finished.
797 * @param resultCode Optional result code to send back to the original
798 * launching fragment.
799 * @param resultData Optional result data to send back to the original
800 * launching fragment.
801 */
802 public void finishPreferencePanel(Fragment caller, int resultCode, Intent resultData) {
803 setResult(resultCode, resultData);
804 }
805
806 /**
Fabrice Di Meglio10afdb82014-02-11 19:50:56 +0000807 * Start a new fragment.
808 *
809 * @param fragment The fragment to start
810 * @param push If true, the current fragment will be pushed onto the back stack. If false,
811 * the current fragment will be replaced.
812 */
813 public void startPreferenceFragment(Fragment fragment, boolean push) {
814 FragmentTransaction transaction = getFragmentManager().beginTransaction();
815 transaction.replace(R.id.prefs, fragment);
816 if (push) {
817 transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
818 transaction.addToBackStack(BACK_STACK_PREFS);
819 } else {
820 transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
821 }
822 transaction.commitAllowingStateLoss();
823 }
824
825 /**
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700826 * Switch to a specific Fragment with taking care of validation, Title and BackStack
827 */
828 private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate,
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700829 boolean addToBackStack, int titleResId, CharSequence title, boolean withTransition) {
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700830 if (validate && !isValidFragment(fragmentName)) {
831 throw new IllegalArgumentException("Invalid fragment for this activity: "
832 + fragmentName);
833 }
834 Fragment f = Fragment.instantiate(this, fragmentName, args);
835 FragmentTransaction transaction = getFragmentManager().beginTransaction();
836 transaction.replace(R.id.prefs, f);
837 if (withTransition) {
Fabrice Di Meglio59a40552014-05-23 16:46:50 -0700838 TransitionManager.beginDelayedTransition(mContent);
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700839 }
840 if (addToBackStack) {
841 transaction.addToBackStack(SettingsActivity.BACK_STACK_PREFS);
842 }
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700843 if (titleResId > 0) {
844 transaction.setBreadCrumbTitle(titleResId);
845 } else if (title != null) {
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700846 transaction.setBreadCrumbTitle(title);
847 }
848 transaction.commitAllowingStateLoss();
Fabrice Di Meglio59a40552014-05-23 16:46:50 -0700849 getFragmentManager().executePendingTransactions();
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700850 return f;
851 }
852
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700853 public void setNeedToRebuildCategories(boolean need) {
854 mNeedToRebuildCategories = need;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700855 }
856
857 /**
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700858 * Called when the activity needs its list of categories/tiles built.
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -0700859 *
860 * @param categories The list in which to place the tiles categories.
861 */
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700862 private void buildDashboardCategories(List<DashboardCategory> categories) {
Fabrice Di Meglio5f995722014-05-19 19:51:31 -0700863 categories.clear();
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -0700864 loadCategoriesFromResource(R.xml.dashboard_categories, categories);
865 updateTilesList(categories);
866 }
867
868 /**
869 * Parse the given XML file as a categories description, adding each
870 * parsed categories and tiles into the target list.
871 *
872 * @param resid The XML resource to load and parse.
873 * @param target The list in which the parsed categories and tiles should be placed.
874 */
875 private void loadCategoriesFromResource(int resid, List<DashboardCategory> target) {
876 XmlResourceParser parser = null;
877 try {
878 parser = getResources().getXml(resid);
879 AttributeSet attrs = Xml.asAttributeSet(parser);
880
881 int type;
882 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
883 && type != XmlPullParser.START_TAG) {
884 // Parse next until start tag is found
885 }
886
887 String nodeName = parser.getName();
888 if (!"dashboard-categories".equals(nodeName)) {
889 throw new RuntimeException(
890 "XML document must start with <preference-categories> tag; found"
891 + nodeName + " at " + parser.getPositionDescription());
892 }
893
894 Bundle curBundle = null;
895
896 final int outerDepth = parser.getDepth();
897 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
898 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
899 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
900 continue;
901 }
902
903 nodeName = parser.getName();
904 if ("dashboard-category".equals(nodeName)) {
905 DashboardCategory category = new DashboardCategory();
906
907 TypedArray sa = obtainStyledAttributes(
908 attrs, com.android.internal.R.styleable.PreferenceHeader);
909 category.id = sa.getResourceId(
910 com.android.internal.R.styleable.PreferenceHeader_id,
911 (int)DashboardCategory.CAT_ID_UNDEFINED);
912
913 TypedValue tv = sa.peekValue(
914 com.android.internal.R.styleable.PreferenceHeader_title);
915 if (tv != null && tv.type == TypedValue.TYPE_STRING) {
916 if (tv.resourceId != 0) {
917 category.titleRes = tv.resourceId;
918 } else {
919 category.title = tv.string;
920 }
921 }
922 sa.recycle();
923
924 final int innerDepth = parser.getDepth();
925 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
926 && (type != XmlPullParser.END_TAG || parser.getDepth() > innerDepth)) {
927 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
928 continue;
929 }
930
931 String innerNodeName = parser.getName();
932 if (innerNodeName.equals("dashboard-tile")) {
933 DashboardTile tile = new DashboardTile();
934
935 sa = obtainStyledAttributes(
936 attrs, com.android.internal.R.styleable.PreferenceHeader);
937 tile.id = sa.getResourceId(
938 com.android.internal.R.styleable.PreferenceHeader_id,
Fabrice Di Meglioe9326d22014-05-13 12:49:14 -0700939 (int)TILE_ID_UNDEFINED);
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -0700940 tv = sa.peekValue(
941 com.android.internal.R.styleable.PreferenceHeader_title);
942 if (tv != null && tv.type == TypedValue.TYPE_STRING) {
943 if (tv.resourceId != 0) {
944 tile.titleRes = tv.resourceId;
945 } else {
946 tile.title = tv.string;
947 }
948 }
949 tv = sa.peekValue(
950 com.android.internal.R.styleable.PreferenceHeader_summary);
951 if (tv != null && tv.type == TypedValue.TYPE_STRING) {
952 if (tv.resourceId != 0) {
953 tile.summaryRes = tv.resourceId;
954 } else {
955 tile.summary = tv.string;
956 }
957 }
958 tile.iconRes = sa.getResourceId(
959 com.android.internal.R.styleable.PreferenceHeader_icon, 0);
960 tile.fragment = sa.getString(
961 com.android.internal.R.styleable.PreferenceHeader_fragment);
962 sa.recycle();
963
964 if (curBundle == null) {
965 curBundle = new Bundle();
966 }
967
968 final int innerDepth2 = parser.getDepth();
969 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
970 && (type != XmlPullParser.END_TAG || parser.getDepth() > innerDepth2)) {
971 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
972 continue;
973 }
974
975 String innerNodeName2 = parser.getName();
976 if (innerNodeName2.equals("extra")) {
977 getResources().parseBundleExtra("extra", attrs, curBundle);
978 XmlUtils.skipCurrentTag(parser);
979
980 } else if (innerNodeName2.equals("intent")) {
981 tile.intent = Intent.parseIntent(getResources(), parser, attrs);
982
983 } else {
984 XmlUtils.skipCurrentTag(parser);
985 }
986 }
987
988 if (curBundle.size() > 0) {
989 tile.fragmentArguments = curBundle;
990 curBundle = null;
991 }
992
993 category.addTile(tile);
994
995 } else {
996 XmlUtils.skipCurrentTag(parser);
997 }
998 }
999
1000 target.add(category);
1001 } else {
1002 XmlUtils.skipCurrentTag(parser);
1003 }
1004 }
1005
1006 } catch (XmlPullParserException e) {
1007 throw new RuntimeException("Error parsing categories", e);
1008 } catch (IOException e) {
1009 throw new RuntimeException("Error parsing categories", e);
1010 } finally {
1011 if (parser != null) parser.close();
1012 }
1013 }
1014
1015 private void updateTilesList(List<DashboardCategory> target) {
1016 final boolean showDev = mDevelopmentPreferences.getBoolean(
1017 DevelopmentSettings.PREF_SHOW,
1018 android.os.Build.TYPE.equals("eng"));
1019
1020 final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
1021
1022 final int size = target.size();
1023 for (int i = 0; i < size; i++) {
1024
1025 DashboardCategory category = target.get(i);
1026
1027 // Ids are integers, so downcasting is ok
1028 int id = (int) category.id;
1029 if (id == R.id.account_settings) {
1030 insertAccountsTiles(category);
1031 continue;
1032 }
1033 int n = category.getTilesCount() - 1;
1034 while (n >= 0) {
1035
1036 DashboardTile tile = category.getTile(n);
1037
1038 id = (int) tile.id;
1039 if (id == R.id.operator_settings || id == R.id.manufacturer_settings) {
1040 Utils.updateTileToSpecificActivityFromMetaDataOrRemove(this, category, tile);
1041 } else if (id == R.id.wifi_settings) {
1042 // Remove WiFi Settings if WiFi service is not available.
1043 if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) {
1044 category.removeTile(n);
1045 }
1046 } else if (id == R.id.bluetooth_settings) {
1047 // Remove Bluetooth Settings if Bluetooth service is not available.
1048 if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
1049 category.removeTile(n);
1050 }
1051 } else if (id == R.id.data_usage_settings) {
1052 // Remove data usage when kernel module not enabled
1053 final INetworkManagementService netManager = INetworkManagementService.Stub
1054 .asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
1055 try {
1056 if (!netManager.isBandwidthControlEnabled()) {
1057 category.removeTile(n);
1058 }
1059 } catch (RemoteException e) {
1060 // ignored
1061 }
1062 } else if (id == R.id.battery_settings) {
1063 // Remove battery settings when battery is not available. (e.g. TV)
1064
1065 if (!mBatteryPresent) {
1066 category.removeTile(n);
1067 }
1068 } else if (id == R.id.home_settings) {
1069 if (!updateHomeSettingTiles(tile)) {
1070 category.removeTile(n);
1071 }
1072 } else if (id == R.id.user_settings) {
Amith Yamasani4093e402014-06-06 14:31:37 -07001073 boolean hasMultipleUsers =
1074 ((UserManager) getSystemService(Context.USER_SERVICE))
1075 .getUserCount() > 1;
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -07001076 if (!UserHandle.MU_ENABLED
Amith Yamasani4093e402014-06-06 14:31:37 -07001077 || (!UserManager.supportsMultipleUsers()
1078 && !hasMultipleUsers)
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -07001079 || Utils.isMonkeyRunning()) {
1080 category.removeTile(n);
1081 }
1082 } else if (id == R.id.nfc_payment_settings) {
1083 if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) {
1084 category.removeTile(n);
1085 } else {
1086 // Only show if NFC is on and we have the HCE feature
1087 NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this);
1088 if (!adapter.isEnabled() || !getPackageManager().hasSystemFeature(
1089 PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
1090 category.removeTile(n);
1091 }
1092 }
Fabrice Di Meglio488cae32014-05-13 11:26:34 -07001093 } else if (id == R.id.print_settings) {
1094 boolean hasPrintingSupport = getPackageManager().hasSystemFeature(
1095 PackageManager.FEATURE_PRINTING);
1096 if (!hasPrintingSupport) {
1097 category.removeTile(n);
1098 }
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -07001099 } else if (id == R.id.development_settings) {
Julia Reynolds6c088cb2014-05-08 09:29:41 -04001100 if (!showDev || um.hasUserRestriction(
1101 UserManager.DISALLOW_DEBUGGING_FEATURES)) {
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -07001102 category.removeTile(n);
1103 }
1104 } else if (id == R.id.account_add) {
1105 if (um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) {
1106 category.removeTile(n);
1107 }
1108 }
1109
1110 if (UserHandle.MU_ENABLED && UserHandle.myUserId() != 0
Amith Yamasania97089d2014-04-30 10:58:09 -07001111 && !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, id)
1112 && n < category.getTilesCount()) {
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -07001113 category.removeTile(n);
1114 }
1115
1116 n--;
1117 }
1118 }
1119 }
1120
1121 private boolean updateHomeSettingTiles(DashboardTile tile) {
1122 // Once we decide to show Home settings, keep showing it forever
1123 SharedPreferences sp = getSharedPreferences(HomeSettings.HOME_PREFS, Context.MODE_PRIVATE);
1124 if (sp.getBoolean(HomeSettings.HOME_PREFS_DO_SHOW, false)) {
1125 return true;
1126 }
1127
1128 try {
1129 final ArrayList<ResolveInfo> homeApps = new ArrayList<ResolveInfo>();
1130 getPackageManager().getHomeActivities(homeApps);
1131 if (homeApps.size() < 2) {
1132 // When there's only one available home app, omit this settings
1133 // category entirely at the top level UI. If the user just
1134 // uninstalled the penultimate home app candidiate, we also
1135 // now tell them about why they aren't seeing 'Home' in the list.
1136 if (sShowNoHomeNotice) {
1137 sShowNoHomeNotice = false;
1138 NoHomeDialogFragment.show(this);
1139 }
1140 return false;
1141 } else {
1142 // Okay, we're allowing the Home settings category. Tell it, when
1143 // invoked via this front door, that we'll need to be told about the
1144 // case when the user uninstalls all but one home app.
1145 if (tile.fragmentArguments == null) {
1146 tile.fragmentArguments = new Bundle();
1147 }
1148 tile.fragmentArguments.putBoolean(HomeSettings.HOME_SHOW_NOTICE, true);
1149 }
1150 } catch (Exception e) {
1151 // Can't look up the home activity; bail on configuring the icon
1152 Log.w(LOG_TAG, "Problem looking up home activity!", e);
1153 }
1154
1155 sp.edit().putBoolean(HomeSettings.HOME_PREFS_DO_SHOW, true).apply();
1156 return true;
1157 }
1158
1159 private void insertAccountsTiles(DashboardCategory target) {
1160 String[] accountTypes = mAuthenticatorHelper.getEnabledAccountTypes();
1161 List<DashboardTile> dashboardTiles = new ArrayList<DashboardTile>(accountTypes.length);
1162 for (String accountType : accountTypes) {
1163 CharSequence label = mAuthenticatorHelper.getLabelForType(this, accountType);
1164 if (label == null) {
1165 continue;
1166 }
1167
1168 Account[] accounts = AccountManager.get(this).getAccountsByType(accountType);
1169 boolean skipToAccount = accounts.length == 1
1170 && !mAuthenticatorHelper.hasAccountPreferences(accountType);
1171 DashboardTile accountTile = new DashboardTile();
1172 accountTile.title = label;
1173 if (accountTile.extras == null) {
1174 accountTile.extras = new Bundle();
1175 }
1176 if (skipToAccount) {
1177 accountTile.fragment = AccountSyncSettings.class.getName();
1178 accountTile.fragmentArguments = new Bundle();
1179 // Need this for the icon
1180 accountTile.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType);
1181 accountTile.extras.putParcelable(AccountSyncSettings.ACCOUNT_KEY, accounts[0]);
1182 accountTile.fragmentArguments.putParcelable(AccountSyncSettings.ACCOUNT_KEY,
1183 accounts[0]);
1184 } else {
1185 accountTile.fragment = ManageAccountsSettings.class.getName();
1186 accountTile.fragmentArguments = new Bundle();
1187 accountTile.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType);
1188 accountTile.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE,
1189 accountType);
1190 accountTile.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_LABEL,
1191 label.toString());
1192 }
1193 dashboardTiles.add(accountTile);
1194 mAuthenticatorHelper.preloadDrawableForType(this, accountType);
1195 }
1196
1197 // Sort by label
1198 Collections.sort(dashboardTiles, new Comparator<DashboardTile>() {
1199 @Override
1200 public int compare(DashboardTile t1, DashboardTile t2) {
1201 return t1.title.toString().compareTo(t2.title.toString());
1202 }
1203 });
1204 int index = 0;
1205 for (DashboardTile tile : dashboardTiles) {
1206 target.addTile(index, tile);
1207 index++;
1208 }
1209 if (!mListeningToAccountUpdates) {
1210 AccountManager.get(this).addOnAccountsUpdatedListener(this, null, true);
1211 mListeningToAccountUpdates = true;
1212 }
1213 }
1214
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001215 private void getMetaData() {
1216 try {
1217 ActivityInfo ai = getPackageManager().getActivityInfo(getComponentName(),
1218 PackageManager.GET_META_DATA);
1219 if (ai == null || ai.metaData == null) return;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001220 mFragmentClass = ai.metaData.getString(META_DATA_KEY_FRAGMENT_CLASS);
1221 } catch (NameNotFoundException nnfe) {
1222 // No recovery
1223 Log.d(LOG_TAG, "Cannot get Metadata for: " + getComponentName().toString());
1224 }
1225 }
1226
1227 // give subclasses access to the Next button
1228 public boolean hasNextButton() {
1229 return mNextButton != null;
1230 }
1231
1232 public Button getNextButton() {
1233 return mNextButton;
1234 }
1235
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001236 @Override
1237 public boolean shouldUpRecreateTask(Intent targetIntent) {
1238 return super.shouldUpRecreateTask(new Intent(this, SettingsActivity.class));
1239 }
1240
1241 @Override
1242 public void onAccountsUpdated(Account[] accounts) {
1243 // TODO: watch for package upgrades to invalidate cache; see 7206643
1244 mAuthenticatorHelper.updateAuthDescriptions(this);
1245 mAuthenticatorHelper.onAccountsUpdated(this, accounts);
Fabrice Di Meglio769630c2014-04-24 14:48:48 -07001246 invalidateCategories();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001247 }
1248
1249 public static void requestHomeNotice() {
1250 sShowNoHomeNotice = true;
1251 }
1252
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001253 @Override
1254 public boolean onQueryTextSubmit(String query) {
1255 switchToSearchResultsFragmentIfNeeded();
1256 mSearchQuery = query;
1257 return mSearchResultsFragment.onQueryTextSubmit(query);
1258 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001259
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001260 @Override
1261 public boolean onQueryTextChange(String newText) {
1262 mSearchQuery = newText;
Fabrice Di Meglio7e4855e2014-05-23 16:03:43 -07001263 if (mSearchResultsFragment == null) {
Fabrice Di Meglioa3270762014-04-16 16:54:56 -07001264 return false;
1265 }
1266 return mSearchResultsFragment.onQueryTextChange(newText);
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001267 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001268
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001269 @Override
1270 public boolean onClose() {
1271 return false;
1272 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001273
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001274 @Override
1275 public boolean onMenuItemActionExpand(MenuItem item) {
1276 if (item.getItemId() == mSearchMenuItem.getItemId()) {
Fabrice Di Megliobb16fd82014-04-04 14:48:05 -07001277 switchToSearchResultsFragmentIfNeeded();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001278 }
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001279 return true;
1280 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001281
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001282 @Override
1283 public boolean onMenuItemActionCollapse(MenuItem item) {
1284 if (item.getItemId() == mSearchMenuItem.getItemId()) {
Fabrice Di Megliobb16fd82014-04-04 14:48:05 -07001285 if (mSearchMenuItemExpanded) {
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001286 revertToInitialFragment();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001287 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001288 }
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001289 return true;
1290 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001291
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001292 private void switchToSearchResultsFragmentIfNeeded() {
Fabrice Di Megliobb16fd82014-04-04 14:48:05 -07001293 if (mSearchResultsFragment != null) {
1294 return;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001295 }
Fabrice Di Megliobb16fd82014-04-04 14:48:05 -07001296 Fragment current = getFragmentManager().findFragmentById(R.id.prefs);
1297 if (current != null && current instanceof SearchResultsSummary) {
1298 mSearchResultsFragment = (SearchResultsSummary) current;
1299 } else {
Fabrice Di Megliobb16fd82014-04-04 14:48:05 -07001300 mSearchResultsFragment = (SearchResultsSummary) switchToFragment(
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -07001301 SearchResultsSummary.class.getName(), null, false, true,
1302 R.string.search_results_title, null, true);
Fabrice Di Megliobb16fd82014-04-04 14:48:05 -07001303 }
Fabrice Di Megliod297a582014-04-22 17:23:23 -07001304 mSearchResultsFragment.setSearchView(mSearchView);
Fabrice Di Megliobb16fd82014-04-04 14:48:05 -07001305 mSearchMenuItemExpanded = true;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001306 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001307
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001308 public void needToRevertToInitialFragment() {
1309 mNeedToRevertToInitialFragment = true;
1310 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001311
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001312 private void revertToInitialFragment() {
1313 mNeedToRevertToInitialFragment = false;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -07001314 mSearchResultsFragment = null;
Fabrice Di Megliobb16fd82014-04-04 14:48:05 -07001315 mSearchMenuItemExpanded = false;
1316 getFragmentManager().popBackStackImmediate(SettingsActivity.BACK_STACK_PREFS,
1317 FragmentManager.POP_BACK_STACK_INCLUSIVE);
Fabrice Di Meglio23ae00c2014-04-21 12:43:20 -07001318 if (mSearchMenuItem != null) {
1319 mSearchMenuItem.collapseActionView();
1320 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001321 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001322}