Update Network & internet->Wi-Fi to use MasterSwitchPreference.

- Add a preference controller for Network & internet->Wi-Fi to control
  the preference toggling and summary update.
- Refactor WifiSettings and WifiEnabler to share code between the new
  wifi preference controller and the wifi setting.
- Refactor BluetoothSummaryHelper to have a common base class with the
  WifiSummaryHelper.
- Rename the summary helper to summary updater.

Bug: 34280769
Test: make RunSettingsRoboTests
Change-Id: I00ebfc161bcef89331bb41ba405ed8cb8232d248
This commit is contained in:
Doris Ling
2017-01-23 16:16:06 -08:00
parent 42c61c10cc
commit c4c9f4d50e
24 changed files with 926 additions and 171 deletions

View File

@@ -17,6 +17,7 @@
package com.android.settings.widget;
import android.widget.Switch;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
/*
* The switch controller that is used to update the switch widget in the SwitchBar layout.
@@ -25,11 +26,9 @@ public class SwitchBarController extends SwitchWidgetController implements
SwitchBar.OnSwitchChangeListener {
private final SwitchBar mSwitchBar;
private final Switch mSwitch;
public SwitchBarController(SwitchBar switchBar) {
mSwitchBar = switchBar;
mSwitch = switchBar.getSwitch();
}
@Override
@@ -59,17 +58,17 @@ public class SwitchBarController extends SwitchWidgetController implements
@Override
public void setChecked(boolean checked) {
mSwitch.setChecked(checked);
mSwitchBar.setChecked(checked);
}
@Override
public boolean isChecked() {
return mSwitch.isChecked();
return mSwitchBar.isChecked();
}
@Override
public void setEnabled(boolean enabled) {
mSwitch.setEnabled(enabled);
mSwitchBar.setEnabled(enabled);
}
@Override
@@ -78,4 +77,15 @@ public class SwitchBarController extends SwitchWidgetController implements
mListener.onSwitchToggled(isChecked);
}
}
@Override
public void setDisabledByAdmin(EnforcedAdmin admin) {
mSwitchBar.setDisabledByAdmin(admin);
}
@Override
public Switch getSwitch() {
return mSwitchBar.getSwitch();
}
}