SettingsActivity.java revision 0d643fd182d37d2e8ee5d547b80d80423a5ed98d
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.accounts.Account; 20263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.accounts.AccountManager; 21263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.accounts.OnAccountsUpdateListener; 22263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.app.ActionBar; 23263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.app.Activity; 24263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.app.Fragment; 25263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.app.FragmentManager; 26263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.app.FragmentTransaction; 27263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.BroadcastReceiver; 28d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglioimport android.content.ComponentName; 29263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.Context; 30263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.Intent; 31263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.IntentFilter; 32263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.SharedPreferences; 33263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.pm.ActivityInfo; 34263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.pm.PackageManager; 35263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.pm.PackageManager.NameNotFoundException; 36263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.pm.ResolveInfo; 37263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.res.Configuration; 38263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.res.TypedArray; 39263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.content.res.XmlResourceParser; 40263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.nfc.NfcAdapter; 41263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.os.Bundle; 42263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.os.Handler; 43263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.os.INetworkManagementService; 44263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.os.Message; 45263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.os.RemoteException; 46263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.os.ServiceManager; 47263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.os.UserHandle; 48263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.os.UserManager; 49263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.preference.Preference; 50263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.preference.PreferenceFragment; 51263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.preference.PreferenceManager; 52263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.preference.PreferenceScreen; 53263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.text.TextUtils; 5459a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglioimport android.transition.TransitionManager; 55263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.util.AttributeSet; 56263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.util.Log; 57263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.util.TypedValue; 58263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.util.Xml; 59d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglioimport android.view.Menu; 60d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglioimport android.view.MenuInflater; 61263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.view.MenuItem; 62263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.view.View; 63263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.view.View.OnClickListener; 6459a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglioimport android.view.ViewGroup; 65263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport android.widget.Button; 66d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglioimport android.widget.SearchView; 67c7f8e8ce69e80ea495472aade5f8569c6583c5e8John Spurlock 68263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.internal.util.ArrayUtils; 69263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.internal.util.XmlUtils; 70263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.accessibility.AccessibilitySettings; 71263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.accessibility.CaptionPropertiesFragment; 72263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.accounts.AccountSyncSettings; 73263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.accounts.AuthenticatorHelper; 74263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.accounts.ManageAccountsSettings; 75d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglioimport com.android.settings.applications.InstalledAppDetails; 76263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.applications.ManageApplications; 77263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.applications.ProcessStatsUi; 78263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.bluetooth.BluetoothSettings; 7963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglioimport com.android.settings.dashboard.DashboardCategory; 80263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.dashboard.DashboardSummary; 8163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglioimport com.android.settings.dashboard.DashboardTile; 82d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglioimport com.android.settings.dashboard.NoHomeDialogFragment; 83d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglioimport com.android.settings.dashboard.SearchResultsSummary; 84263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.deviceinfo.Memory; 85263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.deviceinfo.UsbSettings; 86c7f8e8ce69e80ea495472aade5f8569c6583c5e8John Spurlockimport com.android.settings.fuelgauge.BatterySaverSettings; 87263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.fuelgauge.PowerUsageSummary; 887a6bfd132cac4dcff72e3adcdd68a7ef777cee12Fabrice Di Meglioimport com.android.settings.search.DynamicIndexableContentMonitor; 89fa7dc240e978b1b77bb5c80a78cd1f8c77648301Fabrice Di Meglioimport com.android.settings.search.Index; 90263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.inputmethod.InputMethodAndLanguageSettings; 91263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.inputmethod.KeyboardLayoutPickerFragment; 92263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.inputmethod.SpellCheckersSettings; 93263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.inputmethod.UserDictionaryList; 94263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.location.LocationSettings; 95263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.nfc.AndroidBeam; 96263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.nfc.PaymentSettings; 97c9afadb04b00598f5988101681089290cf14f79cJohn Spurlockimport com.android.settings.notification.ConditionProviderSettings; 984a35051565b0ce6d29313c3e4ffe19e1dde78db0John Spurlockimport com.android.settings.notification.NotificationAccessSettings; 994a35051565b0ce6d29313c3e4ffe19e1dde78db0John Spurlockimport com.android.settings.notification.NotificationSettings; 1004a35051565b0ce6d29313c3e4ffe19e1dde78db0John Spurlockimport com.android.settings.notification.NotificationStation; 1014a35051565b0ce6d29313c3e4ffe19e1dde78db0John Spurlockimport com.android.settings.notification.ZenModeSettings; 102263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.print.PrintJobSettingsFragment; 103263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.print.PrintSettingsFragment; 104263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.tts.TextToSpeechSettings; 105263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.users.UserSettings; 106263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.vpn2.VpnSettings; 107263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.wfd.WifiDisplaySettings; 10841937766981423c9252e12e3319b2e7532739627Fabrice Di Meglioimport com.android.settings.widget.SwitchBar; 109263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.wifi.AdvancedWifiSettings; 110263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.wifi.WifiSettings; 111263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport com.android.settings.wifi.p2p.WifiP2pSettings; 112c7f8e8ce69e80ea495472aade5f8569c6583c5e8John Spurlock 113263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport org.xmlpull.v1.XmlPullParser; 114263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport org.xmlpull.v1.XmlPullParserException; 115263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 116263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport java.io.IOException; 117263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport java.util.ArrayList; 118263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport java.util.Collections; 119263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport java.util.Comparator; 120263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglioimport java.util.List; 1210d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglioimport java.util.Set; 122263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 123e9326d276135b657738d851e0a56df447f09567aFabrice Di Meglioimport static com.android.settings.dashboard.DashboardTile.TILE_ID_UNDEFINED; 124d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 125263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Megliopublic class SettingsActivity extends Activity 126263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio implements PreferenceManager.OnPreferenceTreeClickListener, 127263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PreferenceFragment.OnPreferenceStartFragmentCallback, 128d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio ButtonBarHandler, OnAccountsUpdateListener, FragmentManager.OnBackStackChangedListener, 129d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio SearchView.OnQueryTextListener, SearchView.OnCloseListener, 130d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio MenuItem.OnActionExpandListener { 131263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 132263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private static final String LOG_TAG = "Settings"; 133263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 134263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Constants for state save/restore 135769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio private static final String SAVE_KEY_CATEGORIES = ":settings:categories"; 136d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private static final String SAVE_KEY_SEARCH_MENU_EXPANDED = ":settings:search_menu_expanded"; 137d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private static final String SAVE_KEY_SEARCH_QUERY = ":settings:search_query"; 138b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio private static final String SAVE_KEY_SHOW_HOME_AS_UP = ":settings:show_home_as_up"; 1393d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio private static final String SAVE_KEY_SHOW_SEARCH = ":settings:show_search"; 140263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 141263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 142263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * When starting this activity, the invoking Intent can contain this extra 143263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * string to specify which fragment should be initially displayed. 144263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * <p/>Starting from Key Lime Pie, when this argument is passed in, the activity 145263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * will call isValidFragment() to confirm that the fragment class name is valid for this 146263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * activity. 147263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio */ 148263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public static final String EXTRA_SHOW_FRAGMENT = ":settings:show_fragment"; 149263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 150263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 151263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT}, 152263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * this extra can also be specified to supply a Bundle of arguments to pass 153263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * to that fragment when it is instantiated during the initial creation 154263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * of the activity. 155263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio */ 156263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public static final String EXTRA_SHOW_FRAGMENT_ARGUMENTS = ":settings:show_fragment_args"; 157263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 158263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 159c1457323d271309d5d1955743cd806417c84b9d6Fabrice Di Meglio * Fragment "key" argument passed thru {@link #EXTRA_SHOW_FRAGMENT_ARGUMENTS} 160c1457323d271309d5d1955743cd806417c84b9d6Fabrice Di Meglio */ 161c1457323d271309d5d1955743cd806417c84b9d6Fabrice Di Meglio public static final String EXTRA_FRAGMENT_ARG_KEY = ":settings:fragment_args_key"; 162c1457323d271309d5d1955743cd806417c84b9d6Fabrice Di Meglio 1636f0739a3d9a9eca1591ae6bada1dd4d1d92c0defFabrice Di Meglio public static final String BACK_STACK_PREFS = ":settings:prefs"; 1646f0739a3d9a9eca1591ae6bada1dd4d1d92c0defFabrice Di Meglio 165263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // extras that allow any preference activity to be launched as part of a wizard 166263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 167263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // show Back and Next buttons? takes boolean parameter 168263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Back will then return RESULT_CANCELED and Next RESULT_OK 169263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio protected static final String EXTRA_PREFS_SHOW_BUTTON_BAR = "extra_prefs_show_button_bar"; 170263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 171263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // add a Skip button? 172263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private static final String EXTRA_PREFS_SHOW_SKIP = "extra_prefs_show_skip"; 173263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 174263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // specify custom text for the Back or Next buttons, or cause a button to not appear 175263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // at all by setting it to null 176263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio protected static final String EXTRA_PREFS_SET_NEXT_TEXT = "extra_prefs_set_next_text"; 177263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio protected static final String EXTRA_PREFS_SET_BACK_TEXT = "extra_prefs_set_back_text"; 178263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 179263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 180263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT}, 181a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio * those extra can also be specify to supply the title or title res id to be shown for 182263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * that fragment. 183263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio */ 184d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public static final String EXTRA_SHOW_FRAGMENT_TITLE = ":settings:show_fragment_title"; 185a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio public static final String EXTRA_SHOW_FRAGMENT_TITLE_RESID = ":settings:show_fragment_title_resid"; 1860d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio public static final String EXTRA_SHOW_FRAGMENT_AS_SHORTCUT = ":settings:show_fragment_as_shortcut"; 187263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 188263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private static final String META_DATA_KEY_FRAGMENT_CLASS = 189263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio "com.android.settings.FRAGMENT_CLASS"; 190263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 191263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private static final String EXTRA_UI_OPTIONS = "settings:ui_options"; 192263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 193d6985df419549fbb7d420eced8e89f0429e49d71Fabrice Di Meglio private static final String EMPTY_QUERY = ""; 194d6985df419549fbb7d420eced8e89f0429e49d71Fabrice Di Meglio 195263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private static boolean sShowNoHomeNotice = false; 196263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 197263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private String mFragmentClass; 198263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1998eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio private CharSequence mInitialTitle; 200a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio private int mInitialTitleResId; 2018eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio 202263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Show only these settings for restricted users 203263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private int[] SETTINGS_FOR_RESTRICTED = { 204263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.wireless_section, 205263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.wifi_settings, 206263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.bluetooth_settings, 207263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.data_usage_settings, 208263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.wireless_settings, 209263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.device_section, 2104e4cdeffdb6087c953f44808f14f18554a749bdaJohn Spurlock R.id.notification_settings, 211263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.display_settings, 212263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.storage_settings, 213263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.application_settings, 214263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.battery_settings, 215263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.personal_section, 216263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.location_settings, 217263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.security_settings, 218263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.language_settings, 219263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.user_settings, 220263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.account_settings, 221263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.account_add, 222263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.system_section, 223263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.date_time_settings, 224263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.about_settings, 225263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.accessibility_settings, 226263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.print_settings, 227263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio R.id.nfc_payment_settings, 2282858b790ad92bb39e26150d696432f0b717bcddcFabrice Di Meglio R.id.home_settings, 2292858b790ad92bb39e26150d696432f0b717bcddcFabrice Di Meglio R.id.dashboard 230263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }; 231263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 232263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private static final String[] ENTRY_FRAGMENTS = { 233263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio WirelessSettings.class.getName(), 234263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio WifiSettings.class.getName(), 235263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio AdvancedWifiSettings.class.getName(), 236263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio BluetoothSettings.class.getName(), 237263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio TetherSettings.class.getName(), 238263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio WifiP2pSettings.class.getName(), 239263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio VpnSettings.class.getName(), 240263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DateTimeSettings.class.getName(), 241263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio LocalePicker.class.getName(), 242263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio InputMethodAndLanguageSettings.class.getName(), 243263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio SpellCheckersSettings.class.getName(), 244263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio UserDictionaryList.class.getName(), 245263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio UserDictionarySettings.class.getName(), 246263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DisplaySettings.class.getName(), 247263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DeviceInfoSettings.class.getName(), 248263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio ManageApplications.class.getName(), 249263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio ProcessStatsUi.class.getName(), 250263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio NotificationStation.class.getName(), 251263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio LocationSettings.class.getName(), 252263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio SecuritySettings.class.getName(), 253263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PrivacySettings.class.getName(), 254263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DeviceAdminSettings.class.getName(), 255263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio AccessibilitySettings.class.getName(), 256263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio CaptionPropertiesFragment.class.getName(), 257263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio com.android.settings.accessibility.ToggleInversionPreferenceFragment.class.getName(), 258263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment.class.getName(), 259263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio TextToSpeechSettings.class.getName(), 260263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio Memory.class.getName(), 261263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DevelopmentSettings.class.getName(), 262263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio UsbSettings.class.getName(), 263263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio AndroidBeam.class.getName(), 264263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio WifiDisplaySettings.class.getName(), 265263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PowerUsageSummary.class.getName(), 266263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio AccountSyncSettings.class.getName(), 267263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio CryptKeeperSettings.class.getName(), 268263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DataUsageSummary.class.getName(), 269263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio DreamSettings.class.getName(), 270263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio UserSettings.class.getName(), 271263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio NotificationAccessSettings.class.getName(), 272c9afadb04b00598f5988101681089290cf14f79cJohn Spurlock ConditionProviderSettings.class.getName(), 273263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio ManageAccountsSettings.class.getName(), 274263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PrintSettingsFragment.class.getName(), 275263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PrintJobSettingsFragment.class.getName(), 276263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio TrustedCredentialsSettings.class.getName(), 277263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PaymentSettings.class.getName(), 278263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio KeyboardLayoutPickerFragment.class.getName(), 279d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio ZenModeSettings.class.getName(), 280d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio NotificationSettings.class.getName(), 281d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio ChooseLockPassword.ChooseLockPasswordFragment.class.getName(), 282d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio ChooseLockPattern.ChooseLockPatternFragment.class.getName(), 283c7f8e8ce69e80ea495472aade5f8569c6583c5e8John Spurlock InstalledAppDetails.class.getName(), 284c7f8e8ce69e80ea495472aade5f8569c6583c5e8John Spurlock BatterySaverSettings.class.getName(), 285263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }; 286263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 287263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private SharedPreferences mDevelopmentPreferences; 288263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private SharedPreferences.OnSharedPreferenceChangeListener mDevelopmentPreferencesListener; 289263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 290263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private AuthenticatorHelper mAuthenticatorHelper; 291263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private boolean mListeningToAccountUpdates; 292263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 293263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private boolean mBatteryPresent = true; 294263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private BroadcastReceiver mBatteryInfoReceiver = new BroadcastReceiver() { 295263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 296263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 297263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onReceive(Context context, Intent intent) { 298263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio String action = intent.getAction(); 299263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (Intent.ACTION_BATTERY_CHANGED.equals(action)) { 300263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio boolean batteryPresent = Utils.isBatteryPresent(intent); 301263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 302263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (mBatteryPresent != batteryPresent) { 303263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mBatteryPresent = batteryPresent; 304769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio invalidateCategories(); 305263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 306263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 307263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 308263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }; 309263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 310990159abaad7f314fbe1f9eaf064a088806ffb19Svetoslav private final DynamicIndexableContentMonitor mDynamicIndexableContentMonitor = 311990159abaad7f314fbe1f9eaf064a088806ffb19Svetoslav new DynamicIndexableContentMonitor(); 312853e47181dc116ba95e91463735dc79ad4bdc95aSvetoslav 313d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private ActionBar mActionBar; 31441937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio private SwitchBar mSwitchBar; 31541937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio 31641937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio private Button mNextButton; 3173d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio 318b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio private boolean mDisplayHomeAsUpEnabled; 3193d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio private boolean mDisplaySearch; 320d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 32135062d6983e352f5cb6c4a6bbf3c1e4e214d44a9Fabrice Di Meglio private boolean mIsShowingDashboard; 3220d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio private boolean mIsShortcut; 32335062d6983e352f5cb6c4a6bbf3c1e4e214d44a9Fabrice Di Meglio 32459a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglio private ViewGroup mContent; 32559a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglio 326d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private SearchView mSearchView; 327d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private MenuItem mSearchMenuItem; 328d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private boolean mSearchMenuItemExpanded = false; 329d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private SearchResultsSummary mSearchResultsFragment; 330d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private String mSearchQuery; 331d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 332769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio // Categories 333769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio private ArrayList<DashboardCategory> mCategories = new ArrayList<DashboardCategory>(); 334769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio private boolean mNeedToRebuildCategories; 335263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 336769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio private static final int MSG_BUILD_CATEGORIES = 1; 337263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private Handler mHandler = new Handler() { 338263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 339263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void handleMessage(Message msg) { 340263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio switch (msg.what) { 341769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio case MSG_BUILD_CATEGORIES: { 34242c4b0abe5578a7812844ad5205ffc3b87cf3072Fabrice Di Meglio if(mNeedToRebuildCategories) { 34342c4b0abe5578a7812844ad5205ffc3b87cf3072Fabrice Di Meglio buildDashboardCategories(mCategories); 34442c4b0abe5578a7812844ad5205ffc3b87cf3072Fabrice Di Meglio } 345263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } break; 346263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 347263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 348263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }; 349263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 350d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private boolean mNeedToRevertToInitialFragment = false; 351d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 35241937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio public SwitchBar getSwitchBar() { 35341937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio return mSwitchBar; 35441937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio } 35541937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio 356769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio public AuthenticatorHelper getAuthenticatorHelper() { 357769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio return mAuthenticatorHelper; 358769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio } 359769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio 360769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio public List<DashboardCategory> getDashboardCategories() { 36142c4b0abe5578a7812844ad5205ffc3b87cf3072Fabrice Di Meglio if (mNeedToRebuildCategories || mCategories.size() == 0) { 362769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio buildDashboardCategories(mCategories); 363769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio mNeedToRebuildCategories = false; 364769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio } 365769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio return mCategories; 366769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio } 367769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio 368263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 369263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) { 370263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Override the fragment title for Wallpaper settings 371263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio int titleRes = pref.getTitleRes(); 372263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (pref.getFragment().equals(WallpaperTypeSettings.class.getName())) { 373263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio titleRes = R.string.wallpaper_settings_fragment_title; 374263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } else if (pref.getFragment().equals(OwnerInfoSettings.class.getName()) 375263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio && UserHandle.myUserId() != UserHandle.USER_OWNER) { 376263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (UserManager.get(this).isLinkedUser()) { 377263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio titleRes = R.string.profile_info_settings_title; 378263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } else { 379263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio titleRes = R.string.user_info_settings_title; 380263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 381263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 382263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio startPreferencePanel(pref.getFragment(), pref.getExtras(), titleRes, pref.getTitle(), 383263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio null, 0); 384263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return true; 385263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 386263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 387263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 388263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { 389263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return false; 390263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 391263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 392769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio private void invalidateCategories() { 393769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio if (!mHandler.hasMessages(MSG_BUILD_CATEGORIES)) { 394769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio mHandler.sendEmptyMessage(MSG_BUILD_CATEGORIES); 395263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 396263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 397263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 398263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 399263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onConfigurationChanged(Configuration newConfig) { 400263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio super.onConfigurationChanged(newConfig); 4016f0739a3d9a9eca1591ae6bada1dd4d1d92c0defFabrice Di Meglio Index.getInstance(this).update(); 402263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 403263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 404263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 405d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio protected void onStart() { 406d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio super.onStart(); 407d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 408d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (mNeedToRevertToInitialFragment) { 409d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio revertToInitialFragment(); 410263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 411263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 412263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 413263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 414d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onCreateOptionsMenu(Menu menu) { 4153d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio if (!mDisplaySearch) { 4163d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio return false; 4173d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio } 4183d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio 419d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio MenuInflater inflater = getMenuInflater(); 420d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio inflater.inflate(R.menu.options_menu, menu); 421d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 422d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio // Cache the search query (can be overriden by the OnQueryTextListener) 423d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio final String query = mSearchQuery; 424d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 4259593782d154f378a0c911cd015d410c18fe74a92Fabrice Di Meglio mSearchMenuItem = menu.findItem(R.id.search); 4269593782d154f378a0c911cd015d410c18fe74a92Fabrice Di Meglio mSearchView = (SearchView) mSearchMenuItem.getActionView(); 427d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 42823ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio if (mSearchMenuItem == null || mSearchView == null) { 42923ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio return false; 43023ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio } 43123ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio 4328c3b0ce7120da882082eed533462090c4feadff8Fabrice Di Meglio if (mSearchResultsFragment != null) { 4338c3b0ce7120da882082eed533462090c4feadff8Fabrice Di Meglio mSearchResultsFragment.setSearchView(mSearchView); 4348c3b0ce7120da882082eed533462090c4feadff8Fabrice Di Meglio } 4358c3b0ce7120da882082eed533462090c4feadff8Fabrice Di Meglio 4369593782d154f378a0c911cd015d410c18fe74a92Fabrice Di Meglio mSearchMenuItem.setOnActionExpandListener(this); 437d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchView.setOnQueryTextListener(this); 438d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchView.setOnCloseListener(this); 439d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 440d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (mSearchMenuItemExpanded) { 441d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchMenuItem.expandActionView(); 442d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 443d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchView.setQuery(query, true /* submit */); 444d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 445d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return true; 446d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 447d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 4480d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio private static boolean isShortCutIntent(final Intent intent) { 4490d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio Set<String> categories = intent.getCategories(); 4500d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio return (categories != null) && categories.contains("com.android.settings.SHORTCUT"); 4510d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio } 4520d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio 453d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 454d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio protected void onCreate(Bundle savedState) { 4550d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio super.onCreate(savedState); 4560d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio 4570d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio // Should happen before any call to getIntent() 4580d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio getMetaData(); 4590d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio 4600d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio final Intent intent = getIntent(); 4610d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio if (intent.hasExtra(EXTRA_UI_OPTIONS)) { 4620d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0)); 463263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 4645ebabfcd35dd00a1d5beb9bcaca03574ae09b4e8Fabrice Di Meglio 465263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mAuthenticatorHelper = new AuthenticatorHelper(); 466263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mAuthenticatorHelper.updateAuthDescriptions(this); 467263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mAuthenticatorHelper.onAccountsUpdated(this, null); 468263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 469263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mDevelopmentPreferences = getSharedPreferences(DevelopmentSettings.PREF_FILE, 470263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio Context.MODE_PRIVATE); 471263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 472da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio // Getting Intent properties can only be done after the super.onCreate(...) 4730d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio final String initialFragmentName = intent.getStringExtra(EXTRA_SHOW_FRAGMENT); 4740d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio 4750d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio mIsShortcut = isShortCutIntent(intent) || 4760d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SHORTCUT, false); 477da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio 4780d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio mIsShowingDashboard = (initialFragmentName == null) && !mIsShortcut; 479da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio 480da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio final ComponentName cn = getIntent().getComponent(); 4810d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio final boolean isSubSettings = cn.getClassName().equals(SubSettings.class.getName()); 482da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio 4830d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio // If this is a sub settings or not the main Dashboard and not a Shortcut then apply the 4840d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio // correct theme for the ActionBar content inset 4850d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio if (isSubSettings || (!mIsShowingDashboard && !mIsShortcut)) { 486da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio setTheme(R.style.Theme_SubSettings); 487da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio } 488da8babaedf45caf55eb77320f0c3ea873d195c4dFabrice Di Meglio 489263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio setContentView(R.layout.settings_main); 490263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 49159a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglio mContent = (ViewGroup) findViewById(R.id.prefs); 49259a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglio 493263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio getFragmentManager().addOnBackStackChangedListener(this); 494263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 495b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio mDisplayHomeAsUpEnabled = true; 4963d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio mDisplaySearch = true; 497263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 49835062d6983e352f5cb6c4a6bbf3c1e4e214d44a9Fabrice Di Meglio if (mIsShowingDashboard) { 499dba577f8f017baac0086c185579340db1c9281d9Fabrice Di Meglio Index.getInstance(getApplicationContext()).update(); 5005cda21b449a56de42f7868bdcdaa31bb6f587c03Fabrice Di Meglio } 5015cda21b449a56de42f7868bdcdaa31bb6f587c03Fabrice Di Meglio 502d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (savedState != null) { 5031800a9f3e7027e8ab8ffcab51715d39b126bad43Fabrice Di Meglio // We are restarting from a previous saved state; used that to initialize, instead 5041800a9f3e7027e8ab8ffcab51715d39b126bad43Fabrice Di Meglio // of starting fresh. 505d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchMenuItemExpanded = savedState.getBoolean(SAVE_KEY_SEARCH_MENU_EXPANDED); 506d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchQuery = savedState.getString(SAVE_KEY_SEARCH_QUERY); 507263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 5080d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio setTitleFromIntent(intent); 5095529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio 510769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio ArrayList<DashboardCategory> categories = 511769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio savedState.getParcelableArrayList(SAVE_KEY_CATEGORIES); 512769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio if (categories != null) { 5135f995727cc2e4bd27d26a50f3a565fb677fdb294Fabrice Di Meglio mCategories.clear(); 514769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio mCategories.addAll(categories); 515b643cbf6d60bb4cd43d3191106d68680fffe97b5Fabrice Di Meglio setTitleFromBackStack(); 516263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 517b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio 518b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio mDisplayHomeAsUpEnabled = savedState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP); 5193d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio mDisplaySearch = savedState.getBoolean(SAVE_KEY_SHOW_SEARCH); 520263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } else { 52135062d6983e352f5cb6c4a6bbf3c1e4e214d44a9Fabrice Di Meglio if (!mIsShowingDashboard) { 5220d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio // Search is shown we are launched thru a Settings "shortcut". UP will be shown 5230d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio // only if it is a sub settings 5240d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio if (mIsShortcut) { 5250d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio mDisplayHomeAsUpEnabled = isSubSettings; 5263d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio mDisplaySearch = false; 527d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 5280d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio setTitleFromIntent(intent); 529c1457323d271309d5d1955743cd806417c84b9d6Fabrice Di Meglio 5300d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio Bundle initialArguments = intent.getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS); 531a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio switchToFragment(initialFragmentName, initialArguments, true, false, 532a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitleResId, mInitialTitle, false); 53310afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio } else { 534e9326d276135b657738d851e0a56df447f09567aFabrice Di Meglio // No UP if we are displaying the main Dashboard 535b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio mDisplayHomeAsUpEnabled = false; 536a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitleResId = R.string.dashboard_title; 53742c4b0abe5578a7812844ad5205ffc3b87cf3072Fabrice Di Meglio switchToFragment(DashboardSummary.class.getName(), null, false, false, 538a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitleResId, mInitialTitle, false); 539263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 540263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 541263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 542d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mActionBar = getActionBar(); 543d8aec08fa96c42a61bd6ead2aa9859b5b67a3f2cFabrice Di Meglio if (mActionBar != null) { 544d8aec08fa96c42a61bd6ead2aa9859b5b67a3f2cFabrice Di Meglio mActionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled); 545d8aec08fa96c42a61bd6ead2aa9859b5b67a3f2cFabrice Di Meglio mActionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled); 546d8aec08fa96c42a61bd6ead2aa9859b5b67a3f2cFabrice Di Meglio } 54741937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio mSwitchBar = (SwitchBar) findViewById(R.id.switch_bar); 54841937766981423c9252e12e3319b2e7532739627Fabrice Di Meglio 549263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // see if we should show Back/Next buttons 550263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)) { 551263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 552d2b64f339adb8f019e3c712e388e35830d8b68a9Fabrice Di Meglio View buttonBar = findViewById(R.id.button_bar); 553263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (buttonBar != null) { 554263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio buttonBar.setVisibility(View.VISIBLE); 555263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 556d2b64f339adb8f019e3c712e388e35830d8b68a9Fabrice Di Meglio Button backButton = (Button)findViewById(R.id.back_button); 557263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio backButton.setOnClickListener(new OnClickListener() { 558263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onClick(View v) { 559263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio setResult(RESULT_CANCELED); 560263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio finish(); 561263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 562263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }); 563d2b64f339adb8f019e3c712e388e35830d8b68a9Fabrice Di Meglio Button skipButton = (Button)findViewById(R.id.skip_button); 564263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio skipButton.setOnClickListener(new OnClickListener() { 565263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onClick(View v) { 566263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio setResult(RESULT_OK); 567263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio finish(); 568263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 569263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }); 570d2b64f339adb8f019e3c712e388e35830d8b68a9Fabrice Di Meglio mNextButton = (Button)findViewById(R.id.next_button); 571263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mNextButton.setOnClickListener(new OnClickListener() { 572263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onClick(View v) { 573263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio setResult(RESULT_OK); 574263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio finish(); 575263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 576263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }); 577263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 578263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // set our various button parameters 579263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (intent.hasExtra(EXTRA_PREFS_SET_NEXT_TEXT)) { 580263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_NEXT_TEXT); 581263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (TextUtils.isEmpty(buttonText)) { 582263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mNextButton.setVisibility(View.GONE); 583263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 584263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio else { 585263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mNextButton.setText(buttonText); 586263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 587263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 588263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (intent.hasExtra(EXTRA_PREFS_SET_BACK_TEXT)) { 589263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_BACK_TEXT); 590263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (TextUtils.isEmpty(buttonText)) { 591263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio backButton.setVisibility(View.GONE); 592263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 593263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio else { 594263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio backButton.setText(buttonText); 595263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 596263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 597263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_SKIP, false)) { 598263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio skipButton.setVisibility(View.VISIBLE); 599263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 600263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 601263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 602c95be4fbb3ec437517a2190d88fbda5068dba8dfFabrice Di Meglio } 603c95be4fbb3ec437517a2190d88fbda5068dba8dfFabrice Di Meglio 604a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio private void setTitleFromIntent(Intent intent) { 605a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio final int initialTitleResId = intent.getIntExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1); 606a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio if (initialTitleResId > 0) { 607a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitle = null; 608a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitleResId = initialTitleResId; 609a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio setTitle(mInitialTitleResId); 610a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } else { 611a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitleResId = -1; 612a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio final String initialTitle = intent.getStringExtra(EXTRA_SHOW_FRAGMENT_TITLE); 613a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio mInitialTitle = (initialTitle != null) ? initialTitle : getTitle(); 614a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio setTitle(mInitialTitle); 615a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } 616a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } 617a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio 618c95be4fbb3ec437517a2190d88fbda5068dba8dfFabrice Di Meglio @Override 619263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onBackStackChanged() { 620d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio setTitleFromBackStack(); 6218eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio } 6228eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio 623b643cbf6d60bb4cd43d3191106d68680fffe97b5Fabrice Di Meglio private int setTitleFromBackStack() { 6248eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio final int count = getFragmentManager().getBackStackEntryCount(); 625b643cbf6d60bb4cd43d3191106d68680fffe97b5Fabrice Di Meglio 6268eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio if (count == 0) { 627a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio if (mInitialTitleResId > 0) { 628a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio setTitle(mInitialTitleResId); 629a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } else { 630a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio setTitle(mInitialTitle); 631a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } 632b643cbf6d60bb4cd43d3191106d68680fffe97b5Fabrice Di Meglio return 0; 633263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 634b643cbf6d60bb4cd43d3191106d68680fffe97b5Fabrice Di Meglio 6358eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio FragmentManager.BackStackEntry bse = getFragmentManager().getBackStackEntryAt(count - 1); 6368eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio setTitleFromBackStackEntry(bse); 637b643cbf6d60bb4cd43d3191106d68680fffe97b5Fabrice Di Meglio 638b643cbf6d60bb4cd43d3191106d68680fffe97b5Fabrice Di Meglio return count; 639263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 640263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 6418eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio private void setTitleFromBackStackEntry(FragmentManager.BackStackEntry bse) { 6425529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio final CharSequence title; 6438eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio final int titleRes = bse.getBreadCrumbTitleRes(); 6448eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio if (titleRes > 0) { 6458eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio title = getText(titleRes); 6465529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio } else { 6478eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio title = bse.getBreadCrumbTitle(); 6488eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio } 6498eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio if (title != null) { 6508eb3f0fbf2ced7291167755fe74ce50164eb3a9eFabrice Di Meglio setTitle(title); 6515529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio } 6525529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio } 6535529d29f6c22e9f28444ca1c0aa9ea2534264220Fabrice Di Meglio 654263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 655263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio protected void onSaveInstanceState(Bundle outState) { 656263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio super.onSaveInstanceState(outState); 657263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 658769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio if (mCategories.size() > 0) { 659769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio outState.putParcelableArrayList(SAVE_KEY_CATEGORIES, mCategories); 660263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 661d6985df419549fbb7d420eced8e89f0429e49d71Fabrice Di Meglio 662b731dd0554744d91ca89d37ff7c82f8d6e5b502dFabrice Di Meglio outState.putBoolean(SAVE_KEY_SHOW_HOME_AS_UP, mDisplayHomeAsUpEnabled); 6633d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio outState.putBoolean(SAVE_KEY_SHOW_SEARCH, mDisplaySearch); 6643d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio 6653d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio if (mDisplaySearch) { 6663d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio // The option menus are created if the ActionBar is visible and they are also created 6673d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio // asynchronously. If you launch Settings with an Intent action like 6683d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio // android.intent.action.POWER_USAGE_SUMMARY and at the same time your device is locked 6693d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio // thru a LockScreen, onCreateOptionsMenu() is not yet called and references to the search 6703d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio // menu item and search view are null. 6713d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio boolean isExpanded = (mSearchMenuItem != null) && mSearchMenuItem.isActionViewExpanded(); 6723d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio outState.putBoolean(SAVE_KEY_SEARCH_MENU_EXPANDED, isExpanded); 6733d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio 6743d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio String query = (mSearchView != null) ? mSearchView.getQuery().toString() : EMPTY_QUERY; 6753d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio outState.putString(SAVE_KEY_SEARCH_QUERY, query); 6763d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio } 677263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 678263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 679263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 680263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onResume() { 681263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio super.onResume(); 682263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 683263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mDevelopmentPreferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() { 684263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 685263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { 686bb05178dba21509d5b26ae0bd718a471b8c6cd5eFabrice Di Meglio setNeedToRebuildCategories(true); 687769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio invalidateCategories(); 688263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 689263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio }; 690263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mDevelopmentPreferences.registerOnSharedPreferenceChangeListener( 691263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mDevelopmentPreferencesListener); 692263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 693263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); 694853e47181dc116ba95e91463735dc79ad4bdc95aSvetoslav 695990159abaad7f314fbe1f9eaf064a088806ffb19Svetoslav mDynamicIndexableContentMonitor.register(this); 696a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio 6973d35ec729256d4a1e1796be3e9d858eefedda23dFabrice Di Meglio if(mDisplaySearch && !TextUtils.isEmpty(mSearchQuery)) { 698a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio onQueryTextSubmit(mSearchQuery); 699a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio } 700263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 701263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 702263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 703263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onPause() { 704263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio super.onPause(); 705263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 706263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio unregisterReceiver(mBatteryInfoReceiver); 707263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 708990159abaad7f314fbe1f9eaf064a088806ffb19Svetoslav mDynamicIndexableContentMonitor.unregister(); 709263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 710263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 711263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 712263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onDestroy() { 713263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio super.onDestroy(); 714680b064b293888ea47a6211943b51bee3adfb70dFabrice Di Meglio 715680b064b293888ea47a6211943b51bee3adfb70dFabrice Di Meglio mDevelopmentPreferences.unregisterOnSharedPreferenceChangeListener( 716680b064b293888ea47a6211943b51bee3adfb70dFabrice Di Meglio mDevelopmentPreferencesListener); 717680b064b293888ea47a6211943b51bee3adfb70dFabrice Di Meglio mDevelopmentPreferencesListener = null; 718680b064b293888ea47a6211943b51bee3adfb70dFabrice Di Meglio 719263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (mListeningToAccountUpdates) { 720263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio AccountManager.get(this).removeOnAccountsUpdatedListener(this); 721263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 722263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 723263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 724263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio protected boolean isValidFragment(String fragmentName) { 725263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Almost all fragments are wrapped in this, 726263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // except for a few that have their own activities. 727263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio for (int i = 0; i < ENTRY_FRAGMENTS.length; i++) { 728263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (ENTRY_FRAGMENTS[i].equals(fragmentName)) return true; 729263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 730263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return false; 731263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 732263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 733263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 734263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public Intent getIntent() { 735263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio Intent superIntent = super.getIntent(); 736263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio String startingFragment = getStartingFragmentClass(superIntent); 737263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // This is called from super.onCreate, isMultiPane() is not yet reliable 738263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Do not use onIsHidingHeaders either, which relies itself on this method 739263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (startingFragment != null) { 740263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio Intent modIntent = new Intent(superIntent); 741263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio modIntent.putExtra(EXTRA_SHOW_FRAGMENT, startingFragment); 742263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio Bundle args = superIntent.getExtras(); 743263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (args != null) { 744263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio args = new Bundle(args); 745263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } else { 746263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio args = new Bundle(); 747263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 748263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio args.putParcelable("intent", superIntent); 749263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio modIntent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, superIntent.getExtras()); 750263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return modIntent; 751263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 752263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return superIntent; 753263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 754263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 755263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 756263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * Checks if the component name in the intent is different from the Settings class and 757263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * returns the class name to load as a fragment. 758263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio */ 759263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private String getStartingFragmentClass(Intent intent) { 760263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (mFragmentClass != null) return mFragmentClass; 761263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 762263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio String intentClass = intent.getComponent().getClassName(); 763263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (intentClass.equals(getClass().getName())) return null; 764263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 765263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if ("com.android.settings.ManageApplications".equals(intentClass) 766263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio || "com.android.settings.RunningServices".equals(intentClass) 767263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio || "com.android.settings.applications.StorageUse".equals(intentClass)) { 768263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // Old names of manage apps. 769263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio intentClass = com.android.settings.applications.ManageApplications.class.getName(); 770263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 771263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 772263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return intentClass; 773263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 774263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 775263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 77610afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * Start a new fragment containing a preference panel. If the preferences 77710afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * are being displayed in multi-pane mode, the given fragment class will 77810afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * be instantiated and placed in the appropriate pane. If running in 77910afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * single-pane mode, a new activity will be launched in which to show the 78010afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * fragment. 78110afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * 78210afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param fragmentClass Full name of the class implementing the fragment. 78310afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param args Any desired arguments to supply to the fragment. 78410afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param titleRes Optional resource identifier of the title of this 78510afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * fragment. 78610afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param titleText Optional text of the title of this fragment. 78710afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param resultTo Optional fragment that result data should be sent to. 78810afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * If non-null, resultTo.onActivityResult() will be called when this 78910afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * preference panel is done. The launched panel must use 79010afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * {@link #finishPreferencePanel(Fragment, int, Intent)} when done. 79110afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param resultRequestCode If resultTo is non-null, this is the caller's 79210afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * request code to be received with the resut. 79310afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio */ 79410afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes, 795d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio CharSequence titleText, Fragment resultTo, int resultRequestCode) { 796a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio String title = null; 797a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio if (titleRes < 0) { 798a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio if (titleText != null) { 799a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio title = titleText.toString(); 800a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } else { 801a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio // There not much we can do in that case 802a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio title = ""; 803a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } 804911fb2ad907d47a882c023b871c6457db32359f8Fabrice Di Meglio } 805a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio Utils.startWithFragment(this, fragmentClass, args, resultTo, resultRequestCode, 8060d643fd182d37d2e8ee5d547b80d80423a5ed98dFabrice Di Meglio titleRes, title, mIsShortcut); 80710afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio } 80810afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio 80910afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio /** 810263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * Called by a preference panel fragment to finish itself. 811263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * 812263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * @param caller The fragment that is asking to be finished. 813263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * @param resultCode Optional result code to send back to the original 814263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * launching fragment. 815263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * @param resultData Optional result data to send back to the original 816263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio * launching fragment. 817263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio */ 818263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void finishPreferencePanel(Fragment caller, int resultCode, Intent resultData) { 819263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio setResult(resultCode, resultData); 820263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 821263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 822263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio /** 82310afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * Start a new fragment. 82410afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * 82510afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param fragment The fragment to start 82610afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * @param push If true, the current fragment will be pushed onto the back stack. If false, 82710afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio * the current fragment will be replaced. 82810afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio */ 82910afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio public void startPreferenceFragment(Fragment fragment, boolean push) { 83010afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio FragmentTransaction transaction = getFragmentManager().beginTransaction(); 83110afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio transaction.replace(R.id.prefs, fragment); 83210afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio if (push) { 83310afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); 83410afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio transaction.addToBackStack(BACK_STACK_PREFS); 83510afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio } else { 83610afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); 83710afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio } 83810afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio transaction.commitAllowingStateLoss(); 83910afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio } 84010afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio 84110afdb82aca7c6345d2aace30c7b66238e6bfb3cFabrice Di Meglio /** 842d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio * Switch to a specific Fragment with taking care of validation, Title and BackStack 843d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio */ 844d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate, 845a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio boolean addToBackStack, int titleResId, CharSequence title, boolean withTransition) { 846d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (validate && !isValidFragment(fragmentName)) { 847d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio throw new IllegalArgumentException("Invalid fragment for this activity: " 848d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio + fragmentName); 849d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 850d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio Fragment f = Fragment.instantiate(this, fragmentName, args); 851d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio FragmentTransaction transaction = getFragmentManager().beginTransaction(); 852d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio transaction.replace(R.id.prefs, f); 853d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (withTransition) { 85459a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglio TransitionManager.beginDelayedTransition(mContent); 855d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 856d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (addToBackStack) { 857d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio transaction.addToBackStack(SettingsActivity.BACK_STACK_PREFS); 858d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 859a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio if (titleResId > 0) { 860a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio transaction.setBreadCrumbTitle(titleResId); 861a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio } else if (title != null) { 862d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio transaction.setBreadCrumbTitle(title); 863d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 864d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio transaction.commitAllowingStateLoss(); 86559a4055cbb8f5a7b1b0c904bbc4ffc03d8a1239fFabrice Di Meglio getFragmentManager().executePendingTransactions(); 866d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return f; 867d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 868d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio 869769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio public void setNeedToRebuildCategories(boolean need) { 870769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio mNeedToRebuildCategories = need; 871263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 872263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 87363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio /** 874769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio * Called when the activity needs its list of categories/tiles built. 87563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio * 87663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio * @param categories The list in which to place the tiles categories. 87763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio */ 878769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio private void buildDashboardCategories(List<DashboardCategory> categories) { 8795f995727cc2e4bd27d26a50f3a565fb677fdb294Fabrice Di Meglio categories.clear(); 88063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio loadCategoriesFromResource(R.xml.dashboard_categories, categories); 88163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio updateTilesList(categories); 88263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 88363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 88463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio /** 88563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio * Parse the given XML file as a categories description, adding each 88663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio * parsed categories and tiles into the target list. 88763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio * 88863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio * @param resid The XML resource to load and parse. 88963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio * @param target The list in which the parsed categories and tiles should be placed. 89063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio */ 89163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio private void loadCategoriesFromResource(int resid, List<DashboardCategory> target) { 89263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio XmlResourceParser parser = null; 89363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio try { 89463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio parser = getResources().getXml(resid); 89563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio AttributeSet attrs = Xml.asAttributeSet(parser); 89663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 89763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio int type; 89863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio while ((type=parser.next()) != XmlPullParser.END_DOCUMENT 89963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio && type != XmlPullParser.START_TAG) { 90063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // Parse next until start tag is found 90163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 90263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 90363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio String nodeName = parser.getName(); 90463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (!"dashboard-categories".equals(nodeName)) { 90563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio throw new RuntimeException( 90663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio "XML document must start with <preference-categories> tag; found" 90763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio + nodeName + " at " + parser.getPositionDescription()); 90863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 90963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 91063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio Bundle curBundle = null; 91163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 91263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio final int outerDepth = parser.getDepth(); 91363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio while ((type=parser.next()) != XmlPullParser.END_DOCUMENT 91463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { 91563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { 91663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio continue; 91763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 91863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 91963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio nodeName = parser.getName(); 92063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if ("dashboard-category".equals(nodeName)) { 92163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio DashboardCategory category = new DashboardCategory(); 92263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 92363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio TypedArray sa = obtainStyledAttributes( 92463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio attrs, com.android.internal.R.styleable.PreferenceHeader); 92563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio category.id = sa.getResourceId( 92663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio com.android.internal.R.styleable.PreferenceHeader_id, 92763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio (int)DashboardCategory.CAT_ID_UNDEFINED); 92863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 92963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio TypedValue tv = sa.peekValue( 93063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio com.android.internal.R.styleable.PreferenceHeader_title); 93163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (tv != null && tv.type == TypedValue.TYPE_STRING) { 93263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (tv.resourceId != 0) { 93363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio category.titleRes = tv.resourceId; 93463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else { 93563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio category.title = tv.string; 93663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 93763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 93863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio sa.recycle(); 93963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 94063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio final int innerDepth = parser.getDepth(); 94163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio while ((type=parser.next()) != XmlPullParser.END_DOCUMENT 94263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio && (type != XmlPullParser.END_TAG || parser.getDepth() > innerDepth)) { 94363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { 94463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio continue; 94563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 94663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 94763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio String innerNodeName = parser.getName(); 94863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (innerNodeName.equals("dashboard-tile")) { 94963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio DashboardTile tile = new DashboardTile(); 95063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 95163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio sa = obtainStyledAttributes( 95263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio attrs, com.android.internal.R.styleable.PreferenceHeader); 95363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio tile.id = sa.getResourceId( 95463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio com.android.internal.R.styleable.PreferenceHeader_id, 955e9326d276135b657738d851e0a56df447f09567aFabrice Di Meglio (int)TILE_ID_UNDEFINED); 95663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio tv = sa.peekValue( 95763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio com.android.internal.R.styleable.PreferenceHeader_title); 95863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (tv != null && tv.type == TypedValue.TYPE_STRING) { 95963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (tv.resourceId != 0) { 96063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio tile.titleRes = tv.resourceId; 96163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else { 96263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio tile.title = tv.string; 96363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 96463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 96563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio tv = sa.peekValue( 96663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio com.android.internal.R.styleable.PreferenceHeader_summary); 96763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (tv != null && tv.type == TypedValue.TYPE_STRING) { 96863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (tv.resourceId != 0) { 96963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio tile.summaryRes = tv.resourceId; 97063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else { 97163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio tile.summary = tv.string; 97263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 97363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 97463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio tile.iconRes = sa.getResourceId( 97563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio com.android.internal.R.styleable.PreferenceHeader_icon, 0); 97663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio tile.fragment = sa.getString( 97763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio com.android.internal.R.styleable.PreferenceHeader_fragment); 97863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio sa.recycle(); 97963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 98063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (curBundle == null) { 98163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio curBundle = new Bundle(); 98263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 98363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 98463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio final int innerDepth2 = parser.getDepth(); 98563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio while ((type=parser.next()) != XmlPullParser.END_DOCUMENT 98663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio && (type != XmlPullParser.END_TAG || parser.getDepth() > innerDepth2)) { 98763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { 98863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio continue; 98963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 99063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 99163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio String innerNodeName2 = parser.getName(); 99263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (innerNodeName2.equals("extra")) { 99363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio getResources().parseBundleExtra("extra", attrs, curBundle); 99463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio XmlUtils.skipCurrentTag(parser); 99563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 99663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else if (innerNodeName2.equals("intent")) { 99763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio tile.intent = Intent.parseIntent(getResources(), parser, attrs); 99863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 99963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else { 100063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio XmlUtils.skipCurrentTag(parser); 100163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 100263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 100363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 100463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (curBundle.size() > 0) { 100563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio tile.fragmentArguments = curBundle; 100663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio curBundle = null; 100763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 100863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 100963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio category.addTile(tile); 101063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 101163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else { 101263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio XmlUtils.skipCurrentTag(parser); 101363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 101463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 101563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 101663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio target.add(category); 101763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else { 101863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio XmlUtils.skipCurrentTag(parser); 101963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 102063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 102163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 102263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } catch (XmlPullParserException e) { 102363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio throw new RuntimeException("Error parsing categories", e); 102463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } catch (IOException e) { 102563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio throw new RuntimeException("Error parsing categories", e); 102663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } finally { 102763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (parser != null) parser.close(); 102863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 102963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 103063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 103163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio private void updateTilesList(List<DashboardCategory> target) { 103263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio final boolean showDev = mDevelopmentPreferences.getBoolean( 103363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio DevelopmentSettings.PREF_SHOW, 103463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio android.os.Build.TYPE.equals("eng")); 103563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 103663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE); 103763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 103863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio final int size = target.size(); 103963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio for (int i = 0; i < size; i++) { 104063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 104163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio DashboardCategory category = target.get(i); 104263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 104363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // Ids are integers, so downcasting is ok 104463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio int id = (int) category.id; 104563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (id == R.id.account_settings) { 104663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio insertAccountsTiles(category); 104763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio continue; 104863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 104963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio int n = category.getTilesCount() - 1; 105063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio while (n >= 0) { 105163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 105263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio DashboardTile tile = category.getTile(n); 105363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 105463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio id = (int) tile.id; 105563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (id == R.id.operator_settings || id == R.id.manufacturer_settings) { 105663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio Utils.updateTileToSpecificActivityFromMetaDataOrRemove(this, category, tile); 105763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else if (id == R.id.wifi_settings) { 105863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // Remove WiFi Settings if WiFi service is not available. 105963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) { 106063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio category.removeTile(n); 106163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 106263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else if (id == R.id.bluetooth_settings) { 106363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // Remove Bluetooth Settings if Bluetooth service is not available. 106463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) { 106563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio category.removeTile(n); 106663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 106763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else if (id == R.id.data_usage_settings) { 106863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // Remove data usage when kernel module not enabled 106963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio final INetworkManagementService netManager = INetworkManagementService.Stub 107063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio .asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE)); 107163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio try { 107263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (!netManager.isBandwidthControlEnabled()) { 107363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio category.removeTile(n); 107463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 107563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } catch (RemoteException e) { 107663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // ignored 107763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 107863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else if (id == R.id.battery_settings) { 107963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // Remove battery settings when battery is not available. (e.g. TV) 108063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 108163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (!mBatteryPresent) { 108263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio category.removeTile(n); 108363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 108463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else if (id == R.id.home_settings) { 108563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (!updateHomeSettingTiles(tile)) { 108663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio category.removeTile(n); 108763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 108863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else if (id == R.id.user_settings) { 10894093e40e18f2e8d395ca467f54aef6e763c394f6Amith Yamasani boolean hasMultipleUsers = 10904093e40e18f2e8d395ca467f54aef6e763c394f6Amith Yamasani ((UserManager) getSystemService(Context.USER_SERVICE)) 10914093e40e18f2e8d395ca467f54aef6e763c394f6Amith Yamasani .getUserCount() > 1; 109263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (!UserHandle.MU_ENABLED 10934093e40e18f2e8d395ca467f54aef6e763c394f6Amith Yamasani || (!UserManager.supportsMultipleUsers() 10944093e40e18f2e8d395ca467f54aef6e763c394f6Amith Yamasani && !hasMultipleUsers) 109563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio || Utils.isMonkeyRunning()) { 109663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio category.removeTile(n); 109763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 109863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else if (id == R.id.nfc_payment_settings) { 109963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) { 110063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio category.removeTile(n); 110163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else { 110263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // Only show if NFC is on and we have the HCE feature 110363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this); 110463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (!adapter.isEnabled() || !getPackageManager().hasSystemFeature( 110563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) { 110663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio category.removeTile(n); 110763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 110863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 1109488cae39dab2e8c298e8a1f1eec37bf0d96a83d2Fabrice Di Meglio } else if (id == R.id.print_settings) { 1110488cae39dab2e8c298e8a1f1eec37bf0d96a83d2Fabrice Di Meglio boolean hasPrintingSupport = getPackageManager().hasSystemFeature( 1111488cae39dab2e8c298e8a1f1eec37bf0d96a83d2Fabrice Di Meglio PackageManager.FEATURE_PRINTING); 1112488cae39dab2e8c298e8a1f1eec37bf0d96a83d2Fabrice Di Meglio if (!hasPrintingSupport) { 1113488cae39dab2e8c298e8a1f1eec37bf0d96a83d2Fabrice Di Meglio category.removeTile(n); 1114488cae39dab2e8c298e8a1f1eec37bf0d96a83d2Fabrice Di Meglio } 111563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else if (id == R.id.development_settings) { 11166c088cb221bb43d47be065387231ffa7192ff211Julia Reynolds if (!showDev || um.hasUserRestriction( 11176c088cb221bb43d47be065387231ffa7192ff211Julia Reynolds UserManager.DISALLOW_DEBUGGING_FEATURES)) { 111863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio category.removeTile(n); 111963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 112063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else if (id == R.id.account_add) { 112163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) { 112263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio category.removeTile(n); 112363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 112463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 112563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 112663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (UserHandle.MU_ENABLED && UserHandle.myUserId() != 0 1127a97089d389338ca8e3d970b00dd13ffad732b5c1Amith Yamasani && !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, id) 1128a97089d389338ca8e3d970b00dd13ffad732b5c1Amith Yamasani && n < category.getTilesCount()) { 112963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio category.removeTile(n); 113063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 113163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 113263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio n--; 113363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 113463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 113563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 113663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 113763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio private boolean updateHomeSettingTiles(DashboardTile tile) { 113863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // Once we decide to show Home settings, keep showing it forever 113963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio SharedPreferences sp = getSharedPreferences(HomeSettings.HOME_PREFS, Context.MODE_PRIVATE); 114063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (sp.getBoolean(HomeSettings.HOME_PREFS_DO_SHOW, false)) { 114163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio return true; 114263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 114363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 114463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio try { 114563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio final ArrayList<ResolveInfo> homeApps = new ArrayList<ResolveInfo>(); 114663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio getPackageManager().getHomeActivities(homeApps); 114763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (homeApps.size() < 2) { 114863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // When there's only one available home app, omit this settings 114963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // category entirely at the top level UI. If the user just 115063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // uninstalled the penultimate home app candidiate, we also 115163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // now tell them about why they aren't seeing 'Home' in the list. 115263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (sShowNoHomeNotice) { 115363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio sShowNoHomeNotice = false; 115463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio NoHomeDialogFragment.show(this); 115563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 115663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio return false; 115763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else { 115863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // Okay, we're allowing the Home settings category. Tell it, when 115963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // invoked via this front door, that we'll need to be told about the 116063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // case when the user uninstalls all but one home app. 116163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (tile.fragmentArguments == null) { 116263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio tile.fragmentArguments = new Bundle(); 116363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 116463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio tile.fragmentArguments.putBoolean(HomeSettings.HOME_SHOW_NOTICE, true); 116563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 116663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } catch (Exception e) { 116763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // Can't look up the home activity; bail on configuring the icon 116863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio Log.w(LOG_TAG, "Problem looking up home activity!", e); 116963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 117063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 117163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio sp.edit().putBoolean(HomeSettings.HOME_PREFS_DO_SHOW, true).apply(); 117263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio return true; 117363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 117463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 117563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio private void insertAccountsTiles(DashboardCategory target) { 117663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio String[] accountTypes = mAuthenticatorHelper.getEnabledAccountTypes(); 117763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio List<DashboardTile> dashboardTiles = new ArrayList<DashboardTile>(accountTypes.length); 117863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio for (String accountType : accountTypes) { 117963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio CharSequence label = mAuthenticatorHelper.getLabelForType(this, accountType); 118063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (label == null) { 118163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio continue; 118263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 118363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 118463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio Account[] accounts = AccountManager.get(this).getAccountsByType(accountType); 118563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio boolean skipToAccount = accounts.length == 1 118663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio && !mAuthenticatorHelper.hasAccountPreferences(accountType); 118763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio DashboardTile accountTile = new DashboardTile(); 118863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio accountTile.title = label; 118963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (accountTile.extras == null) { 119063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio accountTile.extras = new Bundle(); 119163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 119263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (skipToAccount) { 119363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio accountTile.fragment = AccountSyncSettings.class.getName(); 119463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio accountTile.fragmentArguments = new Bundle(); 119563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // Need this for the icon 119663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio accountTile.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType); 119763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio accountTile.extras.putParcelable(AccountSyncSettings.ACCOUNT_KEY, accounts[0]); 119863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio accountTile.fragmentArguments.putParcelable(AccountSyncSettings.ACCOUNT_KEY, 119963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio accounts[0]); 120063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } else { 120163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio accountTile.fragment = ManageAccountsSettings.class.getName(); 120263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio accountTile.fragmentArguments = new Bundle(); 120363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio accountTile.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType); 120463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio accountTile.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, 120563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio accountType); 120663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio accountTile.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_LABEL, 120763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio label.toString()); 120863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 120963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio dashboardTiles.add(accountTile); 121063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio mAuthenticatorHelper.preloadDrawableForType(this, accountType); 121163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 121263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 121363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio // Sort by label 121463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio Collections.sort(dashboardTiles, new Comparator<DashboardTile>() { 121563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio @Override 121663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio public int compare(DashboardTile t1, DashboardTile t2) { 121763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio return t1.title.toString().compareTo(t2.title.toString()); 121863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 121963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio }); 122063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio int index = 0; 122163bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio for (DashboardTile tile : dashboardTiles) { 122263bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio target.addTile(index, tile); 122363bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio index++; 122463bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 122563bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio if (!mListeningToAccountUpdates) { 122663bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio AccountManager.get(this).addOnAccountsUpdatedListener(this, null, true); 122763bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio mListeningToAccountUpdates = true; 122863bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 122963bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio } 123063bbb8e4fef5d0d0a5fa9c7656daa7ea160fd51bFabrice Di Meglio 1231263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio private void getMetaData() { 1232263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio try { 1233263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio ActivityInfo ai = getPackageManager().getActivityInfo(getComponentName(), 1234263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio PackageManager.GET_META_DATA); 1235263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio if (ai == null || ai.metaData == null) return; 1236263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mFragmentClass = ai.metaData.getString(META_DATA_KEY_FRAGMENT_CLASS); 1237263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } catch (NameNotFoundException nnfe) { 1238263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // No recovery 1239263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio Log.d(LOG_TAG, "Cannot get Metadata for: " + getComponentName().toString()); 1240263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1241263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1242263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1243263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // give subclasses access to the Next button 1244263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public boolean hasNextButton() { 1245263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return mNextButton != null; 1246263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1247263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1248263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public Button getNextButton() { 1249263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return mNextButton; 1250263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1251263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1252263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 1253263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public boolean shouldUpRecreateTask(Intent targetIntent) { 1254263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio return super.shouldUpRecreateTask(new Intent(this, SettingsActivity.class)); 1255263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1256263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1257263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio @Override 1258263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public void onAccountsUpdated(Account[] accounts) { 1259263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio // TODO: watch for package upgrades to invalidate cache; see 7206643 1260263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mAuthenticatorHelper.updateAuthDescriptions(this); 1261263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio mAuthenticatorHelper.onAccountsUpdated(this, accounts); 1262769630c8956fa844545d964166da90cc802fabacFabrice Di Meglio invalidateCategories(); 1263263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1264263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1265263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio public static void requestHomeNotice() { 1266263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio sShowNoHomeNotice = true; 1267263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1268263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1269d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 1270d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onQueryTextSubmit(String query) { 1271d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio switchToSearchResultsFragmentIfNeeded(); 1272d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchQuery = query; 1273d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return mSearchResultsFragment.onQueryTextSubmit(query); 1274d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1275263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1276d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 1277d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onQueryTextChange(String newText) { 1278d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchQuery = newText; 12797e4855e8f644bdecf68ec65b8c1b7c08624a4876Fabrice Di Meglio if (mSearchResultsFragment == null) { 1280a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio return false; 1281a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio } 1282a32707664f85b77602d1fe45458e92fce1448ce2Fabrice Di Meglio return mSearchResultsFragment.onQueryTextChange(newText); 1283d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1284263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1285d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 1286d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onClose() { 1287d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return false; 1288d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1289263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1290d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 1291d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onMenuItemActionExpand(MenuItem item) { 1292d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (item.getItemId() == mSearchMenuItem.getItemId()) { 1293bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio switchToSearchResultsFragmentIfNeeded(); 1294263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1295d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return true; 1296d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1297263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1298d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio @Override 1299d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public boolean onMenuItemActionCollapse(MenuItem item) { 1300d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio if (item.getItemId() == mSearchMenuItem.getItemId()) { 1301bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio if (mSearchMenuItemExpanded) { 1302d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio revertToInitialFragment(); 1303263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1304263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1305d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio return true; 1306d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1307263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1308d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private void switchToSearchResultsFragmentIfNeeded() { 1309bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio if (mSearchResultsFragment != null) { 1310bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio return; 1311263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1312bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio Fragment current = getFragmentManager().findFragmentById(R.id.prefs); 1313bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio if (current != null && current instanceof SearchResultsSummary) { 1314bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio mSearchResultsFragment = (SearchResultsSummary) current; 1315bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio } else { 1316bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio mSearchResultsFragment = (SearchResultsSummary) switchToFragment( 1317a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio SearchResultsSummary.class.getName(), null, false, true, 1318a9e77993d1f82a230ff381134d4a22eff4a907cdFabrice Di Meglio R.string.search_results_title, null, true); 1319bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio } 1320d297a5840230b769a3c7ad8b85232968a7077f64Fabrice Di Meglio mSearchResultsFragment.setSearchView(mSearchView); 1321bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio mSearchMenuItemExpanded = true; 1322d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1323263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1324d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio public void needToRevertToInitialFragment() { 1325d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mNeedToRevertToInitialFragment = true; 1326d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio } 1327263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio 1328d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio private void revertToInitialFragment() { 1329d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mNeedToRevertToInitialFragment = false; 1330d25314d3305ed1a07b53991a978cd71219ef2a10Fabrice Di Meglio mSearchResultsFragment = null; 1331bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio mSearchMenuItemExpanded = false; 1332bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio getFragmentManager().popBackStackImmediate(SettingsActivity.BACK_STACK_PREFS, 1333bb16fd836a5347413e592acbffa189156b28bc53Fabrice Di Meglio FragmentManager.POP_BACK_STACK_INCLUSIVE); 133423ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio if (mSearchMenuItem != null) { 133523ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio mSearchMenuItem.collapseActionView(); 133623ae00c1d87d64578cd62da1894ee25da531ca11Fabrice Di Meglio } 1337263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio } 1338263bcc8b732dbb47d3ce63904e0e05191fabbad6Fabrice Di Meglio} 1339