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:
@@ -24,6 +24,7 @@ import android.widget.CompoundButton;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
/**
|
||||
* A custom preference that provides inline switch toggle. It has a mandatory field for title, and
|
||||
@@ -76,7 +77,7 @@ public class MasterSwitchPreference extends Preference {
|
||||
}
|
||||
|
||||
public boolean isChecked() {
|
||||
return isEnabled() && mChecked;
|
||||
return mSwitch != null && mSwitch.isEnabled() && mChecked;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
@@ -87,7 +88,7 @@ public class MasterSwitchPreference extends Preference {
|
||||
}
|
||||
|
||||
public boolean isSwitchEnabled() {
|
||||
return isEnabled() && mSwitch != null && mSwitch.isEnabled();
|
||||
return mSwitch != null && mSwitch.isEnabled();
|
||||
}
|
||||
|
||||
public void setSwitchEnabled(boolean enabled) {
|
||||
@@ -96,6 +97,18 @@ public class MasterSwitchPreference extends Preference {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If admin is not null, disables the switch.
|
||||
* Otherwise, keep it enabled.
|
||||
*/
|
||||
public void setDisabledByAdmin(EnforcedAdmin admin) {
|
||||
setSwitchEnabled(admin == null);
|
||||
}
|
||||
|
||||
public Switch getSwitch() {
|
||||
return mSwitch;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setWidgetLayoutResource(R.layout.preference_widget_master_switch);
|
||||
}
|
||||
|
Reference in New Issue
Block a user