diff options
author | PauloftheWest <paulofthewest@google.com> | 2014-08-24 11:59:35 -0700 |
---|---|---|
committer | PauloftheWest <paulofthewest@google.com> | 2014-08-25 08:45:05 -0700 |
commit | 656c88cb7142595ae96e17b5ecef4fb5f511779f (patch) | |
tree | fcbf77b53df2e9e88f06b25abd1568c3b7c6de74 | |
parent | 8fe710682ad3f5a5ac0ed1393f3d934bea122bc5 (diff) | |
download | packages_apps_Settings-656c88cb7142595ae96e17b5ecef4fb5f511779f.zip packages_apps_Settings-656c88cb7142595ae96e17b5ecef4fb5f511779f.tar.gz packages_apps_Settings-656c88cb7142595ae96e17b5ecef4fb5f511779f.tar.bz2 |
Updated Tethering and portable hotspot to use switches.
Bug: 17020102
Change-Id: I5da1745d4ea9545f8960c015ca6858fb0a34de0d
-rw-r--r-- | res/xml/tether_prefs.xml | 6 | ||||
-rw-r--r-- | src/com/android/settings/TetherSettings.java | 16 | ||||
-rw-r--r-- | src/com/android/settings/wifi/WifiApEnabler.java | 56 |
3 files changed, 39 insertions, 39 deletions
diff --git a/res/xml/tether_prefs.xml b/res/xml/tether_prefs.xml index 81f6f3a..7a70306 100644 --- a/res/xml/tether_prefs.xml +++ b/res/xml/tether_prefs.xml @@ -16,12 +16,12 @@ <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> - <CheckBoxPreference + <SwitchPreference android:key="usb_tether_settings" android:title="@string/usb_tethering_button_text" android:persistent="false" /> - <CheckBoxPreference + <SwitchPreference android:key="enable_wifi_ap" android:title="@string/wifi_tether_checkbox_text" android:persistent="false" /> @@ -31,7 +31,7 @@ android:title="@string/wifi_tether_configure_ap_text" android:persistent="false" /> - <CheckBoxPreference + <SwitchPreference android:key="enable_bluetooth_tethering" android:title="@string/bluetooth_tether_checkbox_text" android:persistent="false" /> diff --git a/src/com/android/settings/TetherSettings.java b/src/com/android/settings/TetherSettings.java index d960ce6..8069d52 100644 --- a/src/com/android/settings/TetherSettings.java +++ b/src/com/android/settings/TetherSettings.java @@ -40,9 +40,9 @@ import android.os.Environment; import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; -import android.preference.CheckBoxPreference; import android.preference.Preference; import android.preference.PreferenceScreen; +import android.preference.SwitchPreference; import android.text.TextUtils; import android.view.ViewGroup; import android.view.ViewParent; @@ -68,12 +68,12 @@ public class TetherSettings extends SettingsPreferenceFragment private static final int DIALOG_AP_SETTINGS = 1; private WebView mView; - private CheckBoxPreference mUsbTether; + private SwitchPreference mUsbTether; private WifiApEnabler mWifiApEnabler; - private CheckBoxPreference mEnableWifiAp; + private SwitchPreference mEnableWifiAp; - private CheckBoxPreference mBluetoothTether; + private SwitchPreference mBluetoothTether; private BroadcastReceiver mTetherChangeReceiver; @@ -135,10 +135,10 @@ public class TetherSettings extends SettingsPreferenceFragment } mEnableWifiAp = - (CheckBoxPreference) findPreference(ENABLE_WIFI_AP); + (SwitchPreference) findPreference(ENABLE_WIFI_AP); Preference wifiApSettings = findPreference(WIFI_AP_SSID_AND_SECURITY); - mUsbTether = (CheckBoxPreference) findPreference(USB_TETHER_SETTINGS); - mBluetoothTether = (CheckBoxPreference) findPreference(ENABLE_BLUETOOTH_TETHERING); + mUsbTether = (SwitchPreference) findPreference(USB_TETHER_SETTINGS); + mBluetoothTether = (SwitchPreference) findPreference(ENABLE_BLUETOOTH_TETHERING); ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); @@ -484,7 +484,7 @@ public class TetherSettings extends SettingsPreferenceFragment if (resultCode == Activity.RESULT_OK) { startTethering(); } else { - //BT and USB need checkbox turned off on failure + //BT and USB need switch turned off on failure //Wifi tethering is never turned on until afterwards switch (mTetherChoice) { case BLUETOOTH_TETHERING: diff --git a/src/com/android/settings/wifi/WifiApEnabler.java b/src/com/android/settings/wifi/WifiApEnabler.java index 9a3b49d..fc34f3b 100644 --- a/src/com/android/settings/wifi/WifiApEnabler.java +++ b/src/com/android/settings/wifi/WifiApEnabler.java @@ -33,7 +33,7 @@ import android.net.wifi.SupplicantState; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; -import android.preference.CheckBoxPreference; +import android.preference.SwitchPreference; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; @@ -41,7 +41,7 @@ import android.widget.Toast; public class WifiApEnabler { private final Context mContext; - private final CheckBoxPreference mCheckBox; + private final SwitchPreference mSwitch; private final CharSequence mOriginalSummary; private WifiManager mWifiManager; @@ -66,17 +66,17 @@ public class WifiApEnabler { ConnectivityManager.EXTRA_ERRORED_TETHER); updateTetherState(available.toArray(), active.toArray(), errored.toArray()); } else if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(action)) { - enableWifiCheckBox(); + enableWifiSwitch(); } } }; - public WifiApEnabler(Context context, CheckBoxPreference checkBox) { + public WifiApEnabler(Context context, SwitchPreference switchPreference) { mContext = context; - mCheckBox = checkBox; - mOriginalSummary = checkBox.getSummary(); - checkBox.setPersistent(false); + mSwitch = switchPreference; + mOriginalSummary = switchPreference.getSummary(); + switchPreference.setPersistent(false); mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); mCm = (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE); @@ -90,21 +90,21 @@ public class WifiApEnabler { public void resume() { mContext.registerReceiver(mReceiver, mIntentFilter); - enableWifiCheckBox(); + enableWifiSwitch(); } public void pause() { mContext.unregisterReceiver(mReceiver); } - private void enableWifiCheckBox() { + private void enableWifiSwitch() { boolean isAirplaneMode = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) != 0; if(!isAirplaneMode) { - mCheckBox.setEnabled(true); + mSwitch.setEnabled(true); } else { - mCheckBox.setSummary(mOriginalSummary); - mCheckBox.setEnabled(false); + mSwitch.setSummary(mOriginalSummary); + mSwitch.setEnabled(false); } } @@ -122,9 +122,9 @@ public class WifiApEnabler { if (mWifiManager.setWifiApEnabled(null, enable)) { /* Disable here, enabled on receiving success broadcast */ - mCheckBox.setEnabled(false); + mSwitch.setEnabled(false); } else { - mCheckBox.setSummary(R.string.wifi_error); + mSwitch.setSummary(R.string.wifi_error); } /** @@ -147,7 +147,7 @@ public class WifiApEnabler { public void updateConfigSummary(WifiConfiguration wifiConfig) { String s = mContext.getString( com.android.internal.R.string.wifi_tether_configure_ssid_default); - mCheckBox.setSummary(String.format( + mSwitch.setSummary(String.format( mContext.getString(R.string.wifi_tether_enabled_subtext), (wifiConfig == null) ? s : wifiConfig.SSID)); } @@ -173,38 +173,38 @@ public class WifiApEnabler { WifiConfiguration wifiConfig = mWifiManager.getWifiApConfiguration(); updateConfigSummary(wifiConfig); } else if (wifiErrored) { - mCheckBox.setSummary(R.string.wifi_error); + mSwitch.setSummary(R.string.wifi_error); } } private void handleWifiApStateChanged(int state) { switch (state) { case WifiManager.WIFI_AP_STATE_ENABLING: - mCheckBox.setSummary(R.string.wifi_tether_starting); - mCheckBox.setEnabled(false); + mSwitch.setSummary(R.string.wifi_tether_starting); + mSwitch.setEnabled(false); break; case WifiManager.WIFI_AP_STATE_ENABLED: /** * Summary on enable is handled by tether * broadcast notice */ - mCheckBox.setChecked(true); + mSwitch.setChecked(true); /* Doesnt need the airplane check */ - mCheckBox.setEnabled(true); + mSwitch.setEnabled(true); break; case WifiManager.WIFI_AP_STATE_DISABLING: - mCheckBox.setSummary(R.string.wifi_tether_stopping); - mCheckBox.setEnabled(false); + mSwitch.setSummary(R.string.wifi_tether_stopping); + mSwitch.setEnabled(false); break; case WifiManager.WIFI_AP_STATE_DISABLED: - mCheckBox.setChecked(false); - mCheckBox.setSummary(mOriginalSummary); - enableWifiCheckBox(); + mSwitch.setChecked(false); + mSwitch.setSummary(mOriginalSummary); + enableWifiSwitch(); break; default: - mCheckBox.setChecked(false); - mCheckBox.setSummary(R.string.wifi_error); - enableWifiCheckBox(); + mSwitch.setChecked(false); + mSwitch.setSummary(R.string.wifi_error); + enableWifiSwitch(); } } } |