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:
@@ -25,12 +25,13 @@ import com.android.settings.core.lifecycle.events.OnResume;
|
||||
import com.android.settings.core.lifecycle.events.OnStart;
|
||||
import com.android.settings.core.lifecycle.events.OnStop;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.widget.SummaryUpdater.OnSummaryChangeListener;
|
||||
import com.android.settings.widget.MasterSwitchPreference;
|
||||
import com.android.settings.widget.MasterSwitchController;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
|
||||
public class BluetoothMasterSwitchPreferenceController extends PreferenceController
|
||||
implements BluetoothSummaryHelper.OnSummaryChangeListener,
|
||||
implements OnSummaryChangeListener,
|
||||
LifecycleObserver, OnResume, OnPause, OnStart, OnStop {
|
||||
|
||||
private static final String KEY_TOGGLE_BLUETOOTH = "toggle_bluetooth";
|
||||
@@ -38,14 +39,13 @@ public class BluetoothMasterSwitchPreferenceController extends PreferenceControl
|
||||
private LocalBluetoothManager mBluetoothManager;
|
||||
private MasterSwitchPreference mBtPreference;
|
||||
private BluetoothEnabler mBluetoothEnabler;
|
||||
private BluetoothSummaryHelper mSummaryHelper;
|
||||
private BluetoothSummaryUpdater mSummaryUpdater;
|
||||
|
||||
public BluetoothMasterSwitchPreferenceController(Context context,
|
||||
LocalBluetoothManager bluetoothManager) {
|
||||
super(context);
|
||||
mBluetoothManager = bluetoothManager;
|
||||
mSummaryHelper = new BluetoothSummaryHelper(mContext, mBluetoothManager);
|
||||
mSummaryHelper.setOnSummaryChangeListener(this);
|
||||
mSummaryUpdater = new BluetoothSummaryUpdater(mContext, this, mBluetoothManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,12 +68,12 @@ public class BluetoothMasterSwitchPreferenceController extends PreferenceControl
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
mSummaryHelper.setListening(true);
|
||||
mSummaryUpdater.register(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
mSummaryHelper.setListening(false);
|
||||
mSummaryUpdater.register(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user