Merge "Fix scrolling issue after MLS switches" into sc-dev am: 2718cea083

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/14723398

Change-Id: Ia4d3be59a713405159191f391aef3f855b593083
This commit is contained in:
TreeHugger Robot
2021-05-28 03:05:25 +00:00
committed by Automerger Merge Worker

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,