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:
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.android.settings.widget;
|
||||
|
||||
import android.widget.Switch;
|
||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
/*
|
||||
* A controller class for general switch widget handling. We have different containers that provide
|
||||
* different forms of switch layout. Provide a centralized control for updating the switch widget.
|
||||
@@ -24,35 +27,93 @@ public abstract class SwitchWidgetController {
|
||||
|
||||
protected OnSwitchChangeListener mListener;
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked when the switch has been toggled.
|
||||
*/
|
||||
public interface OnSwitchChangeListener {
|
||||
/**
|
||||
* Called when the checked state of the Switch has changed.
|
||||
*
|
||||
* @param isChecked The new checked state of switchView.
|
||||
* @param isChecked The new checked state of switchView.
|
||||
*
|
||||
* @return true to update the state of the switch with the new value.
|
||||
*/
|
||||
boolean onSwitchToggled(boolean isChecked);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform any view setup.
|
||||
*/
|
||||
public void setupView() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform any view teardown.
|
||||
*/
|
||||
public void teardownView() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the callback to be invoked when the switch is toggled by the user (but before the
|
||||
* internal state has been updated).
|
||||
*
|
||||
* @param listener the callback to be invoked
|
||||
*/
|
||||
public void setListener(OnSwitchChangeListener listener) {
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the preference title associated with the switch.
|
||||
*
|
||||
* @param isChecked whether the switch is currently checked
|
||||
*/
|
||||
public abstract void updateTitle(boolean isChecked);
|
||||
|
||||
/**
|
||||
* Start listening to switch toggling.
|
||||
*/
|
||||
public abstract void startListening();
|
||||
|
||||
/**
|
||||
* Stop listening to switch toggling.
|
||||
*/
|
||||
public abstract void stopListening();
|
||||
|
||||
/**
|
||||
* Set the checked state for the switch.
|
||||
*
|
||||
* @param checked whether the switch should be checked or not.
|
||||
*/
|
||||
public abstract void setChecked(boolean checked);
|
||||
|
||||
/**
|
||||
* Get the checked state for the switch.
|
||||
*
|
||||
* @return true if the switch is currently checked, false otherwise.
|
||||
*/
|
||||
public abstract boolean isChecked();
|
||||
|
||||
/**
|
||||
* Set the enabled state for the switch.
|
||||
*
|
||||
* @param enabled whether the switch should be enabled or not.
|
||||
*/
|
||||
public abstract void setEnabled(boolean enabled);
|
||||
|
||||
}
|
||||
/**
|
||||
* Disable the switch based on the enforce admin.
|
||||
*
|
||||
* @param admin Details of the admin who enforced the restriction. If it
|
||||
* is {@code null}, then this preference will be enabled. Otherwise, it will be disabled.
|
||||
*/
|
||||
public abstract void setDisabledByAdmin(EnforcedAdmin admin);
|
||||
|
||||
/**
|
||||
* Get the underlying switch widget.
|
||||
*
|
||||
* @return the switch widget.
|
||||
*/
|
||||
public abstract Switch getSwitch();
|
||||
|
||||
}
|
Reference in New Issue
Block a user