SettingsActivity.java revision 12c4ba4224a42d54ef671302a09c14ed0d3c09b0
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; 52263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.internal.util.ArrayUtils; 534da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monkimport com.android.settings.Settings.WifiSettingsActivity; 54263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.accessibility.AccessibilitySettings; 55b1795f554921249420bf588280396d6920541556Anna Galuszaimport com.android.settings.accessibility.AccessibilitySettingsForSetupWizard; 56263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.accessibility.CaptionPropertiesFragment; 576d839875b74f1570e8807005c586298beb677413Alexandra Gherghinaimport com.android.settings.accounts.AccountSettings; 58263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.accounts.AccountSyncSettings; 5991e2f89b0f8b440728fe395ee02a71ae59e21ffcJason Monkimport com.android.settings.applications.AdvancedAppSettings; 60fee785645b57c519a31ed403e60e8f76dcc8abbbBilly Lauimport com.android.settings.applications.DrawOverlayDetails; 61d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglioimport com.android.settings.applications.InstalledAppDetails; 62263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.applications.ManageApplications; 6386a554091d0705f2152fcf1d78ca1c7720d9842cXiyuan Xiaimport com.android.settings.applications.ManageAssist; 64a2d47fcf59f03d091edaf5895fd3b651e1f499e1Jason Monkimport com.android.settings.applications.NotificationApps; 652cdafc6be386bb767404e42fc728a1a810aa896aJason Monkimport com.android.settings.applications.ProcessStatsSummary; 66263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.applications.ProcessStatsUi; 67d8da51ccfecf16f2c06f788e6bcbc232d1f0cb32Jason Monkimport com.android.settings.applications.UsageAccessDetails; 68fee785645b57c519a31ed403e60e8f76dcc8abbbBilly Lauimport com.android.settings.applications.WriteSettingsDetails; 69c461d5c03d652907c1b726cd0110a407d1c5bee8Ruben Brunkimport com.android.settings.applications.VrListenerSettings; 70263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.bluetooth.BluetoothSettings; 71263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.dashboard.DashboardSummary; 72d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglioimport com.android.settings.dashboard.SearchResultsSummary; 73b37e2887d3112082589997f1bbd802ec282cca6dJason Monkimport com.android.settings.datausage.DataUsageSummary; 74a16257dbd5599135320f4263a2cb438b7a469084Jeff Sharkeyimport com.android.settings.deviceinfo.PrivateVolumeForget; 75e77f0687dd424ccfdc2b1061221c6c8ba4d6ac8dJeff Sharkeyimport com.android.settings.deviceinfo.PrivateVolumeSettings; 7642833b2ff4d7a26dd9a609d2fd4436d9a26f28b5Jeff Sharkeyimport com.android.settings.deviceinfo.PublicVolumeSettings; 7742833b2ff4d7a26dd9a609d2fd4436d9a26f28b5Jeff Sharkeyimport com.android.settings.deviceinfo.StorageSettings; 78c7f8e8ce69e80ea495472aade5f8569c6583c5e8John Spurlockimport com.android.settings.fuelgauge.BatterySaverSettings; 791eb54eb2ff250eccdd700601011bd6457ddcbec1Jason Monkimport com.android.settings.fuelgauge.PowerUsageDetail; 80263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.fuelgauge.PowerUsageSummary; 81976bb3f45915bdd5165d9a50402d4c1163dae809Abodunrinwa Tokiimport com.android.settings.inputmethod.AvailableVirtualKeyboardFragment; 82263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.inputmethod.InputMethodAndLanguageSettings; 83263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.inputmethod.KeyboardLayoutPickerFragment; 845f0b59babfbfe483855b294098613f8d0fc2f9b4Abodunrinwa Tokiimport com.android.settings.inputmethod.KeyboardLayoutPickerFragment2; 85b28b2cc68f0f61388383d1dd75630c3b86597a8eAbodunrinwa Tokiimport com.android.settings.inputmethod.PhysicalKeyboardFragment; 86263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.inputmethod.SpellCheckersSettings; 87263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.inputmethod.UserDictionaryList; 88d7d48fda53747a7a25e903d9ef6defa6ea590ebbMihai Nitaimport com.android.settings.localepicker.LocaleListEditor; 89263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.location.LocationSettings; 90263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.nfc.AndroidBeam; 91263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.nfc.PaymentSettings; 92802ddf99f57e316d0fd87c2cfeed5dc3a0cfa8feJohn Spurlockimport com.android.settings.notification.AppNotificationSettings; 938c0a4238655990094fe444ac8f7b182963497030Julia Reynoldsimport com.android.settings.notification.ConfigureNotificationSettings; 944a35051565b0ce6d29313c3e4ffe19e1dde78db0John Spurlockimport com.android.settings.notification.NotificationAccessSettings; 954a35051565b0ce6d29313c3e4ffe19e1dde78db0John Spurlockimport com.android.settings.notification.NotificationStation; 962ebc8a01696c4e7dd29863b92a15ae0bbbbb254dJason Monkimport com.android.settings.notification.OtherSoundSettings; 97b37e2887d3112082589997f1bbd802ec282cca6dJason Monkimport com.android.settings.notification.SoundSettings; 9808531a81cb34dc45f0da4ca88e8530169831c7d2John Spurlockimport com.android.settings.notification.ZenAccessSettings; 99533a5664da21d6bf8819623673fe14b20ba23207John Spurlockimport com.android.settings.notification.ZenModeAutomationSettings; 100f57bad7d5b0f9044231fc52351ed27e14013f491John Spurlockimport com.android.settings.notification.ZenModeEventRuleSettings; 101c1df2aa9639a27fa6d759b21a760b6b63e38a1c2John Spurlockimport com.android.settings.notification.ZenModePrioritySettings; 10245fa140b8c6846b4546fdeabebf989ae9102cebbJohn Spurlockimport com.android.settings.notification.ZenModeScheduleRuleSettings; 10339b467482d1bf256a111c757e9b7621c6f523271Jason Monkimport com.android.settings.notification.ZenModeSettings; 1045555d26b209d8856d862e7fe369f34cb29dcd3a7Julia Reynoldsimport com.android.settings.notification.ZenModeVisualInterruptionSettings; 105263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.print.PrintJobSettingsFragment; 106263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.print.PrintSettingsFragment; 10712c4ba4224a42d54ef671302a09c14ed0d3c09b0Dan Sandlerimport com.android.settings.qstile.DevelopmentTiles; 1082ebc8a01696c4e7dd29863b92a15ae0bbbbb254dJason Monkimport com.android.settings.search.DynamicIndexableContentMonitor; 1092ebc8a01696c4e7dd29863b92a15ae0bbbbb254dJason Monkimport com.android.settings.search.Index; 1103815561997eced7fd773062ce32eaa50bece072cPauloftheWestimport com.android.settings.sim.SimSettings; 111263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.tts.TextToSpeechSettings; 112263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.users.UserSettings; 113263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.vpn2.VpnSettings; 114263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.wfd.WifiDisplaySettings; 11541937766981423c9252e12e3319b2e7532739627Fabrice Di Meglioimport com.android.settings.widget.SwitchBar; 116263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.wifi.AdvancedWifiSettings; 1177837b999862cf341b0f124be7ace1dfc64d0a5a8PauloftheWestimport com.android.settings.wifi.SavedAccessPointsWifiSettings; 118263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.wifi.WifiSettings; 119263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.wifi.p2p.WifiP2pSettings; 1204da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monkimport com.android.settingslib.drawer.DashboardCategory; 1214da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monkimport com.android.settingslib.drawer.SettingsDrawerActivity; 1227ea14c5625c988a81c09625f54faed846fc07ec7Jason Monkimport com.android.settingslib.drawer.Tile; 1232ebc8a01696c4e7dd29863b92a15ae0bbbbb254dJason Monk 124263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport java.util.ArrayList; 125263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport java.util.List; 1260d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglioimport java.util.Set; 127263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1284da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monkpublic class SettingsActivity extends SettingsDrawerActivity 129263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio implements PreferenceManager.OnPreferenceTreeClickListener, 130263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PreferenceFragment.OnPreferenceStartFragmentCallback, 131cfc7f9d9600f7b4514ce9608314874bf1023eb21Alexandra Gherghina ButtonBarHandler, FragmentManager.OnBackStackChangedListener, 132d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio SearchView.OnQueryTextListener, SearchView.OnCloseListener, 133cfc7f9d9600f7b4514ce9608314874bf1023eb21Alexandra Gherghina MenuItem.OnActionExpandListener { 134263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 135263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private static final String LOG_TAG = "Settings"; 136263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 137d9779db8c966347734c5791cf63b7dc2e466a0f4Philip P. Moltmann private static final int LOADER_ID_INDEXABLE_CONTENT_MONITOR = 1; 138d9779db8c966347734c5791cf63b7dc2e466a0f4Philip P. Moltmann 139263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Constants for state save/restore 140769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio private static final String SAVE_KEY_CATEGORIES = ":settings:categories"; 141d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private static final String SAVE_KEY_SEARCH_MENU_EXPANDED = ":settings:search_menu_expanded"; 142d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private static final String SAVE_KEY_SEARCH_QUERY = ":settings:search_query"; 143b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio private static final String SAVE_KEY_SHOW_HOME_AS_UP = ":settings:show_home_as_up"; 1443d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio private static final String SAVE_KEY_SHOW_SEARCH = ":settings:show_search"; 145ceb335f88fc0df88dafc8063733842afe35c5da1Fabrice Di Meglio private static final String SAVE_KEY_HOME_ACTIVITIES_COUNT = ":settings:home_activities_count"; 146263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 147263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 148263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * When starting this activity, the invoking Intent can contain this extra 149263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * string to specify which fragment should be initially displayed. 150263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * <p/>Starting from Key Lime Pie, when this argument is passed in, the activity 151263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * will call isValidFragment() to confirm that the fragment class name is valid for this 152263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * activity. 153263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio */ 154263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public static final String EXTRA_SHOW_FRAGMENT = ":settings:show_fragment"; 155263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 156263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 157263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT}, 158263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * this extra can also be specified to supply a Bundle of arguments to pass 159263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * to that fragment when it is instantiated during the initial creation 160263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * of the activity. 161263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio */ 162263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public static final String EXTRA_SHOW_FRAGMENT_ARGUMENTS = ":settings:show_fragment_args"; 163263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 164263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 165c1457323d271309d5d1955743cd806417c84b9d6Fabrice Di Meglio * Fragment "key" argument passed thru {@link #EXTRA_SHOW_FRAGMENT_ARGUMENTS} 166c1457323d271309d5d1955743cd806417c84b9d6Fabrice Di Meglio */ 167c1457323d271309d5d1955743cd806417c84b9d6Fabrice Di Meglio public static final String EXTRA_FRAGMENT_ARG_KEY = ":settings:fragment_args_key"; 168c1457323d271309d5d1955743cd806417c84b9d6Fabrice Di Meglio 1696f0739a3d9a9eca1591ae6bada1dd4d1d92c0defFabrice Di Meglio public static final String BACK_STACK_PREFS = ":settings:prefs"; 1706f0739a3d9a9eca1591ae6bada1dd4d1d92c0defFabrice Di Meglio 171263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // extras that allow any preference activity to be launched as part of a wizard 172263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 173263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // show Back and Next buttons? takes boolean parameter 174263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Back will then return RESULT_CANCELED and Next RESULT_OK 175263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio protected static final String EXTRA_PREFS_SHOW_BUTTON_BAR = "extra_prefs_show_button_bar"; 176263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 177263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // add a Skip button? 178263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private static final String EXTRA_PREFS_SHOW_SKIP = "extra_prefs_show_skip"; 179263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 180263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // specify custom text for the Back or Next buttons, or cause a button to not appear 181263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // at all by setting it to null 182263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio protected static final String EXTRA_PREFS_SET_NEXT_TEXT = "extra_prefs_set_next_text"; 183263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio protected static final String EXTRA_PREFS_SET_BACK_TEXT = "extra_prefs_set_back_text"; 184263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 185263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 186263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT}, 187a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio * those extra can also be specify to supply the title or title res id to be shown for 188263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * that fragment. 189263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio */ 190d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public static final String EXTRA_SHOW_FRAGMENT_TITLE = ":settings:show_fragment_title"; 19162464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina /** 19262464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina * The package name used to resolve the title resource id. 19362464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina */ 19462464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina public static final String EXTRA_SHOW_FRAGMENT_TITLE_RES_PACKAGE_NAME = 19562464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina ":settings:show_fragment_title_res_package_name"; 19661a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio public static final String EXTRA_SHOW_FRAGMENT_TITLE_RESID = 19761a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio ":settings:show_fragment_title_resid"; 19861a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio public static final String EXTRA_SHOW_FRAGMENT_AS_SHORTCUT = 19961a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio ":settings:show_fragment_as_shortcut"; 20061a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio 20161a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio public static final String EXTRA_SHOW_FRAGMENT_AS_SUBSETTING = 20261a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio ":settings:show_fragment_as_subsetting"; 203263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 20492779ce70156031f4fa3b8c2d84305f5b3b44105Udam Saini public static final String EXTRA_HIDE_DRAWER = ":settings:hide_drawer"; 20592779ce70156031f4fa3b8c2d84305f5b3b44105Udam Saini 2063069581512bcb9687cb8d79675f6c4950c9ac087Jason Monk public static final String META_DATA_KEY_FRAGMENT_CLASS = 207263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio "com.android.settings.FRAGMENT_CLASS"; 208263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 209263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private static final String EXTRA_UI_OPTIONS = "settings:ui_options"; 210263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 211d6985df419549fbb7d420eced8e89f0429e49d71Fabrice Di Meglio private static final String EMPTY_QUERY = ""; 212d6985df419549fbb7d420eced8e89f0429e49d71Fabrice Di Meglio 213d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk private static final int REQUEST_SUGGESTION = 42; 214d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk 215263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private String mFragmentClass; 216263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 2178eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio private CharSequence mInitialTitle; 218a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio private int mInitialTitleResId; 2198eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio 220263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Show only these settings for restricted users 2214da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk private String[] SETTINGS_FOR_RESTRICTED = { 2224da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk //wireless_section 2234da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk WifiSettingsActivity.class.getName(), 2244da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.BluetoothSettingsActivity.class.getName(), 2254da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.DataUsageSummaryActivity.class.getName(), 2264da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.SimSettingsActivity.class.getName(), 2274da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.WirelessSettingsActivity.class.getName(), 2284da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk //device_section 2294da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.HomeSettingsActivity.class.getName(), 2308c0a4238655990094fe444ac8f7b182963497030Julia Reynolds Settings.SoundSettingsActivity.class.getName(), 2314da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.DisplaySettingsActivity.class.getName(), 2324da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.StorageSettingsActivity.class.getName(), 2334da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.ManageApplicationsActivity.class.getName(), 2344da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.PowerUsageSummaryActivity.class.getName(), 2354da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk //personal_section 2364da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.LocationSettingsActivity.class.getName(), 2374da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.SecuritySettingsActivity.class.getName(), 2384da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.InputMethodAndLanguageSettingsActivity.class.getName(), 2394da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.UserSettingsActivity.class.getName(), 2404da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.AccountSettingsActivity.class.getName(), 2414da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk //system_section 2424da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.DateTimeSettingsActivity.class.getName(), 2434da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.DeviceInfoSettingsActivity.class.getName(), 2444da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.AccessibilitySettingsActivity.class.getName(), 2454da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.PrintSettingsActivity.class.getName(), 2464da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.PaymentSettingsActivity.class.getName(), 247263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }; 248263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 249263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private static final String[] ENTRY_FRAGMENTS = { 250263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio WirelessSettings.class.getName(), 251263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio WifiSettings.class.getName(), 252263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio AdvancedWifiSettings.class.getName(), 2537837b999862cf341b0f124be7ace1dfc64d0a5a8PauloftheWest SavedAccessPointsWifiSettings.class.getName(), 254263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio BluetoothSettings.class.getName(), 2553815561997eced7fd773062ce32eaa50bece072cPauloftheWest SimSettings.class.getName(), 256263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio TetherSettings.class.getName(), 257263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio WifiP2pSettings.class.getName(), 258263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio VpnSettings.class.getName(), 259263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DateTimeSettings.class.getName(), 260d7d48fda53747a7a25e903d9ef6defa6ea590ebbMihai Nita LocaleListEditor.class.getName(), 261263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio InputMethodAndLanguageSettings.class.getName(), 262976bb3f45915bdd5165d9a50402d4c1163dae809Abodunrinwa Toki AvailableVirtualKeyboardFragment.class.getName(), 263263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio SpellCheckersSettings.class.getName(), 264263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio UserDictionaryList.class.getName(), 265263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio UserDictionarySettings.class.getName(), 2663033ce0723103b55b1b5a53145c05e143b5bbfd6Amith Yamasani HomeSettings.class.getName(), 267263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DisplaySettings.class.getName(), 268263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DeviceInfoSettings.class.getName(), 269263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio ManageApplications.class.getName(), 270a2d47fcf59f03d091edaf5895fd3b651e1f499e1Jason Monk NotificationApps.class.getName(), 27186a554091d0705f2152fcf1d78ca1c7720d9842cXiyuan Xia ManageAssist.class.getName(), 272263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio ProcessStatsUi.class.getName(), 273263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio NotificationStation.class.getName(), 274263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio LocationSettings.class.getName(), 275263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio SecuritySettings.class.getName(), 276d8da51ccfecf16f2c06f788e6bcbc232d1f0cb32Jason Monk UsageAccessDetails.class.getName(), 277263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PrivacySettings.class.getName(), 278263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DeviceAdminSettings.class.getName(), 279263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio AccessibilitySettings.class.getName(), 280b1795f554921249420bf588280396d6920541556Anna Galusza AccessibilitySettingsForSetupWizard.class.getName(), 281263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio CaptionPropertiesFragment.class.getName(), 282263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment.class.getName(), 283263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio TextToSpeechSettings.class.getName(), 28442833b2ff4d7a26dd9a609d2fd4436d9a26f28b5Jeff Sharkey StorageSettings.class.getName(), 285a16257dbd5599135320f4263a2cb438b7a469084Jeff Sharkey PrivateVolumeForget.class.getName(), 286e77f0687dd424ccfdc2b1061221c6c8ba4d6ac8dJeff Sharkey PrivateVolumeSettings.class.getName(), 287e77f0687dd424ccfdc2b1061221c6c8ba4d6ac8dJeff Sharkey PublicVolumeSettings.class.getName(), 288263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DevelopmentSettings.class.getName(), 289263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio AndroidBeam.class.getName(), 290263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio WifiDisplaySettings.class.getName(), 291263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PowerUsageSummary.class.getName(), 292263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio AccountSyncSettings.class.getName(), 2936d839875b74f1570e8807005c586298beb677413Alexandra Gherghina AccountSettings.class.getName(), 294263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio CryptKeeperSettings.class.getName(), 295263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DataUsageSummary.class.getName(), 296263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DreamSettings.class.getName(), 297263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio UserSettings.class.getName(), 298263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio NotificationAccessSettings.class.getName(), 29908531a81cb34dc45f0da4ca88e8530169831c7d2John Spurlock ZenAccessSettings.class.getName(), 300263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PrintSettingsFragment.class.getName(), 301263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PrintJobSettingsFragment.class.getName(), 302263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio TrustedCredentialsSettings.class.getName(), 303263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PaymentSettings.class.getName(), 304263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio KeyboardLayoutPickerFragment.class.getName(), 3055f0b59babfbfe483855b294098613f8d0fc2f9b4Abodunrinwa Toki KeyboardLayoutPickerFragment2.class.getName(), 306b28b2cc68f0f61388383d1dd75630c3b86597a8eAbodunrinwa Toki PhysicalKeyboardFragment.class.getName(), 307d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio ZenModeSettings.class.getName(), 3088c0a4238655990094fe444ac8f7b182963497030Julia Reynolds SoundSettings.class.getName(), 3098c0a4238655990094fe444ac8f7b182963497030Julia Reynolds ConfigureNotificationSettings.class.getName(), 310d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio ChooseLockPassword.ChooseLockPasswordFragment.class.getName(), 311d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio ChooseLockPattern.ChooseLockPatternFragment.class.getName(), 312c7f8e8ce69e80ea495472aade5f8569c6583c5e8John Spurlock InstalledAppDetails.class.getName(), 313c7f8e8ce69e80ea495472aade5f8569c6583c5e8John Spurlock BatterySaverSettings.class.getName(), 314dcf59dd82ca5a5b211461f1c2825623325c3811cFabrice Di Meglio AppNotificationSettings.class.getName(), 315e3ff4d8e92a19473c622c1d46b30c63bf2d001d0Fabrice Di Meglio OtherSoundSettings.class.getName(), 31633acb15e032ac65d743b708731004b9a5f7813d5Narayan Kamath ApnSettings.class.getName(), 31745fa140b8c6846b4546fdeabebf989ae9102cebbJohn Spurlock WifiCallingSettings.class.getName(), 318c1df2aa9639a27fa6d759b21a760b6b63e38a1c2John Spurlock ZenModePrioritySettings.class.getName(), 319533a5664da21d6bf8819623673fe14b20ba23207John Spurlock ZenModeAutomationSettings.class.getName(), 32045fa140b8c6846b4546fdeabebf989ae9102cebbJohn Spurlock ZenModeScheduleRuleSettings.class.getName(), 321f57bad7d5b0f9044231fc52351ed27e14013f491John Spurlock ZenModeEventRuleSettings.class.getName(), 3225555d26b209d8856d862e7fe369f34cb29dcd3a7Julia Reynolds ZenModeVisualInterruptionSettings.class.getName(), 3232583fc1e069d0a54df46258d360499492d7e86d2Jason Monk ProcessStatsUi.class.getName(), 3241eb54eb2ff250eccdd700601011bd6457ddcbec1Jason Monk PowerUsageDetail.class.getName(), 3252cdafc6be386bb767404e42fc728a1a810aa896aJason Monk ProcessStatsSummary.class.getName(), 326fee785645b57c519a31ed403e60e8f76dcc8abbbBilly Lau DrawOverlayDetails.class.getName(), 327fee785645b57c519a31ed403e60e8f76dcc8abbbBilly Lau WriteSettingsDetails.class.getName(), 32891e2f89b0f8b440728fe395ee02a71ae59e21ffcJason Monk AdvancedAppSettings.class.getName(), 329b9e5d238b64abf3a45f148b43b8d8fcca912d976Jason Monk WallpaperTypeSettings.class.getName(), 330c461d5c03d652907c1b726cd0110a407d1c5bee8Ruben Brunk VrListenerSettings.class.getName(), 331263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }; 332263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 3335a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio 3345a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio private static final String[] LIKE_SHORTCUT_INTENT_ACTION_ARRAY = { 3355a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio "android.settings.APPLICATION_DETAILS_SETTINGS" 3365a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio }; 3375a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio 338263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private SharedPreferences mDevelopmentPreferences; 339263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private SharedPreferences.OnSharedPreferenceChangeListener mDevelopmentPreferencesListener; 340263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 341263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private boolean mBatteryPresent = true; 342263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private BroadcastReceiver mBatteryInfoReceiver = new BroadcastReceiver() { 343263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 344263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onReceive(Context context, Intent intent) { 345263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio String action = intent.getAction(); 346263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (Intent.ACTION_BATTERY_CHANGED.equals(action)) { 347263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio boolean batteryPresent = Utils.isBatteryPresent(intent); 348263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 349263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (mBatteryPresent != batteryPresent) { 350263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mBatteryPresent = batteryPresent; 3514da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk updateTilesList(); 352263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 353263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 354263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 355263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }; 356263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 3576934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri private final BroadcastReceiver mUserAddRemoveReceiver = new BroadcastReceiver() { 3586934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri @Override 3596934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri public void onReceive(Context context, Intent intent) { 3606934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri String action = intent.getAction(); 3616934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri if (action.equals(Intent.ACTION_USER_ADDED) 3626934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri || action.equals(Intent.ACTION_USER_REMOVED)) { 3636934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri Index.getInstance(getApplicationContext()).update(); 3646934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri } 3656934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri } 3666934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri }; 3676934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri 368990159abaad7f314fbe1f9eaf064a088806ffb19Svetoslav private final DynamicIndexableContentMonitor mDynamicIndexableContentMonitor = 369990159abaad7f314fbe1f9eaf064a088806ffb19Svetoslav new DynamicIndexableContentMonitor(); 370853e47181dc116ba95e91463735dc79ad4bdc95aSvetoslav 371d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private ActionBar mActionBar; 37241937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio private SwitchBar mSwitchBar; 37341937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio 37441937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio private Button mNextButton; 3753d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio 376b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio private boolean mDisplayHomeAsUpEnabled; 3773d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio private boolean mDisplaySearch; 378d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 37935062d6983e352f5cb6c4a6bbf3c1e4e214d44a9Fabrice Di Meglio private boolean mIsShowingDashboard; 3800d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio private boolean mIsShortcut; 38135062d6983e352f5cb6c4a6bbf3c1e4e214d44a9Fabrice Di Meglio 3822f1c11314b9a82f808b376c69c2617962566817fAnna Galusza private int mMainContentId = R.id.main_content; 38359a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglio private ViewGroup mContent; 38459a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglio 385d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private SearchView mSearchView; 386d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private MenuItem mSearchMenuItem; 387d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private boolean mSearchMenuItemExpanded = false; 388d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private SearchResultsSummary mSearchResultsFragment; 389d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private String mSearchQuery; 390d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 391769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio // Categories 392769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio private ArrayList<DashboardCategory> mCategories = new ArrayList<DashboardCategory>(); 393263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 394b0a464fd2cbbe00821d483d28e76a04ac17996eaFabrice Di Meglio private static final String MSG_DATA_FORCE_REFRESH = "msg_data_force_refresh"; 395263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 396d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private boolean mNeedToRevertToInitialFragment = false; 397d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 3980698a216311acd9ab52224602d1a75c08bf89f04Jim Miller private Intent mResultIntentData; 399d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk private ComponentName mCurrentSuggestion; 4000698a216311acd9ab52224602d1a75c08bf89f04Jim Miller 40141937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio public SwitchBar getSwitchBar() { 40241937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio return mSwitchBar; 40341937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio } 40441937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio 405263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 406263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) { 407263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Override the fragment title for Wallpaper settings 40839b467482d1bf256a111c757e9b7621c6f523271Jason Monk CharSequence title = pref.getTitle(); 409263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (pref.getFragment().equals(WallpaperTypeSettings.class.getName())) { 41039b467482d1bf256a111c757e9b7621c6f523271Jason Monk title = getString(R.string.wallpaper_settings_fragment_title); 411263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 412b1dd5c9959baf139cc9627eea44df918b2ed1364Jason Monk startPreferencePanel(pref.getFragment(), pref.getExtras(), -1, title, 413263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio null, 0); 414263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return true; 415263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 416263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 417263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 41839b467482d1bf256a111c757e9b7621c6f523271Jason Monk public boolean onPreferenceTreeClick(Preference preference) { 419263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return false; 420263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 421263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 422263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 423263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onConfigurationChanged(Configuration newConfig) { 424263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio super.onConfigurationChanged(newConfig); 4256f0739a3d9a9eca1591ae6bada1dd4d1d92c0defFabrice Di Meglio Index.getInstance(this).update(); 426263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 427263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 428263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 429d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio protected void onStart() { 430d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio super.onStart(); 431d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 432d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (mNeedToRevertToInitialFragment) { 433d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio revertToInitialFragment(); 434263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 435263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 436263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 437263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 438d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onCreateOptionsMenu(Menu menu) { 4393d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio if (!mDisplaySearch) { 4403d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio return false; 4413d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio } 4423d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio 443d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio MenuInflater inflater = getMenuInflater(); 444d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio inflater.inflate(R.menu.options_menu, menu); 445d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 446d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio // Cache the search query (can be overriden by the OnQueryTextListener) 447d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio final String query = mSearchQuery; 448d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 4499593782d154f378a0c911cd015d410c18fe74a92Fabrice Di Meglio mSearchMenuItem = menu.findItem(R.id.search); 4509593782d154f378a0c911cd015d410c18fe74a92Fabrice Di Meglio mSearchView = (SearchView) mSearchMenuItem.getActionView(); 451d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 45223ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio if (mSearchMenuItem == null || mSearchView == null) { 45323ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio return false; 45423ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio } 45523ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio 4568c3b0ce7120da882082eed533462090c4feadff8Fabrice Di Meglio if (mSearchResultsFragment != null) { 4578c3b0ce7120da882082eed533462090c4feadff8Fabrice Di Meglio mSearchResultsFragment.setSearchView(mSearchView); 4588c3b0ce7120da882082eed533462090c4feadff8Fabrice Di Meglio } 4598c3b0ce7120da882082eed533462090c4feadff8Fabrice Di Meglio 4609593782d154f378a0c911cd015d410c18fe74a92Fabrice Di Meglio mSearchMenuItem.setOnActionExpandListener(this); 461d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchView.setOnQueryTextListener(this); 462d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchView.setOnCloseListener(this); 463d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 464d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (mSearchMenuItemExpanded) { 465d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchMenuItem.expandActionView(); 466d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 467d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchView.setQuery(query, true /* submit */); 468d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 469d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return true; 470d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 471d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 47231c7c32fcc26a421a4d2fef7f006917ef590f426Jason Monk @Override 47331c7c32fcc26a421a4d2fef7f006917ef590f426Jason Monk public SharedPreferences getSharedPreferences(String name, int mode) { 47431c7c32fcc26a421a4d2fef7f006917ef590f426Jason Monk if (name.equals(getPackageName() + "_preferences")) { 475e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk return new SharedPreferencesLogger(this, getMetricsTag()); 47631c7c32fcc26a421a4d2fef7f006917ef590f426Jason Monk } 47731c7c32fcc26a421a4d2fef7f006917ef590f426Jason Monk return super.getSharedPreferences(name, mode); 47831c7c32fcc26a421a4d2fef7f006917ef590f426Jason Monk } 47931c7c32fcc26a421a4d2fef7f006917ef590f426Jason Monk 480e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk private String getMetricsTag() { 481e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk String tag = getClass().getName(); 482e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk if (getIntent() != null && getIntent().hasExtra(EXTRA_SHOW_FRAGMENT)) { 483e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk tag = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT); 484e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk } 485e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk if (tag.startsWith("com.android.settings.")) { 486e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk tag = tag.replace("com.android.settings.", ""); 487e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk } 488e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk return tag; 489e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk } 490e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk 4910d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio private static boolean isShortCutIntent(final Intent intent) { 4920d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio Set<String> categories = intent.getCategories(); 4930d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio return (categories != null) && categories.contains("com.android.settings.SHORTCUT"); 4940d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio } 4950d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio 4965b3c3c00b0a280e29f3767878913f80274bd4993Fabrice Di Meglio private static boolean isLikeShortCutIntent(final Intent intent) { 4975b7a100dbd9135b6b87ae4cc9ff3a5ece123bcf6Fabrice Di Meglio String action = intent.getAction(); 4985a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio if (action == null) { 4995a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio return false; 5005a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio } 5015a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio for (int i = 0; i < LIKE_SHORTCUT_INTENT_ACTION_ARRAY.length; i++) { 5025a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio if (LIKE_SHORTCUT_INTENT_ACTION_ARRAY[i].equals(action)) return true; 5035a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio } 5045a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio return false; 5055b7a100dbd9135b6b87ae4cc9ff3a5ece123bcf6Fabrice Di Meglio } 5065b7a100dbd9135b6b87ae4cc9ff3a5ece123bcf6Fabrice Di Meglio 507d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 508d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio protected void onCreate(Bundle savedState) { 5090d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio super.onCreate(savedState); 510fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk long startTime = System.currentTimeMillis(); 5110d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio 5120d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio // Should happen before any call to getIntent() 5130d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio getMetaData(); 5140d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio 5150d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio final Intent intent = getIntent(); 5160d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio if (intent.hasExtra(EXTRA_UI_OPTIONS)) { 5170d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0)); 518263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 51992779ce70156031f4fa3b8c2d84305f5b3b44105Udam Saini if (intent.getBooleanExtra(EXTRA_HIDE_DRAWER, false)) { 52092779ce70156031f4fa3b8c2d84305f5b3b44105Udam Saini setIsDrawerPresent(false); 52192779ce70156031f4fa3b8c2d84305f5b3b44105Udam Saini } 522263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 523263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mDevelopmentPreferences = getSharedPreferences(DevelopmentSettings.PREF_FILE, 524263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio Context.MODE_PRIVATE); 525263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 526da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio // Getting Intent properties can only be done after the super.onCreate(...) 5270d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio final String initialFragmentName = intent.getStringExtra(EXTRA_SHOW_FRAGMENT); 5280d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio 5295b3c3c00b0a280e29f3767878913f80274bd4993Fabrice Di Meglio mIsShortcut = isShortCutIntent(intent) || isLikeShortCutIntent(intent) || 5300d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SHORTCUT, false); 531da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio 532e817a66e83191c0ae74acd53a538a0965eba2683Fabrice Di Meglio final ComponentName cn = intent.getComponent(); 5335a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio final String className = cn.getClassName(); 534da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio 5354da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk mIsShowingDashboard = className.equals(Settings.class.getName()) 5364da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk || className.equals(Settings.WirelessSettings.class.getName()) 5374da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk || className.equals(Settings.DeviceSettings.class.getName()) 5384da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk || className.equals(Settings.PersonalSettings.class.getName()) 5394da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk || className.equals(Settings.WirelessSettings.class.getName()); 5405a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio 54161a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio // This is a "Sub Settings" when: 54261a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio // - this is a real SubSettings 54361a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio // - or :settings:show_fragment_as_subsetting is passed to the Intent 5444dfcb8208cdb49167ccf99aeaddf9e206eba87d1Jorim Jaggi final boolean isSubSettings = this instanceof SubSettings || 54561a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false); 54661a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio 54761a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio // If this is a sub settings, then apply the SubSettings Theme for the ActionBar content insets 54861a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio if (isSubSettings) { 549712df6cb7050a87985ab30b8d1bad909a6bc09aaFabrice Di Meglio // Check also that we are not a Theme Dialog as we don't want to override them 550712df6cb7050a87985ab30b8d1bad909a6bc09aaFabrice Di Meglio final int themeResId = getThemeResId(); 551712df6cb7050a87985ab30b8d1bad909a6bc09aaFabrice Di Meglio if (themeResId != R.style.Theme_DialogWhenLarge && 552712df6cb7050a87985ab30b8d1bad909a6bc09aaFabrice Di Meglio themeResId != R.style.Theme_SubSettingsDialogWhenLarge) { 553712df6cb7050a87985ab30b8d1bad909a6bc09aaFabrice Di Meglio setTheme(R.style.Theme_SubSettings); 554712df6cb7050a87985ab30b8d1bad909a6bc09aaFabrice Di Meglio } 555da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio } 556da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio 557d40dd45c18a55d574d65b3a0ac16b59d76027049Fabrice Di Meglio setContentView(mIsShowingDashboard ? 558d40dd45c18a55d574d65b3a0ac16b59d76027049Fabrice Di Meglio R.layout.settings_main_dashboard : R.layout.settings_main_prefs); 559263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 5602f1c11314b9a82f808b376c69c2617962566817fAnna Galusza mContent = (ViewGroup) findViewById(mMainContentId); 56159a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglio 562263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio getFragmentManager().addOnBackStackChangedListener(this); 563263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 56435062d6983e352f5cb6c4a6bbf3c1e4e214d44a9Fabrice Di Meglio if (mIsShowingDashboard) { 565dff3faaf30bd6d695e4d9f632af53dbc73cf6506Fabrice Di Meglio // Run the Index update only if we have some space 566dff3faaf30bd6d695e4d9f632af53dbc73cf6506Fabrice Di Meglio if (!Utils.isLowStorage(this)) { 567fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk long indexStartTime = System.currentTimeMillis(); 5686c9e884aa04b19634722d95cb65d7df1050a0c28Jason Monk Index.getInstance(getApplicationContext()).update(); 569fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk if (DEBUG_TIMING) Log.d(LOG_TAG, "Index.update() took " 570fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk + (System.currentTimeMillis() - indexStartTime) + " ms"); 571dff3faaf30bd6d695e4d9f632af53dbc73cf6506Fabrice Di Meglio } else { 572dff3faaf30bd6d695e4d9f632af53dbc73cf6506Fabrice Di Meglio Log.w(LOG_TAG, "Cannot update the Indexer as we are running low on storage space!"); 573dff3faaf30bd6d695e4d9f632af53dbc73cf6506Fabrice Di Meglio } 5745cda21b449a56de42f7868bdcdaa31bb6f587c03Fabrice Di Meglio } 5755cda21b449a56de42f7868bdcdaa31bb6f587c03Fabrice Di Meglio 576d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (savedState != null) { 5771800a9f3e7027e8ab8ffcab51715d39b126bad43Fabrice Di Meglio // We are restarting from a previous saved state; used that to initialize, instead 5781800a9f3e7027e8ab8ffcab51715d39b126bad43Fabrice Di Meglio // of starting fresh. 579d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchMenuItemExpanded = savedState.getBoolean(SAVE_KEY_SEARCH_MENU_EXPANDED); 580d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchQuery = savedState.getString(SAVE_KEY_SEARCH_QUERY); 581263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 5820d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio setTitleFromIntent(intent); 5835529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio 584769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio ArrayList<DashboardCategory> categories = 585769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio savedState.getParcelableArrayList(SAVE_KEY_CATEGORIES); 586769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio if (categories != null) { 5875f995727cc2e4bd27d26a50f3a565fb677fdb294Fabrice Di Meglio mCategories.clear(); 588769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio mCategories.addAll(categories); 589b643cbf6d60bb4cd43d3191106d68680fffe97b5Fabrice Di Meglio setTitleFromBackStack(); 590263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 591b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio 592b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio mDisplayHomeAsUpEnabled = savedState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP); 5933d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio mDisplaySearch = savedState.getBoolean(SAVE_KEY_SHOW_SEARCH); 594263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } else { 59535062d6983e352f5cb6c4a6bbf3c1e4e214d44a9Fabrice Di Meglio if (!mIsShowingDashboard) { 596ea8b1a7dc5fa11742967923251b437a02568f021Jason Monk mDisplaySearch = false; 597ea8b1a7dc5fa11742967923251b437a02568f021Jason Monk // UP will be shown only if it is a sub settings 5980d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio if (mIsShortcut) { 5990d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio mDisplayHomeAsUpEnabled = isSubSettings; 6005a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio } else if (isSubSettings) { 6015a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio mDisplayHomeAsUpEnabled = true; 60261a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio } else { 60361a1fec49fbfbe8bdd0137ddb06e5eacf4f8ec54Fabrice Di Meglio mDisplayHomeAsUpEnabled = false; 604d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 6050d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio setTitleFromIntent(intent); 606c1457323d271309d5d1955743cd806417c84b9d6Fabrice Di Meglio 6070d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio Bundle initialArguments = intent.getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS); 608a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio switchToFragment(initialFragmentName, initialArguments, true, false, 609a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitleResId, mInitialTitle, false); 61010afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio } else { 6115a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio // No UP affordance if we are displaying the main Dashboard 612b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio mDisplayHomeAsUpEnabled = false; 6135a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio // Show Search affordance 6145a62d94a2b1b5a93911e1f2cc9f3190e2f22622cFabrice Di Meglio mDisplaySearch = true; 615a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitleResId = R.string.dashboard_title; 61642c4b0abe5578a7812844ad5205ffc3b87cf3072Fabrice Di Meglio switchToFragment(DashboardSummary.class.getName(), null, false, false, 617a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitleResId, mInitialTitle, false); 618263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 619263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 620263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 621d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mActionBar = getActionBar(); 622d8aec08fa96c42a61bd6ead2aa9859b5b67a3f2cFabrice Di Meglio if (mActionBar != null) { 623d8aec08fa96c42a61bd6ead2aa9859b5b67a3f2cFabrice Di Meglio mActionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled); 624d8aec08fa96c42a61bd6ead2aa9859b5b67a3f2cFabrice Di Meglio mActionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled); 625d8aec08fa96c42a61bd6ead2aa9859b5b67a3f2cFabrice Di Meglio } 62641937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio mSwitchBar = (SwitchBar) findViewById(R.id.switch_bar); 627e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk if (mSwitchBar != null) { 628e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk mSwitchBar.setMetricsTag(getMetricsTag()); 629e4ebcd12be7baae58a1fabcda6c7544c911c95ebJason Monk } 63041937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio 631263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // see if we should show Back/Next buttons 632263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)) { 633263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 634d2b64f339adb8f019e3c712e388e35830d8b68a9Fabrice Di Meglio View buttonBar = findViewById(R.id.button_bar); 635263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (buttonBar != null) { 636263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio buttonBar.setVisibility(View.VISIBLE); 637263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 638d2b64f339adb8f019e3c712e388e35830d8b68a9Fabrice Di Meglio Button backButton = (Button)findViewById(R.id.back_button); 639263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio backButton.setOnClickListener(new OnClickListener() { 640263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onClick(View v) { 6410698a216311acd9ab52224602d1a75c08bf89f04Jim Miller setResult(RESULT_CANCELED, getResultIntentData()); 642263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio finish(); 643263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 644263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }); 645d2b64f339adb8f019e3c712e388e35830d8b68a9Fabrice Di Meglio Button skipButton = (Button)findViewById(R.id.skip_button); 646263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio skipButton.setOnClickListener(new OnClickListener() { 647263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onClick(View v) { 6480698a216311acd9ab52224602d1a75c08bf89f04Jim Miller setResult(RESULT_OK, getResultIntentData()); 649263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio finish(); 650263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 651263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }); 652d2b64f339adb8f019e3c712e388e35830d8b68a9Fabrice Di Meglio mNextButton = (Button)findViewById(R.id.next_button); 653263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mNextButton.setOnClickListener(new OnClickListener() { 654263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onClick(View v) { 6550698a216311acd9ab52224602d1a75c08bf89f04Jim Miller setResult(RESULT_OK, getResultIntentData()); 656263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio finish(); 657263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 658263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }); 659263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 660263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // set our various button parameters 661263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (intent.hasExtra(EXTRA_PREFS_SET_NEXT_TEXT)) { 662263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_NEXT_TEXT); 663263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (TextUtils.isEmpty(buttonText)) { 664263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mNextButton.setVisibility(View.GONE); 665263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 666263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio else { 667263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mNextButton.setText(buttonText); 668263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 669263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 670263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (intent.hasExtra(EXTRA_PREFS_SET_BACK_TEXT)) { 671263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_BACK_TEXT); 672263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (TextUtils.isEmpty(buttonText)) { 673263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio backButton.setVisibility(View.GONE); 674263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 675263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio else { 676263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio backButton.setText(buttonText); 677263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 678263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 679263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_SKIP, false)) { 680263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio skipButton.setVisibility(View.VISIBLE); 681263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 682263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 683263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 684ceb335f88fc0df88dafc8063733842afe35c5da1Fabrice Di Meglio 685fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk if (DEBUG_TIMING) Log.d(LOG_TAG, "onCreate took " + (System.currentTimeMillis() - startTime) 686fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk + " ms"); 687ceb335f88fc0df88dafc8063733842afe35c5da1Fabrice Di Meglio } 688ceb335f88fc0df88dafc8063733842afe35c5da1Fabrice Di Meglio 6892f1c11314b9a82f808b376c69c2617962566817fAnna Galusza /** 6902f1c11314b9a82f808b376c69c2617962566817fAnna Galusza * Sets the id of the view continaing the main content. Should be called before calling super's 6912f1c11314b9a82f808b376c69c2617962566817fAnna Galusza * onCreate. 6922f1c11314b9a82f808b376c69c2617962566817fAnna Galusza */ 6932f1c11314b9a82f808b376c69c2617962566817fAnna Galusza protected void setMainContentId(int contentId) { 6942f1c11314b9a82f808b376c69c2617962566817fAnna Galusza mMainContentId = contentId; 6952f1c11314b9a82f808b376c69c2617962566817fAnna Galusza } 6962f1c11314b9a82f808b376c69c2617962566817fAnna Galusza 697a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio private void setTitleFromIntent(Intent intent) { 698a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio final int initialTitleResId = intent.getIntExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1); 699a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio if (initialTitleResId > 0) { 700a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitle = null; 701a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitleResId = initialTitleResId; 70262464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina 70362464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina final String initialTitleResPackageName = intent.getStringExtra( 70462464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina EXTRA_SHOW_FRAGMENT_TITLE_RES_PACKAGE_NAME); 70562464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina if (initialTitleResPackageName != null) { 70662464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina try { 70762464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina Context authContext = createPackageContextAsUser(initialTitleResPackageName, 70862464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina 0 /* flags */, new UserHandle(UserHandle.myUserId())); 70962464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina mInitialTitle = authContext.getResources().getText(mInitialTitleResId); 71062464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina setTitle(mInitialTitle); 71162464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina mInitialTitleResId = -1; 71262464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina return; 71362464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina } catch (NameNotFoundException e) { 71462464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina Log.w(LOG_TAG, "Could not find package" + initialTitleResPackageName); 71562464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina } 71662464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina } else { 71762464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina setTitle(mInitialTitleResId); 71862464b819e185ce4a1642442fcf4cc18a4932a78Alexandra Gherghina } 719a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } else { 720a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitleResId = -1; 721a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio final String initialTitle = intent.getStringExtra(EXTRA_SHOW_FRAGMENT_TITLE); 722a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitle = (initialTitle != null) ? initialTitle : getTitle(); 723a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio setTitle(mInitialTitle); 724a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } 725a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } 726a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio 727c95be4fbb3ec437517a2190d88fbda5068dba8dfFabrice Di Meglio @Override 728263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onBackStackChanged() { 729d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio setTitleFromBackStack(); 7308eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio } 7318eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio 732b643cbf6d60bb4cd43d3191106d68680fffe97b5Fabrice Di Meglio private int setTitleFromBackStack() { 7338eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio final int count = getFragmentManager().getBackStackEntryCount(); 734b643cbf6d60bb4cd43d3191106d68680fffe97b5Fabrice Di Meglio 7358eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio if (count == 0) { 736a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio if (mInitialTitleResId > 0) { 737a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio setTitle(mInitialTitleResId); 738a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } else { 739a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio setTitle(mInitialTitle); 740a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } 741b643cbf6d60bb4cd43d3191106d68680fffe97b5Fabrice Di Meglio return 0; 742263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 743b643cbf6d60bb4cd43d3191106d68680fffe97b5Fabrice Di Meglio 7448eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio FragmentManager.BackStackEntry bse = getFragmentManager().getBackStackEntryAt(count - 1); 7458eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio setTitleFromBackStackEntry(bse); 746b643cbf6d60bb4cd43d3191106d68680fffe97b5Fabrice Di Meglio 747b643cbf6d60bb4cd43d3191106d68680fffe97b5Fabrice Di Meglio return count; 748263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 749263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 7508eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio private void setTitleFromBackStackEntry(FragmentManager.BackStackEntry bse) { 7515529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio final CharSequence title; 7528eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio final int titleRes = bse.getBreadCrumbTitleRes(); 7538eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio if (titleRes > 0) { 7548eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio title = getText(titleRes); 7555529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio } else { 7568eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio title = bse.getBreadCrumbTitle(); 7578eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio } 7588eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio if (title != null) { 7598eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio setTitle(title); 7605529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio } 7615529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio } 7625529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio 763263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 764263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio protected void onSaveInstanceState(Bundle outState) { 765263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio super.onSaveInstanceState(outState); 766263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 767769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio if (mCategories.size() > 0) { 768769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio outState.putParcelableArrayList(SAVE_KEY_CATEGORIES, mCategories); 769263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 770d6985df419549fbb7d420eced8e89f0429e49d71Fabrice Di Meglio 771b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio outState.putBoolean(SAVE_KEY_SHOW_HOME_AS_UP, mDisplayHomeAsUpEnabled); 7723d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio outState.putBoolean(SAVE_KEY_SHOW_SEARCH, mDisplaySearch); 7733d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio 7743d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio if (mDisplaySearch) { 7753d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio // The option menus are created if the ActionBar is visible and they are also created 7763d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio // asynchronously. If you launch Settings with an Intent action like 7773d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio // android.intent.action.POWER_USAGE_SUMMARY and at the same time your device is locked 7783d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio // thru a LockScreen, onCreateOptionsMenu() is not yet called and references to the search 7793d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio // menu item and search view are null. 7803d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio boolean isExpanded = (mSearchMenuItem != null) && mSearchMenuItem.isActionViewExpanded(); 7813d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio outState.putBoolean(SAVE_KEY_SEARCH_MENU_EXPANDED, isExpanded); 7823d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio 7833d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio String query = (mSearchView != null) ? mSearchView.getQuery().toString() : EMPTY_QUERY; 7843d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio outState.putString(SAVE_KEY_SEARCH_QUERY, query); 7853d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio } 786263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 787263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 788263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 78939b467482d1bf256a111c757e9b7621c6f523271Jason Monk protected void onResume() { 790263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio super.onResume(); 791263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 792263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mDevelopmentPreferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() { 793263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 794263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { 7954da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk updateTilesList(); 796263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 797263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }; 798263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mDevelopmentPreferences.registerOnSharedPreferenceChangeListener( 799263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mDevelopmentPreferencesListener); 800263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 801263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); 8026934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri registerReceiver(mUserAddRemoveReceiver, new IntentFilter(Intent.ACTION_USER_ADDED)); 8036934a044b8ebf4dac28d1c1142b6eee4ecc64f66Clara Bayarri registerReceiver(mUserAddRemoveReceiver, new IntentFilter(Intent.ACTION_USER_REMOVED)); 804853e47181dc116ba95e91463735dc79ad4bdc95aSvetoslav 805d9779db8c966347734c5791cf63b7dc2e466a0f4Philip P. Moltmann mDynamicIndexableContentMonitor.register(this, LOADER_ID_INDEXABLE_CONTENT_MONITOR); 806a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio 8073d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio if(mDisplaySearch && !TextUtils.isEmpty(mSearchQuery)) { 808a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio onQueryTextSubmit(mSearchQuery); 809a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio } 8104da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk updateTilesList(); 811263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 812263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 813263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 81439b467482d1bf256a111c757e9b7621c6f523271Jason Monk protected void onPause() { 815263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio super.onPause(); 816263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio unregisterReceiver(mBatteryInfoReceiver); 8178c9521f27c86e86ff64ca5a086dea4a6a469a3e5Clara Bayarri unregisterReceiver(mUserAddRemoveReceiver); 818990159abaad7f314fbe1f9eaf064a088806ffb19Svetoslav mDynamicIndexableContentMonitor.unregister(); 819263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 820263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 821263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 822263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onDestroy() { 823263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio super.onDestroy(); 824680b064b293888ea47a6211943b51bee3adfb70dFabrice Di Meglio 825680b064b293888ea47a6211943b51bee3adfb70dFabrice Di Meglio mDevelopmentPreferences.unregisterOnSharedPreferenceChangeListener( 826680b064b293888ea47a6211943b51bee3adfb70dFabrice Di Meglio mDevelopmentPreferencesListener); 827680b064b293888ea47a6211943b51bee3adfb70dFabrice Di Meglio mDevelopmentPreferencesListener = null; 828263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 829263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 830263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio protected boolean isValidFragment(String fragmentName) { 831263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Almost all fragments are wrapped in this, 832263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // except for a few that have their own activities. 833263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio for (int i = 0; i < ENTRY_FRAGMENTS.length; i++) { 834263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (ENTRY_FRAGMENTS[i].equals(fragmentName)) return true; 835263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 836263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return false; 837263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 838263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 839263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 840263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public Intent getIntent() { 841263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio Intent superIntent = super.getIntent(); 842263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio String startingFragment = getStartingFragmentClass(superIntent); 843263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // This is called from super.onCreate, isMultiPane() is not yet reliable 844263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Do not use onIsHidingHeaders either, which relies itself on this method 845263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (startingFragment != null) { 846263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio Intent modIntent = new Intent(superIntent); 847263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio modIntent.putExtra(EXTRA_SHOW_FRAGMENT, startingFragment); 848263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio Bundle args = superIntent.getExtras(); 849263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (args != null) { 850263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio args = new Bundle(args); 851263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } else { 852263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio args = new Bundle(); 853263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 854263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio args.putParcelable("intent", superIntent); 855ac1e20ebfc233a4894fa04a29b5d86602ee188eeKenny Guy modIntent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, args); 856263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return modIntent; 857263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 858263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return superIntent; 859263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 860263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 861263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 862263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * Checks if the component name in the intent is different from the Settings class and 863263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * returns the class name to load as a fragment. 864263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio */ 865263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private String getStartingFragmentClass(Intent intent) { 866263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (mFragmentClass != null) return mFragmentClass; 867263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 868263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio String intentClass = intent.getComponent().getClassName(); 869263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (intentClass.equals(getClass().getName())) return null; 870263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 871263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if ("com.android.settings.ManageApplications".equals(intentClass) 872263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio || "com.android.settings.RunningServices".equals(intentClass) 873263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio || "com.android.settings.applications.StorageUse".equals(intentClass)) { 874263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Old names of manage apps. 875263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio intentClass = com.android.settings.applications.ManageApplications.class.getName(); 876263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 877263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 878263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return intentClass; 879263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 880263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 881263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 88210afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * Start a new fragment containing a preference panel. If the preferences 88310afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * are being displayed in multi-pane mode, the given fragment class will 88410afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * be instantiated and placed in the appropriate pane. If running in 88510afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * single-pane mode, a new activity will be launched in which to show the 88610afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * fragment. 88710afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * 88810afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param fragmentClass Full name of the class implementing the fragment. 88910afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param args Any desired arguments to supply to the fragment. 89010afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param titleRes Optional resource identifier of the title of this 89110afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * fragment. 89210afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param titleText Optional text of the title of this fragment. 89310afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param resultTo Optional fragment that result data should be sent to. 89410afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * If non-null, resultTo.onActivityResult() will be called when this 89510afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * preference panel is done. The launched panel must use 89610afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * {@link #finishPreferencePanel(Fragment, int, Intent)} when done. 89710afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param resultRequestCode If resultTo is non-null, this is the caller's 89858146c2b2fa24d774840a07cf697ad315baf4de0Fabrice Di Meglio * request code to be received with the result. 89910afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio */ 90010afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes, 901d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio CharSequence titleText, Fragment resultTo, int resultRequestCode) { 902a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio String title = null; 903a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio if (titleRes < 0) { 904a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio if (titleText != null) { 905a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio title = titleText.toString(); 906a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } else { 907a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio // There not much we can do in that case 908a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio title = ""; 909a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } 910911fb2ad907d47a882c023b871c6457db32359f8Fabrice Di Meglio } 911a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio Utils.startWithFragment(this, fragmentClass, args, resultTo, resultRequestCode, 9120d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio titleRes, title, mIsShortcut); 91310afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio } 91410afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio 91510afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio /** 9167a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * Start a new fragment in a new activity containing a preference panel for a given user. If the 9177a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * preferences are being displayed in multi-pane mode, the given fragment class will be 9187a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * instantiated and placed in the appropriate pane. If running in single-pane mode, a new 9197a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * activity will be launched in which to show the fragment. 9207a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * 9217a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * @param fragmentClass Full name of the class implementing the fragment. 9227a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * @param args Any desired arguments to supply to the fragment. 9237a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * @param titleRes Optional resource identifier of the title of this fragment. 9247a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * @param titleText Optional text of the title of this fragment. 9257a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban * @param userHandle The user for which the panel has to be started. 9267a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban */ 9277a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban public void startPreferencePanelAsUser(String fragmentClass, Bundle args, int titleRes, 9287a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban CharSequence titleText, UserHandle userHandle) { 929d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // This is a workaround. 930d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // 931d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // Calling startWithFragmentAsUser() without specifying FLAG_ACTIVITY_NEW_TASK to the intent 932d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // starting the fragment could cause a native stack corruption. See b/17523189. However, 933d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // adding that flag and start the preference panel with the same UserHandler will make it 934d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // impossible to use back button to return to the previous screen. See b/20042570. 935d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // 936d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // We work around this issue by adding FLAG_ACTIVITY_NEW_TASK to the intent, while doing 937d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // another check here to call startPreferencePanel() instead of startWithFragmentAsUser() 938d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // when we're calling it as the same user. 939d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang if (userHandle.getIdentifier() == UserHandle.myUserId()) { 940d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang startPreferencePanel(fragmentClass, args, titleRes, titleText, null, 0); 941d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang } else { 942d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang String title = null; 943d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang if (titleRes < 0) { 944d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang if (titleText != null) { 945d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang title = titleText.toString(); 946d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang } else { 947d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang // There not much we can do in that case 948d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang title = ""; 949d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang } 9507a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban } 951d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang Utils.startWithFragmentAsUser(this, fragmentClass, args, 952d033285ca7789b464f15cde149bef7df3ad2e1a3Lifu Tang titleRes, title, mIsShortcut, userHandle); 9537a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban } 9547a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban } 9557a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban 9567a2ccf201e839e8755b2184402072113498eef1fZoltan Szatmary-Ban /** 957263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * Called by a preference panel fragment to finish itself. 958263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * 959263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * @param caller The fragment that is asking to be finished. 960263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * @param resultCode Optional result code to send back to the original 961263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * launching fragment. 962263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * @param resultData Optional result data to send back to the original 963263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * launching fragment. 964263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio */ 965263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void finishPreferencePanel(Fragment caller, int resultCode, Intent resultData) { 966263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio setResult(resultCode, resultData); 96758146c2b2fa24d774840a07cf697ad315baf4de0Fabrice Di Meglio finish(); 968263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 969263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 970263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 97110afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * Start a new fragment. 97210afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * 97310afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param fragment The fragment to start 97410afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param push If true, the current fragment will be pushed onto the back stack. If false, 97510afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * the current fragment will be replaced. 97610afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio */ 97710afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio public void startPreferenceFragment(Fragment fragment, boolean push) { 97810afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio FragmentTransaction transaction = getFragmentManager().beginTransaction(); 9792f1c11314b9a82f808b376c69c2617962566817fAnna Galusza transaction.replace(mMainContentId, fragment); 98010afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio if (push) { 98110afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); 98210afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio transaction.addToBackStack(BACK_STACK_PREFS); 98310afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio } else { 98410afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); 98510afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio } 98610afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio transaction.commitAllowingStateLoss(); 98710afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio } 98810afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio 98910afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio /** 990d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio * Switch to a specific Fragment with taking care of validation, Title and BackStack 991d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio */ 992d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate, 993a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio boolean addToBackStack, int titleResId, CharSequence title, boolean withTransition) { 994d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (validate && !isValidFragment(fragmentName)) { 995d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio throw new IllegalArgumentException("Invalid fragment for this activity: " 996d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio + fragmentName); 997d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 998d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio Fragment f = Fragment.instantiate(this, fragmentName, args); 999d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio FragmentTransaction transaction = getFragmentManager().beginTransaction(); 10002f1c11314b9a82f808b376c69c2617962566817fAnna Galusza transaction.replace(mMainContentId, f); 1001d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (withTransition) { 100259a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglio TransitionManager.beginDelayedTransition(mContent); 1003d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1004d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (addToBackStack) { 1005d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio transaction.addToBackStack(SettingsActivity.BACK_STACK_PREFS); 1006d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1007a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio if (titleResId > 0) { 1008a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio transaction.setBreadCrumbTitle(titleResId); 1009a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } else if (title != null) { 1010d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio transaction.setBreadCrumbTitle(title); 1011d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1012d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio transaction.commitAllowingStateLoss(); 101359a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglio getFragmentManager().executePendingTransactions(); 1014d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return f; 1015d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1016d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 10174da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk private void updateTilesList() { 1018fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk // Generally the items that are will be changing from these updates will 1019fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk // not be in the top list of tiles, so run it in the background and the 1020fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk // SettingsDrawerActivity will pick up on the updates automatically. 1021fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk AsyncTask.execute(new Runnable() { 1022fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk @Override 1023fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk public void run() { 1024fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk doUpdateTilesList(); 1025fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk } 1026fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk }); 1027fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk } 1028fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk 1029fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk private void doUpdateTilesList() { 10304da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk PackageManager pm = getPackageManager(); 10314da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk final UserManager um = UserManager.get(this); 10324da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk final boolean isAdmin = um.isAdminUser(); 103363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 10344da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk String packageName = getPackageName(); 10354da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, WifiSettingsActivity.class.getName()), 10364da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk pm.hasSystemFeature(PackageManager.FEATURE_WIFI), isAdmin, pm); 103763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 10384da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, 10394da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.BluetoothSettingsActivity.class.getName()), 10404da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH), isAdmin, pm); 104163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 10424da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, 10434da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.DataUsageSummaryActivity.class.getName()), 10444da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Utils.isBandwidthControlEnabled(), isAdmin, pm); 104563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 10464da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, 10474da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.SimSettingsActivity.class.getName()), 10484da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Utils.showSimCardTile(this), isAdmin, pm); 104963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 10504da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, 10514da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.PowerUsageSummaryActivity.class.getName()), 10524da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk mBatteryPresent, isAdmin, pm); 105363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 10544da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, 10554da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.UserSettingsActivity.class.getName()), 10564da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk UserHandle.MU_ENABLED && UserManager.supportsMultipleUsers() 10574da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk && !Utils.isMonkeyRunning(), isAdmin, pm); 105863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 10594da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this); 10604da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, 10614da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.PaymentSettingsActivity.class.getName()), 10624da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk pm.hasSystemFeature(PackageManager.FEATURE_NFC) 10634da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk && pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION) 10644da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk && adapter != null && adapter.isEnabled(), isAdmin, pm); 10654da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk 10664da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, 10674da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.PrintSettingsActivity.class.getName()), 10684da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk pm.hasSystemFeature(PackageManager.FEATURE_PRINTING), isAdmin, pm); 106963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 107063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio final boolean showDev = mDevelopmentPreferences.getBoolean( 107112c4ba4224a42d54ef671302a09c14ed0d3c09b0Dan Sandler DevelopmentSettings.PREF_SHOW, android.os.Build.TYPE.equals("eng")) 107212c4ba4224a42d54ef671302a09c14ed0d3c09b0Dan Sandler && !um.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES); 10734da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(new ComponentName(packageName, 10744da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk Settings.DevelopmentSettingsActivity.class.getName()), 107512c4ba4224a42d54ef671302a09c14ed0d3c09b0Dan Sandler showDev, isAdmin, pm); 107612c4ba4224a42d54ef671302a09c14ed0d3c09b0Dan Sandler 107712c4ba4224a42d54ef671302a09c14ed0d3c09b0Dan Sandler // Reveal development-only quick settings tiles 107812c4ba4224a42d54ef671302a09c14ed0d3c09b0Dan Sandler DevelopmentTiles.setTilesEnabled(this, showDev); 10794da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk 10804da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk if (UserHandle.MU_ENABLED && !isAdmin) { 10814da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk // When on restricted users, disable all extra categories (but only the settings ones). 1082fd2c7224185bef301cfaa7de6fe1af22cab8df2fJason Monk List<DashboardCategory> categories = getDashboardCategories(); 10834da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk for (DashboardCategory category : categories) { 1084d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk for (Tile tile : category.tiles) { 10854da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk ComponentName component = tile.intent.getComponent(); 10864da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk if (packageName.equals(component)&& !ArrayUtils.contains( 10874da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk SETTINGS_FOR_RESTRICTED, component.getClassName())) { 10884da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk setTileEnabled(component, false, isAdmin, pm); 108963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 109057fd5fd84be2497845f6c03905500d2a36668b6cAmith Yamasani } 109163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 109263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 10932ebc8a01696c4e7dd29863b92a15ae0bbbbb254dJason Monk } 10942ebc8a01696c4e7dd29863b92a15ae0bbbbb254dJason Monk 10954da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk private void setTileEnabled(ComponentName component, boolean enabled, boolean isAdmin, 10964da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk PackageManager pm) { 10974da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk if (UserHandle.MU_ENABLED && !isAdmin 10984da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk && !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, component.getClassName())) { 10994da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk enabled = false; 11002ebc8a01696c4e7dd29863b92a15ae0bbbbb254dJason Monk } 11014da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk int state = pm.getComponentEnabledSetting(component); 1102cd6a2115c64f89fb52119a08a164e242a7363455Clara Bayarri boolean isEnabled = state == PackageManager.COMPONENT_ENABLED_STATE_ENABLED; 11034da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk if (isEnabled != enabled) { 11044da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk pm.setComponentEnabledSetting(component, enabled 11054da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED 11064da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 11074da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk PackageManager.DONT_KILL_APP); 11082ebc8a01696c4e7dd29863b92a15ae0bbbbb254dJason Monk } 110963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 111063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 1111263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private void getMetaData() { 1112263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio try { 1113263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio ActivityInfo ai = getPackageManager().getActivityInfo(getComponentName(), 1114263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PackageManager.GET_META_DATA); 1115263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (ai == null || ai.metaData == null) return; 1116263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mFragmentClass = ai.metaData.getString(META_DATA_KEY_FRAGMENT_CLASS); 1117263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } catch (NameNotFoundException nnfe) { 1118263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // No recovery 1119263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio Log.d(LOG_TAG, "Cannot get Metadata for: " + getComponentName().toString()); 1120263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1121263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1122263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1123263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // give subclasses access to the Next button 1124263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public boolean hasNextButton() { 1125263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return mNextButton != null; 1126263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1127263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1128263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public Button getNextButton() { 1129263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return mNextButton; 1130263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1131263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1132263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 1133263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public boolean shouldUpRecreateTask(Intent targetIntent) { 1134263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return super.shouldUpRecreateTask(new Intent(this, SettingsActivity.class)); 1135263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1136263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1137d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 1138d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onQueryTextSubmit(String query) { 1139d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio switchToSearchResultsFragmentIfNeeded(); 1140d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchQuery = query; 1141d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return mSearchResultsFragment.onQueryTextSubmit(query); 1142d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1143263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1144d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 1145d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onQueryTextChange(String newText) { 1146d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchQuery = newText; 11477e4855e8f644bdecf68ec65b8c1b7c08624a4876Fabrice Di Meglio if (mSearchResultsFragment == null) { 1148a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio return false; 1149a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio } 1150a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio return mSearchResultsFragment.onQueryTextChange(newText); 1151d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1152263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1153d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 1154d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onClose() { 1155d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return false; 1156d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1157263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1158d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 1159d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onMenuItemActionExpand(MenuItem item) { 1160d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (item.getItemId() == mSearchMenuItem.getItemId()) { 1161bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio switchToSearchResultsFragmentIfNeeded(); 1162263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1163d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return true; 1164d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1165263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1166d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 1167d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onMenuItemActionCollapse(MenuItem item) { 1168d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (item.getItemId() == mSearchMenuItem.getItemId()) { 1169bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio if (mSearchMenuItemExpanded) { 1170d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio revertToInitialFragment(); 1171263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1172263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1173d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return true; 1174d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1175263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 11764da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk @Override 1177d4f03ec86f9e8b7b108fc63684e23f5c0fb2a864Jason Monk protected void onTileClicked(Tile tile) { 11784da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk if (mIsShowingDashboard) { 11794da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk // If on dashboard, don't finish so the back comes back to here. 11804da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk openTile(tile); 11814da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk } else { 11824da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk super.onTileClicked(tile); 11834da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk } 11844da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk } 11854da79e088f9e8d9c6123fbbb7590c779e280c893Jason Monk 1186af00109242a5766ca9418b145c4fb098360c5648Jason Monk @Override 1187af00109242a5766ca9418b145c4fb098360c5648Jason Monk public void onProfileTileOpen() { 1188af00109242a5766ca9418b145c4fb098360c5648Jason Monk if (!mIsShowingDashboard) { 1189af00109242a5766ca9418b145c4fb098360c5648Jason Monk finish(); 1190af00109242a5766ca9418b145c4fb098360c5648Jason Monk } 1191af00109242a5766ca9418b145c4fb098360c5648Jason Monk } 1192af00109242a5766ca9418b145c4fb098360c5648Jason Monk 1193d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private void switchToSearchResultsFragmentIfNeeded() { 1194bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio if (mSearchResultsFragment != null) { 1195bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio return; 1196263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 11972f1c11314b9a82f808b376c69c2617962566817fAnna Galusza Fragment current = getFragmentManager().findFragmentById(mMainContentId); 1198bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio if (current != null && current instanceof SearchResultsSummary) { 1199bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio mSearchResultsFragment = (SearchResultsSummary) current; 1200bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio } else { 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