Dupe BluetoothSettings and DeviceListPreferenceFragment
Create the obsolete version of the belowing fragments, so we could flip between old page and new page. BluetoothSettingsObsolete and DeviceListPreferenceObsoleteFragment contains all the old logic but: 1. Logic about BluetoothPairingPreferenceController(ag/2239482), since this preference shouldn't be checked in without the flag :( This cl also adds logic in MasterSwitchPreferenceController to flip these two pages. Following cl will refactor these fragment to make it compatible to new framework. Bug: 35877041 Test: RunSettingsRoboTests Change-Id: I1cc1bc2d49d8a3e11c3127e56f6409fbc84028d8
This commit is contained in:
@@ -15,11 +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.PreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.widget.MasterSwitchController;
|
||||
@@ -43,19 +48,27 @@ public class BluetoothMasterSwitchPreferenceController extends PreferenceControl
|
||||
private BluetoothEnabler mBluetoothEnabler;
|
||||
private BluetoothSummaryUpdater mSummaryUpdater;
|
||||
private RestrictionUtils mRestrictionUtils;
|
||||
private Fragment mFragment;
|
||||
private SettingsActivity mActivity;
|
||||
private BluetoothFeatureProvider mBluetoothFeatureProvider;
|
||||
|
||||
public BluetoothMasterSwitchPreferenceController(Context context,
|
||||
LocalBluetoothManager bluetoothManager) {
|
||||
this(context, bluetoothManager, new RestrictionUtils());
|
||||
LocalBluetoothManager bluetoothManager, Fragment fragment, SettingsActivity activity) {
|
||||
this(context, bluetoothManager, new RestrictionUtils(), fragment, activity);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public BluetoothMasterSwitchPreferenceController(Context context,
|
||||
LocalBluetoothManager bluetoothManager, RestrictionUtils restrictionUtils) {
|
||||
LocalBluetoothManager bluetoothManager, RestrictionUtils restrictionUtils,
|
||||
Fragment fragment, SettingsActivity activity) {
|
||||
super(context);
|
||||
mBluetoothManager = bluetoothManager;
|
||||
mSummaryUpdater = new BluetoothSummaryUpdater(mContext, this, mBluetoothManager);
|
||||
mRestrictionUtils = restrictionUtils;
|
||||
mFragment = fragment;
|
||||
mActivity = activity;
|
||||
mBluetoothFeatureProvider = FeatureFactory.getFactory(
|
||||
mContext).getBluetoothFeatureProvider(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,10 +76,23 @@ public class BluetoothMasterSwitchPreferenceController extends PreferenceControl
|
||||
super.displayPreference(screen);
|
||||
mBtPreference = (MasterSwitchPreference) screen.findPreference(KEY_TOGGLE_BLUETOOTH);
|
||||
mBluetoothEnabler = new BluetoothEnabler(mContext,
|
||||
new MasterSwitchController(mBtPreference),
|
||||
FeatureFactory.getFactory(mContext).getMetricsFeatureProvider(), mBluetoothManager,
|
||||
MetricsEvent.ACTION_SETTINGS_MASTER_SWITCH_BLUETOOTH_TOGGLE,
|
||||
mRestrictionUtils);
|
||||
new MasterSwitchController(mBtPreference),
|
||||
FeatureFactory.getFactory(mContext).getMetricsFeatureProvider(), mBluetoothManager,
|
||||
MetricsEvent.ACTION_SETTINGS_MASTER_SWITCH_BLUETOOTH_TOGGLE,
|
||||
mRestrictionUtils);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (KEY_TOGGLE_BLUETOOTH.equals(preference.getKey())) {
|
||||
final String fragmentClass = mBluetoothFeatureProvider.isPairingPageEnabled() ?
|
||||
BluetoothSettings.class.getName() :
|
||||
BluetoothSettingsObsolete.class.getName();
|
||||
mActivity.startPreferencePanelAsUser(mFragment, fragmentClass, null, R.string.bluetooth,
|
||||
null, new UserHandle(UserHandle.myUserId()));
|
||||
return true;
|
||||
}
|
||||
return super.handlePreferenceTreeClick(preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,6 +105,7 @@ public class BluetoothMasterSwitchPreferenceController extends PreferenceControl
|
||||
return KEY_TOGGLE_BLUETOOTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
mSummaryUpdater.register(true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user