summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/DevelopmentSettings.java24
-rw-r--r--src/com/android/settings/DreamSettings.java17
-rw-r--r--src/com/android/settings/accessibility/CaptionPropertiesFragment.java15
-rw-r--r--src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java10
-rw-r--r--src/com/android/settings/bluetooth/BluetoothEnabler.java14
-rwxr-xr-xsrc/com/android/settings/bluetooth/BluetoothSettings.java8
-rw-r--r--src/com/android/settings/location/LocationSettings.java14
-rw-r--r--src/com/android/settings/nfc/AndroidBeam.java26
-rw-r--r--src/com/android/settings/notification/ZenModeSettings.java15
-rw-r--r--src/com/android/settings/print/PrintServiceSettingsFragment.java8
-rw-r--r--src/com/android/settings/widget/SwitchBar.java104
-rw-r--r--src/com/android/settings/wifi/WifiEnabler.java14
-rw-r--r--src/com/android/settings/wifi/WifiSettings.java10
13 files changed, 195 insertions, 84 deletions
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index ce44907e5..5e5113bec 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -167,7 +167,6 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
private WifiManager mWifiManager;
private SwitchBar mSwitchBar;
- private Switch mEnabledSwitch;
private boolean mLastEnabledState;
private boolean mHaveDebugSettings;
private boolean mDontPokeProperties;
@@ -386,11 +385,12 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
final SettingsActivity activity = (SettingsActivity) getActivity();
mSwitchBar = activity.getSwitchBar();
- mEnabledSwitch = mSwitchBar.getSwitch();
- if (mUnavailable) {
- mEnabledSwitch.setEnabled(false);
+ if (mUnavailable) {
+ mSwitchBar.setEnabled(false);
return;
}
+
+ mSwitchBar.addOnSwitchChangeListener(this);
}
private boolean removePreferenceForProduction(Preference preference) {
@@ -441,7 +441,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
final ContentResolver cr = getActivity().getContentResolver();
mLastEnabledState = Settings.Global.getInt(cr,
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
- mEnabledSwitch.setChecked(mLastEnabledState);
+ mSwitchBar.setChecked(mLastEnabledState);
setPrefsEnabledState(mLastEnabledState);
if (mHaveDebugSettings && !mLastEnabledState) {
@@ -452,17 +452,15 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
Settings.Global.putInt(getActivity().getContentResolver(),
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
mLastEnabledState = true;
- mEnabledSwitch.setChecked(mLastEnabledState);
+ mSwitchBar.setChecked(mLastEnabledState);
setPrefsEnabledState(mLastEnabledState);
}
-
- mSwitchBar.addOnSwitchChangeListener(this);
mSwitchBar.show();
}
@Override
- public void onPause() {
- super.onPause();
+ public void onDestroyView() {
+ super.onDestroyView();
mSwitchBar.removeOnSwitchChangeListener(this);
mSwitchBar.hide();
@@ -1210,7 +1208,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
@Override
public void onSwitchChanged(Switch switchView, boolean isChecked) {
- if (switchView != mEnabledSwitch) {
+ if (switchView != mSwitchBar.getSwitch()) {
return;
}
if (isChecked != mLastEnabledState) {
@@ -1463,7 +1461,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
setPrefsEnabledState(mLastEnabledState);
} else {
// Reset the toggle
- mEnabledSwitch.setChecked(false);
+ mSwitchBar.setChecked(false);
}
}
}
@@ -1477,7 +1475,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
mAdbDialog = null;
} else if (dialog == mEnableDialog) {
if (!mDialogClicked) {
- mEnabledSwitch.setChecked(false);
+ mSwitchBar.setChecked(false);
}
mEnableDialog = null;
}
diff --git a/src/com/android/settings/DreamSettings.java b/src/com/android/settings/DreamSettings.java
index 1175639de..38cba7a22 100644
--- a/src/com/android/settings/DreamSettings.java
+++ b/src/com/android/settings/DreamSettings.java
@@ -61,7 +61,6 @@ public class DreamSettings extends SettingsPreferenceFragment implements
private DreamBackend mBackend;
private DreamInfoAdapter mAdapter;
private SwitchBar mSwitchBar;
- private Switch mSwitch;
private MenuItem[] mMenuItemsWhenEnabled;
private boolean mRefreshing;
@@ -105,6 +104,9 @@ public class DreamSettings extends SettingsPreferenceFragment implements
public void onDestroyView() {
logd("onDestroyView()");
super.onDestroyView();
+
+ mSwitchBar.removeOnSwitchChangeListener(this);
+ mSwitchBar.hide();
}
@Override
@@ -124,7 +126,8 @@ public class DreamSettings extends SettingsPreferenceFragment implements
final SettingsActivity sa = (SettingsActivity) getActivity();
mSwitchBar = sa.getSwitchBar();
- mSwitch = mSwitchBar.getSwitch();
+ mSwitchBar.addOnSwitchChangeListener(this);
+ mSwitchBar.show();
}
@Override
@@ -212,9 +215,6 @@ public class DreamSettings extends SettingsPreferenceFragment implements
super.onPause();
mContext.unregisterReceiver(mPackageReceiver);
-
- mSwitchBar.removeOnSwitchChangeListener(this);
- mSwitchBar.hide();
}
@Override
@@ -231,9 +231,6 @@ public class DreamSettings extends SettingsPreferenceFragment implements
filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
filter.addDataScheme(PACKAGE_SCHEME);
mContext.registerReceiver(mPackageReceiver , filter);
-
- mSwitchBar.addOnSwitchChangeListener(this);
- mSwitchBar.show();
}
public static int getSummaryResource(Context context) {
@@ -263,8 +260,8 @@ public class DreamSettings extends SettingsPreferenceFragment implements
logd("refreshFromBackend()");
mRefreshing = true;
boolean dreamsEnabled = mBackend.isEnabled();
- if (mSwitch.isChecked() != dreamsEnabled)
- mSwitch.setChecked(dreamsEnabled);
+ if (mSwitchBar.isChecked() != dreamsEnabled)
+ mSwitchBar.setChecked(dreamsEnabled);
mAdapter.clear();
if (dreamsEnabled) {
diff --git a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
index 41c80aed6..53d614d38 100644
--- a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
+++ b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
@@ -142,27 +142,30 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
refreshPreviewText();
}
});
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ final boolean enabled = mCaptioningManager.isEnabled();
SettingsActivity activity = (SettingsActivity) getActivity();
mSwitchBar = activity.getSwitchBar();
+ mSwitchBar.setTextViewLabel(enabled);
mToggleSwitch = mSwitchBar.getSwitch();
mToggleSwitch.setCheckedInternal(enabled);
getPreferenceScreen().setEnabled(enabled);
refreshPreviewText();
- }
- @Override
- public void onResume() {
- super.onResume();
installSwitchBarToggleSwitch();
}
@Override
- public void onPause() {
+ public void onDestroyView() {
+ super.onDestroyView();
removeSwitchBarToggleSwitch();
- super.onPause();
}
private void refreshPreviewText() {
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index 331c0e340..bc2175945 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -95,17 +95,17 @@ public abstract class ToggleFeaturePreferenceFragment
}
@Override
- public void onResume() {
- super.onResume();
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
installActionBarToggleSwitch();
}
@Override
- public void onPause() {
- removeActionBarToggleSwitch();
+ public void onDestroyView() {
+ super.onDestroyView();
- super.onPause();
+ removeActionBarToggleSwitch();
}
protected abstract void onPreferenceToggled(String preferenceKey, boolean enabled);
diff --git a/src/com/android/settings/bluetooth/BluetoothEnabler.java b/src/com/android/settings/bluetooth/BluetoothEnabler.java
index be03b6380..45f3d0672 100644
--- a/src/com/android/settings/bluetooth/BluetoothEnabler.java
+++ b/src/com/android/settings/bluetooth/BluetoothEnabler.java
@@ -89,6 +89,16 @@ public final class BluetoothEnabler implements SwitchBar.OnSwitchChangeListener
mIntentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
}
+ public void setupSwitchBar() {
+ mSwitchBar.addOnSwitchChangeListener(this);
+ mSwitchBar.show();
+ }
+
+ public void teardownSwitchBar() {
+ mSwitchBar.removeOnSwitchChangeListener(this);
+ mSwitchBar.hide();
+ }
+
public void resume(Context context) {
if (mLocalAdapter == null) {
mSwitch.setEnabled(false);
@@ -103,8 +113,6 @@ public final class BluetoothEnabler implements SwitchBar.OnSwitchChangeListener
handleStateChanged(mLocalAdapter.getBluetoothState());
mContext.registerReceiver(mReceiver, mIntentFilter);
- mSwitchBar.addOnSwitchChangeListener(this);
- mSwitchBar.show();
mValidListener = true;
}
@@ -114,8 +122,6 @@ public final class BluetoothEnabler implements SwitchBar.OnSwitchChangeListener
}
mContext.unregisterReceiver(mReceiver);
- mSwitchBar.removeOnSwitchChangeListener(this);
- mSwitchBar.hide();
mValidListener = false;
}
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index dd4edffce..eb318cd73 100755
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -119,6 +119,14 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
mSwitchBar = activity.getSwitchBar();
mBluetoothEnabler = new BluetoothEnabler(activity, mSwitchBar);
+ mBluetoothEnabler.setupSwitchBar();
+ }
+
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+
+ mBluetoothEnabler.teardownSwitchBar();
}
@Override
diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java
index 8794a8dca..b10d4b61e 100644
--- a/src/com/android/settings/location/LocationSettings.java
+++ b/src/com/android/settings/location/LocationSettings.java
@@ -73,6 +73,16 @@ public class LocationSettings extends LocationSettingsBase
mSwitchBar = activity.getSwitchBar();
mSwitch = mSwitchBar.getSwitch();
+ mSwitchBar.addOnSwitchChangeListener(this);
+ mSwitchBar.show();
+ }
+
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+
+ mSwitchBar.removeOnSwitchChangeListener(this);
+ mSwitchBar.hide();
}
@Override
@@ -84,8 +94,6 @@ public class LocationSettings extends LocationSettingsBase
public void onResume() {
super.onResume();
createPreferenceHierarchy();
- mSwitchBar.addOnSwitchChangeListener(this);
- mSwitchBar.show();
mValidListener = true;
}
@@ -97,8 +105,6 @@ public class LocationSettings extends LocationSettingsBase
// Ignore exceptions caused by race condition
}
super.onPause();
- mSwitchBar.removeOnSwitchChangeListener(this);
- mSwitchBar.hide();
mValidListener = false;
}
diff --git a/src/com/android/settings/nfc/AndroidBeam.java b/src/com/android/settings/nfc/AndroidBeam.java
index eb3ff9bbc..add0fa7df 100644
--- a/src/com/android/settings/nfc/AndroidBeam.java
+++ b/src/com/android/settings/nfc/AndroidBeam.java
@@ -33,7 +33,6 @@ public class AndroidBeam extends Fragment
private View mView;
private NfcAdapter mNfcAdapter;
private SwitchBar mSwitchBar;
- private Switch mSwitch;
private CharSequence mOldActivityTitle;
@Override
@@ -63,46 +62,33 @@ public class AndroidBeam extends Fragment
SettingsActivity activity = (SettingsActivity) getActivity();
mSwitchBar = activity.getSwitchBar();
- mSwitch = mSwitchBar.getSwitch();
- mSwitch.setChecked(mNfcAdapter.isNdefPushEnabled());
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
+ mSwitchBar.setChecked(mNfcAdapter.isNdefPushEnabled());
mSwitchBar.addOnSwitchChangeListener(this);
mSwitchBar.show();
}
@Override
- public void onPause() {
- super.onPause();
-
- mSwitchBar.removeOnSwitchChangeListener(this);
- mSwitchBar.hide();
- }
-
- @Override
public void onDestroyView() {
super.onDestroyView();
if (mOldActivityTitle != null) {
getActivity().getActionBar().setTitle(mOldActivityTitle);
}
+ mSwitchBar.removeOnSwitchChangeListener(this);
+ mSwitchBar.hide();
}
@Override
public void onSwitchChanged(Switch switchView, boolean desiredState) {
boolean success = false;
- mSwitch.setEnabled(false);
+ mSwitchBar.setEnabled(false);
if (desiredState) {
success = mNfcAdapter.enableNdefPush();
} else {
success = mNfcAdapter.disableNdefPush();
}
if (success) {
- mSwitch.setChecked(desiredState);
+ mSwitchBar.setChecked(desiredState);
}
- mSwitch.setEnabled(true);
+ mSwitchBar.setEnabled(true);
}
}
diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index e9323d87d..40e2c55bf 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -107,7 +107,6 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
private final SettingsObserver mSettingsObserver = new SettingsObserver();
private SwitchBar mSwitchBar;
- private Switch mSwitch;
private Context mContext;
private PackageManager mPM;
private ZenModeConfig mConfig;
@@ -159,7 +158,8 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
if (DEBUG) Log.d(TAG, "Loaded mConfig=" + mConfig);
mSwitchBar = ((SettingsActivity) mContext).getSwitchBar();
- mSwitch = mSwitchBar.getSwitch();
+ mSwitchBar.addOnSwitchChangeListener(this);
+ mSwitchBar.show();
final PreferenceCategory general = (PreferenceCategory) root.findPreference(KEY_GENERAL);
@@ -400,14 +400,17 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
updateControls();
updateZenMode();
mSettingsObserver.register();
- mSwitchBar.addOnSwitchChangeListener(this);
- mSwitchBar.show();
}
@Override
public void onPause() {
super.onPause();
mSettingsObserver.unregister();
+ }
+
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
mSwitchBar.removeOnSwitchChangeListener(this);
mSwitchBar.hide();
}
@@ -415,8 +418,8 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
private void updateZenMode() {
final boolean zenMode = Global.getInt(getContentResolver(),
Global.ZEN_MODE, Global.ZEN_MODE_OFF) != Global.ZEN_MODE_OFF;
- if (mSwitch.isChecked() != zenMode) {
- mSwitch.setChecked(zenMode);
+ if (mSwitchBar.isChecked() != zenMode) {
+ mSwitchBar.setChecked(zenMode);
mIgnoreNext = true;
}
}
diff --git a/src/com/android/settings/print/PrintServiceSettingsFragment.java b/src/com/android/settings/print/PrintServiceSettingsFragment.java
index 872f7b8c8..c68f131c2 100644
--- a/src/com/android/settings/print/PrintServiceSettingsFragment.java
+++ b/src/com/android/settings/print/PrintServiceSettingsFragment.java
@@ -143,16 +143,12 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
mSettingsContentObserver.register(getContentResolver());
updateEmptyView();
updateUiForServiceState();
- mSwitchBar.addOnSwitchChangeListener(this);
- mSwitchBar.show();
}
@Override
public void onPause() {
mSettingsContentObserver.unregister(getContentResolver());
super.onPause();
- mSwitchBar.removeOnSwitchChangeListener(this);
- mSwitchBar.hide();
}
@Override
@@ -168,6 +164,8 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
getActivity().getActionBar().setTitle(mOldActivityTitle);
}
super.onDestroyView();
+ mSwitchBar.removeOnSwitchChangeListener(this);
+ mSwitchBar.hide();
}
private void onPreferenceToggled(String preferenceKey, boolean enabled) {
@@ -292,6 +290,8 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
final SettingsActivity activity = (SettingsActivity) getActivity();
mSwitchBar = activity.getSwitchBar();
+ mSwitchBar.addOnSwitchChangeListener(this);
+ mSwitchBar.show();
mToggleSwitch = mSwitchBar.getSwitch();
mToggleSwitch.setOnBeforeCheckedChangeListener(new ToggleSwitch.OnBeforeCheckedChangeListener() {
diff --git a/src/com/android/settings/widget/SwitchBar.java b/src/com/android/settings/widget/SwitchBar.java
index bc06d8755..b503cf62f 100644
--- a/src/com/android/settings/widget/SwitchBar.java
+++ b/src/com/android/settings/widget/SwitchBar.java
@@ -17,10 +17,11 @@
package com.android.settings.widget;
import android.content.Context;
+import android.os.Parcel;
+import android.os.Parcelable;
import android.transition.TransitionManager;
import android.util.AttributeSet;
import android.view.LayoutInflater;
-import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
@@ -72,12 +73,11 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
mTextView.setText(R.string.switch_off_text);
mSwitch = (ToggleSwitch) findViewById(R.id.switch_widget);
- mSwitch.setOnCheckedChangeListener(this);
addOnSwitchChangeListener(new OnSwitchChangeListener() {
@Override
public void onSwitchChanged(Switch switchView, boolean isChecked) {
- mTextView.setText(isChecked ? R.string.switch_on_text : R.string.switch_off_text);
+ setTextViewLabel(isChecked);
}
});
@@ -90,18 +90,41 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
setVisibility(View.GONE);
}
- public ToggleSwitch getSwitch() {
+ public void setTextViewLabel(boolean isChecked) {
+ mTextView.setText(isChecked ? R.string.switch_on_text : R.string.switch_off_text);
+ }
+
+ public void setChecked(boolean checked) {
+ setTextViewLabel(checked);
+ mSwitch.setChecked(checked);
+ }
+
+ public boolean isChecked() {
+ return mSwitch.isChecked();
+ }
+
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ mTextView.setEnabled(enabled);
+ mSwitch.setEnabled(false);
+ }
+
+ public final ToggleSwitch getSwitch() {
return mSwitch;
}
public void show() {
- TransitionManager.beginDelayedTransition((ViewGroup) getParent());
- setVisibility(View.VISIBLE);
+ if (!isShowing()) {
+ setVisibility(View.VISIBLE);
+ mSwitch.setOnCheckedChangeListener(this);
+ }
}
public void hide() {
- TransitionManager.beginDelayedTransition((ViewGroup) getParent());
- setVisibility(View.GONE);
+ if (isShowing()) {
+ setVisibility(View.GONE);
+ mSwitch.setOnCheckedChangeListener(null);
+ }
}
public boolean isShowing() {
@@ -139,4 +162,69 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
}
mSwitchChangeListeners.remove(listener);
}
+
+ static class SavedState extends BaseSavedState {
+ boolean checked;
+ boolean visible;
+
+ SavedState(Parcelable superState) {
+ super(superState);
+ }
+
+ /**
+ * Constructor called from {@link #CREATOR}
+ */
+ private SavedState(Parcel in) {
+ super(in);
+ checked = (Boolean)in.readValue(null);
+ visible = (Boolean)in.readValue(null);
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ super.writeToParcel(out, flags);
+ out.writeValue(checked);
+ out.writeValue(visible);
+ }
+
+ @Override
+ public String toString() {
+ return "SwitchBar.SavedState{"
+ + Integer.toHexString(System.identityHashCode(this))
+ + " checked=" + checked
+ + " visible=" + visible + "}";
+ }
+
+ public static final Parcelable.Creator<SavedState> CREATOR
+ = new Parcelable.Creator<SavedState>() {
+ public SavedState createFromParcel(Parcel in) {
+ return new SavedState(in);
+ }
+
+ public SavedState[] newArray(int size) {
+ return new SavedState[size];
+ }
+ };
+ }
+
+ @Override
+ public Parcelable onSaveInstanceState() {
+ Parcelable superState = super.onSaveInstanceState();
+
+ SavedState ss = new SavedState(superState);
+ ss.checked = mSwitch.isChecked();
+ ss.visible = isShowing();
+ return ss;
+ }
+
+ @Override
+ public void onRestoreInstanceState(Parcelable state) {
+ SavedState ss = (SavedState) state;
+
+ super.onRestoreInstanceState(ss.getSuperState());
+ mSwitch.setChecked(ss.checked);
+ setTextViewLabel(ss.checked);
+ setVisibility(ss.visible ? View.VISIBLE : View.GONE);
+ requestLayout();
+ }
}
diff --git a/src/com/android/settings/wifi/WifiEnabler.java b/src/com/android/settings/wifi/WifiEnabler.java
index 9f0b6fa53..a48598eda 100644
--- a/src/com/android/settings/wifi/WifiEnabler.java
+++ b/src/com/android/settings/wifi/WifiEnabler.java
@@ -96,18 +96,24 @@ public class WifiEnabler implements SwitchBar.OnSwitchChangeListener {
mIntentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
}
+ public void setupSwitchBar() {
+ mSwitchBar.addOnSwitchChangeListener(this);
+ mSwitchBar.show();
+ }
+
+ public void teardownSwitchBar() {
+ mSwitchBar.removeOnSwitchChangeListener(this);
+ mSwitchBar.hide();
+ }
+
public void resume(Context context) {
mContext = context;
// Wi-Fi state is sticky, so just let the receiver update UI
mContext.registerReceiver(mReceiver, mIntentFilter);
- mSwitchBar.addOnSwitchChangeListener(this);
- mSwitchBar.show();
}
public void pause() {
mContext.unregisterReceiver(mReceiver);
- mSwitchBar.removeOnSwitchChangeListener(this);
- mSwitchBar.hide();
}
private void handleWifiStateChanged(int state) {
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 604275ad4..b374fb778 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -405,6 +405,15 @@ public class WifiSettings extends RestrictedSettingsFragment
}
@Override
+ public void onDestroyView() {
+ super.onDestroyView();
+
+ if (mWifiEnabler != null) {
+ mWifiEnabler.teardownSwitchBar();
+ }
+ }
+
+ @Override
public void onStart() {
super.onStart();
@@ -414,6 +423,7 @@ public class WifiSettings extends RestrictedSettingsFragment
mSwitchBar = activity.getSwitchBar();
mWifiEnabler = new WifiEnabler(activity, mSwitchBar);
+ mWifiEnabler.setupSwitchBar();
}
}