Settings Fragment Migration (Build pass app)
This patch focused on fixing compile errors and some runtime errors. Test: We can't test it now. But we will have an integration test later. Bug: 110259478 Change-Id: I16c471ddcd0fa1460c665b7f74d86fcace5ee67b
This commit is contained in:
@@ -66,7 +66,7 @@ public class AdvancedConnectedDeviceDashboardFragment extends DashboardFragment
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
return buildControllers(context, getLifecycle());
|
||||
return buildControllers(context, getSettingsLifecycle());
|
||||
}
|
||||
|
||||
private static List<AbstractPreferenceController> buildControllers(Context context,
|
||||
|
@@ -92,7 +92,7 @@ public class BluetoothDashboardFragment extends DashboardFragment {
|
||||
mSwitchBar = activity.getSwitchBar();
|
||||
mController = new BluetoothSwitchPreferenceController(activity,
|
||||
new SwitchBarController(mSwitchBar), mFooterPreference);
|
||||
Lifecycle lifecycle = getLifecycle();
|
||||
Lifecycle lifecycle = getSettingsLifecycle();
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(mController);
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
return buildPreferenceControllers(context, getLifecycle());
|
||||
return buildPreferenceControllers(context, getSettingsLifecycle());
|
||||
}
|
||||
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||
|
@@ -36,7 +36,7 @@ import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnPause;
|
||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
import com.android.settingslib.widget.FooterPreferenceMixin;
|
||||
import com.android.settingslib.widget.FooterPreferenceMixinCompat;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -52,7 +52,7 @@ public class DiscoverableFooterPreferenceController extends BasePreferenceContro
|
||||
BroadcastReceiver mBluetoothChangedReceiver;
|
||||
@VisibleForTesting
|
||||
LocalBluetoothManager mLocalManager;
|
||||
private FooterPreferenceMixin mFooterPreferenceMixin;
|
||||
private FooterPreferenceMixinCompat mFooterPreferenceMixin;
|
||||
private FooterPreference mPreference;
|
||||
private LocalBluetoothAdapter mLocalAdapter;
|
||||
private AlwaysDiscoverable mAlwaysDiscoverable;
|
||||
@@ -82,11 +82,12 @@ public class DiscoverableFooterPreferenceController extends BasePreferenceContro
|
||||
}
|
||||
|
||||
public void init(DashboardFragment fragment) {
|
||||
mFooterPreferenceMixin = new FooterPreferenceMixin(fragment, fragment.getLifecycle());
|
||||
mFooterPreferenceMixin = new FooterPreferenceMixinCompat(fragment,
|
||||
fragment.getSettingsLifecycle());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void init(FooterPreferenceMixin footerPreferenceMixin, FooterPreference preference,
|
||||
void init(FooterPreferenceMixinCompat footerPreferenceMixin, FooterPreference preference,
|
||||
AlwaysDiscoverable alwaysDiscoverable) {
|
||||
mFooterPreferenceMixin = footerPreferenceMixin;
|
||||
mPreference = preference;
|
||||
|
@@ -27,7 +27,7 @@ import com.android.settings.Utils;
|
||||
import com.android.settings.widget.RadioButtonPickerFragment;
|
||||
import com.android.settingslib.widget.CandidateInfo;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
import com.android.settingslib.widget.FooterPreferenceMixin;
|
||||
import com.android.settingslib.widget.FooterPreferenceMixinCompat;
|
||||
|
||||
import com.google.android.collect.Lists;
|
||||
|
||||
@@ -49,7 +49,8 @@ public class UsbDefaultFragment extends RadioButtonPickerFragment {
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
super.onCreatePreferences(savedInstanceState, rootKey);
|
||||
FooterPreferenceMixin footer = new FooterPreferenceMixin(this, this.getLifecycle());
|
||||
FooterPreferenceMixinCompat footer = new FooterPreferenceMixinCompat(this,
|
||||
this.getSettingsLifecycle());
|
||||
FooterPreference pref = footer.createFooterPreference();
|
||||
pref.setTitle(R.string.usb_default_info);
|
||||
}
|
||||
|
@@ -85,7 +85,7 @@ public class UsbDetailsFragment extends DashboardFragment {
|
||||
mControllers = createControllerList(context, mUsbBackend, this);
|
||||
mUsbReceiver = new UsbConnectionBroadcastReceiver(context, mUsbConnectionListener,
|
||||
mUsbBackend);
|
||||
this.getLifecycle().addObserver(mUsbReceiver);
|
||||
this.getSettingsLifecycle().addObserver(mUsbReceiver);
|
||||
|
||||
return new ArrayList<>(mControllers);
|
||||
}
|
||||
|
Reference in New Issue
Block a user