Use SettingsLib's MainSwitchBar to replace SwitchBar in Settings.
To log Settings metrics, the MainSwitch extends MainSwitchBar and replace the SwitchBar in SettingsActivity. Bug: 175181773 Test: Run robotest and apply the widget in Settings and see the ui Change-Id: I3add3702e9058ad9192b5172c7cf0e2ccfb55a70
This commit is contained in:
@@ -32,14 +32,13 @@ import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.network.SubscriptionUtil;
|
||||
import com.android.settings.network.SubscriptionsChangeListener;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
import com.android.settings.widget.SettingsMainSwitchPreference;
|
||||
|
||||
/** This controls a switch to allow enabling/disabling a mobile network */
|
||||
public class MobileNetworkSwitchController extends BasePreferenceController implements
|
||||
SubscriptionsChangeListener.SubscriptionsChangeListenerClient, LifecycleObserver {
|
||||
private static final String TAG = "MobileNetworkSwitchCtrl";
|
||||
private SwitchBar mSwitchBar;
|
||||
private SettingsMainSwitchPreference mSwitchBar;
|
||||
private int mSubId;
|
||||
private SubscriptionsChangeListener mChangeListener;
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
@@ -70,12 +69,10 @@ public class MobileNetworkSwitchController extends BasePreferenceController impl
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
final LayoutPreference pref = screen.findPreference(mPreferenceKey);
|
||||
mSwitchBar = pref.findViewById(R.id.switch_bar);
|
||||
mSwitchBar.setSwitchBarText(R.string.mobile_network_use_sim_on,
|
||||
R.string.mobile_network_use_sim_off);
|
||||
mSwitchBar = (SettingsMainSwitchPreference) screen.findPreference(mPreferenceKey);
|
||||
mSwitchBar.setTitle(mContext.getString(R.string.mobile_network_use_sim_on));
|
||||
|
||||
mSwitchBar.getSwitch().setOnBeforeCheckedChangeListener((toggleSwitch, isChecked) -> {
|
||||
mSwitchBar.setOnBeforeCheckedChangeListener((toggleSwitch, isChecked) -> {
|
||||
// TODO b/135222940: re-evaluate whether to use
|
||||
// mSubscriptionManager#isSubscriptionEnabled
|
||||
if (mSubscriptionManager.isActiveSubscriptionId(mSubId) != isChecked) {
|
||||
@@ -118,7 +115,8 @@ public class MobileNetworkSwitchController extends BasePreferenceController impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAirplaneModeChanged(boolean airplaneModeEnabled) {}
|
||||
public void onAirplaneModeChanged(boolean airplaneModeEnabled) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscriptionsChanged() {
|
||||
|
||||
Reference in New Issue
Block a user