1a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne/* 2a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne * Copyright (C) 2011 The Android Open Source Project 3a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne * 4a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne * Licensed under the Apache License, Version 2.0 (the "License"); 5a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne * you may not use this file except in compliance with the License. 6a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne * You may obtain a copy of the License at 7a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne * 8a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne * http://www.apache.org/licenses/LICENSE-2.0 9a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne * 10a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne * Unless required by applicable law or agreed to in writing, software 11a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne * distributed under the License is distributed on an "AS IS" BASIS, 12a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne * See the License for the specific language governing permissions and 14a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne * limitations under the License. 15a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne */ 16a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 17a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunnepackage com.android.settings; 18a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 19a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 20a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunneimport android.content.ContentQueryMap; 21a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunneimport android.content.ContentResolver; 228442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasaniimport android.content.Context; 23a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunneimport android.content.Intent; 24a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunneimport android.database.Cursor; 25a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunneimport android.location.LocationManager; 26ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthallimport android.os.UserManager; 27a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunneimport android.preference.CheckBoxPreference; 28a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunneimport android.preference.Preference; 29a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunneimport android.preference.PreferenceScreen; 308442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasaniimport android.preference.SwitchPreference; 31a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunneimport android.provider.Settings; 328442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasaniimport android.util.AttributeSet; 338442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasaniimport android.view.View; 348442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasaniimport android.widget.TextView; 35a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 36a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunneimport java.util.Observable; 37a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunneimport java.util.Observer; 38a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 39a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne/** 40a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne * Gesture lock pattern settings. 41a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne */ 42a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunnepublic class LocationSettings extends SettingsPreferenceFragment 438442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani implements Preference.OnPreferenceChangeListener { 44a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 45a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne // Location Settings 468442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani private static final String KEY_LOCATION_TOGGLE = "location_toggle"; 47a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne private static final String KEY_LOCATION_NETWORK = "location_network"; 48a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne private static final String KEY_LOCATION_GPS = "location_gps"; 49a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne private static final String KEY_ASSISTED_GPS = "assisted_gps"; 50a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 51a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne private CheckBoxPreference mNetwork; 52a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne private CheckBoxPreference mGps; 53a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne private CheckBoxPreference mAssistedGps; 548442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani private SwitchPreference mLocationAccess; 55a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 56a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne // These provide support for receiving notification when Location Manager settings change. 57a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne // This is necessary because the Network Location Provider can change settings 58a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne // if the user does not confirm enabling the provider. 59a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne private ContentQueryMap mContentQueryMap; 60a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 61a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne private Observer mSettingsObserver; 62a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 63a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne @Override 64a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne public void onStart() { 65a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne super.onStart(); 66a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne // listen for Location Manager settings changes 67a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne Cursor settingsCursor = getContentResolver().query(Settings.Secure.CONTENT_URI, null, 68a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne "(" + Settings.System.NAME + "=?)", 69a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne new String[]{Settings.Secure.LOCATION_PROVIDERS_ALLOWED}, 70a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne null); 71a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne mContentQueryMap = new ContentQueryMap(settingsCursor, Settings.System.NAME, true, null); 72a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } 73a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 74a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne @Override 75a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne public void onStop() { 76a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne super.onStop(); 77a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne if (mSettingsObserver != null) { 78a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne mContentQueryMap.deleteObserver(mSettingsObserver); 79a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } 805416d07100d99e5206ca4de8578ede217ab2c23fPer Allard mContentQueryMap.close(); 81a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } 82a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 83a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne private PreferenceScreen createPreferenceHierarchy() { 84a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne PreferenceScreen root = getPreferenceScreen(); 85a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne if (root != null) { 86a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne root.removeAll(); 87a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } 88a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne addPreferencesFromResource(R.xml.location_settings); 89a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne root = getPreferenceScreen(); 90a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 918442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani mLocationAccess = (SwitchPreference) root.findPreference(KEY_LOCATION_TOGGLE); 92a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne mNetwork = (CheckBoxPreference) root.findPreference(KEY_LOCATION_NETWORK); 93a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne mGps = (CheckBoxPreference) root.findPreference(KEY_LOCATION_GPS); 94a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne mAssistedGps = (CheckBoxPreference) root.findPreference(KEY_ASSISTED_GPS); 95a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 96ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall // Only enable these controls if this user is allowed to change location 97ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall // sharing settings. 98ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE); 990c5a401a58b30041d5fe712d78fccbd47f5b744dMaggie Benthall boolean isToggleAllowed = !um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION); 100ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall if (mLocationAccess != null) mLocationAccess.setEnabled(isToggleAllowed); 101ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall if (mNetwork != null) mNetwork.setEnabled(isToggleAllowed); 102ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall if (mGps != null) mGps.setEnabled(isToggleAllowed); 103ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall if (mAssistedGps != null) mAssistedGps.setEnabled(isToggleAllowed); 104ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall 1058442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani mLocationAccess.setOnPreferenceChangeListener(this); 106a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne return root; 107a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } 108a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 109a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne @Override 110a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne public void onResume() { 111a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne super.onResume(); 112a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 113a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne // Make sure we reload the preference hierarchy since some of these settings 114a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne // depend on others... 115a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne createPreferenceHierarchy(); 116a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne updateLocationToggles(); 117a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 118a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne if (mSettingsObserver == null) { 119a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne mSettingsObserver = new Observer() { 1200c5a401a58b30041d5fe712d78fccbd47f5b744dMaggie Benthall @Override 121a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne public void update(Observable o, Object arg) { 122a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne updateLocationToggles(); 123a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } 124a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne }; 125a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } 126aa5cb065e324caa7307bc413bb30b1e46b6b028fVladimir Baryshnikov 127aa5cb065e324caa7307bc413bb30b1e46b6b028fVladimir Baryshnikov mContentQueryMap.addObserver(mSettingsObserver); 128a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } 129a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 130a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne @Override 131a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { 1328442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani final ContentResolver cr = getContentResolver(); 133ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE); 134a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne if (preference == mNetwork) { 1350c5a401a58b30041d5fe712d78fccbd47f5b744dMaggie Benthall if (!um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) { 136ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall Settings.Secure.setLocationProviderEnabled(cr, 137ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall LocationManager.NETWORK_PROVIDER, mNetwork.isChecked()); 138ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall } 139a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } else if (preference == mGps) { 140a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne boolean enabled = mGps.isChecked(); 1410c5a401a58b30041d5fe712d78fccbd47f5b744dMaggie Benthall if (!um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) { 142ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall Settings.Secure.setLocationProviderEnabled(cr, 143ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall LocationManager.GPS_PROVIDER, enabled); 144ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall if (mAssistedGps != null) { 145ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall mAssistedGps.setEnabled(enabled); 146ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall } 147a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } 148a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } else if (preference == mAssistedGps) { 1495a64c739bfbf644dabd11d5330f577e94d478326Christopher Tate Settings.Global.putInt(cr, Settings.Global.ASSISTED_GPS_ENABLED, 150a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne mAssistedGps.isChecked() ? 1 : 0); 151a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } else { 152a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne // If we didn't handle it, let preferences handle it. 153a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne return super.onPreferenceTreeClick(preferenceScreen, preference); 154a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } 155a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 156a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne return true; 157a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } 158a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 159a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne /* 160a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne * Creates toggles for each available location provider 161a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne */ 162a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne private void updateLocationToggles() { 163a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne ContentResolver res = getContentResolver(); 164a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne boolean gpsEnabled = Settings.Secure.isLocationProviderEnabled( 165a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne res, LocationManager.GPS_PROVIDER); 1668442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani boolean networkEnabled = Settings.Secure.isLocationProviderEnabled( 1678442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani res, LocationManager.NETWORK_PROVIDER); 168a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne mGps.setChecked(gpsEnabled); 1698442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani mNetwork.setChecked(networkEnabled); 1708442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani mLocationAccess.setChecked(gpsEnabled || networkEnabled); 171a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne if (mAssistedGps != null) { 1725a64c739bfbf644dabd11d5330f577e94d478326Christopher Tate mAssistedGps.setChecked(Settings.Global.getInt(res, 1735a64c739bfbf644dabd11d5330f577e94d478326Christopher Tate Settings.Global.ASSISTED_GPS_ENABLED, 2) == 1); 174a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne mAssistedGps.setEnabled(gpsEnabled); 175a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } 176a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } 177a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 178a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne /** 179a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne * see confirmPatternThenDisableAndClear 180a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne */ 181a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne @Override 182a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne public void onActivityResult(int requestCode, int resultCode, Intent data) { 183a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne super.onActivityResult(requestCode, resultCode, data); 184a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne createPreferenceHierarchy(); 185a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } 186a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne 1878442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani /** Enable or disable all providers when the master toggle is changed. */ 1888442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani private void onToggleLocationAccess(boolean checked) { 189ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE); 1900c5a401a58b30041d5fe712d78fccbd47f5b744dMaggie Benthall if (um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) { 191ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall return; 192ea6260d887a7065d65d94be58c05903b3d1fc359Maggie Benthall } 1938442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani final ContentResolver cr = getContentResolver(); 1948442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani Settings.Secure.setLocationProviderEnabled(cr, 1958442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani LocationManager.GPS_PROVIDER, checked); 1968442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani Settings.Secure.setLocationProviderEnabled(cr, 1978442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani LocationManager.NETWORK_PROVIDER, checked); 1988442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani updateLocationToggles(); 1998442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani } 2008442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani 2018442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani @Override 2028442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani public boolean onPreferenceChange(Preference pref, Object newValue) { 2038442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani if (pref.getKey().equals(KEY_LOCATION_TOGGLE)) { 2048442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani onToggleLocationAccess((Boolean) newValue); 205a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } 206a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne return true; 207a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne } 2088442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani 20938223dc4585bb8f11125c90082789db78881e97dAmith Yamasani @Override 21038223dc4585bb8f11125c90082789db78881e97dAmith Yamasani public int getHelpResource() { 21138223dc4585bb8f11125c90082789db78881e97dAmith Yamasani return R.string.help_url_location_access; 21238223dc4585bb8f11125c90082789db78881e97dAmith Yamasani } 2138442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani} 2148442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani 2158442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasaniclass WrappingSwitchPreference extends SwitchPreference { 2168442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani 2178442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani public WrappingSwitchPreference(Context context, AttributeSet attrs, int defStyle) { 2188442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani super(context, attrs, defStyle); 2198442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani } 2208442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani 2218442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani public WrappingSwitchPreference(Context context, AttributeSet attrs) { 2228442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani super(context, attrs); 2238442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani } 2248442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani 2258442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani @Override 2268442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani protected void onBindView(View view) { 2278442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani super.onBindView(view); 2288442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani 2298442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani TextView title = (TextView) view.findViewById(android.R.id.title); 2308442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani if (title != null) { 2318442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani title.setSingleLine(false); 2328442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani title.setMaxLines(3); 2338442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani } 2348442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani } 2358442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani} 2368442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani 2378442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasaniclass WrappingCheckBoxPreference extends CheckBoxPreference { 2388442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani 2398442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani public WrappingCheckBoxPreference(Context context, AttributeSet attrs, int defStyle) { 2408442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani super(context, attrs, defStyle); 2418442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani } 2428442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani 2438442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani public WrappingCheckBoxPreference(Context context, AttributeSet attrs) { 2448442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani super(context, attrs); 2458442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani } 2468442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani 2478442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani @Override 2488442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani protected void onBindView(View view) { 2498442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani super.onBindView(view); 2508442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani 2518442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani TextView title = (TextView) view.findViewById(android.R.id.title); 2528442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani if (title != null) { 2538442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani title.setSingleLine(false); 2548442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani title.setMaxLines(3); 2558442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani } 2568442db24a1f75e67ea658e7fd29708ef3fa4af1bAmith Yamasani } 257a6a8a1479b970d8a84395453703348fe42d17438Gilles Debunne} 258