SettingsActivity.java revision 21ef89fd6be6506487a70394e3649c915253a535
1263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio/* 2263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * Copyright (C) 2014 The Android Open Source Project 3263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * 4263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * Licensed under the Apache License, Version 2.0 (the "License"); 5263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * you may not use this file except in compliance with the License. 6263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * You may obtain a copy of the License at 7263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * 8263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * http://www.apache.org/licenses/LICENSE-2.0 9263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * 10263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * Unless required by applicable law or agreed to in writing, software 11263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * distributed under the License is distributed on an "AS IS" BASIS, 12263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * See the License for the specific language governing permissions and 14263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * limitations under the License. 15263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio */ 16263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 17263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Megliopackage com.android.settings; 18263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 19263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.app.ActionBar; 20263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.app.Fragment; 21263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.app.FragmentManager; 22263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.app.FragmentTransaction; 23263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.BroadcastReceiver; 24d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglioimport android.content.ComponentName; 25263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.Context; 26263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.Intent; 27263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.IntentFilter; 28263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.SharedPreferences; 29263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.pm.ActivityInfo; 30263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.pm.PackageManager; 31263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.pm.PackageManager.NameNotFoundException; 32263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.res.Configuration; 33263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.nfc.NfcAdapter; 34fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monkimport android.os.AsyncTask; 35263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.os.Bundle; 36263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.os.UserHandle; 37263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.os.UserManager; 3839b467482d1bf256a111c757e9b7621c6f523271Jason Monkimport android.support.v14.preference.PreferenceFragment; 3939b467482d1bf256a111c757e9b7621c6f523271Jason Monkimport android.support.v7.preference.Preference; 4039b467482d1bf256a111c757e9b7621c6f523271Jason Monkimport android.support.v7.preference.PreferenceManager; 41263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.text.TextUtils; 4259a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglioimport android.transition.TransitionManager; 43263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.util.Log; 44d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglioimport android.view.Menu; 45d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglioimport android.view.MenuInflater; 46263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.view.MenuItem; 47263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.view.View; 48263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.view.View.OnClickListener; 4959a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglioimport android.view.ViewGroup; 50263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.widget.Button; 51d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglioimport android.widget.SearchView; 522869157ba9b071f56691a285394500fa4c8a0a79Fan Zhang 53263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.internal.util.ArrayUtils; 544da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monkimport com.android.settings.Settings.WifiSettingsActivity; 55263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.accessibility.AccessibilitySettings; 56b1795f554921249420bf588280396d6920541556Anna Galuszaimport com.android.settings.accessibility.AccessibilitySettingsForSetupWizard; 57263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.accessibility.CaptionPropertiesFragment; 586d839875b74f1570e8807005c586298beb677413Alexandra Gherghinaimport com.android.settings.accounts.AccountSettings; 59263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.accounts.AccountSyncSettings; 6064f6d9896f4a7dea961698914177abc15e594f5bTony Makimport com.android.settings.accounts.ManagedProfileSettings; 6191e2f89b0f8b440728fe395ee02a71ae59e21ffcJason Monkimport com.android.settings.applications.AdvancedAppSettings; 62fee785645b57c519a31ed403e60e8f76dcc8abbbBilly Lauimport com.android.settings.applications.DrawOverlayDetails; 63d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglioimport com.android.settings.applications.InstalledAppDetails; 64263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.applications.ManageApplications; 6586a554091d0705f2152fcf1d78ca1c7720d9842cXiyuan Xiaimport com.android.settings.applications.ManageAssist; 66a2d47fcf59f03d091edaf5895fd3b651e1f499e1Jason Monkimport com.android.settings.applications.NotificationApps; 672cdafc6be386bb767404e42fc728a1a810aa896aJason Monkimport com.android.settings.applications.ProcessStatsSummary; 68263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.applications.ProcessStatsUi; 69d8da51ccfecf16f2c06f788e6bcbc232d1f0cb32Jason Monkimport com.android.settings.applications.UsageAccessDetails; 70fee785645b57c519a31ed403e60e8f76dcc8abbbBilly Lauimport com.android.settings.applications.WriteSettingsDetails; 71c461d5c03d652907c1b726cd0110a407d1c5bee8Ruben Brunkimport com.android.settings.applications.VrListenerSettings; 72263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.bluetooth.BluetoothSettings; 732869157ba9b071f56691a285394500fa4c8a0a79Fan Zhangimport com.android.settings.dashboard.DashboardContainerFragment; 74d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglioimport com.android.settings.dashboard.SearchResultsSummary; 75b37e2887d3112082589997f1bbd802ec282cca6dJason Monkimport com.android.settings.datausage.DataUsageSummary; 76287d91181f70c990e1d961eedf13676f2451a169Daniel Nishiimport com.android.settings.deletionhelper.DeletionHelperFragment; 77a16257dbd5599135320f4263a2cb438b7a469084Jeff Sharkeyimport com.android.settings.deviceinfo.PrivateVolumeForget; 78e77f0687dd424ccfdc2b1061221c6c8ba4d6ac8dJeff Sharkeyimport com.android.settings.deviceinfo.PrivateVolumeSettings; 7942833b2ff4d7a26dd9a609d2fd4436d9a26f28b5Jeff Sharkeyimport com.android.settings.deviceinfo.PublicVolumeSettings; 8042833b2ff4d7a26dd9a609d2fd4436d9a26f28b5Jeff Sharkeyimport com.android.settings.deviceinfo.StorageSettings; 81c7f8e8ce69e80ea495472aade5f8569c6583c5e8John Spurlockimport com.android.settings.fuelgauge.BatterySaverSettings; 821eb54eb2ff250eccdd700601011bd6457ddcbec1Jason Monkimport com.android.settings.fuelgauge.PowerUsageDetail; 83263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.fuelgauge.PowerUsageSummary; 84976bb3f45915bdd5165d9a50402d4c1163dae809Abodunrinwa Tokiimport com.android.settings.inputmethod.AvailableVirtualKeyboardFragment; 85263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.inputmethod.InputMethodAndLanguageSettings; 86263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.inputmethod.KeyboardLayoutPickerFragment; 875f0b59babfbfe483855b294098613f8d0fc2f9b4Abodunrinwa Tokiimport com.android.settings.inputmethod.KeyboardLayoutPickerFragment2; 88b28b2cc68f0f61388383d1dd75630c3b86597a8eAbodunrinwa Tokiimport com.android.settings.inputmethod.PhysicalKeyboardFragment; 89263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.inputmethod.SpellCheckersSettings; 90263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.inputmethod.UserDictionaryList; 91d7d48fda53747a7a25e903d9ef6defa6ea590ebbMihai Nitaimport com.android.settings.localepicker.LocaleListEditor; 92263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.location.LocationSettings; 93263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.nfc.AndroidBeam; 94263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.nfc.PaymentSettings; 95802ddf99f57e316d0fd87c2cfeed5dc3a0cfa8feJohn Spurlockimport com.android.settings.notification.AppNotificationSettings; 968c0a4238655990094fe444ac8f7b182963497030Julia Reynoldsimport com.android.settings.notification.ConfigureNotificationSettings; 974a35051565b0ce6d29313c3e4ffe19e1dde78db0John Spurlockimport com.android.settings.notification.NotificationAccessSettings; 984a35051565b0ce6d29313c3e4ffe19e1dde78db0John Spurlockimport com.android.settings.notification.NotificationStation; 992ebc8a01696c4e7dd29863b92a15ae0bbbbb254dJason Monkimport com.android.settings.notification.OtherSoundSettings; 100b37e2887d3112082589997f1bbd802ec282cca6dJason Monkimport com.android.settings.notification.SoundSettings; 10108531a81cb34dc45f0da4ca88e8530169831c7d2John Spurlockimport com.android.settings.notification.ZenAccessSettings; 102533a5664da21d6bf8819623673fe14b20ba23207John Spurlockimport com.android.settings.notification.ZenModeAutomationSettings; 103f57bad7d5b0f9044231fc52351ed27e14013f491John Spurlockimport com.android.settings.notification.ZenModeEventRuleSettings; 104c1df2aa9639a27fa6d759b21a760b6b63e38a1c2John Spurlockimport com.android.settings.notification.ZenModePrioritySettings; 10545fa140b8c6846b4546fdeabebf989ae9102cebbJohn Spurlockimport com.android.settings.notification.ZenModeScheduleRuleSettings; 10639b467482d1bf256a111c757e9b7621c6f523271Jason Monkimport com.android.settings.notification.ZenModeSettings; 1075555d26b209d8856d862e7fe369f34cb29dcd3a7Julia Reynoldsimport com.android.settings.notification.ZenModeVisualInterruptionSettings; 10813792886a71b53d3f424618f411e3d3ddc2c59b3Andrew Sappersteinimport com.android.settings.overlay.FeatureFactory; 109263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.print.PrintJobSettingsFragment; 110263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.print.PrintSettingsFragment; 11112c4ba4224a42d54ef671302a09c14ed0d3c09b0Dan Sandlerimport com.android.settings.qstile.DevelopmentTiles; 1122ebc8a01696c4e7dd29863b92a15ae0bbbbb254dJason Monkimport com.android.settings.search.DynamicIndexableContentMonitor; 1132ebc8a01696c4e7dd29863b92a15ae0bbbbb254dJason Monkimport com.android.settings.search.Index; 1143815561997eced7fd773062ce32eaa50bece072cPauloftheWestimport com.android.settings.sim.SimSettings; 115263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.tts.TextToSpeechSettings; 116263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.users.UserSettings; 117263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.vpn2.VpnSettings; 118263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.wfd.WifiDisplaySettings; 11941937766981423c9252e12e3319b2e7532739627Fabrice Di Meglioimport com.android.settings.widget.SwitchBar; 120263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.wifi.AdvancedWifiSettings; 1217837b999862cf341b0f124be7ace1dfc64d0a5a8PauloftheWestimport com.android.settings.wifi.SavedAccessPointsWifiSettings; 122263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.wifi.WifiSettings; 123263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.wifi.p2p.WifiP2pSettings; 1244da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monkimport com.android.settingslib.drawer.DashboardCategory; 1254da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monkimport com.android.settingslib.drawer.SettingsDrawerActivity; 1267ea14c5625c988a81c09625f54faed846fc07ec7Jason Monkimport com.android.settingslib.drawer.Tile; 1272ebc8a01696c4e7dd29863b92a15ae0bbbbb254dJason Monk 128263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport java.util.ArrayList; 129263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport java.util.List; 1300d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglioimport java.util.Set; 131263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1324da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monkpublic class SettingsActivity extends SettingsDrawerActivity 133263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio implements PreferenceManager.OnPreferenceTreeClickListener, 134263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PreferenceFragment.OnPreferenceStartFragmentCallback, 135cfc7f9d9600f7b4514ce9608314874bf1023eb21Alexandra Gherghina ButtonBarHandler, FragmentManager.OnBackStackChangedListener, 136d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio SearchView.OnQueryTextListener, SearchView.OnCloseListener, 137cfc7f9d9600f7b4514ce9608314874bf1023eb21Alexandra Gherghina MenuItem.OnActionExpandListener { 138263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 139263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private static final String LOG_TAG = "Settings"; 140263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 141d9779db8c966347734c5791cf63b7dc2e466a0f4Philip P. Moltmann private static final int LOADER_ID_INDEXABLE_CONTENT_MONITOR = 1; 142d9779db8c966347734c5791cf63b7dc2e466a0f4Philip P. Moltmann 143263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Constants for state save/restore 144769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio private static final String SAVE_KEY_CATEGORIES = ":settings:categories"; 145d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private static final String SAVE_KEY_SEARCH_MENU_EXPANDED = ":settings:search_menu_expanded"; 146d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private static final String SAVE_KEY_SEARCH_QUERY = ":settings:search_query"; 147b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio private static final String SAVE_KEY_SHOW_HOME_AS_UP = ":settings:show_home_as_up"; 1483d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio private static final String SAVE_KEY_SHOW_SEARCH = ":settings:show_search"; 149ceb335f88fc0df88dafc8063733842afe35c5da1Fabrice Di Meglio private static final String SAVE_KEY_HOME_ACTIVITIES_COUNT = ":settings:home_activities_count"; 150263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 151263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 152263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * When starting this activity, the invoking Intent can contain this extra 153263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * string to specify which fragment should be initially displayed. 154263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * <p/>Starting from Key Lime Pie, when this argument is passed in, the activity 155263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * will call isValidFragment() to confirm that the fragment class name is valid for this 156263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * activity. 157263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio */ 158263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public static final String EXTRA_SHOW_FRAGMENT = ":settings:show_fragment"; 159263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 160263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 161263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT}, 162263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * this extra can also be specified to supply a Bundle of arguments to pass 163263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * to that fragment when it is instantiated during the initial creation 164263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * of the activity. 165263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio */ 166263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public static final String EXTRA_SHOW_FRAGMENT_ARGUMENTS = ":settings:show_fragment_args"; 167263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 168263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 169c1457323d271309d5d1955743cd806417c84b9d6Fabrice Di Meglio * Fragment "key" argument passed thru {@link #EXTRA_SHOW_FRAGMENT_ARGUMENTS} 170c1457323d271309d5d1955743cd806417c84b9d6Fabrice Di Meglio */ 171c1457323d271309d5d1955743cd806417c84b9d6Fabrice Di Meglio public static final String EXTRA_FRAGMENT_ARG_KEY = ":settings:fragment_args_key"; 172c1457323d271309d5d1955743cd806417c84b9d6Fabrice Di Meglio 1736f0739a3d9a9eca1591ae6bada1dd4d1d92c0defFabrice Di Meglio public static final String BACK_STACK_PREFS = ":settings:prefs"; 1746f0739a3d9a9eca1591ae6bada1dd4d1d92c0defFabrice Di Meglio 175263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // extras that allow any preference activity to be launched as part of a wizard 176263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 177263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // show Back and Next buttons? takes boolean parameter 178263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Back will then return RESULT_CANCELED and Next RESULT_OK 179263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio protected static final String EXTRA_PREFS_SHOW_BUTTON_BAR = "extra_prefs_show_button_bar"; 180263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 181263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // add a Skip button? 182263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private static final String EXTRA_PREFS_SHOW_SKIP = "extra_prefs_show_skip"; 183263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 184263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // specify custom text for the Back or Next buttons, or cause a button to not appear 185263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // at all by setting it to null 186263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio protected static final String EXTRA_PREFS_SET_NEXT_TEXT = "extra_prefs_set_next_text"; 187263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio protected static final String EXTRA_PREFS_SET_BACK_TEXT = "extra_prefs_set_back_text"; 188263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 189263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 190263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT}, 191a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio * those extra can also be specify to supply the title or title res id to be shown for 192263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * that fragment. 193263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio */ 194d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public static final String EXTRA_SHOW_FRAGMENT_TITLE = ":settings:show_fragment_title"; 19562464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina /** 19662464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina * The package name used to resolve the title resource id. 19762464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina */ 19862464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina public static final String EXTRA_SHOW_FRAGMENT_TITLE_RES_PACKAGE_NAME = 19962464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina ":settings:show_fragment_title_res_package_name"; 20061a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio public static final String EXTRA_SHOW_FRAGMENT_TITLE_RESID = 20161a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio ":settings:show_fragment_title_resid"; 20261a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio public static final String EXTRA_SHOW_FRAGMENT_AS_SHORTCUT = 20361a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio ":settings:show_fragment_as_shortcut"; 20461a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio 20561a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio public static final String EXTRA_SHOW_FRAGMENT_AS_SUBSETTING = 20661a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio ":settings:show_fragment_as_subsetting"; 207263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 20892779ce70156031f4fa3b8c2d84305f5b3b44105Udam Saini public static final String EXTRA_HIDE_DRAWER = ":settings:hide_drawer"; 20992779ce70156031f4fa3b8c2d84305f5b3b44105Udam Saini 2103069581512bcb9687cb8d79675f6c4950c9ac087Jason Monk public static final String META_DATA_KEY_FRAGMENT_CLASS = 211263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio "com.android.settings.FRAGMENT_CLASS"; 212263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 213263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private static final String EXTRA_UI_OPTIONS = "settings:ui_options"; 214263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 215d6985df419549fbb7d420eced8e89f0429e49d71Fabrice Di Meglio private static final String EMPTY_QUERY = ""; 216d6985df419549fbb7d420eced8e89f0429e49d71Fabrice Di Meglio 217d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk private static final int REQUEST_SUGGESTION = 42; 218d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk 219263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private String mFragmentClass; 220263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 2218eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio private CharSequence mInitialTitle; 222a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio private int mInitialTitleResId; 2238eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio 224263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Show only these settings for restricted users 2254da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk private String[] SETTINGS_FOR_RESTRICTED = { 2264da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk //wireless_section 2274da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk WifiSettingsActivity.class.getName(), 2284da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.BluetoothSettingsActivity.class.getName(), 2294da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.DataUsageSummaryActivity.class.getName(), 2304da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.SimSettingsActivity.class.getName(), 2314da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.WirelessSettingsActivity.class.getName(), 2324da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk //device_section 2334da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.HomeSettingsActivity.class.getName(), 2348c0a4238655990094fe444ac8f7b182963497030Julia Reynolds Settings.SoundSettingsActivity.class.getName(), 2354da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.DisplaySettingsActivity.class.getName(), 2364da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.StorageSettingsActivity.class.getName(), 2374da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.ManageApplicationsActivity.class.getName(), 2384da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.PowerUsageSummaryActivity.class.getName(), 2394da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk //personal_section 2404da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.LocationSettingsActivity.class.getName(), 2414da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.SecuritySettingsActivity.class.getName(), 2424da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.InputMethodAndLanguageSettingsActivity.class.getName(), 2434da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.UserSettingsActivity.class.getName(), 2444da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.AccountSettingsActivity.class.getName(), 2454da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk //system_section 2464da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.DateTimeSettingsActivity.class.getName(), 2474da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.DeviceInfoSettingsActivity.class.getName(), 2484da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.AccessibilitySettingsActivity.class.getName(), 2494da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.PrintSettingsActivity.class.getName(), 2504da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.PaymentSettingsActivity.class.getName(), 251263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }; 252263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 253263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private static final String[] ENTRY_FRAGMENTS = { 254263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio WirelessSettings.class.getName(), 255263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio WifiSettings.class.getName(), 256263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio AdvancedWifiSettings.class.getName(), 2577837b999862cf341b0f124be7ace1dfc64d0a5a8PauloftheWest SavedAccessPointsWifiSettings.class.getName(), 258263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio BluetoothSettings.class.getName(), 2593815561997eced7fd773062ce32eaa50bece072cPauloftheWest SimSettings.class.getName(), 260263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio TetherSettings.class.getName(), 261263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio WifiP2pSettings.class.getName(), 262263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio VpnSettings.class.getName(), 263263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DateTimeSettings.class.getName(), 264d7d48fda53747a7a25e903d9ef6defa6ea590ebbMihai Nita LocaleListEditor.class.getName(), 265263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio InputMethodAndLanguageSettings.class.getName(), 266976bb3f45915bdd5165d9a50402d4c1163dae809Abodunrinwa Toki AvailableVirtualKeyboardFragment.class.getName(), 267263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio SpellCheckersSettings.class.getName(), 268263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio UserDictionaryList.class.getName(), 269263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio UserDictionarySettings.class.getName(), 2703033ce0723103b55b1b5a53145c05e143b5bbfd6Amith Yamasani HomeSettings.class.getName(), 271263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DisplaySettings.class.getName(), 272263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DeviceInfoSettings.class.getName(), 273263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio ManageApplications.class.getName(), 274a2d47fcf59f03d091edaf5895fd3b651e1f499e1Jason Monk NotificationApps.class.getName(), 27586a554091d0705f2152fcf1d78ca1c7720d9842cXiyuan Xia ManageAssist.class.getName(), 276263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio ProcessStatsUi.class.getName(), 277263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio NotificationStation.class.getName(), 278263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio LocationSettings.class.getName(), 279263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio SecuritySettings.class.getName(), 280d8da51ccfecf16f2c06f788e6bcbc232d1f0cb32Jason Monk UsageAccessDetails.class.getName(), 281263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PrivacySettings.class.getName(), 282263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DeviceAdminSettings.class.getName(), 283263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio AccessibilitySettings.class.getName(), 284b1795f554921249420bf588280396d6920541556Anna Galusza AccessibilitySettingsForSetupWizard.class.getName(), 285263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio CaptionPropertiesFragment.class.getName(), 286263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment.class.getName(), 287263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio TextToSpeechSettings.class.getName(), 28842833b2ff4d7a26dd9a609d2fd4436d9a26f28b5Jeff Sharkey StorageSettings.class.getName(), 289a16257dbd5599135320f4263a2cb438b7a469084Jeff Sharkey PrivateVolumeForget.class.getName(), 290e77f0687dd424ccfdc2b1061221c6c8ba4d6ac8dJeff Sharkey PrivateVolumeSettings.class.getName(), 291e77f0687dd424ccfdc2b1061221c6c8ba4d6ac8dJeff Sharkey PublicVolumeSettings.class.getName(), 292263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DevelopmentSettings.class.getName(), 293263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio AndroidBeam.class.getName(), 294263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio WifiDisplaySettings.class.getName(), 295263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PowerUsageSummary.class.getName(), 296263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio AccountSyncSettings.class.getName(), 2976d839875b74f1570e8807005c586298beb677413Alexandra Gherghina AccountSettings.class.getName(), 298263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio CryptKeeperSettings.class.getName(), 299263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DataUsageSummary.class.getName(), 300263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DreamSettings.class.getName(), 301263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio UserSettings.class.getName(), 302263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio NotificationAccessSettings.class.getName(), 30308531a81cb34dc45f0da4ca88e8530169831c7d2John Spurlock ZenAccessSettings.class.getName(), 304263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PrintSettingsFragment.class.getName(), 305263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PrintJobSettingsFragment.class.getName(), 306263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio TrustedCredentialsSettings.class.getName(), 307263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PaymentSettings.class.getName(), 308263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio KeyboardLayoutPickerFragment.class.getName(), 3095f0b59babfbfe483855b294098613f8d0fc2f9b4Abodunrinwa Toki KeyboardLayoutPickerFragment2.class.getName(), 310b28b2cc68f0f61388383d1dd75630c3b86597a8eAbodunrinwa Toki PhysicalKeyboardFragment.class.getName(), 311d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio ZenModeSettings.class.getName(), 3128c0a4238655990094fe444ac8f7b182963497030Julia Reynolds SoundSettings.class.getName(), 3138c0a4238655990094fe444ac8f7b182963497030Julia Reynolds ConfigureNotificationSettings.class.getName(), 314d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio ChooseLockPassword.ChooseLockPasswordFragment.class.getName(), 315d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio ChooseLockPattern.ChooseLockPatternFragment.class.getName(), 316c7f8e8ce69e80ea495472aade5f8569c6583c5e8John Spurlock InstalledAppDetails.class.getName(), 317c7f8e8ce69e80ea495472aade5f8569c6583c5e8John Spurlock BatterySaverSettings.class.getName(), 318dcf59dd82ca5a5b211461f1c2825623325c3811cFabrice Di Meglio AppNotificationSettings.class.getName(), 319e3ff4d8e92a19473c622c1d46b30c63bf2d001d0Fabrice Di Meglio OtherSoundSettings.class.getName(), 32033acb15e032ac65d743b708731004b9a5f7813d5Narayan Kamath ApnSettings.class.getName(), 32145fa140b8c6846b4546fdeabebf989ae9102cebbJohn Spurlock WifiCallingSettings.class.getName(), 322c1df2aa9639a27fa6d759b21a760b6b63e38a1c2John Spurlock ZenModePrioritySettings.class.getName(), 323533a5664da21d6bf8819623673fe14b20ba23207John Spurlock ZenModeAutomationSettings.class.getName(), 32445fa140b8c6846b4546fdeabebf989ae9102cebbJohn Spurlock ZenModeScheduleRuleSettings.class.getName(), 325f57bad7d5b0f9044231fc52351ed27e14013f491John Spurlock ZenModeEventRuleSettings.class.getName(), 3265555d26b209d8856d862e7fe369f34cb29dcd3a7Julia Reynolds ZenModeVisualInterruptionSettings.class.getName(), 3272583fc1e069d0a54df46258d360499492d7e86d2Jason Monk ProcessStatsUi.class.getName(), 3281eb54eb2ff250eccdd700601011bd6457ddcbec1Jason Monk PowerUsageDetail.class.getName(), 3292cdafc6be386bb767404e42fc728a1a810aa896aJason Monk ProcessStatsSummary.class.getName(), 330fee785645b57c519a31ed403e60e8f76dcc8abbbBilly Lau DrawOverlayDetails.class.getName(), 331fee785645b57c519a31ed403e60e8f76dcc8abbbBilly Lau WriteSettingsDetails.class.getName(), 33291e2f89b0f8b440728fe395ee02a71ae59e21ffcJason Monk AdvancedAppSettings.class.getName(), 333b9e5d238b64abf3a45f148b43b8d8fcca912d976Jason Monk WallpaperTypeSettings.class.getName(), 334c461d5c03d652907c1b726cd0110a407d1c5bee8Ruben Brunk VrListenerSettings.class.getName(), 33564f6d9896f4a7dea961698914177abc15e594f5bTony Mak ManagedProfileSettings.class.getName(), 336287d91181f70c990e1d961eedf13676f2451a169Daniel Nishi DeletionHelperFragment.class.getName(), 337263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }; 338263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 3395a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio 3405a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio private static final String[] LIKE_SHORTCUT_INTENT_ACTION_ARRAY = { 3415a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio "android.settings.APPLICATION_DETAILS_SETTINGS" 3425a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio }; 3435a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio 344263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private SharedPreferences mDevelopmentPreferences; 345263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private SharedPreferences.OnSharedPreferenceChangeListener mDevelopmentPreferencesListener; 346263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 347263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private boolean mBatteryPresent = true; 348263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private BroadcastReceiver mBatteryInfoReceiver = new BroadcastReceiver() { 349263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 350263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onReceive(Context context, Intent intent) { 351263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio String action = intent.getAction(); 352263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (Intent.ACTION_BATTERY_CHANGED.equals(action)) { 353263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio boolean batteryPresent = Utils.isBatteryPresent(intent); 354263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 355263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (mBatteryPresent != batteryPresent) { 356263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mBatteryPresent = batteryPresent; 3574da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk updateTilesList(); 358263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 359263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 360263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 361263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }; 362263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 3636934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri private final BroadcastReceiver mUserAddRemoveReceiver = new BroadcastReceiver() { 3646934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri @Override 3656934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri public void onReceive(Context context, Intent intent) { 3666934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri String action = intent.getAction(); 3676934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri if (action.equals(Intent.ACTION_USER_ADDED) 3686934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri || action.equals(Intent.ACTION_USER_REMOVED)) { 3696934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri Index.getInstance(getApplicationContext()).update(); 3706934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri } 3716934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri } 3726934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri }; 3736934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri 374990159abaad7f314fbe1f9eaf064a088806ffb19Svetoslav private final DynamicIndexableContentMonitor mDynamicIndexableContentMonitor = 375990159abaad7f314fbe1f9eaf064a088806ffb19Svetoslav new DynamicIndexableContentMonitor(); 376853e47181dc116ba95e91463735dc79ad4bdc95aSvetoslav 377d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private ActionBar mActionBar; 37841937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio private SwitchBar mSwitchBar; 37941937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio 38041937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio private Button mNextButton; 3813d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio 382b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio private boolean mDisplayHomeAsUpEnabled; 3833d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio private boolean mDisplaySearch; 384d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 38535062d6983e352f5cb6c4a6bbf3c1e4e214d44a9Fabrice Di Meglio private boolean mIsShowingDashboard; 3860d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio private boolean mIsShortcut; 38735062d6983e352f5cb6c4a6bbf3c1e4e214d44a9Fabrice Di Meglio 3882f1c11314b9a82f808b376c69c2617962566817fAnna Galusza private int mMainContentId = R.id.main_content; 38959a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglio private ViewGroup mContent; 39059a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglio 391d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private SearchView mSearchView; 392d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private MenuItem mSearchMenuItem; 393d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private boolean mSearchMenuItemExpanded = false; 394d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private SearchResultsSummary mSearchResultsFragment; 395d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private String mSearchQuery; 396d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 397769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio // Categories 398769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio private ArrayList<DashboardCategory> mCategories = new ArrayList<DashboardCategory>(); 399263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 400b0a464fd2cbbe00821d483d28e76a04ac17996eaFabrice Di Meglio private static final String MSG_DATA_FORCE_REFRESH = "msg_data_force_refresh"; 401263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 402d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private boolean mNeedToRevertToInitialFragment = false; 403d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 4040698a216311acd9ab52224602d1a75c08bf89f04Jim Miller private Intent mResultIntentData; 405d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk private ComponentName mCurrentSuggestion; 4060698a216311acd9ab52224602d1a75c08bf89f04Jim Miller 40741937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio public SwitchBar getSwitchBar() { 40841937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio return mSwitchBar; 40941937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio } 41041937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio 411263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 412263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) { 41321ef89fd6be6506487a70394e3649c915253a535Sunny Goyal startPreferencePanel(pref.getFragment(), pref.getExtras(), -1, pref.getTitle(), 414263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio null, 0); 415263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return true; 416263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 417263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 418263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 41939b467482d1bf256a111c757e9b7621c6f523271Jason Monk public boolean onPreferenceTreeClick(Preference preference) { 420263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return false; 421263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 422263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 423263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 424263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onConfigurationChanged(Configuration newConfig) { 425263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio super.onConfigurationChanged(newConfig); 4266f0739a3d9a9eca1591ae6bada1dd4d1d92c0defFabrice Di Meglio Index.getInstance(this).update(); 427263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 428263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 429263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 430d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio protected void onStart() { 431d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio super.onStart(); 432d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 433d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (mNeedToRevertToInitialFragment) { 434d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio revertToInitialFragment(); 435263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 436263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 437263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 438263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 439d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onCreateOptionsMenu(Menu menu) { 4403d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio if (!mDisplaySearch) { 4413d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio return false; 4423d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio } 4433d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio 444d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio MenuInflater inflater = getMenuInflater(); 445d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio inflater.inflate(R.menu.options_menu, menu); 446d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 447d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio // Cache the search query (can be overriden by the OnQueryTextListener) 448d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio final String query = mSearchQuery; 449d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 4509593782d154f378a0c911cd015d410c18fe74a92Fabrice Di Meglio mSearchMenuItem = menu.findItem(R.id.search); 4519593782d154f378a0c911cd015d410c18fe74a92Fabrice Di Meglio mSearchView = (SearchView) mSearchMenuItem.getActionView(); 452d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 45323ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio if (mSearchMenuItem == null || mSearchView == null) { 45423ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio return false; 45523ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio } 45623ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio 4578c3b0ce7120da882082eed533462090c4feadff8Fabrice Di Meglio if (mSearchResultsFragment != null) { 4588c3b0ce7120da882082eed533462090c4feadff8Fabrice Di Meglio mSearchResultsFragment.setSearchView(mSearchView); 4598c3b0ce7120da882082eed533462090c4feadff8Fabrice Di Meglio } 4608c3b0ce7120da882082eed533462090c4feadff8Fabrice Di Meglio 4619593782d154f378a0c911cd015d410c18fe74a92Fabrice Di Meglio mSearchMenuItem.setOnActionExpandListener(this); 462d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchView.setOnQueryTextListener(this); 463d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchView.setOnCloseListener(this); 464d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 465d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (mSearchMenuItemExpanded) { 466d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchMenuItem.expandActionView(); 467d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 468d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchView.setQuery(query, true /* submit */); 469d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 470d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return true; 471d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 472d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 47331c7c32fcc26a421a4d2fef7f006917ef590f426Jason Monk @Override 47431c7c32fcc26a421a4d2fef7f006917ef590f426Jason Monk public SharedPreferences getSharedPreferences(String name, int mode) { 47531c7c32fcc26a421a4d2fef7f006917ef590f426Jason Monk if (name.equals(getPackageName() + "_preferences")) { 476e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk return new SharedPreferencesLogger(this, getMetricsTag()); 47731c7c32fcc26a421a4d2fef7f006917ef590f426Jason Monk } 47831c7c32fcc26a421a4d2fef7f006917ef590f426Jason Monk return super.getSharedPreferences(name, mode); 47931c7c32fcc26a421a4d2fef7f006917ef590f426Jason Monk } 48031c7c32fcc26a421a4d2fef7f006917ef590f426Jason Monk 481e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk private String getMetricsTag() { 482e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk String tag = getClass().getName(); 483e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk if (getIntent() != null && getIntent().hasExtra(EXTRA_SHOW_FRAGMENT)) { 484e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk tag = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT); 485e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk } 486e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk if (tag.startsWith("com.android.settings.")) { 487e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk tag = tag.replace("com.android.settings.", ""); 488e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk } 489e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk return tag; 490e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk } 491e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk 4920d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio private static boolean isShortCutIntent(final Intent intent) { 4930d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio Set<String> categories = intent.getCategories(); 4940d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio return (categories != null) && categories.contains("com.android.settings.SHORTCUT"); 4950d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio } 4960d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio 4975b3c3c00b0a280e29f3767878913f80274bd4993Fabrice Di Meglio private static boolean isLikeShortCutIntent(final Intent intent) { 4985b7a100dbd9135b6b87ae4cc9ff3a5ece123bcf6Fabrice Di Meglio String action = intent.getAction(); 4995a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio if (action == null) { 5005a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio return false; 5015a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio } 5025a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio for (int i = 0; i < LIKE_SHORTCUT_INTENT_ACTION_ARRAY.length; i++) { 5035a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio if (LIKE_SHORTCUT_INTENT_ACTION_ARRAY[i].equals(action)) return true; 5045a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio } 5055a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio return false; 5065b7a100dbd9135b6b87ae4cc9ff3a5ece123bcf6Fabrice Di Meglio } 5075b7a100dbd9135b6b87ae4cc9ff3a5ece123bcf6Fabrice Di Meglio 508d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 509d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio protected void onCreate(Bundle savedState) { 5100d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio super.onCreate(savedState); 511fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk long startTime = System.currentTimeMillis(); 5120d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio 5130d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio // Should happen before any call to getIntent() 5140d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio getMetaData(); 5150d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio 5160d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio final Intent intent = getIntent(); 5170d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio if (intent.hasExtra(EXTRA_UI_OPTIONS)) { 5180d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0)); 519263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 52092779ce70156031f4fa3b8c2d84305f5b3b44105Udam Saini if (intent.getBooleanExtra(EXTRA_HIDE_DRAWER, false)) { 52192779ce70156031f4fa3b8c2d84305f5b3b44105Udam Saini setIsDrawerPresent(false); 52292779ce70156031f4fa3b8c2d84305f5b3b44105Udam Saini } 523263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 524263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mDevelopmentPreferences = getSharedPreferences(DevelopmentSettings.PREF_FILE, 525263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio Context.MODE_PRIVATE); 526263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 527da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio // Getting Intent properties can only be done after the super.onCreate(...) 5280d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio final String initialFragmentName = intent.getStringExtra(EXTRA_SHOW_FRAGMENT); 5290d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio 5305b3c3c00b0a280e29f3767878913f80274bd4993Fabrice Di Meglio mIsShortcut = isShortCutIntent(intent) || isLikeShortCutIntent(intent) || 5310d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SHORTCUT, false); 532da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio 533e817a66e83191c0ae74acd53a538a0965eba2683Fabrice Di Meglio final ComponentName cn = intent.getComponent(); 5345a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio final String className = cn.getClassName(); 535da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio 5364da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk mIsShowingDashboard = className.equals(Settings.class.getName()) 5374da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk || className.equals(Settings.WirelessSettings.class.getName()) 5384da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk || className.equals(Settings.DeviceSettings.class.getName()) 5394da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk || className.equals(Settings.PersonalSettings.class.getName()) 5404da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk || className.equals(Settings.WirelessSettings.class.getName()); 5415a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio 54261a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio // This is a "Sub Settings" when: 54361a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio // - this is a real SubSettings 54461a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio // - or :settings:show_fragment_as_subsetting is passed to the Intent 5454dfcb8208cdb49167ccf99aeaddf9e206eba87d1Jorim Jaggi final boolean isSubSettings = this instanceof SubSettings || 54661a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false); 54761a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio 54861a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio // If this is a sub settings, then apply the SubSettings Theme for the ActionBar content insets 54961a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio if (isSubSettings) { 550712df6cb7050a87985ab30b8d1bad909a6bc09aaFabrice Di Meglio // Check also that we are not a Theme Dialog as we don't want to override them 551712df6cb7050a87985ab30b8d1bad909a6bc09aaFabrice Di Meglio final int themeResId = getThemeResId(); 552712df6cb7050a87985ab30b8d1bad909a6bc09aaFabrice Di Meglio if (themeResId != R.style.Theme_DialogWhenLarge && 553712df6cb7050a87985ab30b8d1bad909a6bc09aaFabrice Di Meglio themeResId != R.style.Theme_SubSettingsDialogWhenLarge) { 554712df6cb7050a87985ab30b8d1bad909a6bc09aaFabrice Di Meglio setTheme(R.style.Theme_SubSettings); 555712df6cb7050a87985ab30b8d1bad909a6bc09aaFabrice Di Meglio } 556da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio } 557da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio 558d40dd45c18a55d574d65b3a0ac16b59d76027049Fabrice Di Meglio setContentView(mIsShowingDashboard ? 559d40dd45c18a55d574d65b3a0ac16b59d76027049Fabrice Di Meglio R.layout.settings_main_dashboard : R.layout.settings_main_prefs); 560263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 5612f1c11314b9a82f808b376c69c2617962566817fAnna Galusza mContent = (ViewGroup) findViewById(mMainContentId); 56259a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglio 563263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio getFragmentManager().addOnBackStackChangedListener(this); 564263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 56535062d6983e352f5cb6c4a6bbf3c1e4e214d44a9Fabrice Di Meglio if (mIsShowingDashboard) { 566dff3faaf30bd6d695e4d9f632af53dbc73cf6506Fabrice Di Meglio // Run the Index update only if we have some space 567dff3faaf30bd6d695e4d9f632af53dbc73cf6506Fabrice Di Meglio if (!Utils.isLowStorage(this)) { 568fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk long indexStartTime = System.currentTimeMillis(); 5696c9e884aa04b19634722d95cb65d7df1050a0c28Jason Monk Index.getInstance(getApplicationContext()).update(); 570fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk if (DEBUG_TIMING) Log.d(LOG_TAG, "Index.update() took " 571fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk + (System.currentTimeMillis() - indexStartTime) + " ms"); 572dff3faaf30bd6d695e4d9f632af53dbc73cf6506Fabrice Di Meglio } else { 573dff3faaf30bd6d695e4d9f632af53dbc73cf6506Fabrice Di Meglio Log.w(LOG_TAG, "Cannot update the Indexer as we are running low on storage space!"); 574dff3faaf30bd6d695e4d9f632af53dbc73cf6506Fabrice Di Meglio } 5755cda21b449a56de42f7868bdcdaa31bb6f587c03Fabrice Di Meglio } 5765cda21b449a56de42f7868bdcdaa31bb6f587c03Fabrice Di Meglio 577d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (savedState != null) { 5781800a9f3e7027e8ab8ffcab51715d39b126bad43Fabrice Di Meglio // We are restarting from a previous saved state; used that to initialize, instead 5791800a9f3e7027e8ab8ffcab51715d39b126bad43Fabrice Di Meglio // of starting fresh. 580d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchMenuItemExpanded = savedState.getBoolean(SAVE_KEY_SEARCH_MENU_EXPANDED); 581d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchQuery = savedState.getString(SAVE_KEY_SEARCH_QUERY); 582263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 5830d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio setTitleFromIntent(intent); 5845529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio 585769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio ArrayList<DashboardCategory> categories = 586769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio savedState.getParcelableArrayList(SAVE_KEY_CATEGORIES); 587769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio if (categories != null) { 5885f995727cc2e4bd27d26a50f3a565fb677fdb294Fabrice Di Meglio mCategories.clear(); 589769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio mCategories.addAll(categories); 590b643cbf6d60bb4cd43d3191106d68680fffe97b5Fabrice Di Meglio setTitleFromBackStack(); 591263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 592b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio 593b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio mDisplayHomeAsUpEnabled = savedState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP); 5943d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio mDisplaySearch = savedState.getBoolean(SAVE_KEY_SHOW_SEARCH); 595263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } else { 59635062d6983e352f5cb6c4a6bbf3c1e4e214d44a9Fabrice Di Meglio if (!mIsShowingDashboard) { 597ea8b1a7dc5fa11742967923251b437a02568f021Jason Monk mDisplaySearch = false; 598ea8b1a7dc5fa11742967923251b437a02568f021Jason Monk // UP will be shown only if it is a sub settings 5990d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio if (mIsShortcut) { 6000d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio mDisplayHomeAsUpEnabled = isSubSettings; 6015a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio } else if (isSubSettings) { 6025a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio mDisplayHomeAsUpEnabled = true; 60361a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio } else { 60461a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio mDisplayHomeAsUpEnabled = false; 605d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 6060d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio setTitleFromIntent(intent); 607c1457323d271309d5d1955743cd806417c84b9d6Fabrice Di Meglio 6080d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio Bundle initialArguments = intent.getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS); 609a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio switchToFragment(initialFragmentName, initialArguments, true, false, 610a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitleResId, mInitialTitle, false); 61110afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio } else { 6125a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio // No UP affordance if we are displaying the main Dashboard 613b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio mDisplayHomeAsUpEnabled = false; 6145a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio // Show Search affordance 6155a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio mDisplaySearch = true; 616a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitleResId = R.string.dashboard_title; 6172869157ba9b071f56691a285394500fa4c8a0a79Fan Zhang switchToFragment(DashboardContainerFragment.class.getName(), null, false, false, 618a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitleResId, mInitialTitle, false); 619263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 620263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 621263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 622d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mActionBar = getActionBar(); 623d8aec08fa96c42a61bd6ead2aa9859b5b67a3f2cFabrice Di Meglio if (mActionBar != null) { 624d8aec08fa96c42a61bd6ead2aa9859b5b67a3f2cFabrice Di Meglio mActionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled); 625d8aec08fa96c42a61bd6ead2aa9859b5b67a3f2cFabrice Di Meglio mActionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled); 626d8aec08fa96c42a61bd6ead2aa9859b5b67a3f2cFabrice Di Meglio } 62741937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio mSwitchBar = (SwitchBar) findViewById(R.id.switch_bar); 628e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk if (mSwitchBar != null) { 629e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk mSwitchBar.setMetricsTag(getMetricsTag()); 630e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk } 63141937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio 632263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // see if we should show Back/Next buttons 633263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)) { 634263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 635d2b64f339adb8f019e3c712e388e35830d8b68a9Fabrice Di Meglio View buttonBar = findViewById(R.id.button_bar); 636263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (buttonBar != null) { 637263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio buttonBar.setVisibility(View.VISIBLE); 638263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 639d2b64f339adb8f019e3c712e388e35830d8b68a9Fabrice Di Meglio Button backButton = (Button)findViewById(R.id.back_button); 640263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio backButton.setOnClickListener(new OnClickListener() { 641263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onClick(View v) { 6420698a216311acd9ab52224602d1a75c08bf89f04Jim Miller setResult(RESULT_CANCELED, getResultIntentData()); 643263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio finish(); 644263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 645263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }); 646d2b64f339adb8f019e3c712e388e35830d8b68a9Fabrice Di Meglio Button skipButton = (Button)findViewById(R.id.skip_button); 647263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio skipButton.setOnClickListener(new OnClickListener() { 648263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onClick(View v) { 6490698a216311acd9ab52224602d1a75c08bf89f04Jim Miller setResult(RESULT_OK, getResultIntentData()); 650263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio finish(); 651263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 652263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }); 653d2b64f339adb8f019e3c712e388e35830d8b68a9Fabrice Di Meglio mNextButton = (Button)findViewById(R.id.next_button); 654263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mNextButton.setOnClickListener(new OnClickListener() { 655263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onClick(View v) { 6560698a216311acd9ab52224602d1a75c08bf89f04Jim Miller setResult(RESULT_OK, getResultIntentData()); 657263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio finish(); 658263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 659263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }); 660263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 661263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // set our various button parameters 662263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (intent.hasExtra(EXTRA_PREFS_SET_NEXT_TEXT)) { 663263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_NEXT_TEXT); 664263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (TextUtils.isEmpty(buttonText)) { 665263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mNextButton.setVisibility(View.GONE); 666263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 667263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio else { 668263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mNextButton.setText(buttonText); 669263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 670263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 671263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (intent.hasExtra(EXTRA_PREFS_SET_BACK_TEXT)) { 672263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_BACK_TEXT); 673263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (TextUtils.isEmpty(buttonText)) { 674263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio backButton.setVisibility(View.GONE); 675263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 676263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio else { 677263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio backButton.setText(buttonText); 678263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 679263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 680263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_SKIP, false)) { 681263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio skipButton.setVisibility(View.VISIBLE); 682263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 683263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 684263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 685ceb335f88fc0df88dafc8063733842afe35c5da1Fabrice Di Meglio 686fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk if (DEBUG_TIMING) Log.d(LOG_TAG, "onCreate took " + (System.currentTimeMillis() - startTime) 687fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk + " ms"); 688ceb335f88fc0df88dafc8063733842afe35c5da1Fabrice Di Meglio } 689ceb335f88fc0df88dafc8063733842afe35c5da1Fabrice Di Meglio 6902f1c11314b9a82f808b376c69c2617962566817fAnna Galusza /** 6912869157ba9b071f56691a285394500fa4c8a0a79Fan Zhang * Sets the id of the view containing the main content. Should be called before calling super's 6922f1c11314b9a82f808b376c69c2617962566817fAnna Galusza * onCreate. 6932f1c11314b9a82f808b376c69c2617962566817fAnna Galusza */ 6942f1c11314b9a82f808b376c69c2617962566817fAnna Galusza protected void setMainContentId(int contentId) { 6952f1c11314b9a82f808b376c69c2617962566817fAnna Galusza mMainContentId = contentId; 6962f1c11314b9a82f808b376c69c2617962566817fAnna Galusza } 6972f1c11314b9a82f808b376c69c2617962566817fAnna Galusza 698a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio private void setTitleFromIntent(Intent intent) { 699a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio final int initialTitleResId = intent.getIntExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1); 700a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio if (initialTitleResId > 0) { 701a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitle = null; 702a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitleResId = initialTitleResId; 70362464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina 70462464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina final String initialTitleResPackageName = intent.getStringExtra( 70562464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina EXTRA_SHOW_FRAGMENT_TITLE_RES_PACKAGE_NAME); 70662464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina if (initialTitleResPackageName != null) { 70762464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina try { 70862464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina Context authContext = createPackageContextAsUser(initialTitleResPackageName, 70962464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina 0 /* flags */, new UserHandle(UserHandle.myUserId())); 71062464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina mInitialTitle = authContext.getResources().getText(mInitialTitleResId); 71162464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina setTitle(mInitialTitle); 71262464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina mInitialTitleResId = -1; 71362464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina return; 71462464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina } catch (NameNotFoundException e) { 71562464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina Log.w(LOG_TAG, "Could not find package" + initialTitleResPackageName); 71662464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina } 71762464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina } else { 71862464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina setTitle(mInitialTitleResId); 71962464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina } 720a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } else { 721a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitleResId = -1; 722a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio final String initialTitle = intent.getStringExtra(EXTRA_SHOW_FRAGMENT_TITLE); 723a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitle = (initialTitle != null) ? initialTitle : getTitle(); 724a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio setTitle(mInitialTitle); 725a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } 726a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } 727a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio 728c95be4fbb3ec437517a2190d88fbda5068dba8dfFabrice Di Meglio @Override 729263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onBackStackChanged() { 730d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio setTitleFromBackStack(); 7318eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio } 7328eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio 7332869157ba9b071f56691a285394500fa4c8a0a79Fan Zhang private void setTitleFromBackStack() { 7348eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio final int count = getFragmentManager().getBackStackEntryCount(); 735b643cbf6d60bb4cd43d3191106d68680fffe97b5Fabrice Di Meglio 7368eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio if (count == 0) { 737a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio if (mInitialTitleResId > 0) { 738a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio setTitle(mInitialTitleResId); 739a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } else { 740a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio setTitle(mInitialTitle); 741a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } 7422869157ba9b071f56691a285394500fa4c8a0a79Fan Zhang return; 743263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 744b643cbf6d60bb4cd43d3191106d68680fffe97b5Fabrice Di Meglio 7458eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio FragmentManager.BackStackEntry bse = getFragmentManager().getBackStackEntryAt(count - 1); 7468eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio setTitleFromBackStackEntry(bse); 747263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 748263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 7498eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio private void setTitleFromBackStackEntry(FragmentManager.BackStackEntry bse) { 7505529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio final CharSequence title; 7518eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio final int titleRes = bse.getBreadCrumbTitleRes(); 7528eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio if (titleRes > 0) { 7538eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio title = getText(titleRes); 7545529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio } else { 7558eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio title = bse.getBreadCrumbTitle(); 7568eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio } 7578eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio if (title != null) { 7588eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio setTitle(title); 7595529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio } 7605529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio } 7615529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio 762263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 763263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio protected void onSaveInstanceState(Bundle outState) { 764263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio super.onSaveInstanceState(outState); 765263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 766769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio if (mCategories.size() > 0) { 767769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio outState.putParcelableArrayList(SAVE_KEY_CATEGORIES, mCategories); 768263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 769d6985df419549fbb7d420eced8e89f0429e49d71Fabrice Di Meglio 770b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio outState.putBoolean(SAVE_KEY_SHOW_HOME_AS_UP, mDisplayHomeAsUpEnabled); 7713d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio outState.putBoolean(SAVE_KEY_SHOW_SEARCH, mDisplaySearch); 7723d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio 7733d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio if (mDisplaySearch) { 7743d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio // The option menus are created if the ActionBar is visible and they are also created 7753d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio // asynchronously. If you launch Settings with an Intent action like 7763d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio // android.intent.action.POWER_USAGE_SUMMARY and at the same time your device is locked 7773d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio // thru a LockScreen, onCreateOptionsMenu() is not yet called and references to the search 7783d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio // menu item and search view are null. 7793d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio boolean isExpanded = (mSearchMenuItem != null) && mSearchMenuItem.isActionViewExpanded(); 7803d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio outState.putBoolean(SAVE_KEY_SEARCH_MENU_EXPANDED, isExpanded); 7813d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio 7823d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio String query = (mSearchView != null) ? mSearchView.getQuery().toString() : EMPTY_QUERY; 7833d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio outState.putString(SAVE_KEY_SEARCH_QUERY, query); 7843d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio } 785263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 786263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 787263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 78839b467482d1bf256a111c757e9b7621c6f523271Jason Monk protected void onResume() { 789263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio super.onResume(); 790263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 791263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mDevelopmentPreferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() { 792263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 793263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { 7944da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk updateTilesList(); 795263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 796263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }; 797263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mDevelopmentPreferences.registerOnSharedPreferenceChangeListener( 798263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mDevelopmentPreferencesListener); 799263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 800263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); 8016934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri registerReceiver(mUserAddRemoveReceiver, new IntentFilter(Intent.ACTION_USER_ADDED)); 8026934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri registerReceiver(mUserAddRemoveReceiver, new IntentFilter(Intent.ACTION_USER_REMOVED)); 803853e47181dc116ba95e91463735dc79ad4bdc95aSvetoslav 804d9779db8c966347734c5791cf63b7dc2e466a0f4Philip P. Moltmann mDynamicIndexableContentMonitor.register(this, LOADER_ID_INDEXABLE_CONTENT_MONITOR); 805a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio 8063d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio if(mDisplaySearch && !TextUtils.isEmpty(mSearchQuery)) { 807a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio onQueryTextSubmit(mSearchQuery); 808a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio } 8094da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk updateTilesList(); 810263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 811263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 812263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 81339b467482d1bf256a111c757e9b7621c6f523271Jason Monk protected void onPause() { 814263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio super.onPause(); 815263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio unregisterReceiver(mBatteryInfoReceiver); 8168c9521f27c86e86ff64ca5a086dea4a6a469a3e5Clara Bayarri unregisterReceiver(mUserAddRemoveReceiver); 817990159abaad7f314fbe1f9eaf064a088806ffb19Svetoslav mDynamicIndexableContentMonitor.unregister(); 818263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 819263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 820263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 821263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onDestroy() { 822263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio super.onDestroy(); 823680b064b293888ea47a6211943b51bee3adfb70dFabrice Di Meglio 824680b064b293888ea47a6211943b51bee3adfb70dFabrice Di Meglio mDevelopmentPreferences.unregisterOnSharedPreferenceChangeListener( 825680b064b293888ea47a6211943b51bee3adfb70dFabrice Di Meglio mDevelopmentPreferencesListener); 826680b064b293888ea47a6211943b51bee3adfb70dFabrice Di Meglio mDevelopmentPreferencesListener = null; 827263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 828263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 829263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio protected boolean isValidFragment(String fragmentName) { 830263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Almost all fragments are wrapped in this, 831263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // except for a few that have their own activities. 832263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio for (int i = 0; i < ENTRY_FRAGMENTS.length; i++) { 833263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (ENTRY_FRAGMENTS[i].equals(fragmentName)) return true; 834263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 835263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return false; 836263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 837263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 838263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 839263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public Intent getIntent() { 840263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio Intent superIntent = super.getIntent(); 841263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio String startingFragment = getStartingFragmentClass(superIntent); 842263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // This is called from super.onCreate, isMultiPane() is not yet reliable 843263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Do not use onIsHidingHeaders either, which relies itself on this method 844263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (startingFragment != null) { 845263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio Intent modIntent = new Intent(superIntent); 846263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio modIntent.putExtra(EXTRA_SHOW_FRAGMENT, startingFragment); 847263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio Bundle args = superIntent.getExtras(); 848263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (args != null) { 849263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio args = new Bundle(args); 850263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } else { 851263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio args = new Bundle(); 852263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 853263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio args.putParcelable("intent", superIntent); 854ac1e20ebfc233a4894fa04a29b5d86602ee188eeKenny Guy modIntent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, args); 855263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return modIntent; 856263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 857263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return superIntent; 858263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 859263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 860263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 861263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * Checks if the component name in the intent is different from the Settings class and 862263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * returns the class name to load as a fragment. 863263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio */ 864263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private String getStartingFragmentClass(Intent intent) { 865263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (mFragmentClass != null) return mFragmentClass; 866263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 867263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio String intentClass = intent.getComponent().getClassName(); 868263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (intentClass.equals(getClass().getName())) return null; 869263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 870263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if ("com.android.settings.ManageApplications".equals(intentClass) 871263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio || "com.android.settings.RunningServices".equals(intentClass) 872263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio || "com.android.settings.applications.StorageUse".equals(intentClass)) { 873263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Old names of manage apps. 874263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio intentClass = com.android.settings.applications.ManageApplications.class.getName(); 875263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 876263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 877263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return intentClass; 878263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 879263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 880263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 88110afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * Start a new fragment containing a preference panel. If the preferences 88210afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * are being displayed in multi-pane mode, the given fragment class will 88310afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * be instantiated and placed in the appropriate pane. If running in 88410afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * single-pane mode, a new activity will be launched in which to show the 88510afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * fragment. 88610afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * 88710afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param fragmentClass Full name of the class implementing the fragment. 88810afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param args Any desired arguments to supply to the fragment. 88910afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param titleRes Optional resource identifier of the title of this 89010afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * fragment. 89110afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param titleText Optional text of the title of this fragment. 89210afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param resultTo Optional fragment that result data should be sent to. 89310afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * If non-null, resultTo.onActivityResult() will be called when this 89410afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * preference panel is done. The launched panel must use 89510afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * {@link #finishPreferencePanel(Fragment, int, Intent)} when done. 89610afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param resultRequestCode If resultTo is non-null, this is the caller's 89758146c2b2fa24d774840a07cf697ad315baf4de0Fabrice Di Meglio * request code to be received with the result. 89810afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio */ 89910afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes, 900d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio CharSequence titleText, Fragment resultTo, int resultRequestCode) { 901a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio String title = null; 902a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio if (titleRes < 0) { 903a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio if (titleText != null) { 904a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio title = titleText.toString(); 905a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } else { 906a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio // There not much we can do in that case 907a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio title = ""; 908a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } 909911fb2ad907d47a882c023b871c6457db32359f8Fabrice Di Meglio } 910a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio Utils.startWithFragment(this, fragmentClass, args, resultTo, resultRequestCode, 9110d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio titleRes, title, mIsShortcut); 91210afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio } 91310afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio 91410afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio /** 9157a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * Start a new fragment in a new activity containing a preference panel for a given user. If the 9167a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * preferences are being displayed in multi-pane mode, the given fragment class will be 9177a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * instantiated and placed in the appropriate pane. If running in single-pane mode, a new 9187a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * activity will be launched in which to show the fragment. 9197a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * 9207a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * @param fragmentClass Full name of the class implementing the fragment. 9217a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * @param args Any desired arguments to supply to the fragment. 9227a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * @param titleRes Optional resource identifier of the title of this fragment. 9237a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * @param titleText Optional text of the title of this fragment. 9247a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * @param userHandle The user for which the panel has to be started. 9257a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban */ 9267a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban public void startPreferencePanelAsUser(String fragmentClass, Bundle args, int titleRes, 9277a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban CharSequence titleText, UserHandle userHandle) { 928d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // This is a workaround. 929d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // 930d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // Calling startWithFragmentAsUser() without specifying FLAG_ACTIVITY_NEW_TASK to the intent 931d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // starting the fragment could cause a native stack corruption. See b/17523189. However, 932d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // adding that flag and start the preference panel with the same UserHandler will make it 933d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // impossible to use back button to return to the previous screen. See b/20042570. 934d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // 935d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // We work around this issue by adding FLAG_ACTIVITY_NEW_TASK to the intent, while doing 936d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // another check here to call startPreferencePanel() instead of startWithFragmentAsUser() 937d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // when we're calling it as the same user. 938d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang if (userHandle.getIdentifier() == UserHandle.myUserId()) { 939d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang startPreferencePanel(fragmentClass, args, titleRes, titleText, null, 0); 940d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang } else { 941d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang String title = null; 942d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang if (titleRes < 0) { 943d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang if (titleText != null) { 944d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang title = titleText.toString(); 945d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang } else { 946d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // There not much we can do in that case 947d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang title = ""; 948d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang } 9497a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban } 950d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang Utils.startWithFragmentAsUser(this, fragmentClass, args, 951d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang titleRes, title, mIsShortcut, userHandle); 9527a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban } 9537a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban } 9547a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban 9557a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban /** 956263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * Called by a preference panel fragment to finish itself. 957263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * 958263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * @param caller The fragment that is asking to be finished. 959263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * @param resultCode Optional result code to send back to the original 960263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * launching fragment. 961263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * @param resultData Optional result data to send back to the original 962263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * launching fragment. 963263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio */ 964263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void finishPreferencePanel(Fragment caller, int resultCode, Intent resultData) { 965263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio setResult(resultCode, resultData); 96658146c2b2fa24d774840a07cf697ad315baf4de0Fabrice Di Meglio finish(); 967263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 968263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 969263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 97010afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * Start a new fragment. 97110afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * 97210afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param fragment The fragment to start 97310afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param push If true, the current fragment will be pushed onto the back stack. If false, 97410afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * the current fragment will be replaced. 97510afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio */ 97610afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio public void startPreferenceFragment(Fragment fragment, boolean push) { 97710afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio FragmentTransaction transaction = getFragmentManager().beginTransaction(); 9782f1c11314b9a82f808b376c69c2617962566817fAnna Galusza transaction.replace(mMainContentId, fragment); 97910afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio if (push) { 98010afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); 98110afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio transaction.addToBackStack(BACK_STACK_PREFS); 98210afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio } else { 98310afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); 98410afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio } 98510afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio transaction.commitAllowingStateLoss(); 98610afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio } 98710afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio 98810afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio /** 989d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio * Switch to a specific Fragment with taking care of validation, Title and BackStack 990d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio */ 991d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate, 992a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio boolean addToBackStack, int titleResId, CharSequence title, boolean withTransition) { 993d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (validate && !isValidFragment(fragmentName)) { 994d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio throw new IllegalArgumentException("Invalid fragment for this activity: " 995d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio + fragmentName); 996d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 997d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio Fragment f = Fragment.instantiate(this, fragmentName, args); 998d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio FragmentTransaction transaction = getFragmentManager().beginTransaction(); 9992f1c11314b9a82f808b376c69c2617962566817fAnna Galusza transaction.replace(mMainContentId, f); 1000d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (withTransition) { 100159a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglio TransitionManager.beginDelayedTransition(mContent); 1002d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1003d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (addToBackStack) { 1004d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio transaction.addToBackStack(SettingsActivity.BACK_STACK_PREFS); 1005d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1006a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio if (titleResId > 0) { 1007a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio transaction.setBreadCrumbTitle(titleResId); 1008a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } else if (title != null) { 1009d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio transaction.setBreadCrumbTitle(title); 1010d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1011d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio transaction.commitAllowingStateLoss(); 101259a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglio getFragmentManager().executePendingTransactions(); 1013d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return f; 1014d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1015d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 10164da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk private void updateTilesList() { 1017fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk // Generally the items that are will be changing from these updates will 1018fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk // not be in the top list of tiles, so run it in the background and the 1019fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk // SettingsDrawerActivity will pick up on the updates automatically. 1020fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk AsyncTask.execute(new Runnable() { 1021fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk @Override 1022fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk public void run() { 1023fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk doUpdateTilesList(); 1024fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk } 1025fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk }); 1026fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk } 1027fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk 1028fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk private void doUpdateTilesList() { 10294da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk PackageManager pm = getPackageManager(); 10304da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk final UserManager um = UserManager.get(this); 10314da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk final boolean isAdmin = um.isAdminUser(); 103263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 10334da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk String packageName = getPackageName(); 10344da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, WifiSettingsActivity.class.getName()), 10354da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk pm.hasSystemFeature(PackageManager.FEATURE_WIFI), isAdmin, pm); 103663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 10374da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, 10384da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.BluetoothSettingsActivity.class.getName()), 10394da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH), isAdmin, pm); 104063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 10414da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, 10424da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.DataUsageSummaryActivity.class.getName()), 10434da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Utils.isBandwidthControlEnabled(), isAdmin, pm); 104463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 10454da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, 10464da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.SimSettingsActivity.class.getName()), 10474da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Utils.showSimCardTile(this), isAdmin, pm); 104863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 10494da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, 10504da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.PowerUsageSummaryActivity.class.getName()), 10514da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk mBatteryPresent, isAdmin, pm); 105263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 10534da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, 10544da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.UserSettingsActivity.class.getName()), 10554da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk UserHandle.MU_ENABLED && UserManager.supportsMultipleUsers() 10564da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk && !Utils.isMonkeyRunning(), isAdmin, pm); 105763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 10584da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this); 10594da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, 10604da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.PaymentSettingsActivity.class.getName()), 10614da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk pm.hasSystemFeature(PackageManager.FEATURE_NFC) 10624da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk && pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION) 10634da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk && adapter != null && adapter.isEnabled(), isAdmin, pm); 10644da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk 10654da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, 10664da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.PrintSettingsActivity.class.getName()), 10674da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk pm.hasSystemFeature(PackageManager.FEATURE_PRINTING), isAdmin, pm); 106863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 106963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio final boolean showDev = mDevelopmentPreferences.getBoolean( 107012c4ba4224a42d54ef671302a09c14ed0d3c09b0Dan Sandler DevelopmentSettings.PREF_SHOW, android.os.Build.TYPE.equals("eng")) 107112c4ba4224a42d54ef671302a09c14ed0d3c09b0Dan Sandler && !um.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES); 10724da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, 10734da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.DevelopmentSettingsActivity.class.getName()), 107412c4ba4224a42d54ef671302a09c14ed0d3c09b0Dan Sandler showDev, isAdmin, pm); 107512c4ba4224a42d54ef671302a09c14ed0d3c09b0Dan Sandler 107612c4ba4224a42d54ef671302a09c14ed0d3c09b0Dan Sandler // Reveal development-only quick settings tiles 107712c4ba4224a42d54ef671302a09c14ed0d3c09b0Dan Sandler DevelopmentTiles.setTilesEnabled(this, showDev); 10784da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk 10794da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk if (UserHandle.MU_ENABLED && !isAdmin) { 10804da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk // When on restricted users, disable all extra categories (but only the settings ones). 1081fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk List<DashboardCategory> categories = getDashboardCategories(); 10824da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk for (DashboardCategory category : categories) { 1083d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk for (Tile tile : category.tiles) { 10844da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk ComponentName component = tile.intent.getComponent(); 10854da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk if (packageName.equals(component)&& !ArrayUtils.contains( 10864da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk SETTINGS_FOR_RESTRICTED, component.getClassName())) { 10874da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(component, false, isAdmin, pm); 108863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 108957fd5fd84be2497845f6c03905500d2a36668b6cAmith Yamasani } 109063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 109163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 10922ebc8a01696c4e7dd29863b92a15ae0bbbbb254dJason Monk } 10932ebc8a01696c4e7dd29863b92a15ae0bbbbb254dJason Monk 10944da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk private void setTileEnabled(ComponentName component, boolean enabled, boolean isAdmin, 10954da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk PackageManager pm) { 10964da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk if (UserHandle.MU_ENABLED && !isAdmin 10974da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk && !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, component.getClassName())) { 10984da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk enabled = false; 10992ebc8a01696c4e7dd29863b92a15ae0bbbbb254dJason Monk } 11004da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk int state = pm.getComponentEnabledSetting(component); 1101cd6a2115c64f89fb52119a08a164e242a7363455Clara Bayarri boolean isEnabled = state == PackageManager.COMPONENT_ENABLED_STATE_ENABLED; 11024da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk if (isEnabled != enabled) { 11034da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk pm.setComponentEnabledSetting(component, enabled 11044da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED 11054da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 11064da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk PackageManager.DONT_KILL_APP); 11072ebc8a01696c4e7dd29863b92a15ae0bbbbb254dJason Monk } 110863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 110963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 1110263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private void getMetaData() { 1111263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio try { 1112263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio ActivityInfo ai = getPackageManager().getActivityInfo(getComponentName(), 1113263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PackageManager.GET_META_DATA); 1114263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (ai == null || ai.metaData == null) return; 1115263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mFragmentClass = ai.metaData.getString(META_DATA_KEY_FRAGMENT_CLASS); 1116263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } catch (NameNotFoundException nnfe) { 1117263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // No recovery 1118263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio Log.d(LOG_TAG, "Cannot get Metadata for: " + getComponentName().toString()); 1119263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1120263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1121263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1122263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // give subclasses access to the Next button 1123263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public boolean hasNextButton() { 1124263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return mNextButton != null; 1125263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1126263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1127263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public Button getNextButton() { 1128263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return mNextButton; 1129263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1130263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1131263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 1132263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public boolean shouldUpRecreateTask(Intent targetIntent) { 1133263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return super.shouldUpRecreateTask(new Intent(this, SettingsActivity.class)); 1134263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1135263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1136d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 1137d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onQueryTextSubmit(String query) { 1138d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio switchToSearchResultsFragmentIfNeeded(); 1139d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchQuery = query; 1140d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return mSearchResultsFragment.onQueryTextSubmit(query); 1141d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1142263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1143d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 1144d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onQueryTextChange(String newText) { 1145d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchQuery = newText; 11467e4855e8f644bdecf68ec65b8c1b7c08624a4876Fabrice Di Meglio if (mSearchResultsFragment == null) { 1147a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio return false; 1148a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio } 1149a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio return mSearchResultsFragment.onQueryTextChange(newText); 1150d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1151263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1152d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 1153d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onClose() { 1154d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return false; 1155d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1156263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1157d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 1158d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onMenuItemActionExpand(MenuItem item) { 1159d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (item.getItemId() == mSearchMenuItem.getItemId()) { 1160bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio switchToSearchResultsFragmentIfNeeded(); 1161263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1162d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return true; 1163d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1164263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1165d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 1166d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onMenuItemActionCollapse(MenuItem item) { 1167d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (item.getItemId() == mSearchMenuItem.getItemId()) { 1168bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio if (mSearchMenuItemExpanded) { 1169d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio revertToInitialFragment(); 1170263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1171263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1172d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return true; 1173d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1174263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 11754da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk @Override 1176d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk protected void onTileClicked(Tile tile) { 11774da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk if (mIsShowingDashboard) { 11784da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk // If on dashboard, don't finish so the back comes back to here. 11794da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk openTile(tile); 11804da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk } else { 11814da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk super.onTileClicked(tile); 11824da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk } 11834da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk } 11844da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk 1185af00109242a5766ca9418b145c4fb098360c5648Jason Monk @Override 1186af00109242a5766ca9418b145c4fb098360c5648Jason Monk public void onProfileTileOpen() { 1187af00109242a5766ca9418b145c4fb098360c5648Jason Monk if (!mIsShowingDashboard) { 1188af00109242a5766ca9418b145c4fb098360c5648Jason Monk finish(); 1189af00109242a5766ca9418b145c4fb098360c5648Jason Monk } 1190af00109242a5766ca9418b145c4fb098360c5648Jason Monk } 1191af00109242a5766ca9418b145c4fb098360c5648Jason Monk 1192d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private void switchToSearchResultsFragmentIfNeeded() { 1193bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio if (mSearchResultsFragment != null) { 1194bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio return; 1195263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 11962f1c11314b9a82f808b376c69c2617962566817fAnna Galusza Fragment current = getFragmentManager().findFragmentById(mMainContentId); 1197bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio if (current != null && current instanceof SearchResultsSummary) { 1198bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio mSearchResultsFragment = (SearchResultsSummary) current; 1199bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio } else { 12002869157ba9b071f56691a285394500fa4c8a0a79Fan Zhang setContentHeaderView(null); 1201bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio mSearchResultsFragment = (SearchResultsSummary) switchToFragment( 1202a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio SearchResultsSummary.class.getName(), null, false, true, 1203a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio R.string.search_results_title, null, true); 1204bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio } 1205d297a5840230b769a3c7ad8b85232968a7077f64Fabrice Di Meglio mSearchResultsFragment.setSearchView(mSearchView); 1206bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio mSearchMenuItemExpanded = true; 1207d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1208263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1209d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public void needToRevertToInitialFragment() { 1210d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mNeedToRevertToInitialFragment = true; 1211d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1212263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1213d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private void revertToInitialFragment() { 1214d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mNeedToRevertToInitialFragment = false; 1215d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchResultsFragment = null; 1216bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio mSearchMenuItemExpanded = false; 1217bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio getFragmentManager().popBackStackImmediate(SettingsActivity.BACK_STACK_PREFS, 1218bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio FragmentManager.POP_BACK_STACK_INCLUSIVE); 121923ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio if (mSearchMenuItem != null) { 122023ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio mSearchMenuItem.collapseActionView(); 122123ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio } 1222263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 12230698a216311acd9ab52224602d1a75c08bf89f04Jim Miller 12240698a216311acd9ab52224602d1a75c08bf89f04Jim Miller public Intent getResultIntentData() { 12250698a216311acd9ab52224602d1a75c08bf89f04Jim Miller return mResultIntentData; 12260698a216311acd9ab52224602d1a75c08bf89f04Jim Miller } 12270698a216311acd9ab52224602d1a75c08bf89f04Jim Miller 12280698a216311acd9ab52224602d1a75c08bf89f04Jim Miller public void setResultIntentData(Intent resultIntentData) { 12290698a216311acd9ab52224602d1a75c08bf89f04Jim Miller mResultIntentData = resultIntentData; 12300698a216311acd9ab52224602d1a75c08bf89f04Jim Miller } 1231d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk 1232d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk public void startSuggestion(Intent intent) { 1233d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk mCurrentSuggestion = intent.getComponent(); 1234d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk startActivityForResult(intent, REQUEST_SUGGESTION); 1235d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk } 1236d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk 1237d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk @Override 1238d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk protected void onActivityResult(int requestCode, int resultCode, Intent data) { 1239d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk if (requestCode == REQUEST_SUGGESTION && mCurrentSuggestion != null 1240d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk && resultCode != RESULT_CANCELED) { 1241d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk getPackageManager().setComponentEnabledSetting(mCurrentSuggestion, 1242d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); 1243d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk } 1244d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk super.onActivityResult(requestCode, resultCode, data); 1245d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk } 1246d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk 1247263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio} 1248