Migrate more settings to SubSettingsLauncher
Bug: 73250851 Test: robotests Change-Id: I4100bef20e2ed477e4e31c9b7816f1b03f3f2809
This commit is contained in:
@@ -15,17 +15,16 @@
|
||||
*/
|
||||
package com.android.settings.bluetooth;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.widget.MasterSwitchController;
|
||||
import com.android.settings.widget.MasterSwitchPreference;
|
||||
@@ -50,27 +49,22 @@ public class BluetoothMasterSwitchPreferenceController extends AbstractPreferenc
|
||||
private BluetoothEnabler mBluetoothEnabler;
|
||||
private BluetoothSummaryUpdater mSummaryUpdater;
|
||||
private RestrictionUtils mRestrictionUtils;
|
||||
private Fragment mFragment;
|
||||
private SettingsActivity mActivity;
|
||||
private BluetoothFeatureProvider mBluetoothFeatureProvider;
|
||||
private InstrumentedPreferenceFragment mFragment;
|
||||
|
||||
public BluetoothMasterSwitchPreferenceController(Context context,
|
||||
LocalBluetoothManager bluetoothManager, Fragment fragment, SettingsActivity activity) {
|
||||
this(context, bluetoothManager, new RestrictionUtils(), fragment, activity);
|
||||
LocalBluetoothManager bluetoothManager, InstrumentedPreferenceFragment fragment) {
|
||||
this(context, bluetoothManager, new RestrictionUtils(), fragment);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public BluetoothMasterSwitchPreferenceController(Context context,
|
||||
LocalBluetoothManager bluetoothManager, RestrictionUtils restrictionUtils,
|
||||
Fragment fragment, SettingsActivity activity) {
|
||||
InstrumentedPreferenceFragment fragment) {
|
||||
super(context);
|
||||
mBluetoothManager = bluetoothManager;
|
||||
mSummaryUpdater = new BluetoothSummaryUpdater(mContext, this, mBluetoothManager);
|
||||
mRestrictionUtils = restrictionUtils;
|
||||
mFragment = fragment;
|
||||
mActivity = activity;
|
||||
mBluetoothFeatureProvider = FeatureFactory.getFactory(
|
||||
mContext).getBluetoothFeatureProvider(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,8 +81,11 @@ public class BluetoothMasterSwitchPreferenceController extends AbstractPreferenc
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (KEY_TOGGLE_BLUETOOTH.equals(preference.getKey())) {
|
||||
mActivity.startPreferencePanelAsUser(mFragment, BluetoothSettings.class.getName(), null,
|
||||
R.string.bluetooth, new UserHandle(UserHandle.myUserId()));
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(BluetoothSettings.class.getName())
|
||||
.setTitle(R.string.bluetooth)
|
||||
.setSourceMetricsCategory(mFragment.getMetricsCategory())
|
||||
.launch();
|
||||
return true;
|
||||
}
|
||||
return super.handlePreferenceTreeClick(preference);
|
||||
|
@@ -17,13 +17,12 @@
|
||||
package com.android.settings.bluetooth;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v14.preference.PreferenceFragment;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
|
||||
@@ -35,15 +34,12 @@ public class BluetoothPairingPreferenceController extends AbstractPreferenceCont
|
||||
private static final String TAG = "BluetoothPairingPrefCtrl";
|
||||
|
||||
public static final String KEY_PAIRING = "pref_bt_pairing";
|
||||
private PreferenceFragment mFragment;
|
||||
private SettingsActivity mActivity;
|
||||
private DashboardFragment mFragment;
|
||||
private Preference mPreference;
|
||||
|
||||
public BluetoothPairingPreferenceController(Context context, PreferenceFragment fragment,
|
||||
SettingsActivity activity) {
|
||||
public BluetoothPairingPreferenceController(Context context, DashboardFragment fragment) {
|
||||
super(context);
|
||||
mFragment = fragment;
|
||||
mActivity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,9 +55,12 @@ public class BluetoothPairingPreferenceController extends AbstractPreferenceCont
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (KEY_PAIRING.equals(preference.getKey())) {
|
||||
mActivity.startPreferencePanelAsUser(mFragment, BluetoothPairingDetail.class.getName(),
|
||||
null, R.string.bluetooth_pairing_page_title,
|
||||
new UserHandle(UserHandle.myUserId()));
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(BluetoothPairingDetail.class.getName())
|
||||
.setTitle(R.string.bluetooth_pairing_page_title)
|
||||
.setSourceMetricsCategory(mFragment.getMetricsCategory())
|
||||
.launch();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -367,8 +367,7 @@ public class BluetoothSettings extends DeviceListPreferenceFragment implements I
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
final Lifecycle lifecycle = getLifecycle();
|
||||
mDeviceNamePrefController = new BluetoothDeviceNamePreferenceController(context, lifecycle);
|
||||
mPairingPrefController = new BluetoothPairingPreferenceController(context, this,
|
||||
(SettingsActivity) getActivity());
|
||||
mPairingPrefController = new BluetoothPairingPreferenceController(context, this);
|
||||
controllers.add(mDeviceNamePrefController);
|
||||
controllers.add(mPairingPrefController);
|
||||
controllers.add(new BluetoothFilesPreferenceController(context));
|
||||
|
Reference in New Issue
Block a user