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

Commit 14cc8641 authored by Sundeep Ghuman's avatar Sundeep Ghuman
Browse files

Don't scroll when removing saved networks.

Bug: b/62374459
Test: Open saved networks from WifiSettings. Remove a saved network.
Screen should not scroll to the top of the list.

Change-Id: Ia78fc0b5435f659c8fe31abee8b76006d7986b66
parent 22080a1d
Loading
Loading
Loading
Loading
+14 −6
Original line number Original line Diff line number Diff line
@@ -127,16 +127,24 @@ public class SavedAccessPointsWifiSettings extends SettingsPreferenceFragment
        final List<AccessPoint> accessPoints =
        final List<AccessPoint> accessPoints =
                WifiSavedConfigUtils.getAllConfigs(context, mWifiManager);
                WifiSavedConfigUtils.getAllConfigs(context, mWifiManager);
        Collections.sort(accessPoints, SAVED_NETWORK_COMPARATOR);
        Collections.sort(accessPoints, SAVED_NETWORK_COMPARATOR);
        preferenceScreen.removeAll();
        cacheRemoveAllPrefs(preferenceScreen);


        final int accessPointsSize = accessPoints.size();
        final int accessPointsSize = accessPoints.size();
        for (int i = 0; i < accessPointsSize; ++i) {
        for (int i = 0; i < accessPointsSize; ++i) {
            AccessPoint ap = accessPoints.get(i);
            String key = AccessPointPreference.generatePreferenceKey(ap);
            LongPressAccessPointPreference preference =
            LongPressAccessPointPreference preference =
                    new LongPressAccessPointPreference(accessPoints.get(i), context,
                    (LongPressAccessPointPreference) getCachedPreference(key);
                            mUserBadgeCache, true, this);
            if (preference == null) {
                preference = new LongPressAccessPointPreference(
                        ap, context, mUserBadgeCache, true, this);
                preference.setKey(key);
                preference.setIcon(null);
                preference.setIcon(null);
                preferenceScreen.addPreference(preference);
                preferenceScreen.addPreference(preference);
            }
            }
        }

        removeCachedPrefs(preferenceScreen);


        if(getPreferenceScreen().getPreferenceCount() < 1) {
        if(getPreferenceScreen().getPreferenceCount() < 1) {
            Log.w(TAG, "Saved networks activity loaded, but there are no saved networks!");
            Log.w(TAG, "Saved networks activity loaded, but there are no saved networks!");
+1 −14
Original line number Original line Diff line number Diff line
@@ -43,7 +43,6 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceCategory;
import android.text.TextUtils;
import android.util.Log;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.ContextMenu.ContextMenuInfo;
@@ -749,7 +748,7 @@ public class WifiSettings extends RestrictedSettingsFragment
            AccessPoint accessPoint = accessPoints.get(index);
            AccessPoint accessPoint = accessPoints.get(index);
            // Ignore access points that are out of range.
            // Ignore access points that are out of range.
            if (accessPoint.isReachable()) {
            if (accessPoint.isReachable()) {
                String key = generateKey(accessPoint);
                String key = AccessPointPreference.generatePreferenceKey(accessPoint);
                hasAvailableAccessPoints = true;
                hasAvailableAccessPoints = true;
                LongPressAccessPointPreference pref =
                LongPressAccessPointPreference pref =
                        (LongPressAccessPointPreference) getCachedPreference(key);
                        (LongPressAccessPointPreference) getCachedPreference(key);
@@ -791,18 +790,6 @@ public class WifiSettings extends RestrictedSettingsFragment
        }
        }
    }
    }


    private String generateKey(AccessPoint accessPoint) {
        StringBuilder key = new StringBuilder();
        String bssid = accessPoint.getBssid();
        if (TextUtils.isEmpty(bssid)) {
            key.append(accessPoint.getSsidStr());
        } else {
            key.append(bssid);
        }
        key.append(',').append(accessPoint.getSecurity());
        return key.toString();
    }

    @NonNull
    @NonNull
    private LongPressAccessPointPreference createLongPressActionPointPreference(
    private LongPressAccessPointPreference createLongPressActionPointPreference(
            AccessPoint accessPoint) {
            AccessPoint accessPoint) {