Fix scrolling issue after MLS switches

Bug: 187546020
Test: on device
Change-Id: Ie1c573396cbc8b3256db5e350c622e566a44495c
This commit is contained in:
Yu-Han Yang
2021-05-25 14:29:40 -07:00
parent 547cac8d9a
commit fdff6af031

View File

@@ -55,11 +55,14 @@ import java.util.List;
* implementation.
*/
@SearchIndexable
public class LocationSettings extends DashboardFragment {
public class LocationSettings extends DashboardFragment implements
LocationEnabler.LocationModeChangeListener {
private static final String TAG = "LocationSettings";
private static final String RECENT_LOCATION_ACCESS_PREF_KEY = "recent_location_access";
private LocationSwitchBarController mSwitchBarController;
private LocationEnabler mLocationEnabler;
@Override
public int getMetricsCategory() {
@@ -75,6 +78,7 @@ public class LocationSettings extends DashboardFragment {
switchBar.show();
mSwitchBarController = new LocationSwitchBarController(activity, switchBar,
getSettingsLifecycle());
mLocationEnabler = new LocationEnabler(getContext(), this, getSettingsLifecycle());
}
@Override
@@ -98,6 +102,13 @@ public class LocationSettings extends DashboardFragment {
return TAG;
}
@Override
public void onLocationModeChanged(int mode, boolean restricted) {
if (mLocationEnabler.isEnabled(mode)) {
scrollToPreference(RECENT_LOCATION_ACCESS_PREF_KEY);
}
}
static void addPreferencesSorted(List<Preference> prefs, PreferenceGroup container) {
// If there's some items to display, sort the items and add them to the container.
Collections.sort(prefs,