Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fdff6af0 authored by Yu-Han Yang's avatar Yu-Han Yang
Browse files

Fix scrolling issue after MLS switches

Bug: 187546020
Test: on device
Change-Id: Ie1c573396cbc8b3256db5e350c622e566a44495c
parent 547cac8d
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -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,